Skip to content

refactor: rename witness to inputs in zk-helpers#1301

Merged
cedoor merged 2 commits into
mainfrom
refactor/zk-witness-naming
Feb 11, 2026
Merged

refactor: rename witness to inputs in zk-helpers#1301
cedoor merged 2 commits into
mainfrom
refactor/zk-witness-naming

Conversation

@cedoor

@cedoor cedoor commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Re #1302

Summary by CodeRabbit

Release Notes

  • Refactor
    • Renamed "Witness" to "Inputs" terminology across circuit computation modules for improved semantic clarity in documentation.
    • Updated public API types and function signatures in DKG and Threshold circuit implementations.
    • Updated CLI flags and documentation to use "inputs" terminology consistently.
    • Clarified that Prover.toml contains circuit inputs for Nargo execution.

@cedoor cedoor requested a review from 0xjei February 11, 2026 15:53
@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 3:53pm
enclave-docs Ready Ready Preview, Comment Feb 11, 2026 3:53pm

Request Review

@cedoor cedoor requested a review from ctrlc03 February 11, 2026 15:53
@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR systematically refactors the zero-knowledge circuit infrastructure by renaming the "Witness" abstraction to "Inputs" across computation, codegen, and trait layers. The changes include type renames, field updates, method signatures, CLI flags, documentation, and test adjustments. Control flow and logic remain functionally identical.

Changes

Cohort / File(s) Summary
BFV Client Integration
crates/bfv-client/src/client.rs
Updated to use UserDataEncryptionInputs instead of UserDataEncryptionWitness; changed computation call from Witness::compute() to Inputs::compute().
CLI and Documentation
crates/zk-helpers/README.md, crates/zk-helpers/src/bin/zk_cli.rs
Replaced --witness flag with --inputs flag; updated function signature of print_generation_info and struct field witness: Option<String> to inputs: Option<String>; adjusted error messages and docs accordingly.
Codegen Documentation
crates/zk-helpers/src/circuits/codegen.rs, crates/zk-helpers/src/circuits/computation.rs
Updated doc comments to reflect that circuit data includes "circuit inputs" instead of "witness"; public signatures unchanged.
DKG PK Circuit
crates/zk-helpers/src/circuits/dkg/pk/computation.rs, crates/zk-helpers/src/circuits/dkg/pk/codegen.rs, crates/zk-helpers/src/circuits/dkg/pk/mod.rs
Renamed public struct Witness to Inputs; updated PkComputationOutput.witness field to inputs; changed generate_toml signature and re-exports.
DKG Share Computation Circuit
crates/zk-helpers/src/circuits/dkg/share_computation/computation.rs, crates/zk-helpers/src/circuits/dkg/share_computation/codegen.rs, crates/zk-helpers/src/circuits/dkg/share_computation/mod.rs, crates/zk-helpers/src/circuits/dkg/share_computation/circuit.rs
Renamed Witness struct to Inputs with corresponding output field and codegen signature changes; updated test names from test_witness_* to test_input_*; doc comment updates.
DKG Share Decryption Circuit
crates/zk-helpers/src/circuits/dkg/share_decryption/computation.rs, crates/zk-helpers/src/circuits/dkg/share_decryption/codegen.rs, crates/zk-helpers/src/circuits/dkg/share_decryption/mod.rs, crates/zk-helpers/src/circuits/dkg/share_decryption/circuit.rs
Renamed Witness struct to Inputs; updated output field and generate_toml signature; changed test function from test_witness_decryption_consistency to test_input_decryption_consistency.
DKG Share Encryption Circuit
crates/zk-helpers/src/circuits/dkg/share_encryption/computation.rs, crates/zk-helpers/src/circuits/dkg/share_encryption/codegen.rs, crates/zk-helpers/src/circuits/dkg/share_encryption/mod.rs, crates/zk-helpers/src/circuits/dkg/share_encryption/circuit.rs
Renamed Witness struct to Inputs; updated output field and codegen signature; changed test from test_witness_message_consistency to test_input_message_consistency; doc updates.
Threshold Decrypted Shares Aggregation
crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/computation.rs, crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/codegen.rs, crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/sample.rs, crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/utils.rs, crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/circuit.rs, crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/mod.rs
Renamed Witness struct to Inputs; updated output field and test assertions from out.witness.* to out.inputs.*; changed test function name; doc comment updates.
Threshold PK Aggregation
crates/zk-helpers/src/circuits/threshold/pk_aggregation/computation.rs, crates/zk-helpers/src/circuits/threshold/pk_aggregation/codegen.rs, crates/zk-helpers/src/circuits/threshold/pk_aggregation/sample.rs
Renamed Witness struct to Inputs and added fields pk0_agg and pk1_agg to Inputs; updated output field and codegen signature; test imports and usage updated.
Threshold PK Generation
crates/zk-helpers/src/circuits/threshold/pk_generation/computation.rs, crates/zk-helpers/src/circuits/threshold/pk_generation/codegen.rs, crates/zk-helpers/src/circuits/threshold/pk_generation/sample.rs
Renamed Witness struct to Inputs; updated output field and codegen signature; test assertions changed to reference inputs.* fields.
Threshold Share Decryption
crates/zk-helpers/src/circuits/threshold/share_decryption/computation.rs, crates/zk-helpers/src/circuits/threshold/share_decryption/codegen.rs
Renamed Witness struct to Inputs; updated output field and generate_toml signature; no test changes evident in diff.
Threshold User Data Encryption
crates/zk-helpers/src/circuits/threshold/user_data_encryption/computation.rs, crates/zk-helpers/src/circuits/threshold/user_data_encryption/codegen.rs, crates/zk-helpers/src/circuits/threshold/user_data_encryption/utils.rs
Renamed Witness struct to Inputs; updated output field and codegen signature; test field references changed from witness.* to inputs.*.
Core ZK Traits and Utilities
crates/zk-prover/src/traits.rs, crates/zk-prover/src/error.rs, crates/zk-prover/src/circuits/utils.rs, crates/zk-prover/src/circuits/dkg/pk.rs, crates/zk-prover/src/circuits/threshold/pk_generation.rs
Updated Provable trait: renamed associated type Witness to Inputs, method build_witness to build_inputs; updated bounds and error variant from WitnessGenerationFailed to InputsGenerationFailed; renamed utility function witness_json_to_input_map to inputs_json_to_input_map; updated impl blocks for circuit types.
Tests and Examples
crates/zk-prover/tests/local_e2e_tests.rs, examples/CRISP/crates/zk-inputs/src/lib.rs
Updated test assertions and field access from computation_output.witness.* to computation_output.inputs.*; updated example code to access .inputs field instead of .witness.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • 0xjei
  • ctrlc03
  • hmzakhalid

