Snark_intf.Field_var_intf
val length : t -> int
For debug purposes
val var_indices : t -> int list
Convert a t
value to its constituent constant and a list of scaled R1CS variables.
constant x
creates a new R1CS variable containing the constant field element x
.
to_constant x
returns Some f
if x holds only the constant field element f
. Otherwise, it returns None
.
linear_combination [(f1, x1);...;(fn, xn)]
returns the result of calculating f1 * x1 + f2 * x2 + ... + fn * xn
. This does not add a new constraint; see Constraint.t
for more information.
sum l
returns the sum of all R1CS variables in l
.
If the result would be greater than or equal to Field
.size then the value will overflow to be less than Field
.size.
add x y
returns the result of adding the R1CS variables x
and y
.
If the result would be greater than or equal to Field
.size then the value will overflow to be less than Field
.size.
sub x y
returns the result of subtracting the R1CS variables x
and y
.
If the result would be less than 0 then the value will underflow to be between 0 and Field
.size.
scale x f
returns the result of multiplying the R1CS variable x
by the constant field element f
.
If the result would be greater than or equal to Field
.size then the value will overflow to be less than Field
.size.
val project : boolean_var list -> t
Convert a list of bits into a field element.
project [b1;...;bn] = b1 + 2*b2 + 4*b3 + ... + 2^(n-1) * bn
If the result would be greater than or equal to Field
.size then the value will overflow to be less than Field
.size.
val pack : boolean_var list -> t
Convert a list of bits into a field element.
pack [b1;...;bn] = b1 + 2*b2 + 4*b3 + ... + 2^(n-1) * bn
This will raise an assertion error if the length of the list is not strictly less than number of bits in Field
.size.
Use project
if you know that the list represents a value less than Field
.size but where the number of bits may be the maximum, or where overflow is appropriate.