ScalarSize is the size (in bytes) of scalars.
const ScalarSize = 56 // 448 / 8
Curve is the Goldilocks curve x^2+y^2=z^2-39081x^2y^2.
type Curve struct{}
func (Curve) Add(P, Q *Point) *Point
Add returns P+Q.
func (e Curve) CombinedMult(m, n *Scalar, P *Point) *Point
CombinedMult returns mG+nP, where G is the generator point. This function is non-constant time.
func (Curve) Double(P *Point) *Point
Double returns 2P.
func (Curve) Generator() *Point
Generator returns the generator point.
func (Curve) Identity() *Point
Identity returns the identity point.
func (Curve) IsOnCurve(P *Point) bool
IsOnCurve returns true if the point lies on the curve.
func (Curve) Order() Scalar
Order returns the number of points in the prime subgroup.
func (e Curve) ScalarBaseMult(k *Scalar) *Point
ScalarBaseMult returns kG where G is the generator point. This function runs in constant time.
func (e Curve) ScalarMult(k *Scalar, P *Point) *Point
ScalarMult returns kP. This function runs in constant time.
Point is a point on the Goldilocks Curve.
type Point struct {
// contains filtered or unexported fields
}
func FromAffine(x, y *fp.Elt) (*Point, error)
FromAffine creates a point from affine coordinates.
func FromBytes(in []byte) (*Point, error)
FromBytes returns a point from the input buffer.
func (P *Point) Add(Q *Point)
Add sets P =P+Q..
func (P *Point) Double()
Double sets P = 2Q.
func (P *Point) IsEqual(Q *Point) bool
IsEqual returns true if P is equivalent to Q.
func (P *Point) IsIdentity() bool
IsIdentity returns true is P is the identity Point.
func (P *Point) MarshalBinary() (data []byte, err error)
MarshalBinary encodes the receiver into a binary form and returns the result.
func (P *Point) Neg()
Neg obtains the inverse of the Point.
func (P Point) String() string
func (P *Point) ToAffine() (x, y fp.Elt)
ToAffine returns the x,y affine coordinates of P.
func (P *Point) ToBytes(out []byte) error
ToBytes stores P into a slice of bytes.
func (P *Point) UnmarshalBinary(data []byte) error
UnmarshalBinary must be able to decode the form generated by MarshalBinary.
Scalar represents a positive integer stored in little-endian order.
type Scalar [ScalarSize]byte
func (z *Scalar) Add(x, y *Scalar)
Add calculates z = x+y mod order.
func (z *Scalar) FromBytes(x []byte)
FromBytes stores z = x mod order, where x is a number stored in little-endian order.
func (z *Scalar) IsZero() bool
IsZero returns true if z=0.
func (z *Scalar) Mul(x, y *Scalar)
Mul calculates z = x*y mod order.
func (z *Scalar) Neg()
Neg calculates z = -z mod order.
func (z *Scalar) Red()
Red reduces z mod order.
func (z *Scalar) Sub(x, y *Scalar)
Sub calculates z = x-y mod order.