Skip to content

refactor: missing circuits in zk-prover [skip-line-limit]#1317

Merged
cedoor merged 4 commits into
mainfrom
refactor/missing-circits-zk-prover
Feb 13, 2026
Merged

refactor: missing circuits in zk-prover [skip-line-limit]#1317
cedoor merged 4 commits into
mainfrom
refactor/missing-circits-zk-prover

Conversation

@cedoor

@cedoor cedoor commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added several new circuit types and a new proof variant to enable additional aggregation and DKG share-decryption flows.
    • Exposed circuit input metadata in sample data to carry DKG input type.
  • Refactor

    • Renamed and reorganized circuit identifiers and groupings for consistency across the system.
  • Tests

    • Expanded end-to-end tests, fixtures, and coverage for the new circuits and aggregation flows.

@cedoor cedoor requested a review from ctrlc03 February 13, 2026 12:31
@vercel

vercel Bot commented Feb 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Feb 13, 2026 3:30pm
enclave-docs Ready Ready Preview, Comment Feb 13, 2026 3:30pm

Request Review

@coderabbitai

coderabbitai Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Renames and expands circuit identifiers (new DKG and threshold variants), wires new Provable implementations for DKG and threshold share-decryption/aggregation/pk-aggregation circuits, updates ProofType → CircuitName mappings and slash reasons, adds dkg_input_type to share-decryption inputs, and extends e2e tests and fixture handling.

Changes

Cohort / File(s) Summary
Circuit Naming & Events
crates/events/src/enclave_event/proof.rs, crates/events/src/enclave_event/signed_proof.rs
Renamed/added CircuitName variants (DkgSkShareDecryption, DkgESmShareDecryption, PkAggregation, ThresholdShareDecryption, DecryptedSharesAggregation), updated as_str and group mappings, added ProofType::T6DecryptedSharesAggregation and updated circuit_name/slash_reason mappings.
DKG share_decryption helpers
crates/zk-helpers/src/circuits/dkg/share_decryption/circuit.rs, crates/zk-helpers/src/circuits/dkg/share_decryption/sample.rs
Added public dkg_input_type: DkgInputType to ShareDecryptionCircuitData and propagate it in sample output.
zk-prover — DKG circuits
crates/zk-prover/src/circuits/dkg/mod.rs, crates/zk-prover/src/circuits/dkg/share_decryption.rs, crates/zk-prover/src/circuits/dkg/share_computation.rs
Declared mod share_decryption; added Provable impl for DKG ShareDecryptionCircuit (resolve_circuit_name, valid_circuits); removed unused noirc_abi::InputMap import.
zk-prover — Threshold circuits
crates/zk-prover/src/circuits/threshold/mod.rs, crates/zk-prover/src/circuits/threshold/share_decryption.rs, crates/zk-prover/src/circuits/threshold/pk_aggregation.rs, crates/zk-prover/src/circuits/threshold/decrypted_shares_aggregation.rs
Added modules and Provable impls for Threshold ShareDecryption, PkAggregation, and DecryptedSharesAggregation circuits with associated types and circuit() returns.
Tests / e2e harness
crates/zk-prover/tests/local_e2e_tests.rs
Expanded fixture validation and copying, added setup helpers for new circuits, imported new circuit types, extended tests to validate commitment consistency and proof verification across new circuits.

Sequence Diagram(s)

sequenceDiagram
    participant ProofType as ProofType (events)
    participant CircuitName as CircuitName enum
    participant Provable as Provable impls (zk-prover)
    participant Prover as Prover / Proving pipeline
    participant Tests as local_e2e_tests

    ProofType->>CircuitName: map via ProofType::circuit_name()
    CircuitName->>Provable: select impl (resolve_circuit_name / circuit())
    Provable->>Prover: provide Params, Input types, and circuit id
    Prover->>Provable: request inputs / verify
    Tests->>Prover: run e2e flows using fixtures
    Prover->>Tests: return proof & commitments
    Tests->>Provable: independently compute commitments to verify
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • ctrlc03
  • 0xjei

Poem

🐰 I renamed circuits, hopped through code,
DKG and threshold now in mode.
Aggregations gathered neat,
Provable paths all lined and sweet,
hop hop — a tiny celebratory code.

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: adding missing circuits to the zk-prover module through refactoring.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/missing-circits-zk-prover

No actionable comments were generated in the recent review. 🎉


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
crates/zk-helpers/src/circuits/dkg/share_decryption/sample.rs (1)

78-91: ⚠️ Potential issue | 🟡 Minor

Duplicate .map_err produces nested error messages.

