What changed, and why it matters
This is a routine firmware release (version 3.2.2) for the Keystone 3 hardware wallet. The main user-visible change is adding support for the Zcash NU7 network upgrade. The code changes mostly update Zcash-related Rust libraries to newer versions, adjust the code to match new library APIs, fix a timer cleanup bug in the lock screen, fix a signal that was sending the wrong size, and replace a QR-code decoding library in a simulator tool. The changelog does not describe any of these as security fixes, and there is no evidence in the commit of an active vulnerability being patched.
Treat as a normal firmware release. If auditing for security, focus review on the Zcash dependency upgrade (cryptographic correctness and RNG handling via the new DeviceRng adapter), the lock-screen timer lifecycle fix, and the corrected signal argument size. No immediate incident response is indicated by the commit materials alone.
Security signals we found
Zcash dependency major-version upgrades and API migration for NU7 compatibility
Lock-screen countdown timer now initialized to NULL and explicitly stopped on label deletion, reducing dangling-timer risk
Transaction-check-fail signal fixed to pass correct struct size instead of pointer size
Removal of OTA firmware extraction helper script and its test vectors
QR decoder in simulator tool swapped from quircs to rxing
Evidence from the diff
The commit bumps Keystone 3 firmware to 3.2.2. Substantive changes include: (1) upgrading Zcash Rust dependencies (orchard, sapling-crypto, pczt, zcash_primitives, zcash_keys, zcash_transparent, zcash_protocol, zip32, reddsa, etc.) to versions compatible with Zcash NU7; (2) adapting call sites to new APIs (e.g., ufvk.transparent() -> ufvk.p2pkh(), UnifiedFullViewingKey::encode() now returns Result, PCZT v2 serialization, BundlePadding instead of BundleType, new rand_core 0.10 RNG traits via a new DeviceRng adapter); (3) replacing quircs with rxing in sim_qr_reader; (4) initializing g_countDownTimer to NULL and adding a delete-event callback to stop the countdown timer, preventing a potential use-after-free/dangling timer; (5) fixing SIG_TRANSACTION_CHECK_FAIL to pass sizeof(*g_checkResult) instead of sizeof(g_checkResult) (pointer size vs struct size); (6) removing the ota_bin_restore.py QuickLZ extraction tool and its tests; (7) reducing LEGACY_USB_PAD_LEN from 2 to 1. The Zcash changes are large but appear to be a dependency/API migration rather than a targeted security patch. The timer and signal-size fixes are correctness/robustness improvements, but the commit message and changelog do not label them as security-relevant.
Changed components
Zcash signing and PCZT handling (rust/apps/zcash, rust/zcash_vendor, rust/keystore)Lock screen UI widget (src/ui/gui_widgets/gui_lock_widgets.c)Transaction check result signaling (src/ui/gui_model/gui_model.c)Simulator QR reader (rust/sim_qr_reader)Legacy USB update padding (src/config/legacy_web_update_pad.c)Build system (rust/CMakeLists.txt production RUSTFLAGS)Inspect captured patch +1032 / −901
### CHANGELOG-ZH.md
@@ -1,3 +1,18 @@
+## 3.2.2(2026-11-10)
+
+**Web3:**
+
+### 修复
+
+1. 支持 Zcash NU7
+
+**Cypherpunk:**
+
+### 修复
+
+1. 支持 Zcash NU7
+
+
## 3.2.0(2026-10-21)
**Web3:**
### CHANGELOG.md
@@ -1,3 +1,19 @@
+## 3.2.2(2026-11-10)
+
+**Web3:**
+
+### Fixed
+
+1. Support Zcash NU7
+
+**Cypherpunk:**
+
+### Fixed
+
+1. Support Zcash NU7
+
+
+
## 3.2.0(2026-10-21)
**Web3:**
### rust/CMakeLists.txt
@@ -82,13 +82,19 @@ else()
)
endif()
-message(STATUS "cargo build command: " ${CARGO_FLAG})
+if(BUILD_ENVIRONMENT STREQUAL "PRODUCTION")
+ set(CARGO_ENV ${CMAKE_COMMAND} -E env RUSTFLAGS=-Zlocation-detail=none)
+else()
+ set(CARGO_ENV ${CMAKE_COMMAND} -E env)
+endif()
+
+message(STATUS "cargo build command: " ${CARGO_ENV} " " ${CARGO_FLAG})
#TODO: add debug-momery if need
#run build
add_custom_target(rust_c ALL
BYPRODUCTS ${TARGET_PATH}/${LIB_NAME} ${TARGET_PATH}/librust_c.h
- COMMAND rustup run ${RUST_TOOLCHAIN} ${RUST_CARGO_EXECUTABLE} build ${CARGO_FLAG}
+ COMMAND ${CARGO_ENV} rustup run ${RUST_TOOLCHAIN} ${RUST_CARGO_EXECUTABLE} build ${CARGO_FLAG}
COMMAND ${COPY_BUILD_TARGET}
COMMAND ${COPY_BINDINGS_TARGET}
WORKING_DIRECTORY ${RUST_DIR}
### rust/Cargo.lock
@@ -2,6 +2,17 @@
# It is not intended for manual editing.
version = 4
+[[package]]
+name = "addchain"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5665045de74fda906c0abfaec40cf2551f88c34dccea869f3fe950dde7209764"
+dependencies = [
+ "num-bigint 0.4.6",
+ "num-integer",
+ "num-traits",
+]
+
[[package]]
name = "adler2"
version = "2.0.1"
@@ -24,15 +35,36 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "aead"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99"
+dependencies = [
+ "crypto-common 0.2.2",
+ "inout 0.2.4",
+]
+
[[package]]
name = "aes"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [
"cfg-if",
- "cipher",
- "cpufeatures",
+ "cipher 0.4.4",
+ "cpufeatures 0.2.17",
+]
+
+[[package]]
+name = "aes"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"
+dependencies = [
+ "cipher 0.5.2",
+ "cpubits",
+ "cpufeatures 0.3.1",
]
[[package]]
@@ -73,6 +105,15 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "anstream"
version = "0.6.19"
@@ -149,16 +190,16 @@ dependencies = [
name = "app_arweave"
version = "0.1.0"
dependencies = [
- "aes",
+ "aes 0.8.4",
"app_utils",
"base64 0.11.0",
- "cbc",
- "cipher",
+ "cbc 0.1.2",
+ "cipher 0.4.4",
"cryptoxide",
"hex",
"keystore",
"lazy_static",
- "rand_chacha",
+ "rand_chacha 0.3.1",
"rsa",
"rust_tools",
"serde",
@@ -302,15 +343,15 @@ dependencies = [
"app_utils",
"base58-monero",
"bitcoin",
- "chacha20",
+ "chacha20 0.9.1",
"cryptoxide",
"cuprate-cryptonight",
"curve25519-dalek",
"hex",
"keystore",
"monero-serai",
"monero-wallet",
- "rand_chacha",
+ "rand_chacha 0.3.1",
"rand_core 0.6.4",
"rust_tools",
"thiserror-core",
@@ -343,11 +384,11 @@ dependencies = [
"arrayref",
"bincode",
"bitcoin",
- "borsh 1.5.7",
+ "borsh 1.8.1",
"bs58",
"hex",
"keystore",
- "num-derive 0.3.3",
+ "num-derive",
"rust_tools",
"serde",
"serde_derive",
@@ -402,7 +443,7 @@ dependencies = [
"keystore",
"lazy_static",
"no_std_io2",
- "num-bigint",
+ "num-bigint 0.4.6",
"num-integer",
"num-traits",
"rust_tools",
@@ -489,6 +530,7 @@ dependencies = [
"orchard",
"pczt",
"postcard",
+ "rand_core 0.10.1",
"rand_core 0.6.4",
"rust_tools",
"serde",
@@ -598,17 +640,16 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"
[[package]]
name = "bellman"
-version = "0.14.0"
+version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171"
+checksum = "973b16549796a1274a63e00159a03250e66e8263e2ac6344b1c9fdfe9b7a8325"
dependencies = [
"bitvec",
"blake2s_simd",
"byteorder",
- "ff",
- "group",
- "pairing",
- "rand_core 0.6.4",
+ "ff 0.14.0",
+ "group 0.14.0",
+ "rand_core 0.10.1",
"subtle",
]
@@ -640,18 +681,22 @@ dependencies = [
[[package]]
name = "bit-set"
-version = "0.8.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
+checksum = "56d87354e4229f54a44f7bf2435906a4656dba36026ab6eaca629a2c436a691c"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
-version = "0.8.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
+checksum = "5727b15fa97d4f4fee0a3b7c3d550ed0269f54329207b86388de918604e31269"
+dependencies = [
+ "borsh 1.8.1",
+ "serde",
+]
[[package]]
name = "bit_field"
@@ -730,9 +775,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
-version = "2.9.1"
+version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "bitstream-io"
@@ -813,9 +858,18 @@ dependencies = [
[[package]]
name = "block-buffer"
-version = "0.11.0-rc.3"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96eb4cdd6cf1b31d671e9efe75c5d1ec614776856cefbe109ca373554a6d514f"
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fd016a0ddc7cb13661bf5576073ce07330a693f8608a1320b4e20561cc12cdc"
+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
dependencies = [
"hybrid-array",
]
@@ -837,15 +891,16 @@ dependencies = [
[[package]]
name = "bls12_381"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403"
+checksum = "18f887f26229478dcd0e0d063566b51c68fb55a38fba21799c5f3371a74ec61f"
dependencies = [
- "ff",
- "group",
+ "ff 0.14.0",
+ "group 0.14.0",
"pairing",
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"subtle",
+ "zeroize",
]
[[package]]
@@ -860,11 +915,12 @@ dependencies = [
[[package]]
name = "borsh"
-version = "1.5.7"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce"
+checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a"
dependencies = [
- "borsh-derive 1.5.7",
+ "borsh-derive 1.8.1",
+ "bytes",
"cfg_aliases",
]
@@ -883,15 +939,15 @@ dependencies = [
[[package]]
name = "borsh-derive"
-version = "1.5.7"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3"
+checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56"
dependencies = [
"once_cell",
"proc-macro-crate 3.3.0",
"proc-macro2",
"quote",
- "syn 2.0.104",
+ "syn 3.0.3",
]
[[package]]
@@ -988,11 +1044,11 @@ dependencies = [
"js-sys",
"noop_proc_macro",
"num",
- "num-bigint",
+ "num-bigint 0.4.6",
"num-integer",
"num-traits",
- "rand",
- "rand_chacha",
+ "rand 0.8.5",
+ "rand_chacha 0.3.1",
"rand_os",
"ritelinked",
"schemars",
@@ -1009,7 +1065,16 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
dependencies = [
- "cipher",
+ "cipher 0.4.4",
+]
+
+[[package]]
+name = "cbc"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896"
+dependencies = [
+ "cipher 0.5.2",
]
[[package]]
@@ -1020,7 +1085,7 @@ checksum = "3fce8dd7fcfcbf3a0a87d8f515194b49d6135acab73e18bd380d1d93bb1a15eb"
dependencies = [
"clap",
"heck",
- "indexmap 2.10.0",
+ "indexmap",
"log",
"proc-macro2",
"quote",
@@ -1067,8 +1132,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
dependencies = [
"cfg-if",
- "cipher",
- "cpufeatures",
+ "cipher 0.4.4",
+ "cpufeatures 0.2.17",
+]
+
+[[package]]
+name = "chacha20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
+dependencies = [
+ "cfg-if",
+ "cipher 0.5.2",
+ "cpufeatures 0.3.1",
+ "rand_core 0.10.1",
]
[[package]]
@@ -1077,21 +1154,35 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
dependencies = [
- "aead",
- "chacha20",
- "cipher",
- "poly1305",
+ "aead 0.5.2",
+ "chacha20 0.9.1",
+ "cipher 0.4.4",
+ "poly1305 0.8.0",
"zeroize",
]
+[[package]]
+name = "chacha20poly1305"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb"
+dependencies = [
+ "aead 0.6.1",
+ "chacha20 0.10.2",
+ "cipher 0.5.2",
+ "poly1305 0.9.1",
+]
+
[[package]]
name = "chrono"
version = "0.4.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
dependencies = [
+ "iana-time-zone",
"num-traits",
"serde",
+ "windows-link",
]
[[package]]
@@ -1101,10 +1192,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common 0.1.6",
- "inout",
+ "inout 0.1.4",
"zeroize",
]
+[[package]]
+name = "cipher"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
+dependencies = [
+ "block-buffer 0.12.1",
+ "crypto-common 0.2.2",
+ "inout 0.2.4",
+]
+
[[package]]
name = "clap"
version = "4.5.40"
@@ -1150,6 +1252,12 @@ dependencies = [
"bitflags 1.3.2",
]
+[[package]]
+name = "cmov"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
+
[[package]]
name = "cobs"
version = "0.3.0"
@@ -1189,6 +1297,15 @@ dependencies = [
"objc",
]
+[[package]]
+name = "codepage-437"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e40c1169585d8d08e5675a39f2fc056cd19a258fc4cba5e3bbf4a9c1026de535"
+dependencies = [
+ "csv",
+]
+
[[package]]
name = "color_quant"
version = "1.1.0"
@@ -1301,12 +1418,24 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "core_detect"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
+
[[package]]
name = "corez"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4df6f98652d30167eaeea34d77b730e07c8caba6df17bd4551842b9b8da01deb"
+[[package]]
+name = "cpubits"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -1316,6 +1445,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "crc"
version = "3.3.0"
@@ -1399,9 +1537,9 @@ dependencies = [
[[package]]
name = "crypto-common"
-version = "0.2.0-rc.1"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa"
+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
]
@@ -1422,6 +1560,36 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "csv"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938"
+dependencies = [
+ "csv-core",
+ "itoa",
+ "ryu",
+ "serde_core",
+]
+
+[[package]]
+name = "csv-core"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "ctutils"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03bb0e1cc970d482d121d9a1744999169b69a07470b3d644a7894e53fcaf4574"
+dependencies = [
+ "cmov",
+]
+
[[package]]
name = "cty"
version = "0.2.2"
@@ -1448,11 +1616,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"curve25519-dalek-derive",
"digest 0.10.7",
"fiat-crypto",
- "group",
+ "group 0.13.0",
"rand_core 0.6.4",
"rustc_version",
"subtle",
@@ -1478,8 +1646,8 @@ dependencies = [
"crypto-bigint",
"curve25519-dalek",
"digest 0.10.7",
- "ff",
- "group",
+ "ff 0.13.1",
+ "group 0.13.0",
"rand_core 0.6.4",
"rustversion",
"subtle",
@@ -1603,8 +1771,8 @@ version = "0.11.0-pre.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379"
dependencies = [
- "block-buffer 0.11.0-rc.3",
- "crypto-common 0.2.0-rc.1",
+ "block-buffer 0.11.0",
+ "crypto-common 0.2.2",
"subtle",
]
@@ -1680,11 +1848,25 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
+[[package]]
+name = "encoding_rs"
+version = "0.8.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5"
+dependencies = [
+ "cfg-if",
+ "core_detect",
+ "multiversion_no_op",
+ "rustversion",
+ "scopeguard",
+ "simdutf8",
+]
+
[[package]]
name = "equihash"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "306286e8dcc39ab3dfceb74c792ce8baffdab90591321d3ffaae64829734c37f"
+checksum = "49eac9289a160ac92d99537b3434a1a3696df0177fe2c66818bdb9a33b6d5770"
dependencies = [
"blake2b_simd",
"corez",
@@ -1801,9 +1983,9 @@ dependencies = [
[[package]]
name = "f4jumble"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d42773cb15447644d170be20231a3268600e0c4cea8987d013b93ac973d3cf7"
+checksum = "2cae5503f6dc8629246d7e9b3450d3712e5be20f2ed7f9fb6b67212a4f315adc"
dependencies = [
"blake2b_simd",
]
@@ -1834,6 +2016,33 @@ dependencies = [
"subtle",
]
+[[package]]
+name = "ff"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f"
+dependencies = [
+ "bitvec",
+ "ff_derive",
+ "rand_core 0.10.1",
+ "subtle",
+]
+
+[[package]]
+name = "ff_derive"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "241afe8c15ffa21933eaefe8a563af36fd9fc98a3e8a044e8f7db52eb1fae3d8"
+dependencies = [
+ "addchain",
+ "num-bigint 0.4.6",
+ "num-integer",
+ "num-traits",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.104",
+]
+
[[package]]
name = "fiat-crypto"
version = "0.2.9"
@@ -1947,10 +2156,24 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26c4b37de5ae15812a764c958297cfc50f5c010438f60c6ce75d11b802abd404"
dependencies = [
- "cbc",
- "cipher",
+ "cbc 0.1.2",
+ "cipher 0.4.4",
"libm",
- "num-bigint",
+ "num-bigint 0.4.6",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "fpe"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5045d51a6a5e85e0a18d909eedd270c4d82ad634fee57ba707692fb3b1add5a7"
+dependencies = [
+ "cbc 0.2.1",
+ "cipher 0.5.2",
+ "libm",
+ "num-bigint 0.5.1",
"num-integer",
"num-traits",
]
@@ -2007,10 +2230,22 @@ checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
dependencies = [
"cfg-if",
"libc",
- "r-efi",
+ "r-efi 5.3.0",
"wasi 0.14.2+wasi-0.2.4",
]
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi 6.0.0",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "getset"
version = "0.1.6"
@@ -2052,18 +2287,43 @@ dependencies = [
"digest 0.10.7",
]
+[[package]]
+name = "groth16"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8bb1e0bde2dbacd81474ae216c5dd4901307bd1c75fd26ed49590e88048c8442"
+dependencies = [
+ "bellman",
+ "byteorder",
+ "ff 0.14.0",
+ "group 0.14.0",
+ "pairing",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "group"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
dependencies = [
- "ff",
- "memuse",
+ "ff 0.13.1",
"rand_core 0.6.4",
"subtle",
]
+[[package]]
+name = "group"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4"
+dependencies = [
+ "ff 0.14.0",
+ "memuse",
+ "rand_core 0.10.1",
+ "subtle",
+]
+
[[package]]
name = "half"
version = "2.6.0"
@@ -2076,19 +2336,18 @@ dependencies = [
[[package]]
name = "halo2_gadgets"
-version = "0.5.0"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb2a697cad929f706b7987fe804ad57d43622cd37463ba7e4d662a926fdcfea3"
+checksum = "8862c7f2d99964760016516103fcc621352e77a505b22b0fc25140f09e4b8bb0"
dependencies = [
"arrayvec",
"bitvec",
- "ff",
- "group",
+ "ff 0.14.0",
+ "group 0.14.0",
"halo2_poseidon",
"halo2_proofs",
- "lazy_static",
"pasta_curves",
- "rand",
+ "rand 0.10.3",
"sinsemilla",
"subtle",
"uint",
@@ -2102,30 +2361,31 @@ checksum = "47716fe1ae67969c5e0b2ef826f32db8c3be72be325e1aa3c1951d06b5575ec5"
[[package]]
name = "halo2_poseidon"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fa3da60b81f02f9b33ebc6252d766f843291fb4d2247a07ae73d20b791fc56f"
+checksum = "800f76fa421515e2729192e3863bb0a58f30fe17a9a165ea5e778a157adeb579"
dependencies = [
"bitvec",
- "ff",
- "group",
+ "ff 0.14.0",
+ "group 0.14.0",
"pasta_curves",
]
[[package]]
name = "halo2_proofs"
-version = "0.3.2"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05713f117155643ce10975e0bee44a274bcda2f4bb5ef29a999ad67c1fa8d4d3"
+checksum = "f5af2a9457f494f862cd07b81c2e98a19f50b06a2057b7569450d7c26b167d1c"
dependencies = [
"blake2b_simd",
- "ff",
- "group",
+ "ff 0.14.0",
+ "group 0.14.0",
"halo2_legacy_pdqsort",
- "indexmap 1.9.3",
+ "indexmap",
"maybe-rayon",
"pasta_curves",
- "rand_core 0.6.4",
+ "rand 0.10.3",
+ "rand_core 0.10.1",
"tracing",
]
@@ -2147,12 +2407,6 @@ dependencies = [
"ahash 0.7.8",
]
-[[package]]
-name = "hashbrown"
-version = "0.12.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
-
[[package]]
name = "hashbrown"
version = "0.14.5"
@@ -2252,13 +2506,37 @@ dependencies = [
[[package]]
name = "hybrid-array"
-version = "0.2.3"
+version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9"
+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
dependencies = [
"typenum",
]
+[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core 0.58.0",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "ident_case"
version = "1.0.1"
@@ -2323,36 +2601,26 @@ dependencies = [
[[package]]
name = "incrementalmerkletree"
-version = "0.8.2"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30821f91f0fa8660edca547918dc59812893b497d07c1144f326f07fdd94aba9"
+checksum = "c3b0c166f7f34e02988f84a7bed22be9707b1569acc6aeb3afaf34152d0e0400"
dependencies = [
"either",
"proptest",
- "rand",
- "rand_core 0.6.4",
+ "rand 0.10.3",
+ "rand_core 0.10.1",
]
[[package]]
name = "incrementalmerkletree-testing"
-version = "0.3.0"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad20fb6cf815e76ce9b9eca74f347740ab99059fe4b5e4a002403d0441a02983"
+checksum = "e9109f51a90d7533a645acef89934a07893e2516dd7d7c250459643c7150d10f"
dependencies = [
"incrementalmerkletree",
"proptest",
]
-[[package]]
-name = "indexmap"
-version = "1.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
-dependencies = [
- "autocfg",
- "hashbrown 0.12.3",
-]
-
[[package]]
name = "indexmap"
version = "2.10.0"
@@ -2373,6 +2641,15 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "inout"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ce983bb6fb399067d101fbfc9e74174e07e9f29a2bc679efefeb8c645819c3f"
+dependencies = [
+ "hybrid-array",
+]
+
[[package]]
name = "io-lifetimes"
version = "1.0.11"
@@ -2445,16 +2722,17 @@ dependencies = [
[[package]]
name = "jubjub"
-version = "0.10.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61"
+checksum = "95fdd9a071f72385ed8b17d819f273d73c3887a93d34d2ac1419fca5b25dbbd2"
dependencies = [
"bitvec",
"bls12_381",
- "ff",
- "group",
- "rand_core 0.6.4",
+ "ff 0.14.0",
+ "group 0.14.0",
+ "rand_core 0.10.1",
"subtle",
+ "zeroize",
]
[[package]]
@@ -2463,7 +2741,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
dependencies = [
- "cpufeatures",
+ "cpufeatures 0.2.17",
]
[[package]]
@@ -2491,7 +2769,8 @@ dependencies = [
"ed25519-bip32-core",
"hex",
"num-bigint-dig",
- "rand_chacha",
+ "rand_chacha 0.10.0",
+ "rand_chacha 0.3.1",
"rand_core 0.6.4",
"rsa",
"rust_tools",
@@ -2760,7 +3039,7 @@ source = "git+https://github.com/KeystoneHQ/serai#c784e6c6fcd6cfd8ac88cdd0d46718
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
- "group",
+ "group 0.13.0",
"monero-io",
"sha3 0.10.8",
"std-shims",
@@ -2846,8 +3125,8 @@ dependencies = [
"monero-clsag",
"monero-rpc",
"monero-serai",
- "rand",
- "rand_chacha",
+ "rand 0.8.5",
+ "rand_chacha 0.3.1",
"rand_core 0.6.4",
"rand_distr",
"std-shims",
@@ -2860,6 +3139,12 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+[[package]]
+name = "multiversion_no_op"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
+
[[package]]
name = "nix"
version = "0.26.4"
@@ -2900,6 +3185,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
+ "num-bigint 0.4.6",
"num-complex",
"num-integer",
"num-iter",
@@ -2917,6 +3203,16 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "num-bigint"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0"
+dependencies = [
+ "num-integer",
+ "num-traits",
+]
+
[[package]]
name = "num-bigint-dig"
version = "0.8.6"
@@ -2928,7 +3224,7 @@ dependencies = [
"num-integer",
"num-iter",
"num-traits",
- "rand",
+ "rand 0.8.5",
"smallvec",
"zeroize",
]
@@ -2959,17 +3255,6 @@ dependencies = [
"syn 1.0.109",
]
-[[package]]
-name = "num-derive"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.104",
-]
-
[[package]]
name = "num-integer"
version = "0.1.46"
@@ -2996,6 +3281,7 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
+ "num-bigint 0.4.6",
"num-integer",
"num-traits",
]
@@ -3039,18 +3325,18 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
[[package]]
name = "orchard"
-version = "0.15.1"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04153a90834b939edd03c3e1b3ff15c9d305b9224c5e196faf3a490d21dfa299"
+checksum = "4ae7ceb7b5387bd76cf3c0712f57708795c925cecf097036cedb60b5c3706e8f"
dependencies = [
- "aes",
+ "aes 0.9.3",
"bitvec",
"blake2b_simd",
"corez",
- "ff",
- "fpe",
+ "ff 0.14.0",
+ "fpe 0.7.0",
"getset",
- "group",
+ "group 0.14.0",
"halo2_gadgets",
"halo2_poseidon",
"halo2_proofs",
@@ -3061,8 +3347,8 @@ dependencies = [
"nonempty",
"pasta_curves",
"proptest",
- "rand",
- "rand_core 0.6.4",
+ "rand 0.10.3",
+ "rand_core 0.10.1",
"reddsa",
"serde",
"sinsemilla",
@@ -3071,6 +3357,7 @@ dependencies = [
"visibility",
"zcash_note_encryption",
"zcash_spec",
+ "zeroize",
"zip32",
]
@@ -3085,11 +3372,11 @@ dependencies = [
[[package]]
name = "pairing"
-version = "0.23.0"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f"
+checksum = "33f6413397336802d16a342e69a5bd9c8b8cc2fa9fc9298044cd3443f77f1010"
dependencies = [
- "group",
+ "group 0.14.0",
]
[[package]]
@@ -3120,17 +3407,18 @@ dependencies = [
[[package]]
name = "pasta_curves"
-version = "0.5.1"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095"
+checksum = "a0ed53ba43531a06e1f82020907cf192fc3c25d7c0baf5c49c547b74e7103b62"
dependencies = [
"blake2b_simd",
- "ff",
- "group",
+ "ff 0.14.0",
+ "group 0.14.0",
"lazy_static",
- "rand",
+ "rand 0.10.3",
"static_assertions",
"subtle",
+ "zeroize",
]
[[package]]
@@ -3141,30 +3429,32 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pczt"
-version = "0.8.0-rc.1"
+version = "0.10.0-keystone.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8fb3f5ea64b891d40cff8182aca0bd7d063c9460920546fe7066860b781de91"
+checksum = "2ddcc0b4cb11acd99a3b3d3c323652f0e2da10dcb4a8465227d79c9d93d8c75c"
dependencies = [
"blake2b_simd",
"bls12_381",
- "ff",
+ "ff 0.14.0",
"getset",
"jubjub",
"nonempty",
"orchard",
"pasta_curves",
"postcard",
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"redjubjub",
"sapling-crypto",
"secp256k1",
"serde",
"serde_with",
+ "subtle",
"zcash_note_encryption",
"zcash_primitives",
"zcash_protocol",
"zcash_script",
"zcash_transparent",
+ "zeroize",
]
[[package]]
@@ -3180,7 +3470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset",
- "indexmap 2.10.0",
+ "indexmap",
]
[[package]]
@@ -3200,7 +3490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
dependencies = [
"phf_shared",
- "rand",
+ "rand 0.8.5",
]
[[package]]
@@ -3284,9 +3574,19 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
dependencies = [
- "cpufeatures",
+ "cpufeatures 0.2.17",
"opaque-debug",
- "universal-hash",
+ "universal-hash 0.5.1",
+]
+
+[[package]]
+name = "poly1305"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c"
+dependencies = [
+ "cpufeatures 0.3.1",
+ "universal-hash 0.6.1",
]
[[package]]
@@ -3415,19 +3715,19 @@ dependencies = [
[[package]]
name = "proptest"
-version = "1.6.0"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50"
+checksum = "b8530004ccb15eae51c7e40009fbe317f341f804db54dc033eec1c50be28cfa0"
dependencies = [
"bit-set",
"bit-vec",
- "bitflags 2.9.1",
- "lazy_static",
+ "bitflags 2.13.2",
+ "chacha20 0.10.2",
+ "core_detect",
"num-traits",
- "rand",
- "rand_chacha",
+ "rand 0.10.3",
"rand_xorshift",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.11",
"rusty-fork",
"tempfile",
"unarray",
@@ -3520,17 +3820,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "quircs"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec3fec90fc7a119692a6244ed4404d152878a47f0bf3f90f34dc79bb7a339d24"
-dependencies = [
- "num-derive 0.4.2",
- "num-traits",
- "thiserror 1.0.69",
-]
-
[[package]]
name = "quote"
version = "1.0.40"
@@ -3546,6 +3835,12 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
[[package]]
name = "radium"
version = "0.7.0"
@@ -3558,11 +3853,21 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
- "libc",
- "rand_chacha",
+ "rand_chacha 0.3.1",
"rand_core 0.6.4",
]
+[[package]]
+name = "rand"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
+dependencies = [
+ "chacha20 0.10.2",
+ "getrandom 0.4.3",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "rand_chacha"
version = "0.3.1"
@@ -3573,6 +3878,16 @@ dependencies = [
"rand_core 0.6.4",
]
+[[package]]
+name = "rand_chacha"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e6af7f3e25ded52c41df4e0b1af2d047e45896c2f3281792ed68a1c243daedb"
+dependencies = [
+ "ppv-lite86",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "rand_core"
version = "0.3.1"
@@ -3597,14 +3912,20 @@ dependencies = [
"getrandom 0.2.16",
]
+[[package]]
+name = "rand_core"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
+
[[package]]
name = "rand_distr"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31"
dependencies = [
"num-traits",
- "rand",
+ "rand 0.8.5",
]
[[package]]
@@ -3624,11 +3945,11 @@ dependencies = [
[[package]]
name = "rand_xorshift"
-version = "0.3.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
+checksum = "60aa6af80be32871323012e02e6e65f8a7cc7890931ae421d217ad8fe0df2ccf"
dependencies = [
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
]
[[package]]
@@ -3671,31 +3992,31 @@ dependencies = [
[[package]]
name = "reddsa"
-version = "0.5.1"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78a5191930e84973293aa5f532b513404460cd2216c1cfb76d08748c15b40b02"
+checksum = "4a70b6dbd7b3277cbd4d89ee750a30bebab3b9951ee4e166ce15c00975fe410f"
dependencies = [
"blake2b_simd",
"byteorder",
- "group",
+ "group 0.14.0",
"hex",
"jubjub",
"pasta_curves",
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"serde",
- "thiserror 1.0.69",
+ "thiserror 2.0.20",
"zeroize",
]
[[package]]
name = "redjubjub"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89b0ac1bc6bb3696d2c6f52cff8fba57238b81da8c0214ee6cd146eb8fde364e"
+checksum = "19ff57b3369b472353110bea305ced2612a1380e2d2079dd26c200ed42064421"
dependencies = [
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"reddsa",
- "thiserror 1.0.69",
+ "thiserror 2.0.20",
"zeroize",
]
@@ -3721,25 +4042,25 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.11.1"
+version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.11",
]
[[package]]
name = "regex-automata"
-version = "0.4.9"
+version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
dependencies = [
"aho-corasick",
"memchr",
- "regex-syntax 0.8.5",
+ "regex-syntax 0.8.11",
]
[[package]]
@@ -3750,9 +4071,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]]
name = "ripemd"
@@ -3843,7 +4164,7 @@ dependencies = [
name = "rust_c"
version = "0.1.0"
dependencies = [
- "aes",
+ "aes 0.8.4",
"app_aptos",
"app_arweave",
"app_avalanche",
@@ -3868,9 +4189,9 @@ dependencies = [
"bcs",
"bitcoin",
"bitcoin_hashes 0.14.0",
- "cbc",
+ "cbc 0.1.2",
"cbindgen",
- "cipher",
+ "cipher 0.4.4",
"cryptoxide",
"cstr_core",
"cty",
@@ -3948,7 +4269,7 @@ version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
- "bitflags 2.9.1",
+ "bitflags 2.13.2",
"errno",
"libc",
"linux-raw-sys 0.4.15",
@@ -3961,7 +4282,7 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
dependencies = [
- "bitflags 2.9.1",
+ "bitflags 2.13.2",
"errno",
"libc",
"linux-raw-sys 0.9.4",
@@ -3986,6 +4307,22 @@ dependencies = [
"wait-timeout",
]
+[[package]]
+name = "rxing"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fbf2a0e464c316b30b4cab99e898f20a9d8e42ca3d7a767e670c9a330f2202f"
+dependencies = [
+ "chrono",
+ "codepage-437",
+ "encoding_rs",
+ "num",
+ "once_cell",
+ "regex",
+ "thiserror 2.0.20",
+ "unicode-segmentation",
+]
+
[[package]]
name = "ryu"
version = "1.0.23"
@@ -3998,35 +4335,37 @@ version = "0.1.0"
[[package]]
name = "sapling-crypto"
-version = "0.7.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d70756ede56b5e4dd417979777bd87ddb83dfcbd0815dbf8175a9920537f8a0"
+checksum = "4a2cbdcfeef20006adf72699cd466f21fe349674277cc05d3fc9b7302db7b182"
dependencies = [
- "aes",
+ "aes 0.9.3",
"bellman",
"bitvec",
"blake2b_simd",
"blake2s_simd",
"bls12_381",
"corez",
"document-features",
- "ff",
- "fpe",
+ "ff 0.14.0",
+ "fpe 0.7.0",
"getset",
- "group",
+ "groth16",
+ "group 0.14.0",
"hex",
"incrementalmerkletree",
"jubjub",
"lazy_static",
"memuse",
"proptest",
- "rand",
- "rand_core 0.6.4",
+ "rand 0.10.3",
+ "rand_core 0.10.1",
"redjubjub",
"subtle",
"tracing",
"zcash_note_encryption",
"zcash_spec",
+ "zeroize",
"zip32",
]
@@ -4269,7 +4608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest 0.10.7",
]
@@ -4281,7 +4620,7 @@ checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest 0.9.0",
"opaque-debug",
]
@@ -4293,7 +4632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest 0.10.7",
]
@@ -4304,7 +4643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest 0.11.0-pre.9",
]
@@ -4332,11 +4671,11 @@ dependencies = [
[[package]]
name = "shardtree"
-version = "0.6.2"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "359e552886ae54d1642091645980d83f7db465fd9b5b0248e3680713c1773388"
+checksum = "211c5ae6ff1fda9efe2cd8b90737744b3b3989f98740319284946bf110b862ed"
dependencies = [
- "bitflags 2.9.1",
+ "bitflags 2.13.2",
"either",
"incrementalmerkletree",
"tracing",
@@ -4365,7 +4704,7 @@ dependencies = [
"anyhow",
"cocoa",
"image",
- "quircs",
+ "rxing",
"screenshots",
"windows 0.58.0",
]
@@ -4376,13 +4715,19 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
+[[package]]
+name = "simdutf8"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
+
[[package]]
name = "sinsemilla"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d268ae0ea06faafe1662e9967cd4f9022014f5eeb798e0c302c876df8b7af9c"
+checksum = "72744738b764bb3bb7bb5dcf71b62d19c2de8a09f850a7388f6088f244037299"
dependencies = [
- "group",
+ "group 0.14.0",
"pasta_curves",
"subtle",
]
@@ -4538,7 +4883,7 @@ checksum = "c0cec054567d16d85e8c3f6a3139963d1a66d9d3051ed545d31562550e9bcc3d"
dependencies = [
"bytes",
"flex-error",
- "num-derive 0.3.3",
+ "num-derive",
"num-traits",
"prost",
"prost-types",
@@ -4715,7 +5060,7 @@ version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
- "indexmap 2.10.0",
+ "indexmap",
"serde",
"serde_spanned",
"toml_datetime",
@@ -4762,9 +5107,9 @@ dependencies = [
[[package]]
name = "typenum"
-version = "1.18.0"
+version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "uint"
@@ -4796,6 +5141,12 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+[[package]]
+name = "unicode-segmentation"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+
[[package]]
name = "unicode-xid"
version = "0.2.6"
@@ -4812,6 +5163,16 @@ dependencies = [
"subtle",
]
+[[package]]
+name = "universal-hash"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96"
+dependencies = [
+ "crypto-common 0.2.2",
+ "ctutils",
+]
+
[[package]]
name = "unty"
version = "0.0.4"
@@ -5159,6 +5520,12 @@ dependencies = [
"syn 2.0.104",
]
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
[[package]]
name = "windows-result"
version = "0.2.0"
@@ -5405,7 +5772,7 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
- "bitflags 2.9.1",
+ "bitflags 2.13.2",
]
[[package]]
@@ -5430,9 +5797,9 @@ dependencies = [
[[package]]
name = "zcash_address"
-version = "0.13.0"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a854b28c07dba372f4410ea8ad62b4bf7d5c2bf8be32fc4b31bc0db6521a975"
+checksum = "372023d82d978ab3f27b8e9f7f9b56fc61f3c9cc2b72ec2f8e3bbb278497e474"
dependencies = [
"bech32 0.11.0",
"bs58",
@@ -5444,9 +5811,9 @@ dependencies = [
[[package]]
name = "zcash_encoding"
-version = "0.4.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1440921903cdb86133fb9e2fe800be488015db2939a30bedb413078a1acb0306"
+checksum = "b2871fd3c37eaeb635c815a9c97495553bf8237a481b9f8b37eba661764bf937"
dependencies = [
"corez",
"hex",
@@ -5455,21 +5822,21 @@ dependencies = [
[[package]]
name = "zcash_keys"
-version = "0.15.0"
+version = "0.17.0-keystone.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36391ebfce7df2510c6564f79e608ed93f1c0692c6464e2397b248e06dae3912"
+checksum = "563720aa2c32e3edfc95651570ce36e3431c732b8f7e402c39ee12608075b91c"
dependencies = [
"bech32 0.11.0",
"bip32",
"blake2b_simd",
"bls12_381",
"bs58",
"corez",
- "group",
+ "group 0.14.0",
"memuse",
"nonempty",
"orchard",
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"secrecy",
"subtle",
"tracing",
@@ -5482,37 +5849,35 @@ dependencies = [
[[package]]
name = "zcash_note_encryption"
-version = "0.4.1"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77efec759c3798b6e4d829fcc762070d9b229b0f13338c40bf993b7b609c2272"
+checksum = "4812d133908ebf1a1c91d2411a109f63a863a152633db1fc7fbb0f774edeae30"
dependencies = [
- "chacha20",
- "chacha20poly1305",
- "cipher",
- "rand_core 0.6.4",
+ "chacha20 0.10.2",
+ "chacha20poly1305 0.11.0",
+ "cipher 0.5.2",
+ "rand_core 0.10.1",
"subtle",
]
[[package]]
name = "zcash_primitives"
-version = "0.29.0"
+version = "0.31.0-keystone.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bdbeccc05bfe63b6dee9e989c6ff5027421741562a4853c36504dd621f6a81b1"
+checksum = "c1a60882c53f34ad4de5db979c12d9f125e37743d6c6c1c956a1c237cfb7849e"
dependencies = [
"blake2b_simd",
- "block-buffer 0.11.0-rc.3",
"corez",
- "crypto-common 0.2.0-rc.1",
"equihash",
- "ff",
+ "ff 0.14.0",
"hex",
"incrementalmerkletree",
"jubjub",
"memuse",
"nonempty",
"orchard",
"proptest",
- "rand_core 0.6.4",
+ "rand_core 0.10.1",
"redjubjub",
"sapling-crypto",
"secp256k1",
@@ -5526,9 +5891,9 @@ dependencies = [
[[package]]
name = "zcash_protocol"
-version = "0.10.0"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2973d210e74ebd81adc50828fbbb284ab6aaa099308097c42c47dc63cf3420fc"
+checksum = "266da226b6be42545b9fc299f1def9f5e525764845b8afa874f167155de943ba"
dependencies = [
"corez",
"hex",
@@ -5540,12 +5905,12 @@ dependencies = [
[[package]]
name = "zcash_script"
-version = "0.4.4"
+version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "774d808ab619b0f1887d7b90cd815c356101698d16aa681f3d2d9dea063de475"
+checksum = "2f872800287d118be71bdf6fe8c869c6a6ff6fb0a5762f68fb2af54c97edf0f2"
dependencies = [
"bip32",
- "bitflags 2.9.1",
+ "bitflags 2.13.2",
"bounded-vec",
"hex",
"ripemd 0.1.3",
@@ -5566,9 +5931,9 @@ dependencies = [
[[package]]
name = "zcash_transparent"
-version = "0.9.0"
+version = "0.11.0-keystone.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72e0f8c142bed366ed5886dcfa8772ec90b5420cc127e6cdb76b6744c53a287b"
+checksum = "97c07369081853d0ad82996fdea6e3726b5442848e314453d036e54ebf161087"
dependencies = [
"bip32",
"bs58",
@@ -5581,7 +5946,6 @@ dependencies = [
"secp256k1",
"sha2 0.10.9",
"subtle",
- "zcash_address",
"zcash_encoding",
"zcash_protocol",
"zcash_script",
@@ -5599,20 +5963,20 @@ dependencies = [
"blake2b_simd",
"bs58",
"byteorder",
- "chacha20poly1305",
+ "chacha20poly1305 0.10.1",
"f4jumble",
- "ff",
- "fpe",
+ "ff 0.14.0",
+ "fpe 0.6.1",
"getset",
- "group",
+ "group 0.14.0",
"hex",
"incrementalmerkletree-testing",
"no_std_io2",
"orchard",
"pasta_curves",
"pczt",
"postcard",
- "rand_chacha",
+ "rand_chacha 0.3.1",
"reddsa",
"ripemd 0.1.3",
"rust_tools",
@@ -5672,14 +6036,16 @@ dependencies = [
[[package]]
name = "zip32"
-version = "0.2.0"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13ff9ea444cdbce820211f91e6aa3d3a56bde7202d3c0961b7c38f793abf5637"
+checksum = "601ab4bc5f8312fa39f5411e07eb66b538687064c6e936b34eaa78f1e99ebe4d"
dependencies = [
+ "bech32 0.11.0",
"blake2b_simd",
"memuse",
"subtle",
"zcash_spec",
+ "zeroize",
]
[[package]]
### rust/apps/zcash/Cargo.toml
@@ -16,7 +16,9 @@ hex = { workspace = true }
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
blake2b_simd = { workspace = true }
rand_core = { workspace = true, features = ["getrandom"] }
-zcash_note_encryption = "0.4.1"
+# The RNG traits that orchard uses.
+rand_core_010 = { package = "rand_core", version = "0.10", default-features = false }
+zcash_note_encryption = "0.5.1"
postcard = { version = "1.0.3", features = ["alloc"] }
serde = { workspace = true }
serde_with = { version = "3.11.0", features = [
@@ -27,14 +29,14 @@ zeroize = { workspace = true }
[dev-dependencies]
keystore = { path = "../../keystore" }
-pczt = { version = "0.8.0-rc.1", default-features = false, features = ["io-finalizer", "orchard", "sapling", "spend-finalizer", "transparent", "zcp-builder"] }
-zcash_primitives = { version = "0.29.0", default-features = false, features = ["circuits", "test-dependencies", "transparent-inputs"] }
-incrementalmerkletree = { version = "0.8.2", default-features = false }
-shardtree = "0.6.2"
+pczt = { version = "=0.10.0-keystone.0", default-features = false, features = ["io-finalizer", "orchard", "sapling", "spend-finalizer", "transparent", "zcp-builder"] }
+zcash_primitives = { version = "=0.31.0-keystone.0", default-features = false, features = ["circuits", "test-dependencies", "transparent-inputs"] }
+incrementalmerkletree = { version = "0.9", default-features = false }
+shardtree = "0.8"
# Nameable only so the transparent-only `legacy_test_support` can spell the
# `BuildConfig::orchard_pool_bundle_type` value; orchard is already built transitively
# via the `zcash_primitives` dev-dependency.
-orchard = { version = "0.15.1", default-features = false }
+orchard = { version = "0.16", default-features = false }
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
### rust/apps/zcash/src/address_verification.rs
@@ -109,7 +109,7 @@ mod tests {
#[test]
fn uppercase_addresses_are_owned_but_mixed_case_is_invalid() {
let key = key(1);
- let ufvk = key.encode(&MainNetwork);
+ let ufvk = key.encode(&MainNetwork).unwrap();
let (address, _) = key.default_address(UnifiedAddressRequest::ORCHARD).unwrap();
let text = address.encode(&MainNetwork);
assert_eq!(
@@ -144,10 +144,13 @@ mod tests {
}
fn check(key: &UnifiedFullViewingKey, receivers: Vec<Receiver>) -> VerificationResult {
- let text = unified::Address::try_from_items(receivers)
- .unwrap()
- .encode(&NetworkType::Main);
- verify(&MainNetwork, &key.encode(&MainNetwork), &text)
+ let text = unified::Address::try_from_items(
+ unified::Revision::R0,
+ receivers.into_iter().map(unified::Uitem::Data).collect(),
+ )
+ .unwrap()
+ .encode(&NetworkType::Main);
+ verify(&MainNetwork, &key.encode(&MainNetwork).unwrap(), &text)
}
#[test]
@@ -160,7 +163,7 @@ mod tests {
assert_eq!(
verify(
&MainNetwork,
- &key.encode(&MainNetwork),
+ &key.encode(&MainNetwork).unwrap(),
&address.encode(&MainNetwork)
),
VerificationResult::Owned
@@ -176,7 +179,7 @@ mod tests {
assert_eq!(
verify(
&MainNetwork,
- &key.encode(&MainNetwork),
+ &key.encode(&MainNetwork).unwrap(),
&address.encode(&MainNetwork)
),
VerificationResult::Owned
@@ -192,7 +195,7 @@ mod tests {
assert_eq!(
verify(
&MainNetwork,
- &self::key(2).encode(&MainNetwork),
+ &self::key(2).encode(&MainNetwork).unwrap(),
&other.encode(&MainNetwork)
),
VerificationResult::NotOwned
@@ -225,13 +228,15 @@ mod tests {
key.address(1u32.into(), UnifiedAddressRequest::AllAvailableKeys)
.unwrap(),
] {
- let (_, raw) = unified::Address::decode(&other.encode(&MainNetwork)).unwrap();
+ let (_, _, raw) = unified::Address::decode(&other.encode(&MainNetwork)).unwrap();
let transparent = raw
.items_as_parsed()
.iter()
- .find(|r| matches!(r, Receiver::P2pkh(_)))
- .unwrap()
- .clone();
+ .find_map(|item| match item {
+ unified::Uitem::Data(r @ Receiver::P2pkh(_)) => Some(r.clone()),
+ _ => None,
+ })
+ .unwrap();
assert_eq!(
check(&key, vec![orchard.clone(), transparent]),
VerificationResult::NotOwned
@@ -279,7 +284,7 @@ mod tests {
let ua = key
.address(0u32.into(), UnifiedAddressRequest::ORCHARD)
.unwrap();
- let ufvk = key.encode(&MainNetwork);
+ let ufvk = key.encode(&MainNetwork).unwrap();
for text in ["", "u1invalid", "zcash:u1invalid"] {
assert_eq!(
verify(&MainNetwork, &ufvk, text),
### rust/apps/zcash/src/lib.rs
@@ -5,6 +5,8 @@ extern crate alloc;
pub mod address_verification;
pub mod errors;
pub mod pczt;
+#[cfg(any(feature = "cypherpunk", test))]
+mod rng;
pub mod version;
use errors::{Result, ZcashError};
@@ -144,7 +146,7 @@ fn check_pczt_cypherpunk_with_policy<P: consensus::Parameters>(
.map_err(|_e| ZcashError::InvalidDataError("invalid account index".to_string()))?;
let ufvk = UnifiedFullViewingKey::decode(params, ufvk_text)
.map_err(|e| ZcashError::InvalidDataError(e.to_string()))?;
- let xpub = ufvk.transparent().ok_or(ZcashError::InvalidDataError(
+ let xpub = ufvk.p2pkh().ok_or(ZcashError::InvalidDataError(
"transparent xpub is not present".to_string(),
))?;
pczt::check::check_pczt_orchard(params, seed_fingerprint, account_index, &ufvk, &pczt)?;
@@ -217,7 +219,7 @@ fn transparent_account_pubkey_from_xpub(
use core::str::FromStr;
use zcash_vendor::{bip32, transparent};
- let xpub: bip32::ExtendedPublicKey<bitcoin::secp256k1::PublicKey> =
+ let xpub: bip32::ExtendedPublicKey<zcash_vendor::secp256k1::PublicKey> =
bip32::ExtendedPublicKey::from_str(xpub)
.map_err(|e| ZcashError::InvalidDataError(e.to_string()))?;
@@ -344,7 +346,7 @@ fn check_and_parse_batch_pczt_internal<P: consensus::Parameters>(
let account_index = zip32::AccountId::try_from(account_index)
.map_err(|_e| ZcashError::InvalidDataError("invalid account index".to_string()))?;
let ufvk = ctx.ufvk(params)?;
- let xpub = ufvk.transparent().ok_or(ZcashError::InvalidDataError(
+ let xpub = ufvk.p2pkh().ok_or(ZcashError::InvalidDataError(
"transparent xpub is not present".to_string(),
))?;
// `validate_supported_pczt` stays ahead of the wallet-key derivation so the
@@ -1673,7 +1675,7 @@ mod tests {
use ::pczt::roles::creator::Creator;
use zcash_vendor::zcash_protocol::consensus::{BranchId, NetworkConstants};
- let bytes = Creator::new(
+ let pczt = Creator::new(
BranchId::Nu6.into(),
10,
MainNetwork.coin_type(),
@@ -1682,9 +1684,8 @@ mod tests {
)
.unwrap()
.build()
- .unwrap()
- .serialize()
.unwrap();
+ let bytes = ::pczt::v2::Pczt::try_from(pczt).unwrap().serialize();
let (mut prefix, rest) = postcard::take_from_bytes::<PcztWirePrefix>(&bytes[8..]).unwrap();
// v2 omits empty bundles, so the freshly created PCZT has no Sapling bundle.
// Attach one that is empty except for a non-zero value sum, which `check` rejects.
@@ -1729,11 +1730,10 @@ mod tests {
/// sees) and the check path (pre-sign validation) must reject it.
#[test]
fn test_parse_pczt_rejects_orchard_internal_ovk_change_spoofing() {
+ use crate::rng::DeviceRng;
use ::pczt::roles::creator::Creator;
- use bitcoin::secp256k1::Secp256k1;
- use rand_core::OsRng;
use zcash_primitives::transaction::{
- builder::{BuildConfig, Builder, PcztResult},
+ builder::{BuildConfig, Builder, BundlePadding, PcztResult},
fees::zip317,
};
use zcash_vendor::{
@@ -1763,8 +1763,7 @@ mod tests {
let victim_sk = victim_account
.derive_external_secret_key(address_index)
.unwrap();
- let secp = Secp256k1::signing_only();
- let victim_pubkey = victim_sk.public_key(&secp);
+ let victim_pubkey = victim_sk.public_key(&bitcoin::secp256k1::Secp256k1::signing_only());
// Attacker-controlled Orchard recipient that does NOT belong to the victim wallet.
let attacker_sk = orchard::keys::SpendingKey::from_bytes([2; 32]).unwrap();
@@ -1785,7 +1784,8 @@ mod tests {
sapling_anchor: None,
orchard_anchor: Some(orchard::Anchor::empty_tree()),
ironwood_anchor: None,
- orchard_pool_bundle_type: orchard::builder::BundleType::DEFAULT,
+ orchard_padding: BundlePadding::DEFAULT,
+ ironwood_padding: BundlePadding::DEFAULT,
},
);
builder
@@ -1815,7 +1815,7 @@ mod tests {
.unwrap();
let PcztResult { pczt_parts, .. } = builder
- .build_for_pczt(OsRng, &zip317::FeeRule::standard())
+ .build_for_pczt(DeviceRng, &zip317::FeeRule::standard())
.unwrap();
let pczt_bytes = Creator::build_from_parts(pczt_parts)
.unwrap()
@@ -2362,8 +2362,12 @@ mod tests {
let mut signer = Signer::new(original).expect("sample PCZT should be signable");
let action_index = required_actions[0].index;
let signing_result = match pool {
- SignableShieldedPool::Orchard => signer.sign_orchard(action_index, &ask),
- SignableShieldedPool::Ironwood => signer.sign_ironwood(action_index, &ask),
+ SignableShieldedPool::Orchard => {
+ signer.sign_orchard(crate::rng::DeviceRng, action_index, &ask)
+ }
+ SignableShieldedPool::Ironwood => {
+ signer.sign_ironwood(crate::rng::DeviceRng, action_index, &ask)
+ }
};
signing_result.expect("funded action should sign");
let pczt = signer.finish();
### rust/apps/zcash/src/pczt/mod.rs
@@ -31,7 +31,7 @@ impl PcztEncoding {
) -> core::result::Result<Vec<u8>, zcash_vendor::pczt::EncodingError> {
match self {
Self::V1 => Ok(zcash_vendor::pczt::v1::Pczt::try_from(pczt)?.serialize()),
- Self::V2 => pczt.serialize(),
+ Self::V2 => Ok(zcash_vendor::pczt::v2::Pczt::try_from(pczt)?.serialize()),
}
}
}
@@ -340,12 +340,11 @@ mod consistency_tests {
ShieldedPool::Orchard => BranchId::Nu6,
ShieldedPool::Ironwood => BranchId::Nu6_3,
};
- let bytes = Creator::new(branch_id.into(), 10, MainNetwork.coin_type(), None, None)
+ let pczt = Creator::new(branch_id.into(), 10, MainNetwork.coin_type(), None, None)
.unwrap()
.build()
- .unwrap()
- .serialize()
.unwrap();
+ let bytes = ::pczt::v2::Pczt::try_from(pczt).unwrap().serialize();
let mut wire: EmptyPcztWire = postcard::from_bytes(&bytes[8..]).unwrap();
let bundle = EmptyShieldedBundleWire {
actions: Vec::new(),
@@ -370,6 +369,30 @@ mod consistency_tests {
postcard::to_extend(&wire, bytes[..8].to_vec()).unwrap()
}
+ #[test]
+ fn serializes_in_the_requested_encoding() {
+ let pczt = Creator::new(
+ BranchId::Nu6.into(),
+ 10,
+ MainNetwork.coin_type(),
+ None,
+ None,
+ )
+ .unwrap()
+ .build()
+ .unwrap();
+ for (encoding, version) in [(PcztEncoding::V1, 1u32), (PcztEncoding::V2, 2)] {
+ let bytes = encoding.serialize(pczt.clone()).unwrap();
+ let (parsed, parsed_encoding) = parse_pczt_with_encoding(&bytes).unwrap();
+ assert_eq!(u32::from_le_bytes(bytes[4..8].try_into().unwrap()), version);
+ assert!(matches!(
+ (encoding, parsed_encoding),
+ (PcztEncoding::V1, PcztEncoding::V1) | (PcztEncoding::V2, PcztEncoding::V2)
+ ));
+ assert_eq!(parsed.global().tx_version(), pczt.global().tx_version());
+ }
+ }
+
#[test]
fn rejects_nonzero_value_sum_on_empty_orchard_protocol_bundles() {
for pool in [ShieldedPool::Orchard, ShieldedPool::Ironwood] {
@@ -389,14 +412,14 @@ mod consistency_tests {
pub(crate) mod test_support {
use alloc::{string::String, vec, vec::Vec};
+ use crate::rng::DeviceRng;
use ::pczt::roles::{creator::Creator, updater::Updater};
use incrementalmerkletree::Retention;
use keystore::algorithms::zcash::{calculate_seed_fingerprint, derive_ufvk};
- use rand_core::OsRng;
use shardtree::{store::memory::MemoryShardStore, ShardTree};
use zcash_note_encryption::try_note_decryption;
use zcash_primitives::transaction::{
- builder::{BuildConfig, Builder, PcztParts, PcztResult},
+ builder::{BuildConfig, Builder, BundlePadding, PcztParts, PcztResult},
fees::zip317,
TxVersion,
};
@@ -542,7 +565,10 @@ pub(crate) mod test_support {
orchard_builder
.add_output(None, recipient, value, Memo::Empty.encode().into_bytes())
.unwrap();
- let (bundle, meta) = orchard_builder.build::<i64>(&mut OsRng).unwrap().unwrap();
+ let (bundle, meta) = orchard_builder
+ .build::<i64>(&mut DeviceRng)
+ .unwrap()
+ .unwrap();
let action = bundle
.actions()
.get(meta.output_action_index(0).unwrap())
@@ -577,7 +603,8 @@ pub(crate) mod test_support {
sapling_anchor: None,
orchard_anchor: None,
ironwood_anchor: Some(anchor),
- orchard_pool_bundle_type: orchard::builder::BundleType::DEFAULT,
+ orchard_padding: BundlePadding::DEFAULT,
+ ironwood_padding: BundlePadding::DEFAULT,
},
);
builder
@@ -596,7 +623,7 @@ pub(crate) mod test_support {
ironwood_meta,
..
} = builder
- .build_for_pczt(OsRng, &zip317::FeeRule::standard())
+ .build_for_pczt(DeviceRng, &zip317::FeeRule::standard())
.unwrap();
let spend_action_index = ironwood_meta.spend_action_index(0).unwrap();
let seed_fingerprint = calculate_seed_fingerprint(&seed).unwrap();
@@ -720,7 +747,10 @@ pub(crate) mod test_support {
Memo::Empty.encode().into_bytes(),
)
.unwrap();
- let (bundle, meta) = orchard_builder.build::<i64>(&mut OsRng).unwrap().unwrap();
+ let (bundle, meta) = orchard_builder
+ .build::<i64>(&mut DeviceRng)
+ .unwrap()
+ .unwrap();
let action = bundle
.actions()
.get(meta.output_action_index(0).unwrap())
@@ -755,7 +785,8 @@ pub(crate) mod test_support {
sapling_anchor: None,
orchard_anchor: Some(anchor),
ironwood_anchor: Some(orchard::Anchor::empty_tree()),
- orchard_pool_bundle_type: orchard::builder::BundleType::DEFAULT,
+ orchard_padding: BundlePadding::DEFAULT,
+ ironwood_padding: BundlePadding::DEFAULT,
},
);
builder
@@ -785,7 +816,7 @@ pub(crate) mod test_support {
ironwood_meta,
..
} = builder
- .build_for_pczt(OsRng, &zip317::FeeRule::standard())
+ .build_for_pczt(DeviceRng, &zip317::FeeRule::standard())
.unwrap();
let spend_action_index = orchard_meta.spend_action_index(0).unwrap();
let displayable_zero_action = match zero_output.as_ref() {
@@ -995,7 +1026,10 @@ pub(crate) mod test_support {
Memo::Empty.encode().into_bytes(),
)
.unwrap();
- let (bundle, meta) = orchard_builder.build::<i64>(&mut OsRng).unwrap().unwrap();
+ let (bundle, meta) = orchard_builder
+ .build::<i64>(&mut DeviceRng)
+ .unwrap()
+ .unwrap();
let action = bundle
.actions()
.get(meta.output_action_index(0).unwrap())
@@ -1042,7 +1076,7 @@ pub(crate) mod test_support {
Memo::Empty.encode().into_bytes(),
)
.unwrap();
- let (orchard_bundle, _) = builder.build_for_pczt(&mut OsRng).unwrap();
+ let (orchard_bundle, _) = builder.build_for_pczt(&mut DeviceRng).unwrap();
let seed_fingerprint = calculate_seed_fingerprint(&seed).unwrap();
let pczt = Creator::build_from_parts(PcztParts {
params,
@@ -1107,14 +1141,13 @@ pub(crate) mod legacy_test_support {
use alloc::string::{String, ToString};
use alloc::{vec, vec::Vec};
+ use crate::rng::DeviceRng;
use ::pczt::roles::{creator::Creator, updater::Updater};
- use bitcoin::secp256k1::Secp256k1;
#[cfg(feature = "multi_coins")]
use keystore::algorithms::secp256k1::get_extended_public_key_by_seed;
use keystore::algorithms::zcash::calculate_seed_fingerprint;
- use rand_core::OsRng;
use zcash_primitives::transaction::{
- builder::{BuildConfig, Builder, PcztResult},
+ builder::{BuildConfig, Builder, BundlePadding, PcztResult},
fees::zip317,
};
#[cfg(feature = "multi_coins")]
@@ -1220,8 +1253,7 @@ pub(crate) mod legacy_test_support {
.unwrap()
.default_address();
let input_sk = account.derive_external_secret_key(address_index).unwrap();
- let secp = Secp256k1::signing_only();
- let input_pubkey = input_sk.public_key(&secp);
+ let input_pubkey = input_sk.public_key(&bitcoin::secp256k1::Secp256k1::signing_only());
let recipient_account =
AccountPrivKey::from_seed(¶ms, &[8u8; 32], zip32::AccountId::ZERO).unwrap();
@@ -1230,7 +1262,10 @@ pub(crate) mod legacy_test_support {
.derive_external_ivk()
.unwrap()
.default_address();
- let transparent_recipient = recipient.to_zcash_address(params.network_type()).encode();
+ let transparent_recipient =
+ zcash_vendor::zcash_keys::address::Receiver::Transparent(recipient)
+ .to_zcash_address(params.network_type())
+ .encode();
let coin = transparent::TxOut::new(
Zatoshis::const_from_u64(1_000_000),
@@ -1243,7 +1278,8 @@ pub(crate) mod legacy_test_support {
sapling_anchor: None,
orchard_anchor,
ironwood_anchor: None,
- orchard_pool_bundle_type: orchard::builder::BundleType::DEFAULT,
+ orchard_padding: BundlePadding::DEFAULT,
+ ironwood_padding: BundlePadding::DEFAULT,
},
);
builder
@@ -1258,7 +1294,7 @@ pub(crate) mod legacy_test_support {
.unwrap();
let PcztResult { pczt_parts, .. } = builder
- .build_for_pczt(OsRng, &zip317::FeeRule::standard())
+ .build_for_pczt(DeviceRng, &zip317::FeeRule::standard())
.unwrap();
let seed_fingerprint = calculate_seed_fingerprint(&seed).unwrap();
let input_pubkey = input_pubkey.serialize();
### rust/apps/zcash/src/pczt/parse.rs
@@ -30,7 +30,7 @@ use zcash_vendor::orchard::{
#[cfg(feature = "cypherpunk")]
use zcash_vendor::{
zcash_address::{
- unified::{self, Encoding, Receiver},
+ unified::{self, Encoding, Receiver, Revision, Uitem},
ConversionError, TryFromAddress,
},
zcash_keys::keys::UnifiedFullViewingKey,
@@ -652,7 +652,7 @@ impl WalletKeys {
let external_ovk = fvk.to_ovk(zcash_vendor::zip32::Scope::External).clone();
let internal_ovk = fvk.to_ovk(zcash_vendor::zip32::Scope::Internal).clone();
let transparent_internal_ovk = ufvk
- .transparent()
+ .p2pkh()
.map(|k| orchard::keys::OutgoingViewingKey::from(k.internal_ovk().as_bytes()));
Ok(Self {
external_ivk,
@@ -728,9 +728,12 @@ pub(crate) fn parse_orchard_output<P: consensus::Parameters>(
"recipient is not match with address in decoded note".to_string(),
));
}
- let ua = unified::Address::try_from_items(vec![Receiver::Orchard(
- address.to_raw_address_bytes(),
- )])
+ let ua = unified::Address::try_from_items(
+ Revision::R0,
+ vec![Uitem::Data(Receiver::Orchard(
+ address.to_raw_address_bytes(),
+ ))],
+ )
.unwrap()
.encode(¶ms.network_type());
let user_address = action.output().user_address();
### rust/apps/zcash/src/pczt/sign.rs
@@ -33,14 +33,11 @@ use zcash_vendor::{
#[cfg(feature = "cypherpunk")]
use {
blake2b_simd::Hash,
- core::{
- cell::{Cell, RefCell},
- mem::MaybeUninit,
- },
- rand_core::OsRng,
- zeroize::Zeroize,
+ core::cell::{Cell, RefCell},
};
+#[cfg(feature = "cypherpunk")]
+use crate::rng::DeviceRng;
use crate::{errors::ZcashError, version::KEYSTONE_FW_VERSION};
/// `global.proprietary` key stamped into every signed PCZT response.
@@ -121,69 +118,49 @@ fn reject_unsupported_pczt(pczt: &Pczt) -> Result<(), ZcashError> {
/// One cached spend authorizing key slot, scrubbed on replacement and drop.
///
-/// `SpendAuthorizingKey` bottoms out in reddsa's `Copy` `SigningKey`, which
-/// holds the secret ask scalar and has no `Zeroize` or `Drop` of its own, so a
-/// plainly-dropped cache would leave the scalar bytes behind in memory.
#[cfg(feature = "cypherpunk")]
-struct AskCacheSlot {
- account: Option<zcash_vendor::zip32::AccountId>,
- // `MaybeUninit` makes every post-scrub bit pattern valid without depending
- // on private Orchard/reddsa layout invariants. The slot invariant is that
- // this field is initialized exactly when `account` is `Some`.
- ask: MaybeUninit<orchard::keys::SpendAuthorizingKey>,
-}
+struct AskCacheSlot(
+ Option<(
+ zcash_vendor::zip32::AccountId,
+ orchard::keys::SpendAuthorizingKey,
+ )>,
+);
-// `MaybeUninit` deliberately suppresses the wrapped value's destructor. Fail
-// the build if a dependency bump gives either secret type drop glue; any change
-// to an indirect or owning representation requires a fresh zeroization audit
-// rather than silently retaining this type-specific strategy.
#[cfg(feature = "cypherpunk")]
-const _: () = assert!(!core::mem::needs_drop::<orchard::keys::SpendAuthorizingKey>());
-#[cfg(feature = "cypherpunk")]
-const _: () = assert!(!core::mem::needs_drop::<orchard::keys::SpendingKey>());
+#[allow(dead_code)]
+fn assert_orchard_keys_zeroize_on_drop() {
+ fn zeroize_on_drop<T: zeroize::ZeroizeOnDrop>() {}
+ zeroize_on_drop::<orchard::keys::SpendAuthorizingKey>();
+ zeroize_on_drop::<orchard::keys::SpendingKey>();
+}
#[cfg(feature = "cypherpunk")]
impl AskCacheSlot {
fn empty() -> Self {
- Self {
- account: None,
- ask: MaybeUninit::uninit(),
- }
+ Self(None)
}
fn get(
&self,
account: zcash_vendor::zip32::AccountId,
) -> Option<&orchard::keys::SpendAuthorizingKey> {
- if self.account == Some(account) {
- // SAFETY: `account` is only set to `Some` after `ask` is written.
- Some(unsafe { self.ask.assume_init_ref() })
- } else {
- None
+ match &self.0 {
+ Some((cached, ask)) if *cached == account => Some(ask),
+ _ => None,
}
}
fn replace(
&mut self,
account: zcash_vendor::zip32::AccountId,
ask: orchard::keys::SpendAuthorizingKey,
- ) -> &orchard::keys::SpendAuthorizingKey {
- self.account = None;
- self.ask.zeroize();
- self.ask.write(ask);
- self.account = Some(account);
-
- // SAFETY: the value was written immediately above, before `account`
- // was set to `Some`.
- unsafe { self.ask.assume_init_ref() }
+ ) {
+ self.0 = Some((account, ask));
}
-}
-#[cfg(feature = "cypherpunk")]
-impl Drop for AskCacheSlot {
- fn drop(&mut self) {
- self.account = None;
- self.ask.zeroize();
+ #[cfg(test)]
+ fn cached_account(&self) -> Option<zcash_vendor::zip32::AccountId> {
+ self.0.as_ref().map(|(account, _)| *account)
}
}
@@ -254,27 +231,18 @@ impl<'a> SeedSigner<'a> {
}
}
- /// Derives the spend authorizing key for `account_index` from the seed,
- /// scrubbing the intermediate spending key before returning.
fn derive_spend_authorizing_key(
&self,
account_index: zcash_vendor::zip32::AccountId,
) -> Result<orchard::keys::SpendAuthorizingKey, ZcashError> {
- let mut osk = MaybeUninit::new(
- orchard::keys::SpendingKey::from_zip32_seed(self.seed, 133, account_index).map_err(
- |e| {
- ZcashError::SigningError(format!(
- "failed to derive {} spending key: {e:?}",
- self.pool
- ))
- },
- )?,
- );
- // SAFETY: `osk` was initialized immediately above and is only scrubbed
- // after this borrow ends.
- let ask = orchard::keys::SpendAuthorizingKey::from(unsafe { osk.assume_init_ref() });
- osk.zeroize();
- Ok(ask)
+ let osk = orchard::keys::SpendingKey::from_zip32_seed(self.seed, 133, account_index)
+ .map_err(|e| {
+ ZcashError::SigningError(format!(
+ "failed to derive {} spending key: {e:?}",
+ self.pool
+ ))
+ })?;
+ Ok(orchard::keys::SpendAuthorizingKey::from(&osk))
}
/// Looks up (or derives and caches) the spend authorizing key for
@@ -381,7 +349,7 @@ impl PcztSigner for SeedSigner<'_> {
.sign(
hash.as_bytes().try_into().expect("sighash is 32 bytes"),
ask,
- OsRng,
+ DeviceRng,
)
.map_err(|e| {
ZcashError::SigningError(format!("failed to sign {} action: {e:?}", self.pool))
@@ -627,47 +595,35 @@ mod tests {
zip32,
};
- /// Extracts the ask scalar bytes via public API only: randomizing by zero
- /// returns `rsk = ask + 0 = ask`.
fn ask_scalar_bytes(ask: &orchard::keys::SpendAuthorizingKey) -> [u8; 32] {
- (&ask.randomize(&Fq::ZERO)).into()
+ let rsk = ask.randomize(&Fq::ZERO);
+ (&orchard::primitives::redpallas::VerificationKey::from(&rsk)).into()
}
#[test]
- fn test_ask_cache_slot_zeroizes_on_drop() {
+ fn test_ask_cache_slot_replaces_cached_key() {
let seed = [7u8; 32];
- let osk = orchard::keys::SpendingKey::from_zip32_seed(&seed, 133, zip32::AccountId::ZERO)
- .unwrap();
- let mut storage = MaybeUninit::<AskCacheSlot>::uninit();
- let slot = storage.write(AskCacheSlot::empty());
- slot.replace(
- zip32::AccountId::ZERO,
- orchard::keys::SpendAuthorizingKey::from(&osk),
- );
- assert_ne!(
- ask_scalar_bytes(slot.get(zip32::AccountId::ZERO).unwrap()),
- [0u8; 32],
- "a real ask must not start out zero"
- );
-
- // The outer `MaybeUninit` keeps the backing storage alive after the
- // slot itself is dropped.
- unsafe { core::ptr::drop_in_place(storage.as_mut_ptr()) };
-
- // SAFETY: `Drop` initialized every byte of the still-allocated
- // `MaybeUninit<SpendAuthorizingKey>` storage to zero. `addr_of!`
- // projects the dropped slot without reading it.
- let bytes = unsafe {
- let ask_storage = core::ptr::addr_of!((*storage.as_ptr()).ask);
- core::slice::from_raw_parts(
- ask_storage.cast::<u8>(),
- core::mem::size_of::<MaybeUninit<orchard::keys::SpendAuthorizingKey>>(),
+ let ask = |i: u32| {
+ let osk = orchard::keys::SpendingKey::from_zip32_seed(
+ &seed,
+ 133,
+ zip32::AccountId::try_from(i).unwrap(),
)
+ .unwrap();
+ orchard::keys::SpendAuthorizingKey::from(&osk)
};
- assert!(
- bytes.iter().all(|b| *b == 0),
- "cached ask storage must be fully scrubbed"
+ let mut slot = AskCacheSlot::empty();
+ let zero = zip32::AccountId::ZERO;
+ let one = zip32::AccountId::try_from(1).unwrap();
+
+ slot.replace(zero, ask(0));
+ assert_eq!(
+ ask_scalar_bytes(slot.get(zero).unwrap()),
+ ask_scalar_bytes(&ask(0))
);
+ slot.replace(one, ask(1));
+ assert!(slot.get(zero).is_none());
+ assert_eq!(slot.cached_account(), Some(one));
}
#[test]
@@ -699,7 +655,7 @@ mod tests {
}
// The slot holds exactly the most recently used account's key.
- assert_eq!(cache.0.borrow().account, Some(account(0)));
+ assert_eq!(cache.0.borrow().cached_account(), Some(account(0)));
}
#[test]
@@ -717,7 +673,10 @@ mod tests {
.expect("shared-cache PCZT should sign");
}
- assert_eq!(cache.0.borrow().account, Some(zip32::AccountId::ZERO));
+ assert_eq!(
+ cache.0.borrow().cached_account(),
+ Some(zip32::AccountId::ZERO)
+ );
}
#[test]
@@ -809,7 +768,11 @@ mod tests {
where
F: FnOnce(SignableInput) -> [u8; 32],
{
- self.0.set(Some(input.with_signable_input(index, hash)));
+ self.0.set(Some(
+ input
+ .with_signable_input(index, hash)
+ .expect("transparent input should be signable"),
+ ));
Ok(())
}
@@ -1035,7 +998,7 @@ mod tests {
.finish();
assert!(!dummy_indices.is_empty());
let pczt = zcash_vendor::pczt::roles::io_finalizer::IoFinalizer::new(pczt)
- .finalize_io()
+ .finalize_io(crate::rng::DeviceRng)
.unwrap();
let pczt = zcash_vendor::pczt::roles::verifier::Verifier::new(pczt)
.with_ironwood::<(), _>(|bundle| {
### rust/apps/zcash/src/rng.rs
@@ -0,0 +1,36 @@
+
+pub(crate) struct DeviceRng;
+
+impl rand_core_010::TryRng for DeviceRng {
+ type Error = core::convert::Infallible;
+
+ fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
+ Ok(rand_core::RngCore::next_u32(&mut rand_core::OsRng))
+ }
+
+ fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
+ Ok(rand_core::RngCore::next_u64(&mut rand_core::OsRng))
+ }
+
+ fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
+ rand_core::RngCore::fill_bytes(&mut rand_core::OsRng, dst);
+ Ok(())
+ }
+}
+
+impl rand_core_010::TryCryptoRng for DeviceRng {}
+
+#[cfg(test)]
+mod tests {
+ use super::DeviceRng;
+ use rand_core_010::Rng;
+
+ #[test]
+ fn fills_bytes() {
+ let mut a = [0u8; 32];
+ let mut b = [0u8; 32];
+ DeviceRng.fill_bytes(&mut a);
+ DeviceRng.fill_bytes(&mut b);
+ assert_ne!(a, b);
+ }
+}
### rust/keystore/Cargo.toml
@@ -23,6 +23,9 @@ rsa = { workspace = true }
zcash_vendor = { workspace = true }
zeroize = { workspace = true }
+[dev-dependencies]
+rand_chacha_010 = { package = "rand_chacha", version = "0.10" }
+
[features]
default = ["std", "multi_coins"]
std = []
### rust/keystore/src/algorithms/zcash/mod.rs
@@ -40,7 +40,8 @@ pub fn derive_ufvk<P: consensus::Parameters>(
let usk = UnifiedSpendingKey::from_seed(params, seed, account_index)
.map_err(|e| KeystoreError::DerivationError(e.to_string()))?;
let ufvk = usk.to_unified_full_viewing_key();
- Ok(ufvk.encode(params))
+ ufvk.encode(params)
+ .map_err(|e| KeystoreError::DerivationError(e.to_string()))
}
_ => Err(KeystoreError::DerivationError(format!(
"invalid account path: {account_path}"
@@ -75,8 +76,8 @@ mod orchard_tests {
use zcash_vendor::pasta_curves::group::ff::PrimeField;
use hex;
- use rand_chacha::rand_core::SeedableRng;
- use rand_chacha::ChaCha8Rng;
+ use rand_chacha_010::rand_core::SeedableRng;
+ use rand_chacha_010::ChaCha8Rng;
extern crate std;
@@ -101,7 +102,7 @@ mod orchard_tests {
assert!(!orchard_bytes.is_empty());
// Verify UFVK can be encoded to string format
- let encoded_ufvk = ufvk.encode(&MAIN_NETWORK);
+ let encoded_ufvk = ufvk.encode(&MAIN_NETWORK).unwrap();
assert!(!encoded_ufvk.is_empty());
assert!(encoded_ufvk.starts_with("uview"));
@@ -125,7 +126,7 @@ mod orchard_tests {
#[test]
fn test_orchard_signing() {
let rng_seed = [0u8; 32];
- let rng: ChaCha8Rng = ChaCha8Rng::from_seed(rng_seed);
+ let mut rng: ChaCha8Rng = ChaCha8Rng::from_seed(rng_seed);
let seed: std::vec::Vec<u8> =
hex::decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
.unwrap();
@@ -144,7 +145,7 @@ mod orchard_tests {
// randm.to_repr();
let msg = hex::decode("90b4ba49d75eb5df50b68e927dbd196a6f120ba8544664b116f6d74f0bc3812c")
.unwrap();
- let sig = osak.randomize(&randm).sign(rng, &msg);
+ let sig = osak.randomize(&randm).sign(&mut rng, &msg);
let bytes = <[u8; 64]>::from(&sig);
assert_eq!(hex::encode(bytes), "065ef82c33af0ed487e8932112e3359e93c5955d3eac6c3a1f9cb6dd24e19d8a2bba454a4274154dd4ad0c6bdb2022a646950ed521f3de18e99015f4821cbb10");
}
### rust/sim_qr_reader/Cargo.toml
@@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
screenshots = "0.8.5"
image = "0.24.7"
-quircs = "0.10.0"
+rxing = { version = "0.9.4", default-features = false, features = ["qrcode", "decoders", "encoding_rs"] }
anyhow = "1.0.75"
[target.'cfg(target_os = "macos")'.dependencies]
@@ -19,4 +19,7 @@ windows = { version = "0.58.0", features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_UI_HiDpi",
-]}
\ No newline at end of file
+]}
+
+[dev-dependencies]
+rxing = { version = "0.9.4", default-features = false, features = ["encoders"] }
### rust/sim_qr_reader/src/lib.rs
@@ -1,6 +1,5 @@
use anyhow::Result;
use image::DynamicImage;
-use quircs::{Code, Quirc};
use screenshots::Screen;
use std::thread;
use std::time::Duration;
@@ -47,14 +46,13 @@ where
{
let screens = Screen::all()?;
let screen = screens.first().ok_or(anyhow::anyhow!("No screen found"))?;
- let mut decoder = Quirc::default();
let scaling_factor = get_screen_scaling_factor();
println!("Screen scaling factor: {scaling_factor}");
let mut qr_area: Option<(i32, i32, u32, u32)> = None;
- let mut capture_and_decode =
+ let capture_and_decode =
|area: Option<(i32, i32, u32, u32)>| -> Result<(String, Option<(i32, i32, u32, u32)>)> {
let image = match area {
Some((x, y, width, height)) => {
@@ -69,21 +67,7 @@ where
}
None => screen.capture()?,
};
- let dynamic_image = DynamicImage::ImageRgba8(image);
- let mut codes = decoder.identify(
- dynamic_image.width() as usize,
- dynamic_image.height() as usize,
- &dynamic_image.to_luma8(),
- );
-
- if let Some(Ok(code)) = codes.next() {
- let decoded = code.decode()?;
- let content = String::from_utf8(decoded.payload)?;
- let new_area = Some(get_qr_area(&code, &dynamic_image));
- Ok((content, new_area))
- } else {
- Err(anyhow::anyhow!("No QR code found on screen"))
- }
+ decode_image(&DynamicImage::ImageRgba8(image))
};
let interval = Duration::from_millis(100);
@@ -116,21 +100,99 @@ where
Ok(())
}
-fn get_qr_area(code: &Code, image: &DynamicImage) -> (i32, i32, u32, u32) {
- let points = code.corners;
- let min_x = points.iter().map(|p| p.x).min().unwrap();
- let min_y = points.iter().map(|p| p.y).min().unwrap();
- let max_x = points.iter().map(|p| p.x).max().unwrap();
- let max_y = points.iter().map(|p| p.y).max().unwrap();
+type ScanArea = (i32, i32, u32, u32);
+
+fn decode_image(image: &DynamicImage) -> Result<(String, Option<ScanArea>)> {
+ let gray = image.to_luma8();
+ let result = rxing::helpers::detect_in_luma_slice(
+ gray.as_raw(),
+ gray.width(),
+ gray.height(),
+ Some(rxing::BarcodeFormat::QR_CODE),
+ )
+ .map_err(|error| anyhow::anyhow!("No QR code decoded: {error}"))?;
+ let area = get_qr_area(result.getPoints(), image.width(), image.height());
+ Ok((result.getText().to_owned(), area))
+}
+
+fn get_qr_area(points: &[rxing::Point], width: u32, height: u32) -> Option<ScanArea> {
+ if points.len() < 3 || points.iter().any(|p| !p.x.is_finite() || !p.y.is_finite()) {
+ return None;
+ }
+ let min_x = points.iter().map(|p| p.x).fold(f32::INFINITY, f32::min);
+ let min_y = points.iter().map(|p| p.y).fold(f32::INFINITY, f32::min);
+ let max_x = points.iter().map(|p| p.x).fold(f32::NEG_INFINITY, f32::max);
+ let max_y = points.iter().map(|p| p.y).fold(f32::NEG_INFINITY, f32::max);
+
+ let margin = ((max_x - min_x).max(max_y - min_y) * 0.6).max(10.0);
+ let x = (min_x - margin).floor().clamp(0.0, width as f32) as u32;
+ let y = (min_y - margin).floor().clamp(0.0, height as f32) as u32;
+ let right = (max_x + margin).ceil().clamp(0.0, width as f32) as u32;
+ let bottom = (max_y + margin).ceil().clamp(0.0, height as f32) as u32;
+ if right <= x || bottom <= y {
+ return None;
+ }
+ Some((x as i32, y as i32, right - x, bottom - y))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use image::{GrayImage, Luma};
+ use rxing::{qrcode::QRCodeWriter, BarcodeFormat, Writer};
+
+ fn qr_image(content: &str) -> DynamicImage {
+ let matrix = QRCodeWriter
+ .encode(content, &BarcodeFormat::QR_CODE, 600, 600)
+ .unwrap();
+ DynamicImage::ImageLuma8(GrayImage::from_fn(600, 600, |x, y| {
+ Luma([if matrix.get(x, y) { 0 } else { 255 }])
+ }))
+ }
- let width = (max_x - min_x) as u32;
- let height = (max_y - min_y) as u32;
+ #[test]
+ fn dense_qr_decodes_with_cached_crop() {
+ let content = format!("ur:bytes/{}", "abcdef0123456789".repeat(50));
+ let image = qr_image(&content);
+ let (decoded, area) = decode_image(&image).unwrap();
+ assert_eq!(decoded, content);
+ let (x, y, width, height) = area.unwrap();
+ let crop = image.crop_imm(x as u32, y as u32, width, height);
+ assert_eq!(decode_image(&crop).unwrap().0, content);
+ }
- let margin = 10;
- let x = (min_x - margin).max(0);
- let y = (min_y - margin).max(0);
- let width = (width + 2 * margin as u32).min(image.width() - x as u32);
- let height = (height + 2 * margin as u32).min(image.height() - y as u32);
+ #[test]
+ fn small_qr_near_screen_edge_retains_decodable_capture_area() {
+ let content = "screen QR regression";
+ let qr = qr_image(content)
+ .resize_exact(180, 180, image::imageops::FilterType::Nearest)
+ .to_luma8();
+ let mut screen = GrayImage::from_pixel(1200, 800, Luma([255]));
+ image::imageops::replace(&mut screen, &qr, 1000, 10);
+ let image = DynamicImage::ImageLuma8(screen);
+ let (decoded, area) = decode_image(&image).unwrap();
+ assert_eq!(decoded, content);
+ let (x, y, width, height) = area.unwrap();
+ assert!(width < image.width() && height < image.height());
+ let crop = image.crop_imm(x as u32, y as u32, width, height);
+ assert_eq!(decode_image(&crop).unwrap().0, content);
+ }
- (x, y, width, height)
+ #[test]
+ fn blank_image_is_not_a_qr_code() {
+ let image = DynamicImage::ImageLuma8(GrayImage::from_pixel(320, 240, Luma([255])));
+ assert!(decode_image(&image).is_err());
+ }
+
+ #[test]
+ #[ignore = "requires a local screenshot via SIM_QR_TEST_IMAGE"]
+ fn screenshot_regression() {
+ let image = image::open(std::env::var("SIM_QR_TEST_IMAGE").unwrap()).unwrap();
+ let (content, area) = decode_image(&image).unwrap();
+ assert!(!content.is_empty());
+ if let Some((x, y, width, height)) = area {
+ let crop = image.crop_imm(x as u32, y as u32, width, height);
+ assert_eq!(decode_image(&crop).unwrap().0, content);
+ }
+ }
}
### rust/zcash_vendor/Cargo.toml
@@ -10,19 +10,19 @@ bech32 = { workspace = true }
rand_chacha = { version = "0.3.1", default-features = false }
sha2 = { version = "0.10.6", default-features = false, features = ["oid"] }
# zcash
-reddsa = { version = "0.5.1", default-features = false, features = ["alloc"] }
+reddsa = { version = "0.6", default-features = false, features = ["alloc"] }
blake2b_simd = { workspace = true }
-ff = { version = "0.13.0", default-features = false, features = [
+ff = { version = "0.14", default-features = false, features = [
"alloc",
"bits",
] }
-pasta_curves = { version = "0.5.1", default-features = false, features = [
+pasta_curves = { version = "0.6", default-features = false, features = [
"alloc",
"bits",
] }
-sinsemilla = "0.1"
+sinsemilla = "0.2"
subtle = { version = "2.6", default-features = false }
-group = { version = "0.13.0" }
+group = { version = "0.14" }
fpe = { version = "0.6", default-features = false, features = ["alloc"] }
f4jumble = { version = "0.1.1", default-features = false, features = ["alloc"] }
byteorder = { version = "1", default-features = false }
@@ -41,21 +41,21 @@ chacha20poly1305 = { version = "0.10.1", default-features = false, features = [
] }
postcard = { version = "1.0.3", features = ["alloc"] }
getset = { version = "0.1.3" }
-orchard = { version = "0.15.1", default-features = false, optional = true }
-pczt = { version = "0.8.0-rc.1", default-features = false }
+orchard = { version = "0.16", default-features = false, features = ["zeroize"], optional = true }
+pczt = { version = "=0.10.0-keystone.0", default-features = false }
serde = { workspace = true }
serde_with = { version = "3.11.0", features = [
"alloc",
"macros",
], default-features = false }
-transparent = { package = "zcash_transparent", version = "0.9.0", default-features = false, features = [
+transparent = { package = "zcash_transparent", version = "=0.11.0-keystone.0", default-features = false, features = [
"transparent-inputs",
] }
-zcash_address = { version = "0.13.0", default-features = false }
-zcash_encoding = { version = "0.4", default-features = false }
-zcash_keys = { version = "0.15.0", default-features = false }
-zcash_protocol = { version = "0.10.0", default-features = false }
-zip32 = { version = "0.2", default-features = false }
+zcash_address = { version = "0.14", default-features = false }
+zcash_encoding = { version = "0.5", default-features = false }
+zcash_keys = { version = "=0.17.0-keystone.0", default-features = false }
+zcash_protocol = { version = "0.11", default-features = false }
+zip32 = { version = "0.3", default-features = false, features = ["zeroize"] }
rust_tools = { workspace = true }
#zcash end
@@ -65,11 +65,11 @@ unexpected_cfgs = { level = "warn", check-cfg = [
] }
[dev-dependencies]
-transparent = { package = "zcash_transparent", version = "0.9.0", default-features = false, features = [
+transparent = { package = "zcash_transparent", version = "=0.11.0-keystone.0", default-features = false, features = [
"transparent-inputs",
"test-dependencies",
] }
-incrementalmerkletree-testing = { version = "0.3" }
+incrementalmerkletree-testing = { version = "0.4" }
[features]
### rust/zcash_vendor/src/lib.rs
@@ -9,6 +9,7 @@ pub use orchard;
pub use pasta_curves;
pub use pczt;
pub use ripemd;
+pub use secp256k1;
pub use sha2;
pub use transparent;
pub use zcash_address;
### src/config/legacy_web_update_pad.c
@@ -3,7 +3,7 @@
#ifdef WEB3_VERSION
#ifndef LEGACY_USB_PAD_LEN
-#define LEGACY_USB_PAD_LEN 2U
+#define LEGACY_USB_PAD_LEN 1U
#endif
#endif
### src/config/version.h
@@ -7,7 +7,7 @@
#define SOFTWARE_VERSION_MAJOR 13
#define SOFTWARE_VERSION_MAJOR_OFFSET 10
#define SOFTWARE_VERSION_MINOR 2
-#define SOFTWARE_VERSION_BUILD 0
+#define SOFTWARE_VERSION_BUILD 2
#define SOFTWARE_VERSION_BETA 0
#define SOFTWARE_VERSION (SOFTWARE_VERSION_MAJOR * 10000 + SOFTWARE_VERSION_MINOR * 100 + SOFTWARE_VERSION_BUILD)
#ifdef WEB3_VERSION
### src/ui/gui_analyze/gui_zcash_template.h
@@ -0,0 +1,6 @@
+#ifndef GUI_ZCASH_TEMPLATE_H
+#define GUI_ZCASH_TEMPLATE_H
+
+#define GUI_ZCASH_PAGE_TEMPLATE "{\"name\":\"zcash_page\",\"type\":\"custom_container\",\"pos\":[36,0],\"size\":[408,900],\"bg_color\":0,\"custom_show_func\":\"GuiZcashOverview\"}"
+
+#endif
### src/ui/gui_analyze/multi/cypherpunk/gui_cypherpunk_analyze.h
@@ -1,3 +1,4 @@
+#include "gui_zcash_template.h"
#ifdef CYPHERPUNK_VERSION
#ifndef COMPILE_SIMULATOR
#ifndef _GUI_CYPHERPUNK_ANALYZE_WIDGETS_H
@@ -6,7 +7,7 @@
#define GUI_ANALYZE_OBJ_SURPLUS \
{ \
REMAPVIEW_ZCASH, \
- "{\"name\":\"zcash_page\",\"type\":\"custom_container\",\"pos\":[36,0],\"size\":[408,900],\"bg_color\":0,\"custom_show_func\":\"GuiZcashOverview\"}", \
+ GUI_ZCASH_PAGE_TEMPLATE, \
GuiGetZcashGUIData, \
NULL, \
FreeZcashMemory, \
### src/ui/gui_analyze/multi/web3/gui_general_analyze.h
@@ -1,3 +1,4 @@
+#include "gui_zcash_template.h"
#ifndef _GUI_GENERAL_ANALYZE_WIDGETS_H
#define _GUI_GENERAL_ANALYZE_WIDGETS_H
@@ -199,7 +200,7 @@
},\
{ \
REMAPVIEW_ZCASH, \
- "{\"name\":\"zcash_page\",\"type\":\"custom_container\",\"pos\":[36,0],\"size\":[408,900],\"bg_color\":0,\"custom_show_func\":\"GuiZcashOverview\"}", \
+ GUI_ZCASH_PAGE_TEMPLATE, \
GuiGetZcashGUIData, \
NULL, \
FreeZcashMemory, \
### src/ui/gui_model/gui_model.c
@@ -1922,7 +1922,7 @@ static int32_t ModelCheckTransaction(const void *inData, uint32_t inDataLen)
g_checkResult->error_message != NULL ? g_checkResult->error_message : "");
}
GuiApiEmitSignal(SIG_HIDE_TRANSACTION_LOADING, NULL, 0);
- GuiApiEmitSignal(SIG_TRANSACTION_CHECK_FAIL, g_checkResult, sizeof(g_checkResult));
+ GuiApiEmitSignal(SIG_TRANSACTION_CHECK_FAIL, g_checkResult, sizeof(*g_checkResult));
}
return SUCCESS_CODE;
### src/ui/gui_widgets/gui_lock_widgets.c
@@ -58,7 +58,7 @@ static LOCK_SCREEN_PURPOSE_ENUM g_purpose = LOCK_SCREEN_PURPOSE_UNLOCK;
static PageWidget_t *g_pageWidget;
static lv_obj_t *g_LoadingView = NULL;
static lv_obj_t *g_verifyLoadingCont = NULL;
-static lv_timer_t *g_countDownTimer;
+static lv_timer_t *g_countDownTimer = NULL;
static int8_t g_countDown = 0;
static bool g_canDismissLoading = false;
static bool g_isShowLoading = false;
@@ -531,18 +531,27 @@ void GuiLockScreenUpdatePassCode(void)
#include "keystore.h"
#endif
+static void StopCountDownTimer(void)
+{
+ if (g_countDownTimer != NULL) {
+ lv_timer_del(g_countDownTimer);
+ g_countDownTimer = NULL;
+ }
+ g_countDown = 0;
+}
+
+static void CountDownLabelDelete(lv_event_t *e)
+{
+ StopCountDownTimer();
+}
+
static void CountDownTimerChangeLabelTextHandler(lv_timer_t *timer)
{
lv_obj_t *obj = (lv_obj_t *)timer->user_data;
++g_countDown;
if (g_countDown == 3) {
lv_label_set_text(obj, _("prepare_wallet_third_step"));
- if (g_countDownTimer != NULL) {
- g_countDown = 0;
- lv_timer_del(g_countDownTimer);
- g_countDownTimer = NULL;
- UNUSED(g_countDownTimer);
- }
+ StopCountDownTimer();
}
}
@@ -585,6 +594,7 @@ void GuiShowGenerateXPubLoading(void)
g_isShowLoading = true;
g_countDown = 0;
g_countDownTimer = lv_timer_create(CountDownTimerChangeLabelTextHandler, 1000, hintLabel);
+ lv_obj_add_event_cb(hintLabel, CountDownLabelDelete, LV_EVENT_DELETE, NULL);
}
void GuiHideGenerateXPubLoading(void)
### tools/ota_bin_restore/ota_bin_restore.py
@@ -1,180 +0,0 @@
-#!/usr/bin/env python3
-"""Restore a Keystone OTA image using bounded QuickLZ level-3 decoding.
-
-Usage: python3 ota_bin_restore.py <keystone3.bin> [uncompressed.bin]
-Uses only the Python standard library. The default output is uncompressed.bin
-next to the input. Input and output must be different files.
-
-Lengths and SHA-256 hashes are checked, but the OTA signature is NOT verified;
-this extraction tool does not establish firmware authenticity.
-"""
-
-import argparse
-import hashlib
-import os
-import struct
-import sys
-import tempfile
-from pathlib import Path
-
-MAX_IMAGE_SIZE = 64 * 1024 * 1024
-CHUNK_SIZE = 16384
-OTA_HEADER = struct.Struct(">8sII32s32sIII")
-
-
-class InvalidFirmware(ValueError):
- pass
-
-
-def chunk_header(source):
- if not source:
- raise InvalidFirmware("missing QuickLZ header")
- flags = source[0]
- header_size = 9 if flags & 2 else 3
- if len(source) < header_size:
- raise InvalidFirmware("truncated QuickLZ header")
- if (flags & 0xFC) != 0x4C:
- raise InvalidFirmware("unsupported QuickLZ flags (requires level 3, no streaming)")
- width = 4 if flags & 2 else 1
- compressed = int.from_bytes(source[1:1 + width], "little")
- decompressed = int.from_bytes(source[1 + width:header_size], "little")
- if not header_size < compressed <= len(source):
- raise InvalidFirmware("invalid QuickLZ compressed length")
- if not 0 < decompressed <= CHUNK_SIZE:
- raise InvalidFirmware("invalid QuickLZ decompressed length")
- if not (flags & 1) and compressed != header_size + decompressed:
- raise InvalidFirmware("uncompressed QuickLZ block length mismatch")
- return header_size, compressed, decompressed
-
-
-def decompress_chunk(chunk):
- header_size, compressed, expected = chunk_header(chunk)
- if compressed != len(chunk):
- raise InvalidFirmware("trailing data after QuickLZ chunk")
- if not (chunk[0] & 1):
- return bytes(chunk[header_size:])
- position = header_size
- control = 1
- output = bytearray()
-
- def read(width):
- nonlocal position
- if position + width > compressed:
- raise InvalidFirmware("truncated QuickLZ token")
- value = int.from_bytes(chunk[position:position + width], "little")
- position += width
- return value
-
- while len(output) < expected:
- if control == 1:
- control = read(4)
- if not (control & (1 << 31)):
- raise InvalidFirmware("invalid QuickLZ control word")
- match = control & 1
- control >>= 1
- if not match:
- output.append(read(1))
- continue
- first = read(1)
- if (first & 3) == 0:
- distance, length = first >> 2, 3
- elif (first & 2) == 0:
- value = first | (read(1) << 8)
- distance, length = value >> 2, 3
- elif (first & 1) == 0:
- value = first | (read(1) << 8)
- distance, length = value >> 6, ((value >> 2) & 15) + 3
- elif (first & 127) != 3:
- value = first | (read(2) << 8)
- distance, length = value >> 7, ((value >> 2) & 31) + 2
- else:
- value = first | (read(3) << 8)
- distance, length = value >> 15, ((value >> 7) & 255) + 3
- if not 3 <= distance <= len(output):
- raise InvalidFirmware("invalid QuickLZ back-reference")
- if len(output) + length > expected - 4:
- raise InvalidFirmware("QuickLZ match exceeds output boundary")
- for _ in range(length):
- output.append(output[-distance])
- if compressed != max(position, header_size + 9):
- raise InvalidFirmware("unexpected trailing QuickLZ payload")
- return bytes(output)
-
-
-def restore(content):
- if not 4 <= len(content) <= MAX_IMAGE_SIZE:
- raise InvalidFirmware("invalid OTA file size")
- header_size = struct.unpack_from("<I", content)[0]
- data_offset = 4 + header_size + 1
- if header_size < OTA_HEADER.size or data_offset >= len(content):
- raise InvalidFirmware("invalid OTA header length")
- (mark, compressed_size, original_size, compressed_hash, original_hash,
- encoding, unit, encryption) = OTA_HEADER.unpack_from(content, 4)
- if mark != b"~fwdata!":
- raise InvalidFirmware("invalid OTA magic")
- if (encoding, unit, encryption) != (1, CHUNK_SIZE, 0):
- raise InvalidFirmware("unsupported OTA encoding, chunk size or encryption")
- if content[data_offset - 1] != 0:
- raise InvalidFirmware("invalid OTA padding byte")
- if not 0 < original_size <= MAX_IMAGE_SIZE:
- raise InvalidFirmware("invalid OTA original size")
- data = memoryview(content)[data_offset:]
- if compressed_size != len(data):
- raise InvalidFirmware("OTA compressed size mismatch")
- if hashlib.sha256(data).digest() != compressed_hash:
- raise InvalidFirmware("OTA compressed hash mismatch")
- output = bytearray()
- offset = 0
- while offset < len(data):
- _, size, expected = chunk_header(data[offset:])
- if expected != min(CHUNK_SIZE, original_size - len(output)):
- raise InvalidFirmware("OTA chunk output size mismatch")
- output.extend(decompress_chunk(data[offset:offset + size]))
- offset += size
- if len(output) != original_size:
- raise InvalidFirmware("OTA original size mismatch")
- if hashlib.sha256(output).digest() != original_hash:
- raise InvalidFirmware("OTA original hash mismatch")
- return bytes(output)
-
-
-def restore_file(src, dst):
- src, dst = Path(src), Path(dst)
- if src.resolve() == dst.resolve() or (dst.exists() and os.path.samefile(src, dst)):
- raise InvalidFirmware("input and output must be different files")
- with src.open("rb") as source:
- content = source.read(MAX_IMAGE_SIZE + 1)
- restored = restore(content)
- temporary = None
- try:
- with tempfile.NamedTemporaryFile(
- dir=dst.parent, prefix=".ota-restore-", delete=False
- ) as out:
- temporary = out.name
- out.write(restored)
- out.flush()
- os.fsync(out.fileno())
- os.replace(temporary, dst)
- temporary = None
- finally:
- if temporary is not None:
- os.unlink(temporary)
-
-
-def main(argv=None):
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument("source", type=Path)
- parser.add_argument("destination", nargs="?", type=Path)
- args = parser.parse_args(argv)
- dst = (args.destination if args.destination is not None
- else args.source.with_name("uncompressed.bin"))
- try:
- restore_file(args.source, dst)
- except (InvalidFirmware, OSError) as error:
- print(f"error: {error}", file=sys.stderr)
- return 1
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
### tools/ota_bin_restore/quicklz_vectors.json
@@ -1,23 +0,0 @@
-{
- "source": "external/quicklz/quicklz.c, QuickLZ 1.5.0, level 3, streaming 0; generated with qlz_compress",
- "vectors": [
- {
- "name": "short",
- "size": 28,
- "sha256": "b90e09d6cc99aaa02c3e22084326917d8ee4bb02b479f69a1127b76dec971c25",
- "chunk_base64": "TREcCAAAgGFiY88BAGFiYyE="
- },
- {
- "name": "long",
- "size": 10000,
- "sha256": "83ed00fd4410b12c310f75982abda5672efbdc8dbcdab4cf6578efcc7987f5f5",
- "chunk_base64": "T+wAAAAQJwAAAAAAgEtleXN0b25lIGZpcm13YXJlIAABAgMEBQYHCAkKCwwAAPj/DQ4PEBESExQVFhcYGRobHB0eHwN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAP///4cDfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQADfhkAA34ZAAN+GQAbHB0eAAAAgB8="
- },
- {
- "name": "repeated",
- "size": 16384,
- "sha256": "7f7d7f621694cdc133548e9a3eb50d7f1dfdf6abd00bef37d46d18bc7967a433",
- "chunk_base64": "T2MBAAAAQAAAqKqqqlpaWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFpVVVXVA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAKqqqqpaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaVVVV1QP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQBaA/4BAFoD/gEAWgP+AQAqAACAWgP+AQBaA/4BAFoD+wEAWlpaWg=="
- }
- ]
-}
### tools/ota_bin_restore/requirements.txt
[binary or diff unavailable]
### tools/ota_bin_restore/test_ota_bin_restore.py
@@ -1,207 +0,0 @@
-import base64
-import hashlib
-import json
-import os
-from pathlib import Path
-import random
-import struct
-import subprocess
-import sys
-import tempfile
-import unittest
-from unittest.mock import patch
-
-import ota_bin_restore as ota
-
-
-def raw_chunk(data, long_header=False):
- if long_header or len(data) + 3 > 255:
- return b'\x4e' + struct.pack('<II', len(data) + 9, len(data)) + data
- return bytes([0x4c, len(data) + 3, len(data)]) + data
-
-
-def compressed_chunk(payload, output_size):
- payload = payload.ljust(9, b'\0')
- return b'\x4f' + struct.pack('<II', len(payload) + 9, output_size) + payload
-
-
-def package(raw, chunks=None, **overrides):
- if chunks is None:
- chunks = b''.join(raw_chunk(raw[i:i + ota.CHUNK_SIZE])
- for i in range(0, len(raw), ota.CHUNK_SIZE))
- fields = dict(mark=b'~fwdata!', size=len(chunks), original_size=len(raw),
- compressed_hash=hashlib.sha256(chunks).digest(),
- original_hash=hashlib.sha256(raw).digest(), encoding=1,
- unit=ota.CHUNK_SIZE, encryption=0)
- fields.update(overrides)
- header = ota.OTA_HEADER.pack(*fields.values())
- return struct.pack('<I', len(header)) + header + b'\0' + chunks
-
-
-class DecodeTests(unittest.TestCase):
- def test_independent_reference_vectors(self):
- vectors = json.loads(Path(__file__).with_name('quicklz_vectors.json').read_text())
- for vector in vectors['vectors']:
- with self.subTest(vector=vector['name']):
- chunk = base64.b64decode(vector['chunk_base64'])
- decoded = ota.decompress_chunk(chunk)
- self.assertEqual(len(decoded), vector['size'])
- self.assertEqual(hashlib.sha256(decoded).hexdigest(), vector['sha256'])
- self.assertEqual(ota.restore(package(decoded, chunk)), decoded)
-
- def test_raw_blocks_and_multiple_chunks(self):
- for raw in [b'x', bytes(range(100)), bytes(range(256)) * 130]:
- self.assertEqual(ota.restore(package(raw)), raw)
- self.assertEqual(ota.decompress_chunk(raw_chunk(b'x', True)), b'x')
-
- def test_all_five_back_reference_forms_and_overlap(self):
- tokens = [(bytes([3 << 2]), 3),
- (struct.pack('<H', (3 << 2) | 1), 3),
- (struct.pack('<H', (3 << 6) | ((6 - 3) << 2) | 2), 6),
- (((3 << 7) | ((10 - 2) << 2) | 3).to_bytes(3, 'little'), 10),
- (struct.pack('<I', (3 << 15) | ((40 - 3) << 7) | 3), 40)]
- for token, length in tokens:
- expected = b'abc' + (b'abc' * 20)[:length] + b'WXYZ'
- payload = struct.pack('<I', 0x80000008) + b'abc' + token + b'WXYZ'
- self.assertEqual(ota.decompress_chunk(compressed_chunk(payload, len(expected))), expected)
-
- def test_bad_chunk_headers(self):
- cases = [b'', b'\x4c', b'\x4c\x03', b'\x4f' + b'\0' * 7,
- b'\x4c\x00\x01', b'\x4c\x02\x01', b'\x4c\x09\x01x',
- b'\x4c\x04\x00x', b'\x4c\x05\x01xy',
- b'\x4f' + struct.pack('<II', 10, ota.CHUNK_SIZE + 1) + b'x']
- for flags in [0, 0x48, 0x5c, 0xcc]:
- cases.append(bytes([flags, 4, 1]) + b'x')
- for case in cases:
- with self.subTest(case=case.hex()), self.assertRaises(ota.InvalidFirmware):
- ota.decompress_chunk(case)
-
- def test_invalid_back_reference_and_output_overrun(self):
- for token, expected in [(b'\0', 20), (b'\x10', 20),
- (struct.pack('<I', (3 << 15) | (250 << 7) | 3), 20)]:
- payload = struct.pack('<I', 0x80000008) + b'abc' + token + b'WXYZ'
- with self.assertRaises(ota.InvalidFirmware):
- ota.decompress_chunk(compressed_chunk(payload, expected))
-
- def test_truncated_tokens_controls_and_trailing_payload(self):
- cases = [compressed_chunk(b'\0' * 9, 10),
- compressed_chunk(struct.pack('<I', 0x80000000) + b'12345', 20),
- compressed_chunk(struct.pack('<I', 0x80000000) + b'12345EXTRA', 5)]
- cases.append(b'\x4f' + struct.pack('<II', 17, 20)
- + struct.pack('<I', 0x80000008) + b'abc\x03')
- for case in cases:
- with self.assertRaises(ota.InvalidFirmware):
- ota.decompress_chunk(case)
-
- def test_every_truncated_ota_is_rejected(self):
- data = package(b'firmware')
- for end in range(len(data)):
- with self.subTest(end=end), self.assertRaises(ota.InvalidFirmware):
- ota.restore(data[:end])
-
- def test_ota_header_bounds(self):
- data = package(b'firmware')
- for size in [0, 91, len(data), 0xFFFFFFFF]:
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore(struct.pack('<I', size) + data[4:])
- for changes in [dict(mark=b'invalid!'), dict(encoding=0), dict(unit=0),
- dict(encryption=1), dict(size=1), dict(original_size=0),
- dict(original_size=ota.MAX_IMAGE_SIZE + 1),
- dict(compressed_hash=b'\0' * 32), dict(original_hash=b'\0' * 32)]:
- with self.subTest(changes=changes), self.assertRaises(ota.InvalidFirmware):
- ota.restore(package(b'firmware', **changes))
- damaged = bytearray(data)
- damaged[4 + ota.OTA_HEADER.size] = 1
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore(damaged)
-
- def test_extra_or_missing_chunk_and_total_output_bounds(self):
- raw = b'x' * ota.CHUNK_SIZE + b'y'
- for chunks in [raw_chunk(raw[:ota.CHUNK_SIZE]),
- raw_chunk(raw[:ota.CHUNK_SIZE]) + raw_chunk(b'yz'),
- raw_chunk(b'x') + raw_chunk(b'y')]:
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore(package(raw, chunks))
- data = package(b'firmware')
- with patch.object(ota, 'MAX_IMAGE_SIZE', len(data) - 1):
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore(data)
-
- def test_mutated_chunks_are_bounded(self):
- rng = random.Random(71)
- vectors = json.loads(Path(__file__).with_name('quicklz_vectors.json').read_text())
- original = base64.b64decode(vectors['vectors'][1]['chunk_base64'])
- for _ in range(500):
- chunk = bytearray(original)
- for _ in range(rng.randrange(1, 5)):
- chunk[rng.randrange(len(chunk))] = rng.randrange(256)
- try:
- decoded = ota.decompress_chunk(chunk)
- except ota.InvalidFirmware:
- continue
- self.assertLessEqual(len(decoded), ota.CHUNK_SIZE)
-
-
-class FileTests(unittest.TestCase):
- def setUp(self):
- self.temp = tempfile.TemporaryDirectory()
- self.addCleanup(self.temp.cleanup)
- self.root = Path(self.temp.name)
- self.src = self.root / 'keystone3.bin'
- self.dst = self.root / 'uncompressed.bin'
- self.image = package(b'firmware')
- self.src.write_bytes(self.image)
-
- def test_success_and_existing_destination(self):
- self.dst.write_bytes(b'old')
- ota.restore_file(self.src, self.dst)
- self.assertEqual(self.dst.read_bytes(), b'firmware')
- self.assertEqual(self.src.read_bytes(), self.image)
-
- def test_same_path_symlink_and_hardlink_preserve_input(self):
- for alias in [self.src, self.root / 'link', self.root / 'hardlink']:
- if alias.name == 'link':
- alias.symlink_to(self.src)
- elif alias.name == 'hardlink':
- os.link(self.src, alias)
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore_file(self.src, alias)
- self.assertEqual(self.src.read_bytes(), self.image)
-
- def test_default_output_cannot_overwrite_input(self):
- self.dst.write_bytes(self.image)
- result = subprocess.run([sys.executable, str(Path(ota.__file__)), str(self.dst)], capture_output=True)
- self.assertEqual(result.returncode, 1)
- self.assertIn(b'different files', result.stderr)
- self.assertEqual(self.dst.read_bytes(), self.image)
-
- def test_corruption_leaves_destination_untouched(self):
- self.dst.write_bytes(b'old')
- self.src.write_bytes(b'bad')
- with self.assertRaises(ota.InvalidFirmware):
- ota.restore_file(self.src, self.dst)
- self.assertEqual(self.dst.read_bytes(), b'old')
- self.assertEqual(list(self.root.glob('.ota-restore-*')), [])
-
- def test_failed_flush_or_replace_leaves_destination_untouched(self):
- for target in ['fsync', 'replace']:
- self.dst.write_bytes(b'old')
- with patch.object(ota.os, target, side_effect=OSError('disk failure')):
- with self.assertRaises(OSError):
- ota.restore_file(self.src, self.dst)
- self.assertEqual(self.dst.read_bytes(), b'old')
- self.assertEqual(list(self.root.glob('.ota-restore-*')), [])
-
- def test_cli_default_output_and_invalid_arguments(self):
- command = [sys.executable, str(Path(ota.__file__))]
- result = subprocess.run(command + [str(self.src)], capture_output=True)
- self.assertEqual(result.returncode, 0, result.stderr)
- self.assertEqual(self.dst.read_bytes(), b'firmware')
- self.assertEqual(subprocess.run(command, capture_output=True).returncode, 2)
- result = subprocess.run(command + [str(self.root / 'missing')], capture_output=True)
- self.assertEqual(result.returncode, 1)
- self.assertNotIn(b'Traceback', result.stderr)
-
-
-if __name__ == '__main__':
- unittest.main()
### ui_simulator/simulator_model.h
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include "err_code.h"
#include "qrdecode_task.h"
+#include "gui_zcash_template.h"
#include "gui_lock_device_widgets.h"
extern bool g_fingerUnlockDeviceFlag;
extern bool g_fingerSingTransitionsFlag;
@@ -55,7 +56,7 @@ extern bool g_reboot;
#define GUI_ANALYZE_OBJ_SURPLUS \
{ \
REMAPVIEW_ZCASH, \
- PC_SIMULATOR_PATH "/page_zcash.json", \
+ GUI_ZCASH_PAGE_TEMPLATE, \
GuiGetZcashGUIData, \
NULL, \
FreeZcashMemory, \
@@ -271,7 +272,7 @@ extern bool g_reboot;
},\
{ \
REMAPVIEW_ZCASH, \
- PC_SIMULATOR_PATH "/page_zcash.json", \
+ GUI_ZCASH_PAGE_TEMPLATE, \
GuiGetZcashGUIData, \
NULL, \
FreeZcashMemory, \Why this scored 45/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.