Skip to content

refactor: rename circuit_input to circuit_data [skip-line-limit]#1304

Merged
ctrlc03 merged 4 commits into
mainfrom
refactor/input-to-data
Feb 11, 2026
Merged

refactor: rename circuit_input to circuit_data [skip-line-limit]#1304
ctrlc03 merged 4 commits into
mainfrom
refactor/input-to-data

Conversation

@cedoor

@cedoor cedoor commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Renamed public "Input" types to "Data" across the zero-knowledge tooling and CLI, updating sample generation and codegen usage.
    • Several circuit data structures were expanded with new fields; generated samples and artifacts now include the extended payloads.
    • Minor formatting updates to developer scripts and docs; no functional behavior changes.

@vercel

vercel Bot commented Feb 11, 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 11, 2026 8:26pm
enclave-docs Ready Ready Preview, Comment Feb 11, 2026 8:26pm

Request Review

@cedoor cedoor requested a review from 0xjei February 11, 2026 17:56
@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Renames public circuit input types from *Input to *Data across zk-helpers, zk-prover, client, multithread, examples, and tests; updates associated trait associated-type names (InputData) and method parameters to accept &Self::Data; adds or expands fields on several circuit data structs; updates imports and sample-generation call sites.

Changes

Cohort / File(s) Summary
Core traits
crates/zk-helpers/src/circuits/codegen.rs, crates/zk-helpers/src/circuits/computation.rs
Renamed associated type InputData and changed method parameters from input: &Self::Inputdata: &Self::Data in CircuitCodegen, Computation, and CircuitComputation traits.
DKG — PK
crates/zk-helpers/src/circuits/dkg/pk/... (circuit.rs, codegen.rs, computation.rs, mod.rs, sample.rs), crates/zk-prover/src/circuits/dkg/pk.rs, crates/zk-prover/tests/local_e2e_tests.rs
Renamed PkCircuitInputPkCircuitData, updated trait impls/codegen/computation call sites, imports, tests, and Provable associated type.
DKG — Share Computation
crates/zk-helpers/src/circuits/dkg/share_computation/...
Renamed ShareComputationCircuitInputShareComputationCircuitData; added fields parity_matrix, n_parties, threshold; updated codegen/computation/samples/tests and re-exports.
DKG — Share Encryption / Decryption
crates/zk-helpers/src/circuits/dkg/share_encryption/..., crates/zk-helpers/src/circuits/dkg/share_decryption/...
Renamed *CircuitInput*CircuitData across circuit/codegen/computation/sample/tests and re-exports; updated internal field references to use data.* instead of input.*.
Threshold — Various circuits
crates/zk-helpers/src/circuits/threshold/... (decrypted_shares_aggregation, pk_aggregation, pk_generation, share_decryption, user_data_encryption, related samples/codegen/computation)
Renamed many *CircuitInput*CircuitData; several structs gained fields (e.g., DecryptedSharesAggregation: reconstructing_parties, message_vec; PkAggregation: a; PkGeneration: eek, e_sm, sk; ShareDecryption: e, d_share); updated all trait impls, compute/codegen call sites, samples, imports, and tests.
Prover integration & traits
crates/zk-prover/src/traits.rs, crates/zk-prover/src/circuits/threshold/pk_generation.rs
Adjusted Provable trait bounds to require Computation<..., Data = Self::Input> and updated provable impls to use *CircuitData types.
CLI / Client / Multithread / Examples
crates/zk-helpers/src/bin/zk_cli.rs, crates/bfv-client/src/client.rs, crates/multithread/src/multithread.rs, examples/CRISP/crates/zk-inputs/src/lib.rs
Replaced usages/imports of *Input types with *Data equivalents and updated generate_sample / compute call sites.
Tests & README
crates/zk-prover/tests/local_e2e_tests.rs, crates/zk-helpers/README.md
Updated tests to construct/pass *CircuitData types; minor README formatting changes.
Non-functional formatting
packages/enclave-contracts/tasks/*.ts, packages/enclave-contracts/contracts/interfaces/IEnclave.sol
Formatting only: dynamic import expressions and function parameter formatting changed to multi-line; no behavioral changes.

🎯 4 (Complex) | ⏱️ ~60 minutes

Sequence Diagram(s)

Possibly related PRs

Suggested labels

sdk

Suggested reviewers

  • 0xjei
  • ctrlc03

Poem

🐰 Hopping through the repo with a cheerful pat,

Inputs turned to Data — tidy as that!
Circuits refreshed, imports aligned,
Traits now take Data and tests pass fine,
A carrot-coded refactor—snack for the devs 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: a systematic rename of circuit input types to circuit data types across the codebase.

✏️ 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/input-to-data

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
crates/zk-helpers/src/circuits/threshold/pk_aggregation/circuit.rs (1)

24-30: Consider documenting the new a field.

The renamed struct aligns with the PR objective. The new a: CrtPolynomial field is added without any doc comment explaining its purpose. The other fields (committee, public_key, pk0_shares) are similarly undocumented, but since you're already touching this struct, it would be a good time to add a brief doc comment on a (e.g., what polynomial it represents in the aggregation context).

crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/circuit.rs (1)

24-35: Doc comment still references "input" terminology.

Line 24 says "Raw input for circuit input computation" — consider updating to align with the *Data naming convention used throughout this refactor (e.g., "Raw data for circuit computation").

crates/zk-prover/src/traits.rs (1)

25-32: Consider renaming Provable::Input to Provable::Data for consistency.

The Computation trait's associated type was renamed from Input to Data, but Provable still uses type Input (Line 25), resulting in the slightly confusing bound Data = Self::Input. For full naming consistency across the codebase, consider renaming this associated type as well.

crates/zk-prover/src/circuits/threshold/pk_generation.rs (1)

15-22: Inconsistency: Provable trait uses type Input while CircuitComputation uses type Data.

The CircuitComputation trait (in zk-helpers) and its parent Computation trait both use type Data as the associated type name, but the Provable trait here uses type Input. Both refer to the same semantic concept—the input data for computation. This naming inconsistency is visible in the trait's constraint: Computation<Preset = Self::Params, Data = Self::Input>, which explicitly maps Input to Data.

Renaming Provable::Input to Provable::Data would align with the zk-helpers naming convention and only affect 2 implementations. Alternatively, document why the divergence is intentional.


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.

@cedoor cedoor requested a review from ctrlc03 February 11, 2026 17:57
@cedoor cedoor changed the title refactor: rename circuit_input to circuit_data refactor: rename circuit_input to circuit_data [skip-line-limit] Feb 11, 2026

@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.

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (2)
crates/zk-helpers/src/circuits/threshold/pk_generation/circuit.rs (1)

23-31: ⚠️ Potential issue | 🟡 Minor

Update documentation reference in mod.rs — struct was renamed from PkGenerationCircuitInput to PkGenerationCircuitData.

All code construction sites correctly use the new struct name with the three new CrtPolynomial fields (eek, e_sm, sk). However, the documentation comment in crates/zk-helpers/src/circuits/threshold/pk_generation/mod.rs:11 still references the old type name and should be updated to PkGenerationCircuitData.

crates/zk-helpers/src/circuits/dkg/share_computation/circuit.rs (1)

22-22: ⚠️ Potential issue | 🟡 Minor

Stale reference to ShareComputationCircuitInput in comment.

Line 22 still references the old type name ShareComputationCircuitInput::dkg_input_type. Should be updated to ShareComputationCircuitData.

Proposed fix
-    /// None: circuit accepts runtime-varying input type (SecretKey or SmudgingNoise via `ShareComputationCircuitInput::dkg_input_type`).
+    /// None: circuit accepts runtime-varying input type (SecretKey or SmudgingNoise via `ShareComputationCircuitData::dkg_input_type`).
🤖 Fix all issues with AI agents
In `@crates/zk-helpers/src/bin/zk_cli.rs`:
- Around line 23-26: The import alias re-introduces the old "Input" suffix;
change the alias from ShareDecryptionCircuitData as
DkgShareDecryptionCircuitInput to ShareDecryptionCircuitData as
DkgShareDecryptionCircuitData, then update all usages of
DkgShareDecryptionCircuitInput (e.g., the construction/typing site where the
share decryption circuit data is used) to the new DkgShareDecryptionCircuitData
identifier so names are consistent with the PR rename.
- Around line 35-38: The import alias incorrectly preserves the old "Input"
naming: change the import alias from "ShareDecryptionCircuitData as
ThresholdShareDecryptionCircuitInput" to "ShareDecryptionCircuitData as
ThresholdShareDecryptionCircuitData", and then update any usages of the old
alias (e.g., the variable/type referenced as
ThresholdShareDecryptionCircuitInput around the code that constructs or reads
the share decryption input) to use ThresholdShareDecryptionCircuitData instead
so references to the circuit data type match the renamed import.

In `@crates/zk-helpers/src/circuits/dkg/share_decryption/computation.rs`:
- Around line 45-48: The CircuitComputation::compute method currently uses the
parameter name `input` but should be `data` to match other Computation::compute
implementations; rename the parameter from `input` to `data` in the compute
signature and update all usages inside the function (calls to Bounds::compute,
Bits::compute, Inputs::compute and any local references) so they pass `data`
instead of `input`, keeping the rest of the method body unchanged.
🧹 Nitpick comments (13)
crates/zk-helpers/src/circuits/dkg/share_encryption/circuit.rs (1)

30-31: Nit: stale doc comment still says "Input to the share-encryption circuit".

Should read "Data for the share-encryption circuit" (or similar) to match the renamed struct.

Suggested fix
-/// Input to the share-encryption circuit: plaintext, ciphertext, keys, and encryption randomness.
+/// Data for the share-encryption circuit: plaintext, ciphertext, keys, and encryption randomness.
crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/circuit.rs (1)

24-27: Nit: doc comment on Line 24 still references "input" twice.

Consider updating to align with the *Data naming convention used throughout this PR.

Suggested fix
-/// Raw input for circuit input computation: decryption share polynomials from T+1 parties,
+/// Raw data for circuit computation: decryption share polynomials from T+1 parties,
crates/zk-helpers/src/circuits/threshold/share_decryption/circuit.rs (1)

7-7: Nit: doc comment still references "input" instead of "data".

Line 7: //! Circuit type and input for threshold share decryption. — consider updating to match the rename convention.

Proposed fix
-//! Circuit type and input for threshold share decryption.
+//! Circuit type and data for threshold share decryption.
crates/zk-helpers/src/circuits/dkg/share_computation/circuit.rs (1)

27-27: Slightly awkward phrasing in doc comment.

"Which secret type this data is for (determines which branch to use in data)" — the trailing "in data" reads oddly. Consider rephrasing.

Proposed fix
-    /// Which secret type this data is for (determines which branch to use in data).
+    /// Which secret type this data is for (determines which branch the circuit uses).
crates/zk-helpers/src/circuits/dkg/share_computation/codegen.rs (1)

53-55: Stale "input" wording in error message.

Line 54 still says "input json is not an object". Consider updating to "data json is not an object" for consistency with the rename.

Suggested fix
     let obj = json.as_object_mut().ok_or(CircuitsErrors::Other(
-        "input json is not an object".to_string(),
+        "data json is not an object".to_string(),
     ))?;
crates/zk-helpers/src/circuits/computation.rs (1)

9-10: Doc comments still reference "input" in multiple places.

Lines 9, 22, 28, 41, and 48 still mention "input" in doc comments (e.g., "parameters and input", "parameters and input produce bounds"). Consider updating these to say "data" for consistency with the rename.

Also applies to: 22-22, 28-28, 41-41, 48-48

crates/zk-helpers/src/circuits/dkg/share_encryption/sample.rs (1)

68-81: Pre-existing: double .map_err on smudging error generation.

Lines 70-81 chain two identical .map_err(...) calls on generate_smudging_error. The second one wraps the already-mapped CircuitsErrors in another CircuitsErrors::Sample(...), producing a nested debug-format string. Not introduced by this PR, but worth a cleanup.

Suggested fix — remove the duplicate `.map_err`
                 let esi_coeffs = trbfv
                     .generate_smudging_error(num_ciphertexts as usize, 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
-                        ))
                     })?;
crates/zk-helpers/src/circuits/dkg/share_decryption/sample.rs (2)

86-91: Pre-existing: duplicate .map_err chain on smudging error generation.

Lines 80–91 chain two identical .map_err(|e| CircuitsErrors::Sample(...)) calls. The first one already converts the error, so the second is a no-op identity mapping. Not introduced by this PR, but worth cleaning up.

♻️ Remove redundant `.map_err`
                     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
-                            ))
                         })?;

98-111: Pre-existing: same duplicate .map_err pattern on error shares generation.

Lines 98–111 also chain two identical .map_err calls. Same cleanup opportunity as above.

♻️ Remove redundant `.map_err`
                     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/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/codegen.rs (1)

115-116: Nit: local variable still named input.

The test variable on line 115 is still named input while the rest of the PR consistently uses data or sample for this concept. Consider renaming for consistency with the broader refactor.

♻️ Rename local variable
-        let input =
+        let data =
             DecryptedSharesAggregationCircuitData::generate_sample(preset, committee).unwrap();
         let circuit = DecryptedSharesAggregationCircuit;
 
-        let artifacts = circuit.codegen(preset, &input).unwrap();
+        let artifacts = circuit.codegen(preset, &data).unwrap();
crates/zk-helpers/src/circuits/threshold/pk_aggregation/computation.rs (1)

43-46: Unnecessary double-reference &data on line 46.

data is already &Self::Data (i.e., &PkAggregationCircuitData), so &data creates &&PkAggregationCircuitData. Rust auto-derefs, so this compiles, but it's inconsistent with all other CircuitComputation::compute implementations which pass data directly.

Proposed fix
-        let inputs = Inputs::compute(preset, &data)?;
+        let inputs = Inputs::compute(preset, data)?;
crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/computation.rs (2)

7-11: Stale doc references to Input after the rename.

Lines 10–11 still mention "Input coefficients" and [`Input::standard_form`]. Since the struct is Inputs (and the PR is specifically about this rename), consider updating these doc strings to stay consistent.

Suggested diff
-//! Bounds, configs, bits, and input computation for the Decryption Share Aggregation TRBFV circuit.
+//! Bounds, configs, bits, and data computation for the Decryption Share Aggregation TRBFV circuit.
 //!
-//! Uses [`crate::threshold::decrypted_shares_aggregation::utils`] for Q/delta, modular inverses,
-//! Lagrange-at-zero recovery, and scalar CRT reconstruction. Input coefficients are normalized
-//! with [`e3_polynomial::reduce`] in [`Input::standard_form`], consistent with other circuits.
+//! Uses [`crate::threshold::decrypted_shares_aggregation::utils`] for Q/delta, modular inverses,
+//! Lagrange-at-zero recovery, and scalar CRT reconstruction. Coefficients are normalized
+//! with [`e3_polynomial::reduce`] in [`Inputs::standard_form`], consistent with other circuits.

413-417: Local variable still named input after the rename.

The compute signatures now use data, but this test variable is still called input. Consider renaming it for consistency with the refactor.

-        let input =
+        let data =
             DecryptedSharesAggregationCircuitData::generate_sample(preset, committee.clone())
                 .unwrap();
 
-        let out = DecryptedSharesAggregationCircuit::compute(preset, &input).unwrap();
+        let out = DecryptedSharesAggregationCircuit::compute(preset, &data).unwrap();

Comment thread crates/zk-helpers/src/bin/zk_cli.rs
Comment thread crates/zk-helpers/src/bin/zk_cli.rs
Comment thread crates/zk-helpers/src/circuits/dkg/share_decryption/computation.rs Outdated
@ctrlc03 ctrlc03 merged commit 1d2e8e8 into main Feb 11, 2026
27 checks passed
@github-actions github-actions Bot deleted the refactor/input-to-data branch February 19, 2026 03:15
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