package ecc import ( "bytes" "errors" "math/big" ) // EC is the data structure for the elliptic curve parameters type EC struct { A *big.Int B *big.Int Q *big.Int } // NewEC (y^2 = x^3 + ax + b) mod q, where q is a prime number func NewEC(a, b, q *big.Int) (ec EC) { ec.A = a ec.B = b ec.Q = q return ec } // At gets a point x in the curve func (ec *EC) At(x *big.Int) (Point, Point, error) { if x.Cmp(ec.Q) > 0 { return Point{}, Point{}, errors.New("x>1 p2, err = ec.Add(p2, p2) if err != nil { return p, err } } return r, nil } // Order returns smallest n where nG = O (point at zero) func (ec *EC) Order(g Point) (*big.Int, error) { // loop from i:=1 to i