goldilocks

package
v0.0.0-...-0310684 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package goldilocks provides elliptic curve operations over the goldilocks curve.

Index

Constants

View Source
const ScalarSize = 56 // 448 / 8

ScalarSize is the size (in bytes) of scalars.

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

type Curve struct{}

Curve is the Goldilocks curve x^2+y^2=z^2-39081x^2y^2.

func (Curve) Add

func (Curve) Add(P, Q *Point) *Point

Add returns P+Q.

func (Curve) CombinedMult

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

func (Curve) Double(P *Point) *Point

Double returns 2P.

func (Curve) Generator

func (Curve) Generator() *Point

Generator returns the generator point.

func (Curve) Identity

func (Curve) Identity() *Point

Identity returns the identity point.

func (Curve) IsOnCurve

func (Curve) IsOnCurve(P *Point) bool

IsOnCurve returns true if the point lies on the curve.

func (Curve) Order

func (Curve) Order() Scalar

Order returns the number of points in the prime subgroup.

func (Curve) ScalarBaseMult

func (e Curve) ScalarBaseMult(k *Scalar) *Point

ScalarBaseMult returns kG where G is the generator point. This function runs in constant time.

func (Curve) ScalarMult

func (e Curve) ScalarMult(k *Scalar, P *Point) *Point

ScalarMult returns kP. This function runs in constant time.

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point is a point on the Goldilocks Curve.

func FromAffine

func FromAffine(x, y *fp.Elt) (*Point, error)

FromAffine creates a point from affine coordinates.

func FromBytes

func FromBytes(in []byte) (*Point, error)

FromBytes returns a point from the input buffer.

func (*Point) Add

func (P *Point) Add(Q *Point)

Add sets P =P+Q..

func (*Point) Double

func (P *Point) Double()

Double sets P = 2Q.

func (*Point) IsEqual

func (P *Point) IsEqual(Q *Point) bool

IsEqual returns true if P is equivalent to Q.

func (*Point) IsIdentity

func (P *Point) IsIdentity() bool

IsIdentity returns true is P is the identity Point.

func (*Point) MarshalBinary

func (P *Point) MarshalBinary() (data []byte, err error)

MarshalBinary encodes the receiver into a binary form and returns the result.

func (*Point) Neg

func (P *Point) Neg()

Neg obtains the inverse of the Point.

func (Point) String

func (P Point) String() string

func (*Point) ToAffine

func (P *Point) ToAffine() (x, y fp.Elt)

ToAffine returns the x,y affine coordinates of P.

func (*Point) ToBytes

func (P *Point) ToBytes(out []byte) error

ToBytes stores P into a slice of bytes.

func (*Point) UnmarshalBinary

func (P *Point) UnmarshalBinary(data []byte) error

UnmarshalBinary must be able to decode the form generated by MarshalBinary.

type Scalar

type Scalar [ScalarSize]byte

Scalar represents a positive integer stored in little-endian order.

func (*Scalar) Add

func (z *Scalar) Add(x, y *Scalar)

Add calculates z = x+y mod order.

func (*Scalar) FromBytes

func (z *Scalar) FromBytes(x []byte)

FromBytes stores z = x mod order, where x is a number stored in little-endian order.

func (*Scalar) IsZero

func (z *Scalar) IsZero() bool

IsZero returns true if z=0.

func (*Scalar) Mul

func (z *Scalar) Mul(x, y *Scalar)

Mul calculates z = x*y mod order.

func (*Scalar) Neg

func (z *Scalar) Neg()

Neg calculates z = -z mod order.

func (*Scalar) Red

func (z *Scalar) Red()

Red reduces z mod order.

func (*Scalar) Sub

func (z *Scalar) Sub(x, y *Scalar)

Sub calculates z = x-y mod order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL