Skip to content

Use qp-zk-circuits proof-of-burn circuits - #192

Open
illuzen wants to merge 5 commits into
mainfrom
cursor/update-zk-circuits-88e9
Open

illuzen wants to merge 5 commits into
mainfrom
cursor/update-zk-circuits-88e9

Conversation

@illuzen

@illuzen illuzen commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Cooldown-bypass-reason: RUSTSEC-2026-0381, RUSTSEC-2026-0382, and RUSTSEC-2026-0383 are fixed only by rustls-webpki 0.103.16 and webpki root bundles 1.0.10, published 2026-10-19 and 2026-10-20, which are still inside the 30-day cooldown.

The CLI builds and proves against qp-zk-circuits 3ba7cefaee5dc1d382ec4d29e19c0f02882b1e05 (proof-of-burn). Those sources are vendored under third_party/qp-zk-circuits and published as quantus-wormhole-*, quantus-zk-circuits-common, and quantus-ownership-* 4.5.0. A crates.io release therefore does not resolve the older qp-* 4.4.0 crates. Rust library names stay qp_wormhole_*, qp_zk_circuits_common, and qp_ownership_*.

Volume fee

The private-batch circuit allows floor(sum(real inputs) * (10000 - fee_bps) / 10000). Default aggregate payouts, reward collection, and dissolve apply that fee once to the batch sum, then partition it. Eight burns of 100 quantized units at 4 bps pay 799, not the per-leaf sum 792. Eight 1-unit burns pay 7. Explicit --exit-amount is unchanged.

Crystals

Published qp-rusty-crystals 4.1.1 pins zeroize =1.8.2, which cannot unify with the circuits. third_party/qp-rusty-crystals is the Apache-2.0 rewrite at 279cd773, published as quantus-crystals-dilithium and quantus-crystals-hdwallet 4.2.0. Seed, wormhole address, and ML-DSA public key match 4.1.1. qp-dilithium-crypto 0.6.1 is vendored as quantus-dilithium-crypto 0.7.0 so it links those crates instead of 4.1.1. There is no [patch.crates-io].

Release

The publish job uploads the vendored crates in dependency order, then quantus-cli. "Already uploaded" is success, so a later CLI release can repeat the job. cargo package of quantus-wormhole-inputs succeeds. cargo package of quantus-cli fails until these names exist on crates.io, and it does not rewrite them to qp-* 4.4.0. The release token has to be allowed to create the new crate names. This agent cannot publish.

Chain

Quantus chain is still on qp-wormhole-* 4.3.0. Proofs from this CLI will not verify on chain until the runtime is built from the same circuits.

Production shape remains 8 leaves, 32 exit slots, public-batch arity 89. Generating that shape completed in about two and a half minutes. The private-batch and ownership circuits need qp-plonky2's rand feature; the build script enables it directly because it does not inherit features from the CLI's normal dependency.

Security audit

cargo audit was failing on four crates that already had patched releases inside their existing ranges. quinn-udp 0.5.16 is old enough for the cooldown. rustls-webpki 0.103.16 and webpki-roots / webpki-root-certs 1.0.10 are the oldest releases that clear RUSTSEC-2026-0381, 0382, and 0383. They were published on 2026-10-19 and 2026-10-20, so the 30-day cooldown still rejects them. crypto-bigint 0.5.5 (RUSTSEC-2026-0387) has no compatible fix. sp-core through 43.0.0 requires k256 0.13, which requires elliptic-curve 0.13 and crypto-bigint ^0.5, while the patched line starts at 0.7.6. That advisory is ignored in .cargo/audit.toml until Substrate moves off k256 0.13.

Open in Web Open in Cursor 

Leaves are proof-of-burn. Private batches pay batch-level exits, and the
production shape is 8 leaves, 32 exit slots, and public-batch arity 89.
Vendor the Apache-2.0 crystals rewrite so zeroize 1.9.1 can unify with
the circuits.

Co-authored-by: illuzen <illuzen@users.noreply.github.com>
@illuzen illuzen added the bot-review Request automated review from review-bot label Nov 17, 2026 — with Cursor

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

Verdict: Request changes
Reviewer: GPT-6.1 Sol

