@function(lt, @out: 0:1, @in: 0:1, 0:1) @plugin(extended_arithmetic_v1, less_than); @function(lte, @out: 0:1, @in: 0:1, 0:1) @plugin(extended_arithmetic_v1, less_than_equal); @function(div, @out: 0:1, 0:1, @in: 0:1, 0:1) @plugin(extended_arithmetic_v1, division); @function(bit_decomp, @out: 0:7, @in: 0:1) @plugin(extended_arithmetic_v1, bit_decompose);
The Extended Arithmetic Plugin
The extended_arithmetic_v1
plugin provides additional arithmetic operations over the basic addition and multiplication, easing the development of a broader range of statements.
Operations
The following operations are supported.
less_than
-
Compares two inputs, returning 1 if the first input is less than the second input, or 0 otherwise.
less_than_equal
-
Compares two inputs, returning 1 if the first input is less than or equal to the second input, or 0 otherwise.
division
-
Divides two inputs as if they were integers, returning first the quotient and then the remainder.
bit_decompose
-
Decomposes a single input into a bit vector, returning it as range whose length is the prime’s width.
less_than
and less_than_equal
These compare two inputs and indicate 1 or 0 for truth or false.
For a given type t
the following parameters are used.
-
Output
t:1
: 1 or 0 -
Input
t:1
: Left side of comparison -
Input
t:1
: Right side of comparison
-
Plugin Name:
extended_arithmetic_v1
-
Operation:
less_than
orless_than_equal
division
This operation divides one input by the other, returning a quotient or a remainder.
For a given type t
the following parameters are used.
-
Output
t:1
: Quotient -
Output
t:1
: Remainder -
Input
t:1
: Numerator/dividend -
Input
t:1
: Denominator/divisor
-
Plugin Name:
extended_arithmetic_v1
-
Operation:
division
bit_decompose
The operation accepts one input, n, and decomposes it into a bit vector.
The vector, v, is represented as a range of output wires with each element chosen from {0,1}, such that sum(vi * 2l-i) == n.
The output vector’s length, l, must be exactly ceiling(log2(p)), where p is the field’s prime.
The most significant bit is stored first and the least significant bit is last.
For a given type t
with prime p
, the following parameters are used.
-
Output
t:ceiling(log2(p))
: The decomposed bits -
Input
t:1
: Value to decompose
-
Plugin Name:
extended_arithmetic_v1
-
Operation:
bit_decompose
Implementing the Wizkit Arithmetic Plugin
TODO: Coming Soon