Documentation ¶
Overview ¶
Library for arithmetic modulo any 193-bit to 256-bit modulus
Index ¶
- type ExpBase
- type Modulus
- type Residue
- func (z *Residue) Add(x *Residue) *Residue
- func (z *Residue) Copy(x *Residue) *Residue
- func (z *Residue) Double() *Residue
- func (x *Residue) Equal(y *Residue) bool
- func (z *Residue) Exp(x [4]uint64) *Residue
- func (z *Residue) ExpPrecomp(x *ExpBase, y [4]uint64) *Residue
- func (z *Residue) FromUint64(m *Modulus, x [4]uint64) *Residue
- func (z *Residue) Inv() bool
- func (z *Residue) Mul(x *Residue) *Residue
- func (z *Residue) Neg() *Residue
- func (x *Residue) NotEqual(y *Residue) bool
- func (z *Residue) Square() *Residue
- func (z *Residue) Sub(x *Residue) *Residue
- func (z *Residue) ToUint64() [4]uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpBase ¶
type ExpBase struct {
// contains filtered or unexported fields
}
The ExpBase type contains lookup tables allowing fast repeated modular exponentiation with the same base value.
func (*ExpBase) FromResidue ¶
FromResidue initialises ExpBase from a residue. It performs 224 squarings and 22 multiplications.
type Modulus ¶
type Modulus struct {
// contains filtered or unexported fields
}
Modulus contains a modulus `m` as well as derived values that help speed up computations. The allowed range for `m` is `2^192` to `2^256-1`.
func NewModulusFromUint64 ¶
NewModulusFromUint64 creates a new modulus object from a little-endian array of uint64.
type Residue ¶
type Residue struct {
// contains filtered or unexported fields
}
Residue contains a representative of a residue class, and the pointer to its modulus. The residue is stored as any 256-bit unsigned integer in the residue class, represented by a 4-element little-endian array of uint64.
func (*Residue) Copy ¶
Copy copies one residue to another. Both the residue value and the modulus pointer are copied.
func (*Residue) Exp ¶
Exp performs modular exponentiation without storing precomputed values for later use. It performs 255 squarings and 74 multiplications.
func (*Residue) ExpPrecomp ¶
ExpPrecomp takes an ExpBase computed from the base value, a 256-bit integer as the exponent, and performs modular exponentiation. It performs 31 squarings and 63 multiplications.
func (*Residue) FromUint64 ¶
FromUint64 sets the residue value from a little-endian array of uint64.