Skip to content

Commit

Permalink
feat: non-inclusion gnark circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeytimoshin committed Mar 28, 2024
1 parent 78f865a commit 7fcb868
Show file tree
Hide file tree
Showing 47 changed files with 2,682 additions and 924 deletions.
2 changes: 1 addition & 1 deletion circuit-lib/circuit-lib.circom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"license": "GPL-3.0",
"scripts": {
"build-merkle": "./scripts/buildMerkle.sh"
"build-circuits": "./scripts/buildCircuits.sh"
},
"author": "",
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,4 @@ for ((i=1; i<=MAX_COUNT; i++)); do
execute_commands "non-inclusion" "$MERKLE_TREE_HEIGHT" "$i" "$POWERS_OF_TAU" || exit
done

execute_commands "non-inclusion" "$MERKLE_TREE_HEIGHT" 8 "$POWERS_OF_TAU" || exit


for ((i=1; i<=MAX_COUNT; i++)); do
execute_commands "combined" "$MERKLE_TREE_HEIGHT" "$i" "$POWERS_OF_TAU" 1 || exit
done

execute_commands "combined" "$MERKLE_TREE_HEIGHT" 8 "$POWERS_OF_TAU" 1 || exit

for ((i=1; i<=MAX_COUNT; i++)); do
execute_commands "combined" "$MERKLE_TREE_HEIGHT" "$i" "$POWERS_OF_TAU" 2 || exit
done

execute_commands "combined" "$MERKLE_TREE_HEIGHT" 8 "$POWERS_OF_TAU" 2 || exit
execute_commands "non-inclusion" "$MERKLE_TREE_HEIGHT" 8 "$POWERS_OF_TAU" || exit
82 changes: 0 additions & 82 deletions circuit-lib/circuit-lib.circom/scripts/buildMerkle.sh

This file was deleted.

82 changes: 0 additions & 82 deletions circuit-lib/circuit-lib.circom/scripts/buildNonInclusion.sh

This file was deleted.

