Documentation
¶
Overview ¶
Package secp256k1 allows simple and abstracted operations in the Secp256k1 group.
Index ¶
- Constants
- func Ciphersuite() string
- func ElementLength() int
- func Order() []byte
- func ScalarLength() int
- 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) int
- func (e *Element) Hex() string
- func (e *Element) Identity() *Element
- func (e *Element) IsIdentity() bool
- func (e *Element) MarshalBinary() ([]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) XCoordinate() []byte
- type Scalar
- func (s *Scalar) Add(scalar *Scalar) *Scalar
- func (s *Scalar) Copy() *Scalar
- func (s *Scalar) Decode(in []byte) error
- func (s *Scalar) DecodeHex(h string) error
- func (s *Scalar) Encode() []byte
- func (s *Scalar) Equal(scalar *Scalar) int
- func (s *Scalar) Hex() string
- func (s *Scalar) Invert() *Scalar
- func (s *Scalar) IsZero() bool
- func (s *Scalar) LessOrEqual(scalar *Scalar) int
- func (s *Scalar) MarshalBinary() ([]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) UnmarshalBinary(data []byte) error
- func (s *Scalar) Zero() *Scalar
Constants ¶
const ( // H2CSECP256K1 represents the hash-to-curve string identifier for Secp256k1. H2CSECP256K1 = "secp256k1_XMD:SHA-256_SSWU_RO_" // E2CSECP256K1 represents the encode-to-curve string identifier for Secp256k1. E2CSECP256K1 = "secp256k1_XMD:SHA-256_SSWU_NU_" )
Variables ¶
This section is empty.
Functions ¶
func Ciphersuite ¶
func Ciphersuite() string
Ciphersuite returns the hash-to-curve ciphersuite identifier.
func ElementLength ¶
func ElementLength() int
ElementLength returns the byte size of an encoded element.
func ScalarLength ¶
func ScalarLength() int
ScalarLength returns the byte size of an encoded scalar.
Types ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element implements the Element interface for the Secp256k1 group element.
func 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 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 NewElement ¶
func NewElement() *Element
NewElement returns a new element set to the identity point.
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) 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) XCoordinate ¶
XCoordinate returns the encoded x coordinate of the element, which is the same as Encode().
type Scalar ¶
type Scalar struct {
// contains filtered or unexported fields
}
Scalar implements the Scalar interface for Edwards25519 group scalars.
func 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 (*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) LessOrEqual ¶
LessOrEqual returns 1 if s <= scalar and 0 otherwise.
func (*Scalar) MarshalBinary ¶
MarshalBinary returns the compressed byte encoding of the scalar.
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) UnmarshalBinary ¶
UnmarshalBinary sets e to the decoding of the byte encoded scalar.