Reviewed commit b91d081ffc24b0236351e62ffb61a95c54203062 against base bc3bf6ac2702509216bfbf88eb734f411a555f7d.

  1. [P2] Apply the volume fee once to the batch total before rounding. In src/cli/wormhole.rs:1375–1381, the default payout still sums individually rounded leaf payouts. The pinned circuit now allows floor(sum(real inputs) * (10000 - fee_bps) / 10000). For eight burns of 100 quantized units at 4 bps, the CLI pays 792 units instead of 799: 7.92 tokens instead of 7.99. Those extra seven units cannot be recovered after the burns' nullifiers are spent. A standalone Rust probe using the actual extracted compute_batch_exits source reproduced this; eight one-unit burns likewise produce zero payout despite permitting seven units. The same rounding occurs in compute_batch_exits (line 488), reward collection (src/collect_rewards_lib.rs:859–865), and dissolve (line 4207). Use one shared calculation with a wide batch input total, apply the fee once, then partition the payout. Cover these sibling paths with tests asserting the batch formula; the current expected-total helper repeats the per-leaf rounding.

  2. [P2] Preserve the crates.io release and installation path. The new git dependencies in Cargo.toml:150–151, and the other circuit dependency declarations, omit version requirements. cargo package --locked --no-verify --offline fails immediately: all dependencies must have a version requirement specified when packaging, identifying qp-ownership-circuit. The existing release workflow runs cargo publish, so its publication job now fails. Adding version = "4.4.0" alone would select the older, incompatible circuits when Cargo removes git declarations for publication. The root-only crystals patches also cannot supply the changed API to downstream SDK consumers. Publish compatible circuit/crystals releases and reference their versions, or provide another publishable dependency arrangement, then verify packaging and a downstream install/build.

Validation:

  • Passed 141 focused library tests: wormhole (58), reward collection (19), artifact manifests (15), and wallets (49), each command capped with timeout 60 and circuit generation skipped.
  • Passed SKIP_CIRCUIT_BUILD=1 cargo clippy --all-targets --locked --offline -- -D warnings, pinned rustfmt, Taplo, and git diff --check.
  • Confirmed vendored production source matches crystals revision 279cd773f819f344d56a37d11af47390a92f528b; source differences are omitted test modules, and both licenses match the upstream root license.
  • Full-library run reached the 60-second limit: 454 tests had passed and the artifact-dependent batch-verifier test had failed because generated-bins was absent with generation skipped. Production circuit generation and on-chain acceptance were not exercised.
  • GitHub Security Audit failed on five advisories affecting dependency versions already present in the base lockfile. Format and dependency-cooldown checks passed; the remaining substantive CI jobs were still running at the last check.

@n13 n13 removed the bot-review Request automated review from review-bot label Nov 17, 2026
The private-batch circuit allows floor(sum(inputs) * (10000 - fee) / 10000).
Default payouts, reward collection, and dissolve now use that total instead
of summing per-leaf floors.

Circuits, the Apache crystals rewrite, and qp-dilithium-crypto are path
dependencies with versions, published as quantus-* crates so packaging does
not fall back to the older qp-* 4.4.0 releases. The release job publishes
those crates before quantus-cli.

Co-authored-by: illuzen <illuzen@users.noreply.github.com>
@illuzen illuzen added the bot-review Request automated review from review-bot label Nov 17, 2026 — with Cursor

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

Verdict: Request changes
Reviewer: GPT-6.1 Sol

Reviewed head 2d7d9dd5c6ab2423b83a2ab7d8e274694d489ac8 against base bc3bf6ac2702509216bfbf88eb734f411a555f7d.

  1. [P1] Enable Plonky2 randomness in the build dependency graph. third_party/qp-zk-circuits/wormhole/circuit-builder/Cargo.toml:22 disables default features and enables only std. The build script generates a private-batch circuit with zero knowledge enabled, which requires qp-plonky2/rand. The CLI's normal dependency enables rand, but Cargo separates normal and build dependency features, so that does not enable it for the build script. After cleaning only the isolated worktree's CLI artifacts, timeout 60 env -u SKIP_CIRCUIT_BUILD cargo build --locked --offline failed with Cannot use zero_knowledge without rand feature at qp-plonky2-1.6.0/src/plonk/circuit_builder.rs:1031. Both Ubuntu and macOS CI fail at the same point. This blocks ordinary builds, release builds, and default publish/install verification. Enable rand in the circuit-builder's Plonky2 dependency, or another shared proving dependency that reaches the host graph, then rerun an ordinary build with circuit generation enabled. The checks using SKIP_CIRCUIT_BUILD=1 bypass this failure.

The earlier batch-rounding finding is fixed across default aggregation, multiround, reward collection, and dissolve. Versioned publishable dependencies and the dependency-ordered publication workflow address the earlier packaging declarations; the build failure above remains a release blocker.

Validation:

  • Passed 223 focused library tests: wormhole CLI (50), wormhole library (6), reward collection (19), artifact manifests (15), wallet paths (102), and airdrop/derivation (31). Each Cargo test command used SKIP_CIRCUIT_BUILD=1 timeout 60 cargo test --locked --offline --lib <filter>; the library tests include successful dummy leaf-proof generation.
  • A standalone Rust probe using the actual fee and dissolve helper sources passed 23,328 small-batch fee/conservation cases and u32 boundary checks, including the 799-unit and 7-unit rounding cases.
  • Passed strict all-target Clippy, pinned rustfmt, Taplo, git diff --check, publication-script syntax, and a metadata check of all 14 packages' publication order and exact local dependency versions.
  • Circuit Rust sources match upstream 3ba7cef after formatting; crystals production sources match 279cd773 with test-module omissions; the Dilithium adapter sources match published 0.6.1 after formatting. License comparisons passed.
  • quantus-wormhole-inputs packages successfully. CLI packaging still requires the new crate names to be published first; downstream registry installation was not verified.
  • GitHub Security Audit reports five vulnerabilities; all five affected crate versions are unchanged from the base lockfile. Production private/public circuit generation cannot complete because of the finding above, and on-chain acceptance was not exercised.