Poem

🐰 From Witness to Inputs, our circuits take flight,
With types and with traits all renamed just right,
Each struct, each field, every doc comment true,
A hop-skip-and-jump—the refactor breaks through!
No logic askew, just clarity's call,
The abstraction's refreshed, and it's sweeter for all! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.42% 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 clearly and specifically describes the main change: renaming 'witness' to 'inputs' throughout the zk-helpers crate, which is the primary objective of this refactoring PR.

✏️ 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/zk-witness-naming

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@crates/zk-helpers/src/circuits/threshold/decrypted_shares_aggregation/computation.rs`:
- Around line 10-11: The module doc comment incorrectly references
Input::standard_form but the struct is named Inputs; update the intra-doc link
to the correct identifier (e.g., Inputs::standard_form) so rustdoc resolves the
link—search for the doc comment at the top of computation.rs and replace
`Input::standard_form` with the exact public item name `Inputs::standard_form`
(or adjust to `crate::...::Inputs::standard_form` if needed) to match the actual
struct/method symbol.
🧹 Nitpick comments (5)
crates/zk-helpers/src/bin/zk_cli.rs (1)

230-230: Minor grammar nit: "a inputs-type" → "an inputs-type".

-    // DKG circuits have a inputs-type choice (secret-key vs smudging-noise) excluding `pk` or C0 circuit.
+    // DKG circuits have an inputs-type choice (secret-key vs smudging-noise) excluding `pk` or C0 circuit.
crates/zk-prover/tests/local_e2e_tests.rs (1)

230-230: Stale comment: still says "from the witness".

-    // Recompute commitments from the witness
+    // Recompute commitments from the inputs
crates/zk-helpers/src/circuits/threshold/share_decryption/codegen.rs (1)

39-43: Inconsistent ownership: generate_toml takes Inputs by value here but by reference elsewhere.

The DKG share_decryption codegen (crates/zk-helpers/src/circuits/dkg/share_decryption/codegen.rs, Line 42) and share_encryption codegen both accept &Inputs. This file takes Inputs by value. Consider taking &Inputs for consistency across codegen modules.

♻️ Suggested fix
-pub fn generate_toml(inputs: Inputs) -> Result<CodegenToml, CircuitsErrors> {
-    let json = inputs.to_json().map_err(|e| CircuitsErrors::SerdeJson(e))?;
+pub fn generate_toml(inputs: &Inputs) -> Result<CodegenToml, CircuitsErrors> {
+    let json = inputs.to_json().map_err(|e| CircuitsErrors::SerdeJson(e))?;

And at the call site (Line 32):

-        let toml = generate_toml(inputs)?;
+        let toml = generate_toml(&inputs)?;
examples/CRISP/crates/zk-inputs/src/lib.rs (1)

122-128: Variable names still reference "witness" despite the rename.

ciphertext_addition_witness_json and user_data_encryption_witness_json still use "witness" terminology. Since CiphertextAdditionWitness wasn't renamed in this PR, the first is arguably fine, but user_data_encryption_witness_json (Line 123) could be updated to user_data_encryption_inputs_json to align with the .inputs field access on Line 124.

Same applies to the duplicate in generate_inputs at Lines 190-192.

crates/zk-helpers/src/circuits/threshold/pk_aggregation/computation.rs (1)

46-46: Nit: unnecessary double-reference &input.

input is already &PkAggregationCircuitInput (from the method signature). Passing &input creates &&PkAggregationCircuitInput, which works via auto-deref but is unnecessary and inconsistent with sibling computation modules (e.g., dkg/pk/computation.rs, share_decryption/computation.rs) which pass input directly.

Suggested fix
-        let inputs = Inputs::compute(preset, &input)?;
+        let inputs = Inputs::compute(preset, input)?;

@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

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

utACK

@cedoor cedoor merged commit 286813a into main Feb 11, 2026
43 of 46 checks passed
@ctrlc03 ctrlc03 deleted the refactor/zk-witness-naming branch February 11, 2026 19:23
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