Crate libbgs_util
source ·Expand description
Various number theory utility methods used throughout the libbgs crate.
Functions
- Returns the sum of
aandbas 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
aandb, 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
xto the power ofn, modulom. - Returns the product of
aandbmodulom. This function will panic ifm >= 2^127. Otherwise, it is guarenteed that there will not be integer overflow. - Shifts
dstto the rightnbits, filling in from the left with the least significant bits ofsrc. - Returns a pseudo-random integer modulo
q, unique for everyibetween0andq. This acts suitably well as a random number generator for several modular arithmetic operations, including randomly searching for quadratic (non) residues.