@n13 n13 removed the bot-review Request automated review from review-bot label Nov 17, 2026
The private-batch and ownership circuits use row blinding. Plonky2 panics
while building them unless its rand feature is on, and the build script
does not inherit that feature from the CLI's normal dependency.

Co-authored-by: illuzen <illuzen@users.noreply.github.com>
@illuzen illuzen added the bot-review Request automated review from review-bot label Nov 17, 2026 — with Cursor

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

Verdict: Approve
Reviewer: GPT-6.1 Sol

Reviewed head 08c12a365784a2a86eadff829dd2cd3eee7e3f73 against base bc3bf6ac2702509216bfbf88eb734f411a555f7d.

No blocking findings remain. The previous randomness failure is fixed in the build dependency graph: a clean CLI library build with circuit generation enabled completes successfully for the production 8-leaf / 32-exit / 89-arity shape. The fee-rounding fix applies the fee once to the batch sum across default aggregation, multiround, reward collection, and dissolve. Versioned vendored dependencies and dependency-ordered publication address the earlier packaging declarations.

Validation:

  • Passed 224 focused library tests: wormhole CLI (50), wormhole library (6), reward collection (19), artifact manifests (15), wallet paths (102), airdrop/derivation (31), and loading generated private/public batch verifiers (1). Each test command was capped with timeout 60.
  • Passed a standalone Rust probe using the actual fee/apportionment/dissolve helper sources: 39,652 independent fee, conservation, and boundary cases, including the 799-unit and 7-unit rounding cases.
  • Passed env -u SKIP_CIRCUIT_BUILD cargo build --lib --locked --offline after cleaning this worktree's CLI artifacts. Production circuit generation completed in 79 seconds; the build completed in 94 seconds. An independent verifier harness accepted the generated canonical leaf artifacts and verified both generated dummy leaf and private-batch proofs.
  • Passed SKIP_CIRCUIT_BUILD=1 cargo clippy --all-targets --locked --offline -- -D warnings, pinned rustfmt, Taplo, and git diff --check.
  • All 59 vendored circuit Rust files match upstream 3ba7cef after formatting. Crystals production sources match 279cd773, with only test-module omissions; adapter sources match published 0.6.1 after formatting. Circuit/crystals license comparisons passed.
  • quantus-wormhole-inputs packages and verifies successfully. Checked all 14 packages' publication order, 36 local dependency declarations and their exact versions, and publication-script syntax.

Validation limits: full CLI packaging in offline mode stops because the new quantus-dilithium-crypto package is unavailable in the local registry index. Publishing the new dependency versions and downstream registry installation remain unverified. On-chain acceptance was not exercised; deployment requires a runtime built from matching circuits, as documented in the PR.

GitHub format, dependency-cooldown, and analysis checks passed. Security Audit reports five vulnerabilities; all five affected dependency versions are unchanged from the base lockfile. Ubuntu/macOS build-and-test and Examples were still running at the last check.

@n13 n13 removed the bot-review Request automated review from review-bot label Nov 17, 2026
cursoragent and others added 2 commits November 17, 2026 11:08
cargo audit failed on quinn-udp 0.5.15, rustls-webpki 0.103.15,
webpki-roots 1.0.9, and webpki-root-certs 1.0.9. Those releases sit
inside ranges the existing dependencies already allow.

crypto-bigint 0.5.5 stays. k256 0.13, required by every published
sp-core, pins elliptic-curve 0.13, which only accepts crypto-bigint
^0.5. The patched line starts at 0.7.6.

Co-authored-by: illuzen <illuzen@users.noreply.github.com>
The 30-day cooldown rejects rustls-webpki 0.103.17 and the 1.0.12 root
bundles. 0.103.16 and 1.0.10 are the first releases that fix
RUSTSEC-2026-0381, 0382, and 0383, and they are still inside that window.

Co-authored-by: illuzen <illuzen@users.noreply.github.com>
@illuzen illuzen added the dependency-cooldown-bypass Emergency bypass for the dependency cooldown gate (requires Cooldown-bypass-reason in PR body) label Nov 17, 2026 — with Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependency-cooldown-bypass Emergency bypass for the dependency cooldown gate (requires Cooldown-bypass-reason in PR body)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants