the principles behind JSnark
framework
An arithmetic circuit is quite simple. Typically, it consists of a set of wires and gates. For example, the function f(x1, x2, x3, x4) = (x1 * x2 + 5) * ((x3 + x4) * 6) can be computed by the following circuit:
total 12
input 0 # The one-input wire.
const-mul-0 in 1 <0> out 1 <1>
input 2
input 3
input 4
input 5
mul in 2 <2 3> out 1 <6> # 2 inputs and 1 output
add in 2 <4 5> out 1 <7>
const-mul-5 in 1 <0> out 1 <8>
add in 2 <6 8> out 1 <9>
const-mul-6 in 1 <7> out 1 <10>
mul in 2 <9 10> out 1 <11>
output 11
JSnark implements several basic operations such as
- multiply:
- isEqualTo:
checkNonZero()
invAsBit()
getBitWires()
xorBitwise()
andBitwise()
orBitwise()