Documentation
¶
Overview ¶
Package internal wraps all nist and ristretto255 curves into interfaces
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrParamNilPoint indicated a forbidden nil or empty point. ErrParamNilPoint = errors.New("nil or empty point") // ErrParamNilScalar indicates a forbidden nil or empty scalar. ErrParamNilScalar = errors.New("nil or empty scalar") // ErrCastElement indicates a failed attempt to cast to a point. ErrCastElement = errors.New("could not cast to same group element (you should not use different group e.g. P224 and P256)") // ErrCastScalar indicates a failed attempt to cast to a scalar. ErrCastScalar = errors.New("could not cast to same group scalar (you should not use different group e.g. P224 and P256)") // ErrWrongField indicates an incompatible field has been encountered. ErrWrongField = errors.New("incompatible field (different prime)") )
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element interface {
// Base sets the element to the group's base point a.k.a. canonical generator.
Base() Element
// Identity sets the element to the point at infinity of the Group's underlying curve.
Identity() Element
// Add sets the receiver to the sum of the input and the receiver, and returns the receiver.
Add(ee Element) Element
// Double sets the receiver to its double, and returns it.
Double() Element
// Negate sets the receiver to its negation, and returns it.
Negate() Element
// Subtract subtracts the input from the receiver, and returns the receiver.
Subtract(ee Element) Element
// Multiply sets the receiver to the scalar multiplication of the receiver with the given Scalar, and returns it.
// If s parameter is nil, then the receiver is not modified
Multiply(s Scalar) Element
// Equal returns 1 if the elements are equivalent, and 0 otherwise.
Equal(ee Element) int
// IsIdentity returns whether the Element is the point at infinity of the Group's underlying curve.
IsIdentity() bool
// Set sets the receiver to ee if not nil; else the receiver not modified; returns the receiver.
Set(ee Element) Element
// Copy returns a copy of the receiver.
Copy() Element
// Encode returns the compressed byte encoding of the element.
Encode() []byte
// Decode sets the receiver to a decoding of the input data, and returns an error on failure.
Decode(data []byte) error
// BinaryMarshaler implementation.
encoding.BinaryMarshaler
// BinaryUnmarshaler implementation.
encoding.BinaryUnmarshaler
// TextMarshaler implementation.
encoding.TextMarshaler
// TextUnmarshaler implementation.
encoding.TextUnmarshaler
}
Element interface represents the element of underlying curve's element
type Group ¶
type Group interface {
// NewScalar returns a new, empty, scalar.
NewScalar() Scalar
// NewElement returns the identity element (point at infinity).
NewElement() Element
// RandomScalar returns randomly generated scalar.
RandomScalar() Scalar
// RandomElement returns randomly generated element.
RandomElement() Element
// Base returns the group's base point a.k.a. canonical generator.
Base() Element
// HashToScalar returns a safe mapping of the arbitrary input to a Scalar.
// The DST must not be empty or nil, and is recommended to be longer than 16 bytes.
HashToScalar(input, dst []byte) Scalar
// HashToGroup returns a safe mapping of the arbitrary input to an Element in the Group.
// The DST must not be empty or nil, and is recommended to be longer than 16 bytes.
HashToGroup(input, dst []byte) Element
// EncodeToGroup returns a non-uniform mapping of the arbitrary input to an Element in the Group.
// The DST must not be empty or nil, and is recommended to be longer than 16 bytes.
EncodeToGroup(input, dst []byte) Element
// Ciphersuite returns the hash-to-curve ciphersuite identifier.
Ciphersuite() string
// ScalarLength returns the byte size of an encoded scalar.
ScalarLength() uint
// ElementLength returns the byte size of an encoded element.
ElementLength() uint
}
Group interface represents the prime-order group
type Scalar ¶
type Scalar interface {
// Zero sets the scalar to 0, and returns it.
Zero() Scalar
// One sets the scalar to 1, and returns it.
One() Scalar
// Random sets the current scalar to a new random scalar and returns it.
// The random source is crypto/rand, and this functions is guaranteed to return a non-zero scalar.
Random() Scalar
// Add sets the receiver to the sum of the input and the receiver, and returns the receiver.
Add(s Scalar) Scalar
// Subtract subtracts the input from the receiver, and returns the receiver.
Subtract(s Scalar) Scalar
// Multiply multiplies the receiver with the input, and returns the receiver.
// If s parameter is nil, then the receiver is not modified
Multiply(s Scalar) Scalar
// Invert sets the receiver to the scalar's modular inverse ( 1 / scalar ), and returns it.
Invert() Scalar
// Equal returns 1 if the scalars are equal, and 0 otherwise.
Equal(s Scalar) int
// IsZero returns whether the scalar is 0.
IsZero() bool
// Set sets the receiver to the value of the argument scalar, and returns the receiver.
// If s parameter is nil, then the receiver is not modified
Set(s Scalar) Scalar
// Copy returns a copy of the receiver.
Copy() Scalar
// Encode returns the compressed byte encoding of the scalar.
Encode() []byte
// Decode sets the receiver to a decoding of the input data, and returns an error on failure.
Decode(in []byte) error
// BinaryMarshaler returns a byte representation of the element.
encoding.BinaryMarshaler
// BinaryUnmarshaler recovers an element from a byte representation
// produced either by encoding.BinaryMarshaler or MarshalBinaryCompress.
encoding.BinaryUnmarshaler
// TextMarshaler returns a base64 standard string encoding of the element.
encoding.TextMarshaler
// TextUnmarshaler sets the base64 standard string encoding of the element.
encoding.TextUnmarshaler
}
Scalar interface represents the scalar of underlying curve's scalar
Directories
¶
| Path | Synopsis |
|---|---|
|
Package nist implements nist's curves prime-order group
|
Package nist implements nist's curves prime-order group |
|
Package r255 implements Ristretto255 curve prime-order groups with backend "filippo.io/edwards25519"
|
Package r255 implements Ristretto255 curve prime-order groups with backend "filippo.io/edwards25519" |
Click to show internal directories.
Click to hide internal directories.