Documentation ¶
Overview ¶
Package ecc exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
It implements the latest hash-to-curve specification to date (https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/).
Index ¶
- type Element
- func (e *Element) Add(element *Element) *Element
- func (e *Element) Base() *Element
- func (e *Element) Copy() *Element
- func (e *Element) Decode(data []byte) error
- func (e *Element) DecodeHex(h string) error
- func (e *Element) Double() *Element
- func (e *Element) Encode() []byte
- func (e *Element) Equal(element *Element) bool
- func (e *Element) Group() Group
- func (e *Element) Hex() string
- func (e *Element) Identity() *Element
- func (e *Element) IsIdentity() bool
- func (e *Element) MarshalBinary() ([]byte, error)
- func (e *Element) MarshalJSON() ([]byte, error)
- func (e *Element) Multiply(scalar *Scalar) *Element
- func (e *Element) Negate() *Element
- func (e *Element) Set(element *Element) *Element
- func (e *Element) Subtract(element *Element) *Element
- func (e *Element) UnmarshalBinary(data []byte) error
- func (e *Element) UnmarshalJSON(data []byte) error
- func (e *Element) XCoordinate() []byte
- type Group
- func (g Group) Available() bool
- func (g Group) Base() *Element
- func (g Group) ElementLength() int
- func (g Group) EncodeToGroup(input, dst []byte) *Element
- func (g Group) HashFunc() crypto.Hash
- func (g Group) HashToGroup(input, dst []byte) *Element
- func (g Group) HashToScalar(input, dst []byte) *Scalar
- func (g Group) MakeDST(app string, version uint8) []byte
- func (g Group) NewElement() *Element
- func (g Group) NewScalar() *Scalar
- func (g Group) Order() []byte
- func (g Group) ScalarLength() int
- func (g Group) String() string
- type Scalar
- func (s *Scalar) Add(scalar *Scalar) *Scalar
- func (s *Scalar) Copy() *Scalar
- func (s *Scalar) Decode(data []byte) error
- func (s *Scalar) DecodeHex(h string) error
- func (s *Scalar) Encode() []byte
- func (s *Scalar) Equal(scalar *Scalar) bool
- func (s *Scalar) Group() Group
- func (s *Scalar) Hex() string
- func (s *Scalar) Invert() *Scalar
- func (s *Scalar) IsZero() bool
- func (s *Scalar) LessOrEqual(scalar *Scalar) bool
- func (s *Scalar) MarshalBinary() ([]byte, error)
- func (s *Scalar) MarshalJSON() ([]byte, error)
- func (s *Scalar) MinusOne() *Scalar
- func (s *Scalar) Multiply(scalar *Scalar) *Scalar
- func (s *Scalar) One() *Scalar
- func (s *Scalar) Pow(scalar *Scalar) *Scalar
- func (s *Scalar) Random() *Scalar
- func (s *Scalar) Set(scalar *Scalar) *Scalar
- func (s *Scalar) SetUInt64(i uint64) *Scalar
- func (s *Scalar) Subtract(scalar *Scalar) *Scalar
- func (s *Scalar) UInt64() (uint64, error)
- func (s *Scalar) UnmarshalBinary(data []byte) error
- func (s *Scalar) UnmarshalJSON(data []byte) error
- func (s *Scalar) Zero() *Scalar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
Element represents an element on the curve of the prime-order group.
func (*Element) Add ¶
Add sets the receiver to the sum of the input and the receiver, and returns the receiver.
func (*Element) Decode ¶
Decode sets the receiver to a decoding of the input data, and returns an error on failure.
func (*Element) Identity ¶
Identity sets the element to the point at infinity of the Group's underlying curve.
func (*Element) IsIdentity ¶
IsIdentity returns whether the Element is the point at infinity of the Group's underlying curve.
func (*Element) MarshalBinary ¶
MarshalBinary returns the compressed byte encoding of the element.
func (*Element) MarshalJSON ¶
MarshalJSON marshals the element into valid JSON.
func (*Element) Multiply ¶
Multiply sets the receiver to the scalar multiplication of the receiver with the given Scalar, and returns it.
func (*Element) Subtract ¶
Subtract subtracts the input from the receiver, and returns the receiver.
func (*Element) UnmarshalBinary ¶
UnmarshalBinary sets e to the decoding of the byte encoded element.
func (*Element) UnmarshalJSON ¶
UnmarshalJSON unmarshals the input into the element.
func (*Element) XCoordinate ¶
XCoordinate returns the encoded x coordinate of the element.
type Group ¶
type Group byte
Group identifies prime-order groups over elliptic curves with hash-to-group operations.
const ( // Ristretto255Sha512 identifies the Ristretto255 group with SHA2-512 hash-to-group hashing. Ristretto255Sha512 Group = 1 + iota // P256Sha256 identifies a group over P256 with SHA2-256 hash-to-group hashing. P256Sha256 // P384Sha384 identifies a group over P384 with SHA2-384 hash-to-group hashing. P384Sha384 // P521Sha512 identifies a group over P521 with SHA2-512 hash-to-group hashing. P521Sha512 // Edwards25519Sha512 identifies the Edwards25519 group with SHA2-512 hash-to-group hashing. Edwards25519Sha512 // Secp256k1Sha256 identifies the SECp256k1 group with SHA2-256 hash-to-group hashing. Secp256k1Sha256 )
func (Group) ElementLength ¶
ElementLength returns the byte size of an encoded element.
func (Group) EncodeToGroup ¶
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.
func (Group) HashToGroup ¶
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.
func (Group) HashToScalar ¶
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.
func (Group) MakeDST ¶
MakeDST builds a domain separation tag in the form of <app>-V<version>-CS<id>-<hash-to-curve-ID>, and returns no error.
func (Group) NewElement ¶
NewElement returns the identity element (point at infinity).
func (Group) ScalarLength ¶
ScalarLength returns the byte size of an encoded scalar.
type Scalar ¶
Scalar represents a scalar in the prime-order group.
func (*Scalar) Add ¶
Add sets the receiver to the sum of the input and the receiver, and returns the receiver.
func (*Scalar) Decode ¶
Decode sets the receiver to a decoding of the input data, and returns an error on failure.
func (*Scalar) Invert ¶
Invert sets the receiver to the scalar's modular inverse ( 1 / scalar ), and returns it.
func (*Scalar) LessOrEqual ¶
LessOrEqual returns 1 if s <= scalar, and 0 otherwise.
func (*Scalar) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Scalar) MarshalJSON ¶
MarshalJSON marshals the scalar into valid JSON.
func (*Scalar) Multiply ¶
Multiply multiplies the receiver with the input, and returns the receiver.
func (*Scalar) Pow ¶
Pow sets s to s**scalar modulo the group order, and returns s. If scalar is nil, it returns 1.
func (*Scalar) Random ¶
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.
func (*Scalar) Set ¶
Set sets the receiver to the value of the argument scalar, and returns the receiver.
func (*Scalar) SetUInt64 ¶
SetUInt64 sets s to i modulo the field order, and returns an error if one occurs.
func (*Scalar) UInt64 ¶
UInt64 returns the uint64 representation of the scalar, or an error if its value is higher than the authorized limit for uint64.
func (*Scalar) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Scalar) UnmarshalJSON ¶
UnmarshalJSON unmarshals the input into the scalar.
Directories ¶
Path | Synopsis |
---|---|
Package debug provides tools to help debugging.
|
Package debug provides tools to help debugging. |
Package encoding provides serde utilities.
|
Package encoding provides serde utilities. |
Package internal defines simple and abstract APIs to group Elements and Scalars.
|
Package internal defines simple and abstract APIs to group Elements and Scalars. |
edwards25519
Package edwards25519 allows simple and abstracted operations in the Edwards25519 group.
|
Package edwards25519 allows simple and abstracted operations in the Edwards25519 group. |
field
Package field provides modular operations over very high integers.
|
Package field provides modular operations over very high integers. |
nist
Package nist allows simple and abstracted operations in the NIST P-256, P-384, and P-521 groups, wrapping filippo.io/nistec.
|
Package nist allows simple and abstracted operations in the NIST P-256, P-384, and P-521 groups, wrapping filippo.io/nistec. |
ristretto
Package ristretto allows simple and abstracted operations in the Ristretto255 group.
|
Package ristretto allows simple and abstracted operations in the Ristretto255 group. |
secp256k1
Package secp256k1 allows simple and abstracted operations in the Secp256k1 group.
|
Package secp256k1 allows simple and abstracted operations in the Secp256k1 group. |