mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
All operators finished
This commit is contained in:
15
test/circuits/condternary.circom
Normal file
15
test/circuits/condternary.circom
Normal file
@@ -0,0 +1,15 @@
|
||||
template CondTernary() {
|
||||
signal input in;
|
||||
signal output out;
|
||||
|
||||
var a = 3;
|
||||
var b = a==3 ? 1 : 2; // b is 1
|
||||
var c = a!=3 ? 10 : 20; // c is 20
|
||||
var d = b+c; // d is 21
|
||||
|
||||
|
||||
out <-- ((in & 1) != 1) ? in + d : in; // Add 21 if in is pair
|
||||
|
||||
}
|
||||
|
||||
component main = CondTernary()
|
||||
16
test/circuits/whilerolled.circom
Normal file
16
test/circuits/whilerolled.circom
Normal file
@@ -0,0 +1,16 @@
|
||||
template WhileRolled() {
|
||||
signal input in;
|
||||
signal output out;
|
||||
|
||||
var acc = 0;
|
||||
|
||||
var i=0;
|
||||
while (i<in) {
|
||||
acc = acc + 1;
|
||||
i++
|
||||
}
|
||||
|
||||
out <== acc;
|
||||
}
|
||||
|
||||
component main = WhileRolled();
|
||||
12
test/circuits/whileunrolled.circom
Normal file
12
test/circuits/whileunrolled.circom
Normal file
@@ -0,0 +1,12 @@
|
||||
template WhileUnrolled(n) {
|
||||
signal input in;
|
||||
signal output out[n];
|
||||
|
||||
var i=0;
|
||||
while (i<n) {
|
||||
out[i] <== in + i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
component main = WhileUnrolled(3);
|
||||
Reference in New Issue
Block a user