Skip to content

voting-circuits: orchard 0.13 migration#20

Merged
greg0x merged 4 commits into
mainfrom
valar/orchard-0.13
Apr 25, 2026
Merged

voting-circuits: orchard 0.13 migration#20
greg0x merged 4 commits into
mainfrom
valar/orchard-0.13

Conversation

@p0mvn
Copy link
Copy Markdown
Contributor

@p0mvn p0mvn commented Apr 25, 2026

Catches voting-circuits up to the rest of the orchard 0.13 + valargroup/orchard PR #19 surface area.

Builds on top of #16 (valar/orchard-0.13)'s "Drop vendored valar-orchard 0.12 fork" commit, which only flipped the dependency edge over to orchard 0.13 via git. This PR ports the call sites to the public APIs orchard 0.13 exposes (or, in one case, replicates locally) instead of poking at private fields.

Why

orchard 0.13 closed off the private fields/constructors we used to reach into via the vendored valar-orchard fork. Combined with PR #19 stacking zcash/orchard #495 (NoteValue::ZERO) on top of zcash/orchard #489 (SpendAuthG fixed-base multiplication), we now have a clean public-API path for everything we need:

Old (was reaching into orchard internals) New (orchard 0.13 + PR #19 public API)
Nullifier(rho) Nullifier::from_inner(rho)
nf.0 nf.inner()
NoteValue::zero() NoteValue::ZERO
orchard::circuit::gadget::assign_constant crate::circuit::gadget::assign_constant (local copy — generic halo2 plumbing)

Changes

  • src/delegation/builder.rsNullifier::from_inner / inner() (4 sites), NoteValue::ZERO (5 sites).
  • src/delegation/circuit.rsNullifier::from_inner / inner() (8 sites), NoteValue::ZERO (4 sites), import assign_constant from local module instead of orchard::circuit::gadget.
  • src/delegation/prove.rs — one nf.0nf.inner() in test scaffolding.
  • src/circuit/gadget.rs (new) — local assign_constant helper (generic halo2 plumbing for baking a constant into a free advice cell so it's pinned in the verifier key). Has no orchard-specific dependencies, so a self-contained copy is the right home.
  • src/circuit/mod.rs — export the new gadget module.
  • src/delegation/plans/signed_note_commitment_integrity_*.plan.md — update doc examples to match the new constant.
  • README.md — drop the "depends on valar-orchard" wording, document the orchard 0.13 + PR Rename valar-orchard back to orchard, bump to 0.12.1 #19 pin and the path back to the published crate once both upstream PRs land and an orchard 0.14 ships.
  • Cargo.lock — regenerated against the orchard 0.13 git pin. Locks to commit 7fa213ae7057eb959e5aba4a4195d6ca2e26b252 (head of valar/0.13-spend-auth-g, i.e. PR Rename valar-orchard back to orchard, bump to 0.12.1 #19 tip).

The orchard pin in Cargo.toml is unchanged — the existing git = "https://github.com/valargroup/orchard.git", branch = "valar/0.13-spend-auth-g" already follows the PR #19 branch HEAD; Cargo.lock just advanced to the new tip.

Verification

  • cargo build --tests --benches --all-features — clean. Only the three pre-existing dead-code warnings in vote_proof::authority_decrement test scaffolding.
  • cargo test --tests --benches --all-features --no-run — all test binaries link.
  • rg 'NoteValue::zero\(|_nf\.0|Nullifier\(' src/ — empty (no remaining private-API uses).
  • Downstream consumers also cargo check clean against this voting-circuits + orchard combination, in the umbrella workspace:
    • zcash_voting
    • vote-sdk/circuits
    • vote-sdk/e2e-tests
    • zcash-swift-wallet-sdk (libzcashlc)

Test plan

  • CI green on this PR (lint + unit tests).
  • Manual smoke: cargo test --release -p voting-circuits (Halo2 proving tests are slow in dev profile, intentionally not blocking the local sweep).
  • Confirm downstream branches in the umbrella workspace (zcash_voting, vote-sdk, zcash-swift-wallet-sdk) still pass cargo test after this lands.

Follow-ups

Once zcash/orchard #489 and #495 merge and a published orchard 0.14 ships, drop the [patch.crates-io] orchard pin in this repo's downstream consumers and bump voting-circuits to depend on orchard = "0.14" directly.

Made with Cursor

p0mvn added 2 commits April 24, 2026 23:48
Removes the entire orchard/ subdirectory (the vendored valar-orchard
0.12.0 fork that exposed internal APIs needed by these circuits).
Switches the orchard dependency in voting-circuits to a git pin against
valargroup/orchard's valar/0.13-spend-auth-g branch (= orchard 0.13.0
+ PR #488 visibility-widening + PR #489 SpendAuthG fixed-base
multiplication), with the new "unstable-voting-circuits" feature
enabled in place of the vendored fork's blanket pub-visibility hacks.

Upstream orchard 0.13 added the unstable-voting-circuits feature flag
that exposes the same internals (assign_free_advice, AddInstruction,
add_chip, commit_ivk, etc.) we previously got by maintaining our own
orchard fork in-tree, so the vendored copy is now redundant.

Made-with: Cursor
…sors, local assign_constant)

Catches voting-circuits up to the rest of the orchard 0.13 + valargroup
PR #19 surface area. The previous "Drop vendored valar-orchard fork"
commit only flipped the dependency edge over to orchard 0.13 via git;
this commit ports the call sites to the public APIs that orchard 0.13
exposes (or, in one case, replicates locally) instead of poking at
private fields:

* `Nullifier(rho)` → `Nullifier::from_inner(rho)`
  `nf.0` → `nf.inner()`
  The `Nullifier` tuple field is no longer accessible from outside the
  orchard crate; the new public `from_inner` constructor and `inner`
  accessor are the supported way in.

* `NoteValue::zero()` → `NoteValue::ZERO`
  `NoteValue::zero()` was crate-private in orchard 0.13.0 and stays
  that way. valargroup/orchard PR #19 stacks zcash/orchard #495 on
  top of the SpendAuthG branch, which retires `zero()` in favour of
  a `pub const ZERO: Self = NoteValue(0);` associated constant. All
  9 zero-value sites in the delegation builder/circuit (plus the
  signed-note-commitment-integrity plan markdown) are migrated to
  the constant.

* `orchard::circuit::gadget::assign_constant` is no longer re-exported
  by orchard 0.13 (it lives under module-private paths). Move our
  local copy into `crate::circuit::gadget::assign_constant`; the
  helper is generic halo2 plumbing (load a constant into a free
  advice cell so it's baked into the verifier key) with no
  orchard-specific dependencies, so it belongs here anyway.

The README is updated to drop the "depends on valar-orchard" wording
and explain the current pin: orchard 0.13 + valargroup/orchard PR #19,
which carries cherry-picks of zcash/orchard #489 (SpendAuthG fixed-base
multiplication) and zcash/orchard #495 (`NoteValue::ZERO`). The pin
collapses back to the published crate once both upstream PRs land and
an orchard 0.14 ships.

Cargo.lock is regenerated against the orchard 0.13 git pin (lock now
references commit 7fa213ae7057eb959e5aba4a4195d6ca2e26b252, the head
of `valar/0.13-spend-auth-g` / valargroup/orchard PR #19).

Verification:
* `cargo build --tests --benches --all-features` — clean (only the
  three pre-existing dead-code warnings in
  vote_proof::authority_decrement test scaffolding).
* No `NoteValue::zero(`, `_nf.0`, or `Nullifier(` constructor calls
  remain in `src/`.
* Downstream consumers (zcash_voting, vote-sdk circuits + e2e-tests,
  zcash-swift-wallet-sdk libzcashlc) all `cargo check` clean against
  this voting-circuits + orchard combination.

Made-with: Cursor
Comment thread voting-circuits/Cargo.toml Outdated
@@ -8,7 +8,7 @@ repository = "https://github.com/valargroup/voting-circuits"
readme = "README.md"

[dependencies]
orchard = { path = "../orchard", version = "0.12.0", package = "valar-orchard", features = ["circuit"] }
orchard = { git = "https://github.com/valargroup/orchard.git", branch = "valar/0.13-spend-auth-g", features = ["circuit", "unstable-voting-circuits"] }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: references valargroup/orchard#19

@p0mvn p0mvn force-pushed the valar/orchard-0.13 branch from ec6d3ad to 8472684 Compare April 25, 2026 05:15
p0mvn added a commit to valargroup/zcash_voting that referenced this pull request Apr 25, 2026
…ts PR #20 head)

valargroup/voting-circuits PR #20 was rewritten/force-pushed since the
previous lockfile bump in this branch, so the `ec6d3adb` SHA the lock
referenced is no longer reachable on the PR. Re-resolve the
`branch = "valar/orchard-0.13"` patch entry and pick up the current
two-commit PR head:

  voting-circuits  ec6d3adb → 84726847
                   = valargroup/voting-circuits commits
                       1d5a455  Drop vendored valar-orchard 0.12 fork;
                                depend on orchard 0.13 via git
                       8472684  Migrate to orchard 0.13 public APIs
                                (NoteValue::ZERO, Nullifier accessors,
                                 local assign_constant)
                   = valargroup/voting-circuits#20

No source or Cargo.toml changes — strictly a lockfile pin bump so a
fresh `cargo build` against this branch resolves to the actual head of
the upstream PR rather than a force-pushed-out SHA.

Verification:
* `cargo check --tests --workspace --all-features` clean.
* No drift between Cargo.toml [patch.crates-io] entries and the
  resolved [[package]] sources in Cargo.lock.

Made-with: Cursor
greg0x added 2 commits April 25, 2026 21:27
imt-tree 0.1.1 (just published to crates.io) now depends on halo2_gadgets
0.4 instead of 0.3, matching the rest of the orchard 0.13 stack. Updating
the lockfile drops the duplicate halo2_gadgets 0.3.1 we'd been pulling
transitively through the older imt-tree 0.1.0.
Now that valargroup/orchard PR #19 is merged, repoint from the migration
branch valar/0.13-spend-auth-g to the merge commit on main. This retires
the migration branch as a manifest dependency and gives a deterministic
rev pin instead of a moving branch tip.
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