Skip to content

Commit

Permalink
Merge pull request #11 from okx/dev-cliff-support-bn128
Browse files Browse the repository at this point in the history
support bn128 and circom
  • Loading branch information
cliff0412 authored Apr 2, 2024
2 parents bf94773 + 36957f8 commit b8e4535
Show file tree
Hide file tree
Showing 49 changed files with 11,465 additions and 1,894 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ docs/**bench**

**/*/libposeidon-permute-c-mac.a
**/*/go-iden3-crypto/
node_modules
.vscode
35 changes: 35 additions & 0 deletions circom/circuits/goldilocks.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pragma circom 2.0.9;

template GlExp() {
signal input x;
signal input n;
signal output out;

signal e2[65];
signal temp1[64];
signal temp2[64];
signal mul[65];
mul[0] <== 1;
e2[0] <== x;
for (var i = 0; i < 64; i++) {
temp1[i] <-- (n >> i) & 1;
temp2[i] <== e2[i] * temp1[i] + 1 - temp1[i];
mul[i + 1] <== mul[i] * temp2[i];
e2[i + 1] <== e2[i] * e2[i];
}

out <== mul[64];
}

template GlExtMul() {
signal input a[2];
signal input b[2];
signal output out[2];

var W = 7;
signal tmp1 <== W * a[1] * b[1];
signal tmp2 <== a[1] * b[0];

out[0] <== a[0] * b[0] + tmp1;
out[1] <== a[0] * b[1] + tmp2;
}
Loading

0 comments on commit b8e4535

Please sign in to comment.