Skip to content

Commit 11440d9

Browse files
committed
Add secp256k1 Circom circuits
1 parent a9a08a9 commit 11440d9

File tree

9 files changed

+1926
-0
lines changed

9 files changed

+1926
-0
lines changed

circuits/bigint/bigint.circom

Lines changed: 566 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
pragma circom 2.0.2;
2+
3+
include "bigint.circom";
4+
5+
template A2NoCarry() {
6+
signal input a[4];
7+
8+
// these representations have overflowed, nonnegative registers
9+
signal output a2[7];
10+
component a2Comp = BigMultNoCarry(64, 64, 64, 4, 4);
11+
for (var i = 0; i < 4; i++) {
12+
a2Comp.a[i] <== a[i];
13+
a2Comp.b[i] <== a[i];
14+
}
15+
for (var i = 0; i < 7; i++) {
16+
a2[i] <== a2Comp.out[i]; // 130 bits
17+
}
18+
}
19+
20+
template A3NoCarry() {
21+
signal input a[4];
22+
23+
// these representations have overflowed, nonnegative registers
24+
signal a2[7];
25+
component a2Comp = BigMultNoCarry(64, 64, 64, 4, 4);
26+
for (var i = 0; i < 4; i++) {
27+
a2Comp.a[i] <== a[i];
28+
a2Comp.b[i] <== a[i];
29+
}
30+
for (var i = 0; i < 7; i++) {
31+
a2[i] <== a2Comp.out[i]; // 130 bits
32+
}
33+
signal output a3[10];
34+
component a3Comp = BigMultNoCarry(64, 130, 64, 7, 4);
35+
for (var i = 0; i < 7; i++) {
36+
a3Comp.a[i] <== a2[i];
37+
}
38+
for (var i = 0; i < 4; i++) {
39+
a3Comp.b[i] <== a[i];
40+
}
41+
for (var i = 0; i < 10; i++) {
42+
a3[i] <== a3Comp.out[i]; // 197 bits
43+
}
44+
}
45+
46+
template A2B1NoCarry() {
47+
signal input a[4];
48+
signal input b[4];
49+
50+
// these representations have overflowed, nonnegative registers
51+
signal a2[7];
52+
component a2Comp = BigMultNoCarry(64, 64, 64, 4, 4);
53+
for (var i = 0; i < 4; i++) {
54+
a2Comp.a[i] <== a[i];
55+
a2Comp.b[i] <== a[i];
56+
}
57+
for (var i = 0; i < 7; i++) {
58+
a2[i] <== a2Comp.out[i]; // 130 bits
59+
}
60+
61+
signal output a2b1[10];
62+
component a2b1Comp = BigMultNoCarry(64, 130, 64, 7, 4);
63+
for (var i = 0; i < 7; i++) {
64+
a2b1Comp.a[i] <== a2[i];
65+
}
66+
for (var i = 0; i < 4; i++) {
67+
a2b1Comp.b[i] <== b[i];
68+
}
69+
for (var i = 0; i < 10; i++) {
70+
a2b1[i] <== a2b1Comp.out[i]; // 197 bits
71+
}
72+
}
73+
74+
template A1B1C1NoCarry() {
75+
signal input a[4];
76+
signal input b[4];
77+
signal input c[4];
78+
79+
// these representations have overflowed, nonnegative registers
80+
signal a1b1[7];
81+
component a1b1Comp = BigMultNoCarry(64, 64, 64, 4, 4);
82+
for (var i = 0; i < 4; i++) {
83+
a1b1Comp.a[i] <== a[i];
84+
a1b1Comp.b[i] <== b[i];
85+
}
86+
for (var i = 0; i < 7; i++) {
87+
a1b1[i] <== a1b1Comp.out[i]; // 130 bits
88+
}
89+
90+
signal output a1b1c1[10];
91+
component a1b1c1Comp = BigMultNoCarry(64, 130, 64, 7, 4);
92+
for (var i = 0; i < 7; i++) {
93+
a1b1c1Comp.a[i] <== a1b1[i];
94+
}
95+
for (var i = 0; i < 4; i++) {
96+
a1b1c1Comp.b[i] <== c[i];
97+
}
98+
for (var i = 0; i < 10; i++) {
99+
a1b1c1[i] <== a1b1c1Comp.out[i]; // 197 bits
100+
}
101+
}

0 commit comments

Comments
 (0)