feat: integrate recursive aggregation into zk flow [skip-line-limit]#1392
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds wrapper/fold recursive proof aggregation: switches wrapper Noir circuits to ZK proofs, introduces FoldProofs ZkRequest/ZkResponse and wrapped_proof(s) fields, adds node- and cross-node folding actors/state (NodeProofAggregator, ProofFoldState), propagates wrapped proofs through actors/events, and wires publish orchestration for combined aggregated proofs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant ProofRequestActor
participant Multithread
participant Bus
participant NodeProofAggregator
participant PublicKeyAggregator
ProofRequestActor->>Multithread: ZkRequest (generate proof + wrapped_proof)
Multithread-->>ProofRequestActor: ZkResponse { proof, wrapped_proof }
ProofRequestActor->>Bus: DKGInnerProofReady(e3, seq, wrapped_proof)
Bus->>NodeProofAggregator: DKGInnerProofReady
NodeProofAggregator->>NodeProofAggregator: buffer by seq / try_advance()
alt need folding
NodeProofAggregator->>Multithread: ComputeRequest::zk FoldProofs(proof1, proof2)
Multithread-->>NodeProofAggregator: ComputeResponse FoldProofs { proof }
NodeProofAggregator->>NodeProofAggregator: update accumulated / continue or complete
end
NodeProofAggregator->>Bus: DKGRecursiveAggregationComplete(e3, aggregated_proof)
Bus->>PublicKeyAggregator: DKGRecursiveAggregationComplete
PublicKeyAggregator->>PublicKeyAggregator: try_start_cross_node_fold() -> publish PublicKeyAggregated { dkg_aggregated_proof? }
sequenceDiagram
autonumber
participant ProofRequestActor
participant Multithread
participant Bus
participant ThresholdPlaintextAggregator
ProofRequestActor->>Multithread: ZkRequest::ThresholdShareDecryption (produce proof + wrapped_proofs)
Multithread-->>ProofRequestActor: ZkResponse { proofs, wrapped_proofs }
ProofRequestActor->>Bus: DecryptionshareCreated { wrapped_proofs }
Bus->>ThresholdPlaintextAggregator: DecryptionshareCreated
ThresholdPlaintextAggregator->>ThresholdPlaintextAggregator: add_share(..., wrapped_proofs)
ThresholdPlaintextAggregator->>ThresholdPlaintextAggregator: on C6 verify -> start c6_fold
ThresholdPlaintextAggregator->>Multithread: ComputeRequest::zk FoldProofs
Multithread-->>ThresholdPlaintextAggregator: ComputeResponse FoldProofs { proof }
ThresholdPlaintextAggregator->>ThresholdPlaintextAggregator: try_publish_complete() -> Publish PlaintextAggregated { c6_aggregated_proof? }
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip You can disable poems in the walkthrough.Disable the |
4a3b93f to
f7ce4de
Compare
d180c9e to
0b36612
Compare
f33a90f to
93d5a58
Compare
the #1174 refers to all circuits but this design refers just to the DKG phase. What are the steps from C5 to C7? |
Motivation
Each node generates inner proofs across circuits C0–C4 (DKG) and C6 (decryption). Before submission for cross-node aggregation, these must be recursively aggregated. This PR introduces
NodeProofAggregatorand the cross-node aggregation flow.Architecture — Complete Flow
Phase 1: DKG (C0–C4)
Each node generates proofs C0–C4 + wrapper
Each inner proof is wrapped (single-element
RecursiveAggregation) in the same thread that generates it — fully parallel, no cost on the aggregator side.Each node folds all its wrappers and sends to aggregator
Local
NodeProofAggregatorreceivesDKGInnerProofReady(wrapped proof,seq,total_expected), folds them inseqorder, and publishesDKGRecursiveAggregationComplete— one aggregated proof per node.Aggregator folds proofs aggregated from H nodes
The aggregator collects the aggregated proofs from honest nodes and folds them into one DKG proof.
Phase 2: Decryption (C6)
Each node generates proof C6 + wrapper and sends to aggregator
Each node produces its C6 proof (threshold share decryption), wraps it, and sends it to the aggregator.
Aggregator folds wrappers from all H nodes
The aggregator receives the C6 wrappers from honest nodes and folds them into a single proof (
c6_aggregated_proofinPlaintextAggregated).DKG: Sequence index assignment
total_expected = 4 + sk_enc_count + esm_enc_count + 2DKG: Fold rule (per-node)
buffer[seq]buffer[next_to_aggregate]ready and no fold in progress:accumulated, decrementremainingfold(accumulated, next), setfold_correlationaccumulated, clearfold_correlation, decrementremainingremaining == 0→ publishDKGRecursiveAggregationCompleteCloses #1174
Follow up task -> Post all proofs on-chain and verify them in 2 phases: dkg & decryption.
Summary by CodeRabbit