Skip to content

Commit

Permalink
Use zcash_script in PCZTs
Browse files Browse the repository at this point in the history
This replaces the local script implementation with the one from the
zcash_script crate.

The `Script` type that was here is replaced by a family of three types
- `script::PubKey`;
- `script::Sig<PushValue>` – a v5+ script_sig, used for new sigs;
- `script::Sig<Opcode>` – a pre-v5 script\_sig, used for sigs read off
  the chain, which may predate NU5; and
- an unwrapped `Vec<u8>` for script code.

This uses a number of zcash_script features that haven’t yet made it
into the master branch, let alone a release, so this should not be
merged.
  • Loading branch information
sellout committed Feb 27, 2025
1 parent 90d186f commit 5a8ade8
Show file tree
Hide file tree
Showing 27 changed files with 407 additions and 595 deletions.
141 changes: 127 additions & 14 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ zip321 = { version = "0.3", path = "components/zip321" }
zcash_note_encryption = "0.4.1"
zcash_primitives = { version = "0.22", path = "zcash_primitives", default-features = false }
zcash_proofs = { version = "0.22", path = "zcash_proofs", default-features = false }
zcash_script = "0.2.0"

pczt = { version = "0.2", path = "pczt" }

Expand Down Expand Up @@ -209,3 +210,6 @@ debug = true

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zcash_unstable, values("zfuture"))'] }

[patch.crates-io]
zcash_script = { git = "https://github.com/ZcashFoundation/zcash_script.git", rev = "d0365cd7d75ca45c4595af09d9732146e6132fb2" }
1 change: 1 addition & 0 deletions pczt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ categories.workspace = true
zcash_note_encryption = { workspace = true, optional = true }
zcash_primitives = { workspace = true, optional = true }
zcash_protocol = { workspace = true, optional = true }
zcash_script.workspace = true

blake2b_simd = { workspace = true, optional = true }
rand_core = { workspace = true, optional = true }
Expand Down
8 changes: 5 additions & 3 deletions pczt/src/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use getset::Getters;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use zcash_script::{opcode::PushValue, script};

/// PCZT fields that are specific to producing the transaction's transparent bundle (if
/// any).
#[derive(Clone, Debug, Serialize, Deserialize, Getters)]
Expand Down Expand Up @@ -61,19 +63,19 @@ pub struct Input {
/// A satisfying witness for the `script_pubkey` of the input being spent.
///
/// This is set by the Spend Finalizer.
pub(crate) script_sig: Option<Vec<u8>>,
pub(crate) script_sig: Option<script::Sig<PushValue>>,

// These are required by the Transaction Extractor, to derive the shielded sighash
// needed for computing the binding signatures.
#[getset(get = "pub")]
pub(crate) value: u64,
#[getset(get = "pub")]
pub(crate) script_pubkey: Vec<u8>,
pub(crate) script_pubkey: script::PubKey,

/// The script required to spend this output, if it is P2SH.
///
/// Set to `None` if this is a P2PKH output.
pub(crate) redeem_script: Option<Vec<u8>>,
pub(crate) redeem_script: Option<script::PubKey>,

/// A map from a pubkey to a signature created by it.
///
Expand Down
1 change: 1 addition & 0 deletions zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ zcash_keys = { workspace = true, features = ["sapling"] }
zcash_note_encryption.workspace = true
zcash_primitives = { workspace = true, features = ["std", "circuits"] }
zcash_protocol.workspace = true
zcash_script.workspace = true
zip32.workspace = true
zip321.workspace = true
transparent.workspace = true
Expand Down
Loading

0 comments on commit 5a8ade8

Please sign in to comment.