Skip to content

refactor: new proof aggregation [skip-line-limit]#1516

Draft
cedoor wants to merge 14 commits intomainfrom
refactor/new-proof-aggregation
Draft

refactor: new proof aggregation [skip-line-limit]#1516
cedoor wants to merge 14 commits intomainfrom
refactor/new-proof-aggregation

Conversation

@cedoor
Copy link
Copy Markdown
Member

@cedoor cedoor commented Apr 9, 2026

Summary

Refactors proof aggregation around ad-hoc Noir bins under circuits/bin/recursive_aggregation/, replacing the old generic fold/ and wrapper/ trees. Aggregation is expressed as explicit fold + aggregator circuits with clear public layouts and key hashes.

Recursive aggregation layout

Circuit Role
c2ab_fold Combines C2a + C2b ZK proofs; surfaces C2 public inputs for downstream folds.
c3_fold Sequential C3 fold: inner ZK ShareEncryption + optional prior c3_fold non-ZK proof (is_first_step, slot_index).
c3ab_fold Combines final sk-chain and e_sm-chain c3_fold outputs.
c4ab_fold Combines C4a + C4b folds for the C4 path.
node_fold Per-node DKG fold: C0, C1, c2ab_fold, c3ab_fold, c4ab_fold with same-party assertions between stages.
nodes_fold Sequential non-ZK fold of H node_fold proofs (one honest slot per step), chained with prior nodes_fold.
dkg_aggregator Verifies one non-ZK nodes_fold proof + C5 (pk_aggregation) ZK; enforces cross-node grids and C5↔node public links.
c6_fold Sequential fold of T+1 C6 (ThresholdShareDecryption) rows for the phase-7 path.
decryption_aggregator Verifies one non-ZK c6_fold proof + C7 ZK; ties folded C6 columns to c7_public.

Removed: recursive_aggregation/fold/ and recursive_aggregation/wrapper/ (legacy two-proof fold and generic wrappers).

How reviewers can test

  1. Compile recursive-aggregation circuits (needed for zk-prover tests that read circuits/bin/...):

    pnpm install
    pnpm build:circuits --group recursive_aggregation
  2. Barretenberg — integration tests expect bb on PATH; they print a skip message if it’s missing.

  3. Optional zk-prover integration targets (not run by default CI for this crate yet):

    # Fold accumulators: sequential C3/C6 fold, ABI slot checks, pipeline JSON + artifact staging
    cargo test -p e3-zk-prover --test fold_accumulators_e2e_tests -- --nocapture
    
    # Full correlated node_fold chain (C0→…→node_fold); heavier, use single thread
    cargo test -p e3-zk-prover --test node_fold_correlated_e2e_tests -- --nocapture --test-threads=1

    CI still runs e3-zk-prover’s integration_tests and local_e2e_tests only; these two are for local / follow-up CI if you wire them in.

What those zk-prover tests cover

Test crate Purpose
fold_accumulators_e2e_tests generate_sequential_c3_fold / generate_sequential_c6_fold (prove + verify), slot counts from compiled c3_fold / c6_fold JSON, staging of recursive-aggregation artifacts, and loading the node_fold pipeline (C2ab → C3ab → C4ab → node_fold) without a full correlated DKG witness story.
node_fold_correlated_e2e_tests One end-to-end run with correlated witnesses (C1/C2/C3/C4 commitments aligned) through node_fold prove + verify.

cedoor added 3 commits April 9, 2026 20:26
- C3: private ct limbs, public ct_commitment output (Poseidon DS_CIPHERTEXT)
- C6: public ct_commitment input, witness-only ct0/ct1, verify limb hash
- c3_fold: inner public inputs [Field; 3]; Rust fold + layout metadata
- Flow-trace note on cross-phase ct_commitment vs user_data_encryption

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Apr 16, 2026 0:29am
enclave-docs Ready Ready Preview, Comment Apr 16, 2026 0:29am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a4c4ca99-d574-4525-b9c5-7303dbae401f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/new-proof-aggregation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Redesign c3_fold: one inner ShareEncryption ZK proof + optional prior c3_fold non-ZK proof
- Pub outputs: per-party pk, msg, ct slots; skip acc verification when is_first_step
- Add generate_c3_fold_step and generate_sequential_c3_fold; inner C3 uses extract_output(ct_commitment)
- Remove C3FoldMerge circuit and CircuitName variant; update vk helper and lint-circuits

Made-with: Cursor
- Add c2ab_fold, c3ab_fold, c4ab_fold, c6_fold, nodes_fold, node_fold, dkg_aggregator, and decryption_aggregator Noir bins
- Remove legacy recursive_aggregation fold and wrapper trees; refresh c3_fold
- Document aggregation bins in flow-trace; extend lint-circuits.sh checks
@cedoor
Copy link
Copy Markdown
Member Author

