ffe_t; class Point { friend class EllipticCurve
; typedef FiniteFieldElement
ffe_t; ffe_t x_; ffe_t y_; EllipticCurve *ec_; void addDouble(int m, Point& acc) { if ( m > ) { Point r = acc; for ( int n=0; n < m; ++n ) { r += r; // doubling step } acc = r; } } Point scalarMultiply(int k, const Point& a) { Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa P25 Point acc = a; Point res = Point(0,0,*ec_); int i = 0, j = 0; int b = k; while( b ) { if ( b & ) { // bit is set; acc = 2^(i-j)*acc addDouble(i-j,acc); res += acc; j = i; // last bit set } b >>= 1; ++i; } return res; } void add(ffe_t x1, ffe_t y1, ffe_t x2, ffe_t y2, ffe_t & xR, ffe_t & yR) const { if ( x1 == && y1 == ) { xR = x2; yR = y2; return; } if ( x2 == && y2 == ) {xR = x1; yR = y1; return; } if ( y1 == -y2 ) {xR = yR = 0; return; } ffe_t s; if ( x1 == x2 && y1 == y2 ) Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa P26 { s = (3*(x1.i()*x1.i()) + ec_->a()) / (2*y1); xR = ((s*s) - 2*x1); } else { //P+Q s = (y1 - y2) / (x1 - x2); xR = ((s*s) - x1 - x2); } if ( s != ) { yR = (-y1 + s*(x1 - xR)); } else { xR = yR = 0; } } Point(int x, int y) : x_(x), y_(y), ec_(0) {} Point(int x, int y, EllipticCurve
& EllipticCurve): x_(x), y_(y), ec_(&EllipticCurve) {} Point(const ffe_t& x, const ffe_t& y, EllipticCurve
& EllipticCurve) : x_(x),y_(y), ec_(&EllipticCurve) {} public: static Point ONE; Point(const Point& rhs) {x_ = rhs.x_; y_ = rhs.y_; ec_ = rhs.ec_;} Point& operator=(const Point& rhs) {x_ = rhs.x_; y_ = rhs.y_; ec_ = rhs.ec_; return *this; } ffe_t x() const { return x_; } Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa Nghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoaNghien.cuu.mot.so.giai.phap.nang.cao.hieu.nang.cua.thuat.toan.ma.hoa P27 ffe_t y() const { return y_; } unsigned int Order(unsigned int maxPeriod = ~0) const {Point r = *this; unsigned int n = 0; while( r.x_ != && r.y_ != ) { ++n; r += *this; if ( n > maxPeriod ) break; } return n; } Point operator-() { return Point(x_,-y_);} friend bool operator==(const Point& lhs, const Point& rhs) { return (lhs.ec_ == rhs.ec_) && (lhs.x_ == rhs.x_) && (lhs.y_ == rhs.y_); } // != friend bool operator!=(const Point& lhs, const Point& rhs) { return (lhs.ec_ != rhs.ec_) || (lhs.x_ != rhs.x_) || (lhs.y_ != rhs.y_); } friend Point operator+(const Point& lhs, const Point& rhs) { ffe_t xR, yR; lhs.add(lhs.x_,lhs.y_,rhs.x_,rhs.y_,xR,yR); return Point(xR,yR,*lhs.ec} friend Point operator*(int k, const Point& rhs) { return Point(rhs).operator*=(k);} Point& operator+=(const Point& rhs) { add(x_,y_,rhs.x_,rhs.y_,x_,y_); return *this } Point& operator*=(int k) { return (*this = scalarMultiply(k,*this)); } friend ostream& operator