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 int) (ec EC) { ec.A = big.NewInt(int64(a)) ec.B = big.NewInt(int64(b)) ec.Q = big.NewInt(int64(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 }