Documentation ¶
Overview ¶
Package internal defines simple and abstract APIs to group Elements and Scalars.
Package internal defines simple and abstract APIs to group Elements and Scalars.
Package internal defines simple and abstract APIs to group Elements and Scalars.
Index ¶
Constants ¶
View Source
const ( // DstMinLength is the minimum acceptable length of input DST. DstMinLength = 0 // DstRecommendedMinLength is the minimum recommended length of input DST. DstRecommendedMinLength = 16 )
Variables ¶
View Source
var ( ErrParamNilScalar = errors.New("nil or empty scalar") ErrParamScalarLength = errors.New("invalid scalar length") ErrParamNilPoint = errors.New("nil or empty point") ErrCastElement = errors.New("could not cast to same group element (wrong group ?)") ErrCastScalar = errors.New("could not cast to same group scalar (wrong group ?)") )
Functions ¶
func RandomBytes ¶
RandomBytes returns random bytes of length len (wrapper for crypto/rand).
Types ¶
type Group ¶
type Group interface { // NewScalar returns a new, empty, scalar. NewScalar() Scalar // NewElement returns a new, empty, element. NewElement() Point // ElementLength returns the byte size of an encoded element. ElementLength() int // Identity returns the group's identity element. Identity() Point // HashToGroup allows arbitrary input to be safely mapped to the curve of the Group. HashToGroup(input, dst []byte) Point // HashToScalar allows arbitrary input to be safely mapped to the field. HashToScalar(input, dst []byte) Scalar // Base returns the group's base point a.k.a. canonical generator. Base() Point // MultBytes allows []byte encodings of a scalar and an element of the Group to be multiplied. MultBytes(scalar, element []byte) (Point, error) }
Group abstracts operations in elliptic-curve prime-order groups.
type Point ¶
type Point interface { // Add returns the sum of the Points, and does not change the receiver. Add(Point) Point // Sub returns the difference between the Points, and does not change the receiver. Sub(Point) Point // Mult returns the scalar multiplication of the receiver point with the given scalar. Mult(Scalar) Point // InvertMult returns the scalar multiplication of the receiver point with the inverse of the given scalar. InvertMult(Scalar) Point // IsIdentity returns whether the point is the Group's identity point. IsIdentity() bool // Copy returns a copy of the point. Copy() Point // Decode decodes the input an sets the current point to its value, and returns it. Decode(in []byte) (Point, error) // Bytes returns the compressed byte encoding of the point. Bytes() []byte }
Point interface abstracts common operations on Points in a Group.
type Scalar ¶
type Scalar interface { // Random sets the current scalar to a new random scalar and returns it. Random() Scalar // Add returns the sum of the scalars, and does not change the receiver. Add(scalar Scalar) Scalar // Sub returns the difference between the scalars, and does not change the receiver. Sub(scalar Scalar) Scalar // Mult returns the multiplication of the scalars, and does not change the receiver. Mult(scalar Scalar) Scalar // Invert returns the scalar's modular inverse ( 1 / scalar ), and does not change the receiver. Invert() Scalar // Copy returns a copy of the Scalar. Copy() Scalar // Decode decodes the input an sets the current scalar to its value, and returns it. Decode(in []byte) (Scalar, error) // Bytes returns the byte encoding of the element. Bytes() []byte }
Scalar interface abstracts common operations on scalars in a Group.
Click to show internal directories.
Click to hide internal directories.