Skip to main content

Crate arkworks_small_values_ops

Crate arkworks_small_values_ops 

Source

Functionsยง

abs_diff
Computes the absolute difference between two field elements a and b using slack variables to ensure that the result is correct without directly comparing the two values.
cast_to_boolean
Casts a field element to a Boolean variable, enforcing that the field element is either 0 or 1.
cast_to_u64
Casts a field element to a u64, assuming the field element is in the range [0, 2^64).
enforce_ge
Enforce that a >= b.
enforce_in_binary_bound
Enforces that the given value is in the range [0, 2^BITS - 1] (inclusive!). This is done by introducing BITS new boolean variables and reconstructing the value from them.
enforce_in_bound
(Naively!) enforces that the given value is in the range [0, bound] (inclusive!). This is done by delegating to enforce_in_set with the set of all integers in that range.
enforce_in_set
Naively(!) enforces that the given value is in the set defined by the provided elements. It is done by constructing a vanishing polynomial.
enforce_le
Enforce that a <= b.
from_bits
Given an array of Booleans representing the bits of a field element in little-endian order, reconstruct the field element.
ge
Returns a Boolean indicating whether a >= b.
le
Returns a Boolean indicating whether a <= b.
max
Computes the maximum of two field elements a and b using slack variables to ensure that the result is correct without directly comparing the two values.
min
Computes the minimum of two field elements a and b using slack variables to ensure that the result is correct without directly comparing the two values.
one_hot_encode
One-hot encodes a field element x into a vector of BITS FpVars.
saturating_sub
Computes the saturating difference between two field elements a and b.
to_bits
Given a field element, get its N least significant bits as a vector of Booleans in the little-endian order.