Crate libbgs_util

source ·
Expand description

Various number theory utility methods used throughout the libbgs crate.

Functions

  • Returns the sum of a and b as two 128-bit words. The first element of the tuple is the high word (guaranteed to be either 0 or 1) and the second is the low word.
  • Returns the product of a and b, as two 128-bit words. The first element of the tuple is the high word, and the second is the low word.
  • Returns a quadratic non-residue modulo p. That is, it returns an integer $a \in \mathbb{Z} / p\mathbb{Z}$ such that there is no $x$ satisfying $x^2 = a \mod p$.
  • Returns x to the power of n, modulo m.
  • Returns the product of a and b modulo m. This function will panic if m >= 2^127. Otherwise, it is guarenteed that there will not be integer overflow.
  • Shifts dst to the right n bits, filling in from the left with the least significant bits of src.
  • Returns a pseudo-random integer modulo q, unique for every i between 0 and q. This acts suitably well as a random number generator for several modular arithmetic operations, including randomly searching for quadratic (non) residues.