The first .map_err (line 80) already converts the error to CircuitsErrors::Sample. The second .map_err (line 86) then wraps that CircuitsErrors::Sample again via Debug formatting, producing a message like:
Sample("Failed to generate smudging error: Sample(\"Failed to generate smudging error: ...\")").

The same issue exists on lines 98–111 for generate_secret_shares_from_poly.

Proposed fix — remove the duplicate `.map_err` calls
                     let esi_coeffs = trbfv
                         .generate_smudging_error(sd.z as usize, sd.lambda as usize, &mut rng)
                         .map_err(|e| {
                             CircuitsErrors::Sample(format!(
                                 "Failed to generate smudging error: {:?}",
                                 e
                             ))
-                        })
-                        .map_err(|e| {
-                            CircuitsErrors::Sample(format!(
-                                "Failed to generate smudging error: {:?}",
-                                e
-                            ))
                         })?;
                     let esi_sss_u64 = share_manager
                         .generate_secret_shares_from_poly(esi_poly.clone(), &mut rng.clone())
                         .map_err(|e| {
                             CircuitsErrors::Sample(format!(
                                 "Failed to generate error shares: {:?}",
                                 e
                             ))
-                        })
-                        .map_err(|e| {
-                            CircuitsErrors::Sample(format!(
-                                "Failed to generate error shares: {:?}",
-                                e
-                            ))
                         })?;
crates/events/src/enclave_event/signed_proof.rs (1)

302-321: ⚠️ Potential issue | 🟡 Minor

Missing test assertion for T6DecryptedSharesAggregation in proof_type_circuit_name_mapping.

The new variant T6DecryptedSharesAggregation was added with its circuit_name() mapping (Line 67), but the proof_type_circuit_name_mapping test doesn't verify it. Consider adding coverage for completeness.

Proposed fix
         assert_eq!(
             ProofType::T5ShareDecryption.circuit_name(),
             CircuitName::ThresholdShareDecryption
         );
+        assert_eq!(
+            ProofType::T6DecryptedSharesAggregation.circuit_name(),
+            CircuitName::DecryptedSharesAggregation
+        );
     }
crates/zk-prover/tests/local_e2e_tests.rs (1)

599-606: ⚠️ Potential issue | 🟡 Minor

Stale skip messages in older commitment consistency tests.

The macro skip message at Line 559 was updated to "skipping: bb not found or fixtures missing", and the new tests at Lines 750 and 786 use the same updated message. However, the pre-existing commitment consistency tests still print the old "skipping: bb not found" message. Since setup_circuit_fixtures now also returns None for missing fixtures, these messages are inaccurate.

Proposed fix
-        println!("skipping: bb not found");
+        println!("skipping: bb not found or fixtures missing");

Apply at Lines 604, 654, 693, 722.

Also applies to: 650-656, 688-694, 717-723

🧹 Nitpick comments (2)
crates/events/src/enclave_event/proof.rs (1)

63-98: Note the redundant group prefix in dir_path() for some circuits.

DkgSkShareDecryption.dir_path() produces "dkg/dkg_sk_share_decryption" and ThresholdShareDecryption.dir_path() produces "threshold/threshold_share_decryption" — the group name appears twice. Existing circuits like SkShareEncryption don't repeat the group prefix ("dkg/sk_share_encryption"). This is presumably intentional to match the actual circuit binary directory names — just flagging for awareness.

crates/zk-prover/tests/local_e2e_tests.rs (1)

339-525: Significant code duplication across setup_* test helpers.

All five new setup functions follow an identical pattern (find bb → create prover → copy fixtures → generate sample → return tuple). Consider extracting a generic helper that takes the circuit path, fixture name, and a sample-generation closure to reduce boilerplate — though this can be deferred.

@cedoor cedoor changed the title refactor: missing circuits in zk-prover refactor: missing circuits in zk-prover [skip-size-limit] Feb 13, 2026
ctrlc03
ctrlc03 previously approved these changes Feb 13, 2026

@ctrlc03 ctrlc03 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@cedoor cedoor changed the title refactor: missing circuits in zk-prover [skip-size-limit] refactor: missing circuits in zk-prover [skip-line-limit] Feb 13, 2026
@cedoor cedoor enabled auto-merge (squash) February 13, 2026 15:21
@cedoor cedoor requested a review from ctrlc03 February 13, 2026 15:23
cedoor and others added 4 commits February 13, 2026 16:28
- Add Provable for DKG share_decryption (sk/e_sm), pk_aggregation, threshold share_decryption, decrypted_shares_aggregation
- Add setup and proof tests for all new circuits in local_e2e_tests
- Add commitment consistency tests for pk_aggregation and threshold_share_decryption
- Make setup_circuit_fixtures check for fixture existence; tests skip when missing
- Update CircuitName and ProofType in e3-events

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants