Expand description
Tools useful for interacting with fancy-garbling.
Note: all number representations in this library are little-endian.
Constants§
Traits§
- RngExt
- Extra Rng functionality, useful for
fancy-garbling.
Functions§
- as_
base_ q_ u128 - Convert
xinto baseq. - as_
mixed_ radix - Convert
xinto mixed radix form using the providedradii. - base_
modulus_ with_ width - Generate a CRT modulus that support at least n-bit integers, using provided primes.
- base_
primes_ with_ width - Generate the factors of a CRT modulus that support at least n-bit integers, using provided primes.
- base_
q_ add_ eq - Add a base
qsliceysintoxs. - crt
- Compute the CRT representation of x with respect to the primes ps.
- crt_
factor - Compute the CRT representation of
xwith respect to the factorization ofq. - crt_inv
- Compute the value x given a list of CRT primes and residues.
- crt_
inv_ factor - Compute the value
xgiven a composite CRT modulus provided byxs. - digits_
per_ u128 - Determine how many
mod qdigits fit into au128(includes the color digit). - factor
- Factor using the primes in the global
PRIMESarray. Fancy garbling only supports composites with small prime factors. - from_
base_ q - Convert little-endian base
qdigits intou128. - from_
mixed_ radix - Convert little-endian mixed radix digits into u128.
- generate_
deltas - Generate deltas ahead of time for the Garbler.
- inv
- Invert inp_a mod inp_b.
- is_
power_ of_ 2 - Raise a u16 to a power mod some value.
Returns
trueifxis a power of 2. - modulus_
with_ nprimes - Primes skipping the modulus 2, which allows certain gadgets. Generate a CRT modulus with n primes.
- modulus_
with_ width - Generate a CRT modulus that support at least n-bit integers, using the built-in PRIMES.
- output_
tweak - Compute the output tweak for a garbled gate where i is the gate id and k is the value.
- primes_
with_ width - Generate the factors of a CRT modulus that support at least n-bit integers, using the built-in PRIMES.
- product
- Generate a CRT modulus that support at least n-bit integers, using the built-in PRIMES_SKIP_2 (does not include 2 as a factor). Compute the product of some u16s as a u128.
- tweak
- Tweak function for a single item.
- tweak2
- Tweak function for two items.
- u128_
from_ bits - Convert into a u128 from the “bits” as u16. Assumes each “bit” is 0 or 1.
- u128_
to_ bits - Get the bits of a u128 encoded in 128 u16s, which is convenient for the rest of the library, which uses u16 as the base digit type in Wire.