You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: circuits/comparators.circom
-55Lines changed: 0 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -291,58 +291,3 @@ template CompConstant(ct) {
291
291
out <== num2bits.out[127];
292
292
}
293
293
294
-
/*
295
-
*** MaxValueCheck(ct): template that receives an input, checks its value is smaller than or equal to the constant value ct given as a parameter, and returns the same input but with the tag maxvalue with value ct
296
-
- Inputs: in -> field number
297
-
- Outputs: out -> field number
298
-
satisfies tag maxvalue with value ct
299
-
*/
300
-
301
-
templateMaxValueCheck(ct){
302
-
signalinputin;
303
-
signaloutput {maxvalue} out;
304
-
305
-
signal res <== CompConstant(ct)(Num2Bits(254)(in));
306
-
res === 0;
307
-
out.maxvalue = ct;
308
-
out <== in;
309
-
}
310
-
311
-
/*
312
-
*** MinValueCheck(ct): template that receives an input, checks its value is greater than or equal to the constant value ct given as a parameter, and returns the same input but with the tag minvalue with value ct
313
-
- Inputs: in -> field number
314
-
- Outputs: out -> field number
315
-
satisfies tag minvalue with value ct
316
-
*/
317
-
318
-
templateMinValueCheck(ct){
319
-
signalinputin;
320
-
signaloutput {minvalue} out;
321
-
322
-
signal res <== CompConstant(ct-1)(Num2Bits(254)(in));
323
-
res === 1;
324
-
out.minvalue = ct;
325
-
out <== in;
326
-
}
327
-
328
-
/*
329
-
*** MinMaxValueCheck(ct): template that receives an input, checks its value is greater than or equal to the constant value ct1 given as a first parameter and smaller than or equal to the constant value ct2 given as a second parameter, and returns the same input but with the tag minvalue with value ct1 and the tag maxvalue with value ct2
Copy file name to clipboardExpand all lines: circuits/sha256/maj.circom
+24-11Lines changed: 24 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,32 @@
17
17
along with circom. If not, see <https://www.gnu.org/licenses/>.
18
18
*/
19
19
20
-
/* Maj function for sha256
20
+
pragma circom 2.1.5;
21
21
22
-
out = a&b ^ a&c ^ b&c =>
23
-
24
-
out = a*b + a*c + b*c - 2*a*b*c =>
25
-
26
-
out = a*( b + c - 2*b*c ) + b*c =>
27
-
28
-
mid = b*c
29
-
out = a*( b + c - 2*mid ) + mid
22
+
/*
30
23
31
-
*/
32
-
pragma circom 2.0.0;
24
+
*** Maj_t(n): template that receives three inputs of n bits and returns for each i = 0..n out[i] = 1 in case at least two of a the values of a[i], b[i] and c[i] are 1, and 0 otherwise
25
+
26
+
- Inputs: a[n] -> array of n bits
27
+
requires tag binary
28
+
b[n] -> array of n bits
29
+
requires tag binary
30
+
c[n] -> array of n bits
31
+
requires tag binary
32
+
- Output: out[n] -> array of n bits, it takes the value:
Copy file name to clipboardExpand all lines: circuits/sha256/sigma.circom
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,26 @@
16
16
You should have received a copy of the GNU General Public License
17
17
along with circom. If not, see <https://www.gnu.org/licenses/>.
18
18
*/
19
-
pragma circom 2.0.0;
19
+
pragma circom 2.1.5;
20
20
21
21
include"xor3.circom";
22
22
include"rotate.circom";
23
23
include"shift.circom";
24
24
25
+
26
+
/*
27
+
28
+
*** SmallSigma(ra, rb, rc): template that receives an array in of 32 bits and returns an array out of 32 bits s.t. out[i] = XOR3(rot_a[i], rot_b[i], shift_c[i]) with
29
+
* rot_a is the array in rotated ra bits to the right (see rotate.circom)
30
+
* rot_b is the array in rotated rb bits to the right (see rotate.circom)
31
+
* shift_c is the array in shifted rc bits to the right (see shift.circom)
32
+
- Inputs: in[n] -> array of n bits
33
+
requires tag binary
34
+
- Output: out[n] -> array of n bits, it takes the value described above
*** BigSigma(ra, rb, rc): template that receives an array in of 32 bits and returns an array out of 32 bits s.t. out[i] = XOR3(rot_a[i], rot_b[i], rot_c[i]) with
69
+
* rot_a is the array in rotated ra bits to the right (see rotate.circom)
70
+
* rot_b is the array in rotated rb bits to the right (see rotate.circom)
71
+
* rot_c is the array in rotated rc bits to the right (see rotate.circom)
72
+
- Inputs: in[n] -> array of n bits
73
+
requires tag binary
74
+
- Output: out[n] -> array of n bits, it takes the value described above
0 commit comments