package field
import "crypto/ed25519/internal/edwards25519/field"
Package field implements fast arithmetic modulo 2^255-19.
Index ¶
- type Element
- func (v *Element) Absolute(u *Element) *Element
- func (v *Element) Add(a, b *Element) *Element
- func (v *Element) Bytes() []byte
- func (v *Element) Equal(u *Element) int
- 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
- func (r *Element) SqrtRatio(u, v *Element) (rr *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
Types ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents an element of the field GF(2^255-19). Note that this is not a cryptographically secure group, and should only be used to interact with edwards25519.Point coordinates.
This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.
The zero value is a valid zero element.
func (*Element) Absolute ¶
Absolute sets v to |u|, and returns v.
func (*Element) Add ¶
Add sets v = a + b, and returns v.
func (*Element) Bytes ¶
Bytes returns the canonical 32-byte little-endian encoding of v.
func (*Element) Equal ¶
Equal returns 1 if v and u are equal, and 0 otherwise.
func (*Element) Invert ¶
Invert sets v = 1/z mod p, and returns v.
If z == 0, Invert returns v = 0.
func (*Element) IsNegative ¶
IsNegative returns 1 if v is negative, and 0 otherwise.
func (*Element) Mult32 ¶
Mult32 sets v = x * y, and returns v.
func (*Element) Multiply ¶
Multiply sets v = x * y, and returns v.
func (*Element) Negate ¶
Negate sets v = -a, and returns v.
func (*Element) One ¶
One sets v = 1, and returns v.
func (*Element) Pow22523 ¶
Pow22523 set v = x^((p-5)/8), and returns v. (p-5)/8 is 2^252-3.
func (*Element) Select ¶
Select sets v to a if cond == 1, and to b if cond == 0.
func (*Element) Set ¶
Set sets v = a, and returns v.
func (*Element) SetBytes ¶
SetBytes sets v to x, which must be a 32-byte little-endian encoding.
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.
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.
func (*Element) Square ¶
Square sets v = x * x, and returns v.
func (*Element) Subtract ¶
Subtract sets v = a - b, and returns v.
func (*Element) Swap ¶
Swap swaps v and u if cond == 1 or leaves them unchanged if cond == 0, and returns v.
func (*Element) Zero ¶
Zero sets v = 0, and returns v.
Source Files ¶
fe.go fe_amd64.go fe_arm64_noasm.go fe_generic.go
Directories ¶
Path | Synopsis |
---|---|
crypto/ed25519/internal/edwards25519/field/_asm |
- Version
- v1.18.9
- Published
- Dec 1, 2022
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 54 seconds ago –
Tools for package owners.