Skip to content

Commit 4fe79d4

Browse files
authored
Merge pull request #12 from reclaimprotocol/oprf
OPRF support
2 parents cea243f + 4da0e8c commit 4fe79d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3330
-537
lines changed

.github/workflows/test.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@v4
2121

2222
- name: Setup Node.js
23-
uses: actions/setup-node@v3
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: ${{ matrix.node-version }}
2626

@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/checkout@v4
5252

5353
- name: Setup Node.js
54-
uses: actions/setup-node@v3
54+
uses: actions/setup-node@v4
5555
with:
5656
node-version: ${{ matrix.node-version }}
5757

@@ -75,16 +75,18 @@ jobs:
7575
runs-on: ubuntu-latest
7676
strategy:
7777
matrix:
78-
go-version: [1.23] # Specify the Go versions you want to test with
78+
go-version: ['stable'] # Specify the Go versions you want to test with
7979

8080
steps:
8181
- name: Checkout code
82-
uses: actions/checkout@v3
82+
uses: actions/checkout@v4
8383

8484
- name: Setup Go
85-
uses: actions/setup-go@v4
85+
uses: actions/setup-go@v5
8686
with:
8787
go-version: ${{ matrix.go-version }}
88+
check-latest: true
89+
cache-dependency-path: "**/go.sum"
8890

8991
- name: Install dependencies
9092
working-directory: ./gnark

bin/gnark/darwin-arm64-libprove.so

662 KB
Binary file not shown.
355 KB
Binary file not shown.

bin/gnark/linux-arm64-libprove.so

674 KB
Binary file not shown.

bin/gnark/linux-arm64-libverify.so

381 KB
Binary file not shown.

bin/gnark/linux-x86_64-libprove.so

798 KB
Binary file not shown.
454 KB
Binary file not shown.

circom/circuits/chacha20/chacha20-bits.circom

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,24 @@ template ChaCha20(N, BITS_PER_WORD) {
5151
counter,
5252
nonce[0], nonce[1], nonce[2]
5353
];
54+
55+
// 1 in 32-bit words
56+
signal one[BITS_PER_WORD];
57+
one <== [
58+
0, 0, 0, 0, 0, 0, 0, 0,
59+
0, 0, 0, 0, 0, 0, 0, 0,
60+
0, 0, 0, 0, 0, 0, 0, 0,
61+
0, 0, 0, 0, 0, 0, 0, 1
62+
];
63+
5464
var i = 0;
5565
var j = 0;
5666

5767
// do the ChaCha20 rounds
5868
component rounds[N/16];
5969
component xors[N];
70+
component counter_adder[N/16 - 1];
71+
6072
for(i = 0; i < N/16; i++) {
6173
rounds[i] = Round(BITS_PER_WORD);
6274
rounds[i].in <== tmp;
@@ -67,9 +79,14 @@ template ChaCha20(N, BITS_PER_WORD) {
6779
xors[i*16 + j].b <== rounds[i].out[j];
6880
out[i*16 + j] <== xors[i*16 + j].out;
6981
}
70-
// increment the counter
71-
// TODO: we only use one block
72-
// at a time, so isn't required
73-
// tmp[12] = tmp[12] + 1;
82+
83+
if(i < N/16 - 1) {
84+
counter_adder[i] = AddBits(BITS_PER_WORD);
85+
counter_adder[i].a <== tmp[12];
86+
counter_adder[i].b <== one;
87+
88+
// increment the counter
89+
tmp[12] = counter_adder[i].out;
90+
}
7491
}
7592
}

circom/circuits/chacha20/circuit.circom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pragma circom 2.0.0;
22

33
include "./chacha20-bits.circom";
44

5-
component main{public [in, nonce, counter]} = ChaCha20(16, 32);
5+
component main{public [in, nonce, counter]} = ChaCha20(32, 32);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pragma circom 2.0.0;
2+
3+
include "../chacha20/chacha20-bits.circom";
4+
5+
component main = ChaCha20(32, 32);

0 commit comments

Comments
 (0)