Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 86ea671

Browse files
authored
Merge pull request #56 from gnosisguild/feat/agg-wrapper
feat: add aggregation wrappers
2 parents 7d13f9c + 169672b commit 86ea671

File tree

9 files changed

+141
-22
lines changed

9 files changed

+141
-22
lines changed

bin/aggregation/Nargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[workspace]
2+
members = [
3+
"fold",
4+
"pk_trbfv_wrapper",
5+
"insecure/verify_shares_trbfv_wrapper",
6+
"production/verify_shares_trbfv_wrapper"
7+
]

bin/aggregation/fold/src/main.nr

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
11
use bb_proof_verification::{UltraHonkProof, UltraHonkVerificationKey, verify_honk_proof_non_zk};
2-
use lib::math::helpers::compute_safe;
2+
use lib::math::commitments::compute_aggregation_commitment;
33

44
fn main(
55
verification_key: UltraHonkVerificationKey,
6-
wrapper_proofs: [UltraHonkProof; 2],
6+
proofs: [UltraHonkProof; 2],
77
commitments: pub [Field; 2],
88
key_hash: Field,
99
) -> pub Field {
10-
let proof = wrapper_proofs[0];
11-
let public_inputs = [commitments[0]];
12-
verify_honk_proof_non_zk(verification_key, proof, public_inputs, key_hash);
10+
verify_honk_proof_non_zk(verification_key, proofs[0], [commitments[0]], key_hash);
11+
verify_honk_proof_non_zk(verification_key, proofs[1], [commitments[1]], key_hash);
1312

14-
let proof = wrapper_proofs[1];
15-
let public_inputs = [commitments[1]];
16-
verify_honk_proof_non_zk(verification_key, proof, public_inputs, key_hash);
17-
18-
// Compute commitment of the two commitments using SAFE
19-
let domain_separator = [
20-
0x50, 0x56, 0x53, 0x53, 0x5f, 0x66, 0x6f, 0x6c, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24-
0x00, 0x00, 0x00, 0x00,
25-
]; // "PVSS_fold" in hex
26-
27-
let payload = Vec::from_slice(&[commitments[0], commitments[1]]);
28-
let io_pattern = [0x80000002, 0x00000001];
29-
30-
compute_safe(domain_separator, payload, io_pattern).get(0)
13+
compute_aggregation_commitment::<2>(commitments)
3114
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "verify_shares_trbfv_wrapper"
3+
type = "bin"
4+
authors = ["Gnosis Guild / Enclave"]
5+
version = "1.0.0-beta.15"
6+
7+
[dependencies]
8+
lib = { path = "../../../lib" }
9+
bb_proof_verification = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20260102", directory = "barretenberg/noir/bb_proof_verification" }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use bb_proof_verification::{UltraHonkProof, UltraHonkVerificationKey, verify_honk_proof_non_zk};
2+
use lib::math::commitments::compute_aggregation_commitment;
3+
4+
// Number of proofs.
5+
pub global N_PROOFS: u32 = 2;
6+
/// Number of commitments per proof.
7+
pub global N_COMMITMENTS: u32 = 10;
8+
9+
fn main(
10+
verification_key: UltraHonkVerificationKey,
11+
proofs: [UltraHonkProof; N_PROOFS],
12+
commitments: pub [[Field; N_COMMITMENTS]; N_PROOFS],
13+
key_hash: Field,
14+
) -> pub Field {
15+
for i in 0..N_PROOFS {
16+
verify_honk_proof_non_zk(verification_key, proofs[i], commitments[i], key_hash);
17+
}
18+
19+
let mut aggregated_commitments = Vec::new();
20+
21+
for i in 0..N_PROOFS {
22+
for j in 0..N_COMMITMENTS {
23+
aggregated_commitments.push(commitments[i][j]);
24+
}
25+
}
26+
27+
compute_aggregation_commitment(aggregated_commitments)
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "pk_trbfv_wrapper"
3+
type = "bin"
4+
authors = ["Gnosis Guild / Enclave"]
5+
version = "1.0.0-beta.15"
6+
7+
[dependencies]
8+
lib = { path = "../../../lib" }
9+
bb_proof_verification = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20260102", directory = "barretenberg/noir/bb_proof_verification" }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use bb_proof_verification::{UltraHonkProof, UltraHonkVerificationKey, verify_honk_proof_non_zk};
2+
use lib::math::commitments::compute_aggregation_commitment;
3+
4+
// Number of proofs.
5+
pub global N_PROOFS: u32 = 1;
6+
/// Number of commitments per proof.
7+
pub global N_COMMITMENTS: u32 = 3;
8+
9+
fn main(
10+
verification_key: UltraHonkVerificationKey,
11+
proofs: [UltraHonkProof; N_PROOFS],
12+
commitments: pub [[Field; N_COMMITMENTS]; N_PROOFS],
13+
key_hash: Field,
14+
) -> pub Field {
15+
for i in 0..N_PROOFS {
16+
verify_honk_proof_non_zk(verification_key, proofs[i], commitments[i], key_hash);
17+
}
18+
19+
let mut aggregated_commitments = Vec::new();
20+
21+
for i in 0..N_PROOFS {
22+
for j in 0..N_COMMITMENTS {
23+
aggregated_commitments.push(commitments[i][j]);
24+
}
25+
}
26+
27+
compute_aggregation_commitment(aggregated_commitments)
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "verify_shares_trbfv_wrapper"
3+
type = "bin"
4+
authors = ["Gnosis Guild / Enclave"]
5+
version = "1.0.0-beta.15"
6+
7+
[dependencies]
8+
lib = { path = "../../../lib" }
9+
bb_proof_verification = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20260102", directory = "barretenberg/noir/bb_proof_verification" }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use bb_proof_verification::{UltraHonkProof, UltraHonkVerificationKey, verify_honk_proof_non_zk};
2+
use lib::math::commitments::compute_aggregation_commitment;
3+
4+
// Number of proofs.
5+
pub global N_PROOFS: u32 = 2;
6+
/// Number of commitments per proof.
7+
pub global N_COMMITMENTS: u32 = 20;
8+
9+
fn main(
10+
verification_key: UltraHonkVerificationKey,
11+
proofs: [UltraHonkProof; N_PROOFS],
12+
commitments: pub [[Field; N_COMMITMENTS]; N_PROOFS],
13+
key_hash: Field,
14+
) -> pub Field {
15+
for i in 0..N_PROOFS {
16+
verify_honk_proof_non_zk(verification_key, proofs[i], commitments[i], key_hash);
17+
}
18+
19+
let mut aggregated_commitments = Vec::new();
20+
21+
for i in 0..N_PROOFS {
22+
for j in 0..N_COMMITMENTS {
23+
aggregated_commitments.push(commitments[i][j]);
24+
}
25+
}
26+
27+
compute_aggregation_commitment(aggregated_commitments)
28+
}

lib/src/math/commitments.nr

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,21 @@ pub fn compute_bfv_enc_challenge_commitment<let L: u32>(payload: Vec<Field>) ->
283283

284284
compute_safe(domain_separator, payload, io_pattern)
285285
}
286+
287+
/// Computes aggregation commitment
288+
/// Used in aggregation circuits.
289+
pub fn compute_aggregation_commitment(payload: Vec<Field>) -> Field {
290+
// Domain separator - "Aggregation"
291+
let domain_separator = [
292+
0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00,
293+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296+
0x00, 0x00, 0x00, 0x00,
297+
];
298+
299+
// IO Pattern: ABSORB(payload.len()), SQUEEZE(1)
300+
let io_pattern = [0x80000000 | payload.len(), 0x00000001];
301+
302+
compute_safe(domain_separator, payload, io_pattern).get(0)
303+
}

0 commit comments

Comments
 (0)