Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 50 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ redjubjub = { version = "0.8", default-features = false }
sapling = { package = "sapling-crypto", version = "0.6", default-features = false }

# - Orchard
orchard = { version = "0.12", default-features = false }
#
# Points at the Valar Group `valar-orchard` fork on crates.io, aliased locally to
# `orchard` so every member still writes `use orchard::…`. The fork is
# upstream-0.12.0 + post-release fixes (up to zcash/orchard 6b12c77) + governance-
# visibility additions needed by the shielded-voting circuits in
# valargroup/voting-circuits. Drop back to `orchard = "0.12"` once those
# visibility changes land in zcash/orchard upstream.
orchard = { version = "0.12.0", package = "valar-orchard", default-features = false }
pasta_curves = "0.5"

# - Transparent
Expand Down Expand Up @@ -231,4 +238,6 @@ unexpected_cfgs = { level = "warn", check-cfg = [

[patch.crates-io]
sapling = { package = "sapling-crypto", git = "https://github.com/zcash/sapling-crypto.git", rev = "4f95c2286dbe90f05e6f44d634bc2924b992fab4" }
orchard = { package = "orchard", git = "https://github.com/zcash/orchard.git", rev = "6b12c77260aa7fac0d804983fc31b71b584d48e0" }
# No orchard patch: the workspace resolves `orchard` via its `package = "valar-orchard"`
# alias on crates.io, which already carries the post-0.12.0 upstream fixes plus the
# governance-visibility additions.
2 changes: 2 additions & 0 deletions pczt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ workspace.
### Added
- `pczt::ExtractError`
- `pczt::EffectsOnly`
- `pczt::orchard::Spend::spend_auth_sig` getter (via `getset`).
- `pczt::roles::signer::Signer::shielded_sighash` getter.
- `pczt::roles::signer`:
- `Signer::sighash`
- `Signer::append_transparent_signature`
Expand Down
1 change: 1 addition & 0 deletions pczt/src/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub struct Spend {
///
/// This is set by the Signer.
#[serde_as(as = "Option<[_; 64]>")]
#[getset(get = "pub")]
pub(crate) spend_auth_sig: Option<[u8; 64]>,

/// The [raw encoding] of the Orchard payment address that received the note being spent.
Expand Down
4 changes: 2 additions & 2 deletions pczt/src/roles/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Signer {
/// Calculates the signature digest that must be signed to authorize shielded spends.
///
/// This can be used to produce a signature externally suitable for passing to e.g.
/// [`Self::apply_orchard_signature`].}
/// [`Self::apply_orchard_signature`].
pub fn shielded_sighash(&self) -> [u8; 32] {
self.shielded_sighash
}
Expand All @@ -89,7 +89,7 @@ impl Signer {
/// spend at the given index.
///
/// This can be used to produce a signature externally suitable for passing to e.g.
/// [`Self::append_transparent_signature`].}
/// [`Self::append_transparent_signature`].
///
/// Returns an error if `index` is invalid for this PCZT.
pub fn transparent_sighash(&self, index: usize) -> Result<[u8; 32], Error> {
Expand Down
4 changes: 4 additions & 0 deletions zcash_client_sqlite/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ workspace.
- `zcash_client_sqlite::AccountRef` is now public.
- Implement standalone P2SH address import support
- `impl zcash_client_backend::data_api::WalletWrite::import_standalone_transparent_script()`
- `WalletDb::get_unspent_orchard_notes_at_historical_height` returns Orchard
notes received and unspent as of a given height.
- `WalletDb::generate_orchard_witnesses_at_historical_height` generates Merkle
witnesses at a historical height using an ephemeral in-memory tree.

### Changed
- Migrated to `orchard 0.12`, `sapling-crypto 0.6`.
Expand Down
59 changes: 59 additions & 0 deletions zcash_client_sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,65 @@ impl<'a, C: Borrow<rusqlite::Transaction<'a>>, P: consensus::Parameters, CL: Clo
}
}

// --- Governance-specific methods ---
//
// These methods support Zcash shielded voting and are not part of the
// general-purpose wallet traits. They provide note queries and witness
// generation at a historical height.

#[cfg(feature = "orchard")]
impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters, CL, R> WalletDb<C, P, CL, R> {
/// Return all Orchard notes received at or before `height`
/// and unspent as of that height, for the given account.
///
/// Unlike [`InputSource::select_unspent_notes`] (which applies confirmation,
/// dust, and expiry filters for transaction construction), this returns every
/// note that existed and was unspent at the given height.
pub fn get_unspent_orchard_notes_at_historical_height(
&self,
account: AccountUuid,
height: BlockHeight,
) -> Result<Vec<ReceivedNote<ReceivedNoteId, orchard::note::Note>>, SqliteClientError> {
wallet::orchard::get_unspent_orchard_notes_at_historical_height(
self.conn.borrow(),
&self.params,
account,
height,
)
}

/// Generate Orchard Merkle witnesses at a historical height.
///
/// Copies the wallet's Orchard shard data into an ephemeral in-memory
/// database, inserts the provided frontier as a checkpoint, and generates
/// a witness for each of the given note positions.
///
/// The wallet DB is strictly read-only — shard data is copied, not modified.
pub fn generate_orchard_witnesses_at_historical_height(
&self,
note_positions: &[Position],
frontier_at_height: incrementalmerkletree::frontier::NonEmptyFrontier<
orchard::tree::MerkleHashOrchard,
>,
height: BlockHeight,
) -> Result<
Vec<
incrementalmerkletree::MerklePath<
orchard::tree::MerkleHashOrchard,
{ orchard::NOTE_COMMITMENT_TREE_DEPTH as u8 },
>,
>,
SqliteClientError,
> {
wallet::commitment_tree::generate_orchard_witnesses_at_historical_height(
self.conn.borrow(),
note_positions,
frontier_at_height,
height,
)
}
}

/// A handle for the SQLite block source.
pub struct BlockDb(rusqlite::Connection);

Expand Down
Loading
Loading