4 changes: 2 additions & 2 deletions circuit-lib/circuit-lib.js/tests/gnark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ describe("Tests", () => {
const leaf = hasher.poseidonHashString(["1"]);
const merkleTree = new MerkleTree(merkleHeights[i], hasher, [leaf]);

const pathEements: string[] = merkleTree.path(
const pathElements: string[] = merkleTree.path(
merkleTree.indexOf(leaf),
).pathElements;
const hexPathElements = pathEements.map((value) => toHex(value));
const hexPathElements = pathElements.map((value) => toHex(value));
let inputs = {
root: new Array(utxos[j]).fill(toHex(merkleTree.root())),
inPathIndices: new Array(utxos[j]).fill(merkleTree.indexOf(leaf)),
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/i_26_1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
36, 66, 255, 97, 104, 255, 86, 172, 160, 53, 245, 239, 67, 240, 13, 220, 179, 240, 181,
128, 243, 0, 64, 214, 42, 23, 75, 195, 138, 106, 169, 2, 12, 38, 89, 96, 206, 103, 67, 146,
68, 105, 137, 76, 3, 139, 186, 70, 41, 165, 244, 193, 207, 24, 224, 191, 168, 208, 225, 80,
88, 168, 33, 178, 36, 128, 164, 59, 150, 184, 121, 222, 54, 235, 221, 62, 245, 68, 9, 251,
189, 213, 12, 195, 166, 195, 148, 116, 23, 244, 157, 254, 15, 150, 58, 98, 7, 179, 44, 183,
41, 24, 166, 165, 28, 93, 176, 247, 108, 189, 174, 220, 208, 215, 9, 3, 206, 62, 142, 132,
71, 129, 174, 160, 131, 103, 156, 176,
47, 47, 203, 186, 64, 75, 72, 24, 240, 177, 216, 49, 193, 148, 200, 203, 48, 146, 171, 2,
210, 104, 56, 23, 80, 26, 104, 171, 172, 107, 151, 129, 22, 70, 253, 144, 106, 238, 234,
22, 250, 250, 93, 199, 93, 46, 254, 62, 189, 234, 124, 70, 245, 189, 50, 243, 117, 58, 81,
107, 228, 121, 130, 89, 19, 184, 145, 107, 116, 133, 106, 105, 112, 176, 39, 253, 111, 192,
236, 87, 46, 208, 41, 57, 102, 132, 108, 222, 211, 224, 94, 248, 142, 196, 128, 69, 28,
177, 49, 160, 223, 62, 176, 7, 71, 188, 80, 16, 32, 176, 49, 159, 24, 124, 87, 217, 78, 98,
236, 53, 124, 18, 189, 206, 112, 23, 192, 210,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/i_26_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
28, 91, 90, 60, 112, 211, 18, 130, 79, 183, 192, 192, 86, 114, 33, 92, 255, 168, 34, 215,
18, 131, 96, 103, 41, 214, 156, 14, 38, 25, 176, 104, 27, 100, 29, 249, 169, 211, 33, 87,
104, 117, 122, 216, 158, 119, 250, 2, 126, 164, 126, 183, 147, 88, 97, 181, 187, 19, 103,
85, 252, 49, 77, 174, 8, 225, 111, 88, 179, 65, 253, 71, 227, 155, 226, 56, 115, 150, 228,
130, 34, 214, 223, 12, 24, 32, 180, 98, 166, 71, 213, 148, 191, 150, 53, 5, 19, 141, 192,
18, 69, 203, 225, 115, 137, 250, 132, 86, 234, 207, 187, 13, 77, 93, 27, 166, 134, 113,
152, 204, 221, 168, 224, 250, 247, 118, 153, 185,
47, 227, 76, 114, 196, 38, 33, 159, 239, 45, 220, 128, 224, 250, 116, 117, 57, 7, 38, 81,
6, 193, 106, 203, 67, 255, 124, 70, 70, 141, 27, 128, 13, 38, 11, 37, 82, 149, 156, 205,
161, 113, 219, 15, 230, 116, 212, 207, 165, 2, 52, 27, 118, 20, 164, 90, 229, 58, 129, 135,
224, 3, 221, 121, 29, 138, 184, 163, 118, 126, 126, 80, 161, 206, 6, 13, 225, 91, 96, 41,
71, 66, 14, 25, 51, 71, 147, 164, 46, 155, 20, 167, 228, 120, 82, 194, 22, 52, 166, 53,
108, 109, 102, 64, 179, 33, 53, 189, 149, 238, 106, 106, 113, 52, 217, 180, 135, 224, 60,
52, 223, 6, 103, 116, 120, 235, 70, 221,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/i_26_3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
38, 37, 169, 244, 168, 1, 99, 14, 193, 127, 56, 131, 215, 66, 213, 239, 14, 202, 247, 104,
222, 39, 13, 21, 221, 253, 173, 170, 126, 247, 124, 138, 32, 72, 122, 53, 127, 22, 97, 144,
255, 29, 76, 255, 173, 218, 27, 252, 180, 58, 249, 18, 98, 225, 253, 159, 86, 230, 241,
126, 170, 219, 58, 250, 43, 128, 91, 111, 130, 218, 191, 114, 137, 21, 186, 158, 175, 130,
148, 206, 194, 121, 179, 227, 146, 159, 0, 129, 19, 199, 80, 111, 128, 74, 92, 240, 24,
169, 43, 46, 207, 88, 247, 221, 112, 149, 79, 64, 127, 133, 42, 192, 183, 117, 249, 163,
12, 78, 72, 53, 58, 136, 253, 28, 168, 29, 8, 30,
25, 122, 203, 25, 101, 25, 61, 246, 158, 45, 87, 28, 51, 252, 177, 181, 169, 153, 60, 107,
54, 166, 125, 174, 163, 130, 216, 253, 54, 157, 116, 150, 7, 52, 130, 221, 140, 110, 212,
16, 161, 223, 106, 99, 12, 200, 203, 151, 111, 205, 173, 51, 128, 236, 133, 129, 246, 228,
133, 118, 37, 123, 73, 132, 23, 117, 70, 90, 215, 33, 175, 191, 19, 198, 250, 97, 140, 66,
26, 207, 92, 205, 107, 27, 58, 227, 102, 63, 192, 27, 108, 10, 94, 53, 218, 62, 22, 19,
233, 92, 152, 250, 220, 192, 188, 145, 141, 213, 105, 51, 255, 218, 9, 218, 93, 45, 25, 46,
209, 41, 56, 121, 128, 162, 125, 241, 49, 105,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/i_26_4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
10, 239, 216, 19, 244, 219, 73, 65, 245, 157, 194, 174, 162, 178, 185, 227, 21, 217, 253,
203, 69, 161, 107, 173, 52, 231, 112, 149, 233, 135, 10, 61, 24, 249, 187, 177, 187, 208,
118, 249, 79, 165, 219, 136, 54, 103, 75, 110, 72, 30, 20, 242, 179, 131, 68, 208, 122, 40,
190, 170, 86, 226, 205, 58, 32, 143, 138, 89, 64, 70, 127, 186, 146, 33, 171, 239, 22, 174,
195, 173, 26, 45, 253, 222, 88, 215, 89, 20, 99, 219, 173, 15, 47, 7, 170, 224, 1, 44, 171,
34, 64, 69, 16, 181, 105, 79, 89, 12, 235, 247, 22, 144, 238, 59, 55, 127, 153, 37, 62, 74,
130, 164, 20, 4, 113, 48, 245, 204,
7, 13, 204, 181, 234, 193, 63, 20, 253, 50, 19, 170, 122, 115, 181, 142, 226, 184, 53, 231,
190, 229, 130, 94, 59, 63, 165, 166, 232, 200, 94, 151, 13, 144, 177, 122, 51, 137, 34,
225, 109, 76, 142, 33, 87, 48, 167, 52, 101, 221, 212, 226, 102, 102, 137, 220, 129, 246,
8, 226, 221, 81, 37, 208, 6, 243, 111, 24, 31, 234, 51, 200, 73, 171, 50, 20, 110, 137,
251, 158, 1, 91, 99, 62, 154, 73, 111, 149, 165, 110, 67, 112, 10, 144, 247, 155, 42, 55,
250, 79, 102, 109, 83, 29, 184, 139, 140, 94, 122, 227, 82, 134, 53, 145, 26, 149, 200,
236, 217, 167, 190, 199, 29, 31, 178, 15, 95, 52,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/i_26_8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
44, 138, 174, 99, 141, 159, 152, 24, 247, 249, 217, 149, 163, 228, 48, 24, 129, 198, 255,
253, 193, 57, 252, 27, 158, 31, 103, 211, 113, 37, 95, 158, 27, 178, 64, 251, 223, 180,
193, 204, 78, 86, 31, 156, 211, 65, 192, 27, 42, 247, 161, 211, 214, 210, 81, 78, 54, 89,
24, 16, 61, 13, 133, 108, 43, 71, 176, 147, 103, 140, 87, 181, 67, 234, 241, 96, 100, 127,
140, 188, 140, 79, 213, 242, 190, 122, 53, 89, 19, 149, 106, 243, 172, 251, 36, 58, 33,
210, 172, 208, 46, 123, 27, 161, 150, 53, 153, 195, 136, 129, 108, 235, 85, 153, 9, 250,
175, 32, 110, 228, 92, 32, 247, 185, 100, 117, 44, 170,
38, 64, 170, 170, 131, 189, 246, 56, 6, 217, 77, 180, 0, 18, 226, 170, 9, 202, 49, 150, 68,
226, 148, 30, 204, 232, 28, 47, 246, 184, 30, 136, 47, 186, 93, 158, 183, 30, 86, 236, 36,
68, 164, 171, 204, 237, 70, 155, 57, 237, 46, 239, 179, 153, 220, 43, 99, 34, 210, 243,
148, 18, 64, 231, 36, 53, 217, 237, 138, 186, 188, 6, 34, 218, 185, 146, 118, 69, 101, 48,
253, 158, 74, 130, 94, 249, 80, 37, 155, 59, 172, 200, 219, 193, 149, 24, 24, 3, 188, 85,
75, 164, 243, 182, 94, 246, 215, 38, 18, 132, 229, 108, 228, 112, 67, 8, 249, 167, 179,
206, 145, 167, 91, 225, 100, 219, 76, 63,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/ni_26_1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
9, 112, 121, 8, 13, 41, 99, 52, 161, 125, 153, 212, 159, 69, 135, 252, 216, 149, 83, 187,
190, 50, 80, 251, 92, 155, 252, 24, 34, 154, 149, 156, 12, 39, 163, 21, 24, 164, 28, 39, 1,
49, 81, 221, 174, 174, 31, 9, 96, 209, 121, 84, 15, 98, 107, 24, 9, 180, 146, 101, 69, 140,
19, 51, 29, 132, 210, 240, 238, 97, 1, 123, 110, 124, 123, 100, 83, 11, 244, 228, 7, 157,
70, 158, 206, 146, 71, 96, 157, 215, 31, 176, 6, 174, 87, 54, 25, 9, 41, 6, 193, 123, 171,
221, 187, 65, 17, 238, 133, 25, 161, 81, 251, 176, 189, 151, 76, 59, 55, 237, 108, 178, 60,
235, 99, 68, 225, 189,
36, 193, 161, 116, 185, 230, 1, 83, 32, 225, 156, 92, 93, 2, 89, 116, 132, 96, 83, 147,
199, 33, 238, 159, 88, 9, 140, 69, 20, 196, 227, 102, 13, 112, 124, 241, 185, 27, 188, 67,
184, 79, 124, 136, 23, 155, 223, 72, 139, 135, 115, 142, 142, 87, 160, 111, 7, 255, 36,
132, 123, 46, 135, 138, 9, 172, 55, 98, 103, 78, 59, 180, 43, 208, 147, 36, 151, 129, 239,
132, 137, 135, 75, 219, 129, 8, 99, 19, 148, 197, 248, 86, 106, 141, 235, 195, 14, 47, 241,
127, 102, 249, 91, 98, 202, 81, 168, 26, 250, 251, 128, 123, 99, 126, 132, 225, 53, 42,
199, 66, 35, 180, 242, 71, 231, 59, 104, 207,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/ni_26_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
8, 80, 188, 119, 233, 130, 55, 30, 83, 188, 44, 190, 213, 178, 167, 89, 164, 189, 54, 120,
193, 136, 136, 145, 79, 185, 9, 251, 72, 26, 98, 227, 31, 148, 91, 82, 101, 24, 46, 42,
237, 34, 102, 253, 51, 0, 237, 159, 154, 119, 108, 254, 85, 60, 3, 72, 183, 239, 22, 211,
7, 190, 28, 111, 15, 36, 117, 124, 17, 98, 129, 90, 206, 27, 163, 240, 31, 179, 194, 234,
126, 133, 93, 88, 170, 252, 72, 222, 8, 82, 181, 139, 85, 117, 101, 72, 11, 83, 225, 131,
152, 209, 228, 113, 143, 122, 142, 98, 45, 117, 146, 39, 7, 123, 124, 76, 89, 80, 249, 102,
49, 176, 128, 12, 255, 249, 143, 24,
5, 97, 217, 5, 136, 166, 125, 128, 138, 2, 8, 41, 135, 129, 134, 80, 236, 163, 187, 2, 152,
235, 119, 157, 2, 103, 138, 102, 16, 208, 77, 252, 28, 121, 16, 254, 177, 80, 165, 18, 222,
235, 135, 194, 164, 55, 245, 221, 9, 172, 19, 41, 109, 140, 114, 245, 0, 171, 139, 97, 30,
9, 105, 168, 15, 115, 60, 100, 144, 39, 74, 0, 79, 238, 170, 168, 146, 119, 0, 148, 122,
144, 68, 107, 11, 163, 127, 155, 112, 7, 157, 142, 145, 88, 221, 237, 31, 52, 164, 169, 83,
159, 246, 70, 7, 89, 123, 176, 172, 37, 221, 232, 12, 158, 148, 103, 70, 10, 235, 241, 72,
122, 148, 8, 2, 2, 224, 83,
],

vk_ic: &[
Expand Down
14 changes: 7 additions & 7 deletions circuit-lib/circuitlib-rs/src/verifying_keys/ni_26_3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub const VERIFYINGKEY: Groth16Verifyingkey = Groth16Verifyingkey {
],

vk_delta_g2: [
19, 67, 212, 2, 216, 125, 55, 219, 106, 25, 244, 78, 17, 154, 80, 137, 7, 94, 20, 129, 189,
30, 153, 9, 181, 247, 7, 1, 175, 128, 107, 254, 35, 187, 214, 16, 100, 35, 221, 200, 197,
212, 110, 90, 194, 63, 207, 162, 123, 68, 222, 124, 170, 60, 88, 99, 248, 92, 22, 4, 222,
107, 155, 188, 7, 237, 158, 52, 51, 15, 103, 135, 5, 34, 129, 163, 204, 48, 39, 166, 234,
125, 111, 162, 42, 94, 140, 213, 235, 98, 33, 122, 70, 43, 96, 238, 28, 172, 216, 52, 170,
20, 88, 195, 23, 112, 69, 176, 41, 65, 31, 182, 222, 58, 186, 90, 59, 254, 201, 33, 67,
117, 108, 168, 122, 169, 201, 244,
0, 13, 25, 69, 88, 150, 169, 16, 113, 221, 74, 115, 135, 87, 154, 198, 21, 178, 61, 59,
134, 28, 249, 185, 172, 197, 241, 202, 13, 179, 54, 229, 43, 183, 69, 78, 59, 235, 184, 74,
123, 164, 34, 197, 153, 62, 251, 125, 173, 12, 242, 241, 45, 62, 128, 129, 187, 75, 85, 6,
130, 56, 80, 25, 47, 18, 57, 246, 195, 136, 169, 161, 207, 224, 81, 42, 6, 31, 89, 228,
193, 146, 227, 123, 173, 152, 46, 22, 189, 142, 81, 208, 216, 175, 225, 61, 47, 232, 92, 4,
254, 186, 102, 66, 219, 225, 206, 53, 146, 11, 187, 60, 183, 194, 151, 145, 175, 104, 194,
253, 115, 112, 19, 185, 156, 156, 19, 118,
],

vk_ic: &[
Expand Down
Loading

0 comments on commit 7fcb868

Please sign in to comment.