Bipoint.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef __BIPOINT_HPP
  2. #define __BIPOINT_HPP
  3. //#include "bgn.hpp"
  4. #include "mydouble.h"
  5. extern "C" {
  6. #include "fpe.h"
  7. }
  8. #include "curvepoint_fp.h"
  9. extern "C" {
  10. #include "fp2e.h"
  11. }
  12. #include "twistpoint_fp2.h"
  13. #include "zout.hpp"
  14. template <typename T>
  15. class Bipoint
  16. {}; //il faut une définition de la classe pour un type quelconque, on choisit de rien mettre dedans, on veut traiter seulement des cas particuliers
  17. template <>
  18. class Bipoint <curvepoint_fp_t> //spécialisation pour curvepoint_fp_t
  19. {
  20. public:
  21. //Bipoint() = default;
  22. Bipoint();
  23. Bipoint(curvepoint_fp_t p1,curvepoint_fp_t p2);
  24. //void bipoint_curvepoint_fp_init_set(Bipoint<curvepoint_fp_t> rop, const Bipoint<curvepoint_fp_t> op);
  25. void set_point(curvepoint_fp_t, int numpoint);
  26. void print(int numpoint) const;
  27. curvepoint_fp_t& operator[](int n); //la valeur de retour doit être une référence.
  28. Bipoint <curvepoint_fp_t> operator+(Bipoint <curvepoint_fp_t> b);
  29. bool operator==(Bipoint<curvepoint_fp_t> b);
  30. void makeaffine();
  31. void scalarmult_vartime(Bipoint<curvepoint_fp_t> op, scalar_t s);
  32. void print() const;
  33. private:
  34. curvepoint_fp_t point[2];
  35. };
  36. template <>
  37. class Bipoint <twistpoint_fp2_t> //spécialisation pour twistpoint_fp2_t
  38. {
  39. public:
  40. Bipoint();
  41. Bipoint(twistpoint_fp2_t p1,twistpoint_fp2_t p2);
  42. void set_point(twistpoint_fp2_t, int numpoint);
  43. void print(int numpoint) const;
  44. twistpoint_fp2_t& operator[](int n);
  45. Bipoint<twistpoint_fp2_t> operator+(Bipoint<twistpoint_fp2_t> b);
  46. bool operator==(Bipoint<twistpoint_fp2_t> b);
  47. void makeaffine();
  48. void scalarmult_vartime(Bipoint<twistpoint_fp2_t> op, scalar_t s);
  49. void print() const;
  50. private:
  51. twistpoint_fp2_t point[2];
  52. };
  53. template <>
  54. class Bipoint <fpe_t> //spécialisation pour fpe_t
  55. {
  56. public:
  57. void set_coordonnee(fpe_t, int numcoord);
  58. void get_coordonnee(int numcoord) const;
  59. private:
  60. fpe_t coordonnee[2];
  61. };
  62. template <>
  63. class Bipoint <fp2e_t> //spécialisation pour fp2e_t
  64. {
  65. public:
  66. void set_coordonnee(fp2e_t, int numcoord);
  67. void get_coordonnee(int numcoord) const;
  68. private:
  69. fp2e_t coordonnee[2];
  70. };
  71. #endif