Documentation ¶
Index ¶
- Variables
- type Fq
- func (fq *Fq) Add(lhs, rhs *Fq) *Fq
- func (fq *Fq) BigInt() *big.Int
- func (fq *Fq) Bytes() [32]byte
- func (fq *Fq) CMove(lhs, rhs *Fq, choice int) *Fq
- func (fq *Fq) Cmp(rhs *Fq) int
- func (fq *Fq) Double(elem *Fq) *Fq
- func (fq *Fq) Equal(rhs *Fq) bool
- func (fq *Fq) Exp(base, exp *Fq) *Fq
- func (fq *Fq) Invert(elem *Fq) (*Fq, bool)
- func (fq *Fq) IsOne() bool
- func (fq *Fq) IsZero() bool
- func (fq *Fq) Mul(lhs, rhs *Fq) *Fq
- func (fq *Fq) Neg(elem *Fq) *Fq
- func (fq *Fq) Set(rhs *Fq) *Fq
- func (fq *Fq) SetBigInt(bi *big.Int) *Fq
- func (fq *Fq) SetBool(rhs bool) *Fq
- func (fq *Fq) SetBytes(input *[32]byte) (*Fq, error)
- func (fq *Fq) SetBytesWide(input *[64]byte) *Fq
- func (fq *Fq) SetOne() *Fq
- func (fq *Fq) SetRaw(array *[4]uint64) *Fq
- func (fq *Fq) SetUint64(rhs uint64) *Fq
- func (fq *Fq) SetZero() *Fq
- func (fq *Fq) Sqrt(elem *Fq) (*Fq, bool)
- func (fq *Fq) Square(elem *Fq) *Fq
- func (fq *Fq) Sub(lhs, rhs *Fq) *Fq
- func (fq *Fq) ToRaw() [4]uint64
Constants ¶
This section is empty.
Variables ¶
var BiModulus = new(big.Int).SetBytes([]byte{
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x22, 0x46, 0x98, 0xfc, 0x09, 0x94, 0xa8, 0xdd,
0x8c, 0x46, 0xeb, 0x21, 0x00, 0x00, 0x00, 0x01,
})
Functions ¶
This section is empty.
Types ¶
type Fq ¶
type Fq fiat_pasta_fq_montgomery_domain_field_element
func (*Fq) Bytes ¶
Bytes converts this element into a byte representation in little endian byte order
func (*Fq) Invert ¶
Invert this element i.e. compute the multiplicative inverse return false, zero if this element is zero
func (*Fq) SetBigInt ¶
SetBigInt initializes an element from big.Int The value is reduced by the modulus
func (*Fq) SetBytes ¶
SetBytes attempts to convert a little endian byte representation of a scalar into a `Fq`, failing if input is not canonical
func (*Fq) 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/fq.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 (*Fq) Sqrt ¶
Sqrt this element, if it exists. If true, then value is a square root. If false, value is a QNR