Documentation
¶
Overview ¶
Package field implements fast arithmetic modulo 2^255-19.
Element type API is the same as filippo.io/edwards25519/field.Element.
Performance: The package uses optimized assembly implementations translated from Amazon's s2n-bignum library for arithmetic operations on amd64 and arm64 architectures, providing performance improvement over filippo.io/edwards25519/field implementation.
The Go assembly files are translated from s2n-bignum's proven assembly implementations and verified by comparing the disassembled machine code output from the Go compiler against the original s2n-bignum implementations.
Index ¶
- type Element
- func (v *Element) Absolute(u *Element) *Element
- func (v *Element) Add(x, y *Element) *Element
- func (v *Element) Bytes() []byte
- func (v *Element) Equal(u *Element) int
- func (v *Element) FillBytes(buf []byte) []byte
- func (v *Element) Invert(z *Element) *Element
- func (v *Element) IsNegative() int
- func (v *Element) Mult32(x *Element, y uint32) *Element
- func (v *Element) Multiply(x, y *Element) *Element
- func (v *Element) Negate(a *Element) *Element
- func (v *Element) One() *Element
- func (v *Element) Pow22523(x *Element) *Element
- func (v *Element) Select(a, b *Element, cond int) *Element
- func (v *Element) Set(a *Element) *Element
- func (v *Element) SetBytes(x []byte) (*Element, error)
- func (r *Element) SqrtRatio(u, v *Element) (R *Element, wasSquare int)
- func (v *Element) Square(x *Element) *Element
- func (v *Element) Subtract(a, b *Element) *Element
- func (v *Element) Swap(u *Element, cond int)
- func (v *Element) Zero() *Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents an element of the field GF(2^255-19).
This type works similarly to filippo.io/edwards25519/field.Element, and all arguments and receivers are allowed to alias.
The zero value is a valid zero element.
func (*Element) FillBytes ¶
FillBytes sets buf the canonical 32-byte little-endian encoding of v, and returns buf. If the value of v doesn't fit in buf, FillBytes will panic.
func (*Element) IsNegative ¶
IsNegative returns 1 if v is negative, and 0 otherwise.
func (*Element) SetBytes ¶
SetBytes sets v to x, where x is a 32-byte little-endian encoding. If x is not of the right length, SetBytes returns nil and an error, and the receiver is unchanged.
Consistent with RFC 7748, the most significant bit (the high bit of the last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1) are accepted. Note that this is laxer than specified by RFC 8032, but consistent with most Ed25519 implementations.
func (*Element) SqrtRatio ¶
SqrtRatio sets r to the non-negative square root of the ratio of u and v.
If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00, and returns r and 0.