From 679517b8671afdb4a0e52d59395a6fdacbef6c83 Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 4 Jun 2026 17:58:15 +0700 Subject: [PATCH 1/2] upgrade to NU6.2 --- Cargo.lock | 219 +++++++++++++++++++++-------------- crates/zcash-wasm/Cargo.toml | 33 +++--- crates/zcash-wasm/src/lib.rs | 8 +- 3 files changed, 154 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7ad203..6adcee2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1297,6 +1297,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "corez" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4df6f98652d30167eaeea34d77b730e07c8caba6df17bd4551842b9b8da01deb" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -1887,11 +1893,12 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "equihash" -version = "0.2.2" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306286e8dcc39ab3dfceb74c792ce8baffdab90591321d3ffaae64829734c37f" dependencies = [ "blake2b_simd", - "core2", + "corez", ] [[package]] @@ -1934,14 +1941,6 @@ dependencies = [ "blake2b_simd", ] -[[package]] -name = "f4jumble" -version = "0.1.1" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" -dependencies = [ - "blake2b_simd", -] - [[package]] name = "fastbloom" version = "0.14.1" @@ -2528,6 +2527,26 @@ dependencies = [ "uint", ] +[[package]] +name = "halo2_gadgets" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2a697cad929f706b7987fe804ad57d43622cd37463ba7e4d662a926fdcfea3" +dependencies = [ + "arrayvec", + "bitvec", + "ff", + "group", + "halo2_poseidon", + "halo2_proofs", + "lazy_static", + "pasta_curves", + "rand 0.8.5", + "sinsemilla", + "subtle", + "uint", +] + [[package]] name = "halo2_legacy_pdqsort" version = "0.1.0" @@ -4040,6 +4059,42 @@ dependencies = [ "zip32 0.2.1", ] +[[package]] +name = "orchard" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54f8d29bfb1e76a9d4e868a1a08cce2e57dd2bdc66232982822ad3114b91ab3" +dependencies = [ + "aes", + "bitvec", + "blake2b_simd", + "corez", + "ff", + "fpe", + "getset", + "group", + "halo2_gadgets 0.5.0", + "halo2_poseidon", + "halo2_proofs", + "hex", + "incrementalmerkletree 0.8.2", + "lazy_static", + "memuse", + "nonempty 0.11.0", + "pasta_curves", + "rand 0.8.5", + "rand_core 0.6.4", + "reddsa 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", + "sinsemilla", + "subtle", + "tracing", + "visibility", + "zcash_note_encryption", + "zcash_spec 0.2.1", + "zip32 0.2.1", +] + [[package]] name = "osst" version = "0.1.1" @@ -4218,8 +4273,9 @@ dependencies = [ [[package]] name = "pczt" -version = "0.5.0" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4712bd8688e1d1aa0eb0e78dc5c846bc2d70dcd1de544ecf053516df174c4fcd" dependencies = [ "blake2b_simd", "bls12_381", @@ -4227,7 +4283,7 @@ dependencies = [ "getset", "jubjub", "nonempty 0.11.0", - "orchard 0.12.0", + "orchard 0.14.0", "pasta_curves", "postcard", "rand_core 0.6.4", @@ -4238,9 +4294,9 @@ dependencies = [ "serde_with", "zcash_note_encryption", "zcash_primitives", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_protocol 0.9.0", "zcash_script", - "zcash_transparent 0.6.3 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_transparent 0.8.0", ] [[package]] @@ -5493,9 +5549,9 @@ dependencies = [ [[package]] name = "sapling-crypto" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc5fda664085f3893372b703a81e03003b3be46da50952468d7f41f996208ae" +checksum = "2d70756ede56b5e4dd417979777bd87ddb83dfcbd0815dbf8175a9920537f8a0" dependencies = [ "aes", "bellman", @@ -5503,7 +5559,7 @@ dependencies = [ "blake2b_simd", "blake2s_simd", "bls12_381", - "core2", + "corez", "document-features", "ff", "fpe", @@ -8029,7 +8085,7 @@ dependencies = [ "indexmap 1.9.3", "js-sys", "k256", - "orchard 0.12.0", + "orchard 0.14.0", "pasta_curves", "pczt", "rand 0.8.5", @@ -8047,12 +8103,12 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-rayon", "wasm-bindgen-test", - "zcash_address 0.10.1 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_keys 0.12.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_address 0.12.0", + "zcash_keys 0.14.0", "zcash_note_encryption", "zcash_primitives", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_transparent 0.6.3 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_protocol 0.9.0", + "zcash_transparent 0.8.0", "zip32 0.2.1", "zoda-vss", ] @@ -8066,8 +8122,8 @@ dependencies = [ "bech32", "bs58", "core2", - "f4jumble 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_encoding 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "f4jumble", + "zcash_encoding 0.3.0", "zcash_protocol 0.5.4", ] @@ -8080,22 +8136,23 @@ dependencies = [ "bech32", "bs58", "core2", - "f4jumble 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_encoding 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_protocol 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "f4jumble", + "zcash_encoding 0.3.0", + "zcash_protocol 0.7.2", ] [[package]] name = "zcash_address" -version = "0.10.1" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58342d0aaa8e2fa98849636f52800ac4bf020574c944c974742fc933db58cac2" dependencies = [ "bech32", "bs58", - "core2", - "f4jumble 0.1.1 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_encoding 0.3.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "corez", + "f4jumble", + "zcash_encoding 0.4.0", + "zcash_protocol 0.9.0", ] [[package]] @@ -8110,10 +8167,11 @@ dependencies = [ [[package]] name = "zcash_encoding" -version = "0.3.0" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1440921903cdb86133fb9e2fe800be488015db2939a30bedb413078a1acb0306" dependencies = [ - "core2", + "corez", "hex", "nonempty 0.11.0", ] @@ -8137,36 +8195,37 @@ dependencies = [ "secrecy", "subtle", "tracing", - "zcash_address 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_encoding 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_protocol 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_transparent 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_address 0.10.1", + "zcash_encoding 0.3.0", + "zcash_protocol 0.7.2", + "zcash_transparent 0.6.3", "zip32 0.2.1", ] [[package]] name = "zcash_keys" -version = "0.12.0" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fbcdfbb5c8edb247439d72a397abaae9b7dd14a1c070e7e4fc3536924f9065f" dependencies = [ "bech32", "bip32", "blake2b_simd", "bls12_381", "bs58", - "core2", + "corez", "group", "memuse", "nonempty 0.11.0", - "orchard 0.12.0", + "orchard 0.14.0", "rand_core 0.6.4", "secrecy", "subtle", "tracing", - "zcash_address 0.10.1 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_encoding 0.3.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_transparent 0.6.3 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_address 0.12.0", + "zcash_encoding 0.4.0", + "zcash_protocol 0.9.0", + "zcash_transparent 0.8.0", "zip32 0.2.1", ] @@ -8185,43 +8244,32 @@ dependencies = [ [[package]] name = "zcash_primitives" -version = "0.26.4" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c69e07f5eb3f682a6467b4b08ee4956f1acd1e886d70b21c4766953b3a1beba2" dependencies = [ - "bip32", "blake2b_simd", "block-buffer 0.11.0-rc.3", - "bs58", - "core2", + "corez", "crypto-common 0.2.0-rc.1", "equihash", "ff", - "fpe", - "getset", - "group", "hex", "incrementalmerkletree 0.8.2", "jubjub", "memuse", "nonempty 0.11.0", - "orchard 0.12.0", - "rand 0.8.5", + "orchard 0.14.0", "rand_core 0.6.4", "redjubjub", - "ripemd 0.1.3", "sapling-crypto", "secp256k1", "sha2 0.10.9", - "subtle", - "tracing", - "zcash_address 0.10.1 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_encoding 0.3.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_encoding 0.4.0", "zcash_note_encryption", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_protocol 0.9.0", "zcash_script", - "zcash_spec 0.2.1", - "zcash_transparent 0.6.3 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zip32 0.2.1", + "zcash_transparent 0.8.0", ] [[package]] @@ -8248,12 +8296,13 @@ dependencies = [ [[package]] name = "zcash_protocol" -version = "0.7.2" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bec496a0bd62dae98c4b26f51c5dab112d0c5350bbc2ccfdfd05bb3454f714d" dependencies = [ - "core2", + "corez", "hex", - "zcash_encoding 0.3.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_encoding 0.4.0", ] [[package]] @@ -8307,9 +8356,9 @@ dependencies = [ "ripemd 0.1.3", "sha2 0.10.9", "subtle", - "zcash_address 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_encoding 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_protocol 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_address 0.10.1", + "zcash_encoding 0.3.0", + "zcash_protocol 0.7.2", "zcash_script", "zcash_spec 0.2.1", "zip32 0.2.1", @@ -8317,13 +8366,13 @@ dependencies = [ [[package]] name = "zcash_transparent" -version = "0.6.3" -source = "git+https://github.com/zcash/librustzcash?rev=5333c01b#5333c01bc4878f7b5fd44259caa09f4633303da0" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15df1908b428d4edeb7c7caae5692e05e2e92e5c38007a40b20ac098efdffd96" dependencies = [ "bip32", - "blake2b_simd", "bs58", - "core2", + "corez", "getset", "hex", "nonempty 0.11.0", @@ -8331,9 +8380,9 @@ dependencies = [ "secp256k1", "sha2 0.10.9", "subtle", - "zcash_address 0.10.1 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_encoding 0.3.0 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", - "zcash_protocol 0.7.2 (git+https://github.com/zcash/librustzcash?rev=5333c01b)", + "zcash_address 0.12.0", + "zcash_encoding 0.4.0", + "zcash_protocol 0.9.0", "zcash_script", "zcash_spec 0.2.1", "zip32 0.2.1", @@ -8413,9 +8462,9 @@ dependencies = [ "ur", "urlencoding", "zcash_address 0.7.1", - "zcash_keys 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_keys 0.12.0", "zcash_note_encryption", - "zcash_protocol 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_protocol 0.7.2", "zeroize", "zip32 0.2.1", "zoda-vss", diff --git a/crates/zcash-wasm/Cargo.toml b/crates/zcash-wasm/Cargo.toml index 70c6317..9811853 100644 --- a/crates/zcash-wasm/Cargo.toml +++ b/crates/zcash-wasm/Cargo.toml @@ -22,14 +22,13 @@ ff = "0.13" group = "0.13" # Orchard protocol - real key derivation and note encryption -# Use latest versions to avoid halo2_proofs/indexmap conflict -# All librustzcash crates pinned to git rev 5333c01b so the version coords -# line up with `pczt` (which we pull from the same rev). Keeping any of these -# on crates.io would cause a duplicate-crate-version error in the dep graph. -orchard = { version = "0.12", default-features = false, features = ["circuit"] } -zcash_keys = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", default-features = false, features = ["orchard", "transparent-inputs"] } -zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", default-features = false } -zcash_protocol = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", default-features = false } +# NU6.2 stack (librustzcash nu6.2 release): orchard 0.14 ships the fixed +# Orchard Action circuit (FixedPostNu6_2 VK); the whole librustzcash set +# moves together (zcash_protocol 0.9 / zcash_primitives 0.28 / pczt 0.7). +orchard = { version = "0.14", default-features = false, features = ["circuit"] } +zcash_keys = { version = "0.14", default-features = false, features = ["orchard", "transparent-inputs"] } +zcash_address = { version = "0.12", default-features = false } +zcash_protocol = { version = "0.9", default-features = false } rand_core = "0.6" zip32 = { version = "0.2", default-features = false } @@ -47,22 +46,22 @@ indexmap = { version = "1", features = ["std"] } zcash_note_encryption = "0.4" # transaction primitives -# zcash_primitives 0.26 + sapling-crypto 0.6 + orchard 0.12 line up with the -# librustzcash workspace at git rev 5333c01b — the same version coords zigner -# and zashi/keystone-sdk consume. Required for `pczt` interop. -zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", default-features = false, features = ["non-standard-fees", "transparent-inputs"] } -zcash_transparent = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", package = "zcash_transparent", default-features = false, features = ["transparent-inputs"] } +# zcash_primitives 0.28 + sapling-crypto 0.7 + orchard 0.14 line up with the +# librustzcash nu6.2 release — the same version coords zigner and +# zashi/keystone-sdk consume. Required for `pczt` interop. +zcash_primitives = { version = "0.28", default-features = false, features = ["non-standard-fees", "transparent-inputs"] } +zcash_transparent = { version = "0.8", package = "zcash_transparent", default-features = false, features = ["transparent-inputs"] } # Partially-Created Zcash Transaction (PCZT) construction. -# Pinned to the same librustzcash workspace rev that zigner consumes so -# orchard/sapling/zcash_primitives versions match byte-for-byte. -pczt = { git = "https://github.com/zcash/librustzcash", rev = "5333c01b", default-features = false, features = ["orchard", "transparent", "sapling", "zcp-builder", "prover", "io-finalizer", "tx-extractor", "signer", "spend-finalizer"] } +# Same nu6.2 release coords zigner consumes so orchard/sapling/zcash_primitives +# versions match byte-for-byte. +pczt = { version = "0.7", default-features = false, features = ["orchard", "transparent", "sapling", "zcp-builder", "prover", "io-finalizer", "tx-extractor", "signer", "spend-finalizer"] } # zcash_primitives renames sapling-crypto to `sapling` internally; mirror the # alias so BuildConfig's `Option` field type-checks. # `circuit` feature pulls bellman+groth16 proving — bloats the wasm but is # required because pczt's prover/io-finalizer code paths reference # sapling::pczt::ProverError / Prover even when the tx has no sapling actions. -sapling = { package = "sapling-crypto", version = "0.6", default-features = false, features = ["circuit"] } +sapling = { package = "sapling-crypto", version = "0.7", default-features = false, features = ["circuit"] } # key derivation bip39 = { version = "2.0", features = ["rand"] } diff --git a/crates/zcash-wasm/src/lib.rs b/crates/zcash-wasm/src/lib.rs index 9226440..e8ea96d 100644 --- a/crates/zcash-wasm/src/lib.rs +++ b/crates/zcash-wasm/src/lib.rs @@ -1998,7 +1998,7 @@ pub fn build_unsigned_transaction( .ok_or_else(|| JsError::new("extract_effects produced no bundle"))?; // --- compute ZIP-244 sighash --- - let branch_id: u32 = 0x4DEC4DF0; // NU6.1 + let branch_id: u32 = 0x5437F330; // NU6.2 let expiry_height: u32 = 0; let header_data = { @@ -3661,7 +3661,7 @@ pub fn build_signed_spend_transaction( .map_err(|e| JsError::new(&format!("create_proof: {:?}", e)))?; // --- compute ZIP-244 sighash --- - let branch_id: u32 = 0x4DEC4DF0; // NU6.1 + let branch_id: u32 = 0x5437F330; // NU6.2 let expiry_height: u32 = 0; // no expiry for orchard-only let header_data = { @@ -4106,7 +4106,7 @@ pub fn build_shielding_transaction( // --- compute transparent digests for ZIP-244 sighash --- let n_inputs = selected.len(); - let branch_id: u32 = 0x4DEC4DF0; // NU6.1 + let branch_id: u32 = 0x5437F330; // NU6.2 let expiry_height = anchor_height.saturating_add(100); let mut prevout_data = Vec::new(); @@ -4408,7 +4408,7 @@ pub fn build_unsigned_shielding_transaction( // --- compute transparent digests for ZIP-244 sighash --- let n_inputs = selected.len(); - let branch_id: u32 = 0x4DEC4DF0; // NU6.1 + let branch_id: u32 = 0x5437F330; // NU6.2 let expiry_height = anchor_height.saturating_add(100); let mut prevout_data = Vec::new(); From 11eba575a181aff1c49a758e511b43c92fbe2003 Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 4 Jun 2026 18:36:43 +0700 Subject: [PATCH 2/2] compute txid support on zafu --- crates/zcash-wasm/src/lib.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/zcash-wasm/src/lib.rs b/crates/zcash-wasm/src/lib.rs index e8ea96d..92bfb69 100644 --- a/crates/zcash-wasm/src/lib.rs +++ b/crates/zcash-wasm/src/lib.rs @@ -2750,6 +2750,29 @@ pub fn extract_signed_tx_from_pczt(pczt_hex: &str) -> Result { Ok(hex_encode(&tx_bytes)) } +/// Canonical ZIP-244 txid for a raw signed v5 transaction. +/// +/// Public lightwalletd's `SendResponse` carries no txid, so the wallet derives +/// it locally instead of trusting the server to echo it. This is the same value +/// zidecar computes server-side and the same bytes that appear as +/// `CompactTx.hash` during sync — returned as lowercase hex in internal/wire +/// byte order so the outgoing record reconciles on the next scan. +#[wasm_bindgen] +pub fn compute_txid(tx_hex: &str) -> Result { + use std::io::Cursor; + use zcash_primitives::transaction::Transaction; + use zcash_protocol::consensus::BranchId; + + let tx_bytes = hex_decode(tx_hex).ok_or_else(|| JsError::new("invalid tx hex"))?; + // v5 reads its own consensus branch id from the header; the param only + // matters for pre-v5 formats. + let tx = Transaction::read(&mut Cursor::new(&tx_bytes), BranchId::Nu5) + .map_err(|e| JsError::new(&format!("parse tx: {:?}", e)))?; + let txid = tx.txid(); + let bytes: &[u8; 32] = txid.as_ref(); + Ok(hex_encode(bytes)) +} + /// Get the commitment proof request data for a note /// Returns the cmx that should be sent to zidecar's GetCommitmentProof #[wasm_bindgen]