Documentation ¶
Overview ¶
Package r255 implements Ristretto255 curve prime-order groups with backend "filippo.io/edwards25519"
Index ¶
- Constants
- Variables
- func R255() internal.Group
- type Element
- func (e *Element) Add(ee internal.Element) internal.Element
- func (e *Element) Base() internal.Element
- func (e *Element) Bytes() []byte
- func (e *Element) Copy() internal.Element
- func (e *Element) Decode(data []byte) error
- func (e *Element) Double() internal.Element
- func (e *Element) Encode() []byte
- func (e *Element) Equal(ee internal.Element) int
- func (e *Element) Identity() internal.Element
- func (e *Element) IsIdentity() bool
- func (e *Element) MarshalBinary() ([]byte, error)
- func (e *Element) MarshalText() (text []byte, err error)
- func (e *Element) Multiply(s internal.Scalar) internal.Element
- func (e *Element) Negate() internal.Element
- func (e *Element) Set(ee internal.Element) internal.Element
- func (e *Element) SetCanonicalBytes(in []byte) (*Element, error)
- func (e *Element) SetUniformBytes(b []byte) (internal.Element, error)
- func (e *Element) Subtract(ee internal.Element) internal.Element
- func (e *Element) UnmarshalBinary(data []byte) error
- func (e *Element) UnmarshalText(text []byte) error
- type Group
- func (g *Group) Base() internal.Element
- func (g *Group) Ciphersuite() string
- func (g *Group) ElementLength() uint
- func (g *Group) EncodeToGroup(input, dst []byte) internal.Element
- func (g *Group) HashToGroup(input, dst []byte) internal.Element
- func (g *Group) HashToScalar(input, dst []byte) internal.Scalar
- func (g *Group) NewElement() internal.Element
- func (g *Group) NewScalar() internal.Scalar
- func (g *Group) RandomElement() internal.Element
- func (g *Group) RandomScalar() internal.Scalar
- func (g *Group) ScalarLength() uint
- type Scalar
- func (s *Scalar) Add(ss internal.Scalar) internal.Scalar
- func (s *Scalar) Copy() internal.Scalar
- func (s *Scalar) Decode(in []byte) error
- func (s *Scalar) Encode() []byte
- func (s *Scalar) Equal(ss internal.Scalar) int
- func (s *Scalar) Invert() internal.Scalar
- func (s *Scalar) IsZero() bool
- func (s *Scalar) MarshalBinary() ([]byte, error)
- func (s *Scalar) MarshalText() (text []byte, err error)
- func (s *Scalar) Multiply(ss internal.Scalar) internal.Scalar
- func (s *Scalar) One() internal.Scalar
- func (s *Scalar) Random() internal.Scalar
- func (s *Scalar) Set(ss internal.Scalar) internal.Scalar
- func (s *Scalar) SetCanonicalBytes(x []byte) (*Scalar, error)
- func (s *Scalar) SetUniformBytes(x []byte) (*Scalar, error)
- func (s *Scalar) Subtract(ss internal.Scalar) internal.Scalar
- func (s *Scalar) UnmarshalBinary(data []byte) error
- func (s *Scalar) UnmarshalText(text []byte) error
- func (s *Scalar) Zero() internal.Scalar
Constants ¶
const ( // H2C represents the hash-to-curve string identifier. // See https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-hashing-to-ristretto255 H2C = "ristretto255_XMD:SHA-512_R255MAP_RO_" )
Variables ¶
var ( // ErrInvalidEncoding returns when passed unsuitable data for unmarshaling ErrInvalidEncoding = errors.New("r255: invalid element encoding") )
Functions ¶
Types ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents Ristretto 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) Equal ¶
Equal returns 1 if e is equivalent to ee, and 0 otherwise.
Note that Elements must not be compared in any other way.
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 implements the encoding.BinaryMarshaler interface.
func (*Element) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Element) Multiply ¶
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
func (*Element) Set ¶
Set sets the receiver to ee if not nil; else the receiver not modified; returns the receiver.
func (*Element) SetCanonicalBytes ¶
SetCanonicalBytes sets e to the decoded value of in. If in is not a canonical encoding of s, SetCanonicalBytes returns nil and an error and the receiver is unchanged.
func (*Element) SetUniformBytes ¶
SetUniformBytes deterministically sets e to an uniformly distributed value given 64 uniformly distributed random bytes.
This can be used for hash-to-group operations or to obtain a random element.
func (*Element) Subtract ¶
Subtract subtracts the input from the receiver, and returns the receiver.
func (*Element) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Element) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Group ¶
type Group struct{}
Group represents the Ristretto255 group. It exposes a prime-order group API with hash-to-curve operations.
func (*Group) Ciphersuite ¶
Ciphersuite returns the hash-to-curve ciphersuite identifier.
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) NewElement ¶
NewElement returns the identity element (point at infinity).
func (*Group) RandomElement ¶
RandomElement returns randomly generated element.
func (*Group) RandomScalar ¶
RandomScalar returns randomly generated scalar.
func (*Group) ScalarLength ¶
ScalarLength returns the byte size of an encoded scalar.
type Scalar ¶
type Scalar struct {
// contains filtered or unexported fields
}
Scalar represents the Ristretto255 curve Scalar point
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) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Scalar) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Scalar) Multiply ¶
Multiply multiplies the receiver with the input, and returns the receiver. If s parameter is nil, then the receiver is not modified
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) SetCanonicalBytes ¶
SetCanonicalBytes sets s = x, where x is a 32 bytes little-endian encoding of s. If x is not a canonical encoding of s, SetCanonicalBytes returns nil and an error and the receiver is unchanged.
func (*Scalar) SetUniformBytes ¶
SetUniformBytes sets s to an uniformly distributed value given 64 uniformly distributed random bytes. If x is not of the right length, SetUniformBytes returns nil and an error, and the receiver is unchanged.
func (*Scalar) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Scalar) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.