Module rangeutils

Module rangeutils 

Source
Expand description

A module containing some utility functions useful for the runtime processing of range statements.

Functionsยง

bit_decomp
Convert the low nbits bits of the given Scalar to a vector of Choice. The first element of the vector is the low bit. This version runs in constant time.
bit_decomp_vartime
Convert a Scalar to an u128, assuming it fits in an i128 and is nonnegative. Also output the number of bits of the Scalar. This version assumes that s is public, and so does not need to run in constant time.
bitrep_scalars_vartime
Given a Scalar upper (strictly greater than 1), make a vector of Scalars with the property that a Scalar x can be written as a sum of zero or more (distinct) elements of this vector if and only if 0 <= x < upper.
compute_bitrep
Given a vector of Scalars as output by bitrep_scalars_vartime and a private Scalar x, output a vector of Choice (of the same length as the given bitrep_scalars vector) such that x is the sum of the chosen elements of bitrep_scalars. This function should be constant time in the value of x. If x is not less than the upper used by bitrep_scalars_vartime to generate bitrep_scalars, then x will not (and indeed cannot) equal the sum of the chosen elements of bitrep_scalars.