Skip to content

refactor: add pk_aggregation circuit#1270

Merged
cedoor merged 2 commits into
mainfrom
refactor/pk-aggregation
Feb 6, 2026
Merged

refactor: add pk_aggregation circuit#1270
cedoor merged 2 commits into
mainfrom
refactor/pk-aggregation

Conversation

@cedoor

@cedoor cedoor commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Re #1259

Summary by CodeRabbit

  • New Features

    • Added a public key aggregation (pk-aggregation) circuit with computation, codegen, sample generation, and CLI support.
    • Added scalar multiplication for polynomials and a JSON helper for BigInt conversion.
  • Improvements

    • Improved sample generation and error propagation (no panics) across PK generation paths.
    • Renamed PK generation input fields for clarity.
  • Configuration Changes

    • Tuning of committee and threshold bit/default parameters.

@cedoor cedoor requested a review from 0xjei February 6, 2026 12:21
@vercel

vercel Bot commented Feb 6, 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 6, 2026 1:28pm
enclave-docs Ready Ready Preview, Comment Feb 6, 2026 1:28pm

Request Review

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new threshold public-key-aggregation circuit (PkAggregationCircuit) with computation, codegen, and sample modules to zk-helpers; updates Noir config constants; adds CrtPolynomial::scalar_mul; renames pk_share → pk0_share across pk_generation code; registers the new circuit in the CLI; and adds BigInt JSON helper utilities.

Changes

Cohort / File(s) Summary
Noir Configuration Constants
circuits/lib/src/configs/committee/small.nr, circuits/lib/src/configs/insecure/threshold.nr, circuits/lib/src/configs/secure/threshold.nr
Adjusted constants: H changed 5→3 in small.nr; PK_AGGREGATION_BIT_PK changed 36→35 (insecure) and 53→52 (secure); removed some header comment lines.
CrtPolynomial Enhancement
crates/polynomial/src/crt_polynomial.rs
Added pub fn scalar_mul(&mut self, scalar: &BigInt) to scale each limb in-place.
PK Aggregation Circuit Core
crates/zk-helpers/src/circuits/threshold/pk_aggregation/...
circuit.rs, computation.rs, codegen.rs, sample.rs, mod.rs
New pk_aggregation module: circuit type and input, computation (Configs/Bounds/Bits/Witness), codegen (TOML/config generation and tests), sample generator (input creation), and module wiring + public re-exports.
CLI Circuit Registration
crates/zk-helpers/src/bin/zk_cli.rs
Imported and registered PkAggregationCircuit and PkAggregationCircuitInput; added runtime handling to generate sample and artifacts for the new circuit.
PK Generation Renames & Error Handling
crates/zk-helpers/src/circuits/threshold/pk_generation/...
Renamed pk_sharepk0_share (circuit, sample, computation files); replaced several unwrap() calls with map_err(...)? to surface CircuitsErrors::Sample/Other appropriately.
Utils Refactor
crates/zk-helpers/src/utils.rs
Added bigint_1d_to_json_values() and refactored bigint_3d_to_json_values() to delegate to the new 1D helper.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/CLI
    participant CLI as zk_cli
    participant Registry as CircuitRegistry
    participant Sample as SampleGen
    participant Compute as Computation
    participant Codegen as Codegen

    User->>CLI: request pk-aggregation artifacts
    CLI->>Registry: lookup/register PkAggregationCircuit
    CLI->>Sample: PkAggregationCircuitInput::generate_sample(preset, committee)
    Sample-->>CLI: PkAggregationCircuitInput
    CLI->>Compute: CircuitComputation::compute(preset, input)
    Compute-->>CLI: PkAggregationComputationOutput (Configs, Bits, Witness)
    CLI->>Codegen: CircuitCodegen::codegen(preset, input)
    Codegen-->>CLI: Artifacts (TOML + configs)
    CLI-->>User: deliver artifacts
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • 0xjei

Poem

🐇 A little rabbit hops with glee,
New circuits bloom for all to see,
pk0 now named, polynomials scaled,
Samples made and TOML hailed,
Hops, code, and witness — party! ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 clearly and concisely summarizes the main change: adding a new pk_aggregation circuit, which aligns with the substantial additions across multiple files including circuit definitions, computation logic, codegen, and CLI integration.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/pk-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.

@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 c9ad296 into main Feb 6, 2026
26 checks passed
@github-actions github-actions Bot deleted the refactor/pk-aggregation branch February 14, 2026 03:10
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