cedoor commented Apr 13, 2026

Could you do an early review of the new recursive-aggregation circuits? @zahrajavar @0xjei

@cedoor cedoor changed the title refactor: new proof aggregation refactor: new proof aggregation [skip-line-limit] Apr 13, 2026
@0xjei
Copy link
Copy Markdown
Member

0xjei commented Apr 13, 2026

Could you do an early review of the new recursive-aggregation circuits? @zahrajavar @0xjei

sure, will get a proper look tomorrow 🙏

@0xjei
Copy link
Copy Markdown
Member

0xjei commented Apr 14, 2026

agreed in chat on fixing the C3 fold stuff

- Expand c3_fold and c3ab_fold public IO to N_PARTIES * L_THRESHOLD slots.

- Assert C2 share commitments against C3 for every party/limb in node_fold.

- Sync nodes_fold C3AB_FOLD_PUBLIC_LEN with c3ab_fold; use ASCII comments for nargo.

- Update zk-prover accumulator, VK wiring, events, multithread, and integration tests.
cedoor added 3 commits April 15, 2026 15:43
- Add c3_fold_kernel Noir package and wire recursive aggregation build
- Implement sequential C3 fold in c3_accumulator; export generate_sequential_c3_fold only
- Add recursive_aggregation e2e tests (two inner ShareEncryption proofs)
- Update prover, circuit helpers, Proof extract_input/output, multithread, flow-trace
- Add c6_fold_kernel Noir package for genesis accumulator (aligned with c3_fold_kernel).
- Make c6_fold always verify the non-ZK accumulator like c3_fold.
- Add CircuitName::C6FoldKernel and generate_sequential_c6_fold in aggregation/c6_accumulator.rs.
- Move c3 accumulator into circuits/aggregation/ with a small mod.rs.
- Copy c6_fold_kernel artifacts in integration test circuit staging.
- Extend recursive_aggregation e2e tests (C6 ABI, staged kernel, two-step fold + verify).
- Add NODE_FOLD_PIPELINE (c2ab_fold, c3ab_fold, c4ab_fold, node_fold) JSON load + staged VK tests.
- Stage the same bins in integration test default/recursive_aggregation fixture copy.
…ator tests

- Add node_fold_correlated_e2e_tests for full node_fold prove + verify with correlated C1/C2/C3 chain
- Add tests/common/node_fold_witness.rs (PK sample, share computation, per-slot C3 encrypt)
- Rename recursive_aggregation_e2e_tests to fold_accumulators_e2e_tests; clarify module docs
- Re-export load_vk_artifacts and fold witness helpers from test_utils for integration tests
- Add dev-dependencies fhe-traits, ndarray, rand for witness builders
cedoor added 2 commits April 16, 2026 14:26
- Add nodes_fold_kernel and always verify accumulator in nodes_fold (c3/c6-style genesis)
- Add NodeDkgFold / sequential nodes_fold + DkgAggregation provers; remove proof_fold path
- Pad UltraHonkZKProof witness bytes to 508 fields for dkg_aggregator and decryption_aggregator
- Wire NodeProofAggregator, multithread ZkRequest arms, events, integration fixtures, flow-trace
- Fix cargo fmt --check failures from pre-push hook
assert(nodes_fold_public[4 + i * NODE_FOLD_PUBLIC_LEN] == party_ids[i]);
}

// Cross-node C2 share grid (see `node_fold` public layout).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cedoor Isn't this checking party_i.c3_pk[j] == party_j.c0_pk ?
The comment should be "cross-node C0 --> C3"

@zahrajavar
Copy link
Copy Markdown
Member

zahrajavar commented Apr 16, 2026

In handle_encryption_key_received() function here

fn handle_encryption_key_received(

We are missing this check in the first sync point
Verifies C0 commitment binding for ALL parties (N checks): hash(pk_j) == C0_j.pk_commit (for each party j)
This checks bfv_public_key matches the pk_commitment in the C0 proof's public values.
We need a check like this

let layout = CircuitName::PkBfv.output_layout();
let proof_pk_commitment = layout.extract_field(&proof.public_signals, "pk_commitment")
   .expect("C0 must have pk_commitment");

let computed_pk_commitment = compute_dkg_pk_commitment_from_bfv_pk(
   &msg.key.bfv_public_key, 
   preset
);

if proof_pk_commitment != computed_pk_commitment.as_slice() {
   error!("C0 binding check FAILED for party {}", msg.key.party_id);
   // Emit SignedProofFailed - blame the SENDER
   self.emit_signed_proof_failed(&msg.e3_id, &signed, recovered_address, msg.key.party_id, &ec);
   return;
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants