Documentation ¶
Index ¶
- type Fp
- func (fp *Fp) Add(lhs, rhs *Fp) *Fp
- func (fp *Fp) BigInt() *big.Int
- func (fp *Fp) Bytes() [32]byte
- func (fp *Fp) CMove(lhs, rhs *Fp, choice int) *Fp
- func (fp *Fp) Cmp(rhs *Fp) int
- func (fp *Fp) Double(elem *Fp) *Fp
- func (fp *Fp) Equal(rhs *Fp) bool
- func (fp *Fp) Exp(base, exp *Fp) *Fp
- func (fp *Fp) Invert(elem *Fp) (*Fp, bool)
- func (fp *Fp) IsOdd() bool
- func (fp *Fp) IsOne() bool
- func (fp *Fp) IsZero() bool
- func (fp *Fp) Mul(lhs, rhs *Fp) *Fp
- func (fp *Fp) Neg(elem *Fp) *Fp
- func (fp *Fp) Set(rhs *Fp) *Fp
- func (fp *Fp) SetBigInt(bi *big.Int) *Fp
- func (fp *Fp) SetBool(rhs bool) *Fp
- func (fp *Fp) SetBytes(input *[32]byte) (*Fp, error)
- func (fp *Fp) SetBytesWide(input *[64]byte) *Fp
- func (fp *Fp) SetOne() *Fp
- func (fp *Fp) SetRaw(array *[4]uint64) *Fp
- func (fp *Fp) SetUint64(rhs uint64) *Fp
- func (fp *Fp) SetZero() *Fp
- func (fp *Fp) Sqrt(elem *Fp) (*Fp, bool)
- func (fp *Fp) Square(elem *Fp) *Fp
- func (fp *Fp) Sub(lhs, rhs *Fp) *Fp
- func (fp *Fp) ToRaw() [4]uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fp ¶
type Fp fiat_pasta_fp_montgomery_domain_field_element
func (*Fp) Bytes ¶
Bytes converts this element into a byte representation in little endian byte order
func (*Fp) Invert ¶
Invert this element i.e. compute the multiplicative inverse return false, zero if this element is zero
func (*Fp) SetBigInt ¶
SetBigInt initializes an element from big.Int The value is reduced by the modulus
func (*Fp) SetBytes ¶
SetBytes attempts to convert a little endian byte representation of a scalar into a `Fp`, failing if input is not canonical
func (*Fp) SetBytesWide ¶
SetBytesWide takes 64 bytes as input and treats them as a 512-bit number. Attributed to https://github.com/zcash/pasta_curves/blob/main/src/fields/fp.rs#L255 We reduce an arbitrary 512-bit number by decomposing it into two 256-bit digits with the higher bits multiplied by 2^256. Thus, we perform two reductions
1. the lower bits are multiplied by R^2, as normal 2. the upper bits are multiplied by R^2 * 2^256 = R^3
and computing their sum in the field. It remains to see that arbitrary 256-bit numbers can be placed into Montgomery form safely using the reduction. The reduction works so long as the product is less than R=2^256 multiplied by the modulus. This holds because for any `c` smaller than the modulus, we have that (2^256 - 1)*c is an acceptable product for the reduction. Therefore, the reduction always works so long as `c` is in the field; in this case it is either the constant `r2` or `r3`.
func (*Fp) Sqrt ¶
Sqrt this element, if it exists. If true, then value is a square root. If false, value is a QNR