diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 523cb321..59317e68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ on: # (THREAT_MODEL.md §6.6 T-SC3). permissions: {} +env: + RUSTFLAGS: "" + CARGO_INCREMENTAL: "0" + jobs: check: name: Cargo check & clippy @@ -20,10 +24,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" components: clippy - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 @@ -65,10 +69,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 @@ -168,10 +172,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 @@ -195,10 +199,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 @@ -220,7 +224,7 @@ jobs: # Runs the local fake-lightwalletd tests. Real-node cases remain ignored # unless a provisioned regtest harness is explicitly supplied. - name: cargo test (local argos-network integration) - run: cargo test -p argos-core --features argos-network --test regtest_integration + run: cargo test -p argos-core --features argos-network --locked --test regtest_integration --test nu7_readiness - name: Install Node for GUI interaction tests uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 @@ -238,6 +242,63 @@ jobs: npx playwright install --with-deps chromium npm run test:layout + nu7-node-tests: + name: NU7 block and proxy boundary + runs-on: ubuntu-latest + timeout-minutes: 45 + permissions: + contents: read + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + with: + persist-credentials: false + + # This action has no release tag for the reviewed 2026-03-27 commit. + # Keep the immutable pin; the requested Rust version is explicit below. + - name: Install Rust 1.89 + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 + with: + toolchain: "1.89" + + # Reviewed 2026-03-12 commit; the moving v2 tag has since advanced. + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 + + - name: Install protoc + timeout-minutes: 10 + run: bash scripts/install-ci-apt-deps.sh protobuf-compiler + + # Independent volumes and a short chain qualify branch/block/proxy + # compatibility. Funded supported sweep/PCZT remains a release gate. + - name: Start independent NU7 boundary nodes + working-directory: tests/regtest + run: | + docker compose --profile nu7-fast up -d zebrad-nu7-fast lightwalletd-nu7-fast + for i in $(seq 1 60); do + if curl -sf --max-time 2 -H 'content-type: application/json' \ + --data '{"jsonrpc":"2.0","id":"ci","method":"getblockcount","params":[]}' \ + http://127.0.0.1:18262/ >/dev/null; then + echo "NU7 node accepted RPC after ${i}s" + ARGOS_NU7_PROFILE=fast ./nu7.sh before + exit 0 + fi + sleep 1 + done + echo "NU7 node did not accept RPC within the startup budget" + exit 1 + + - name: NU7 actual block and proxy boundary tests + run: | + set -o pipefail + cargo test -p argos-core --features argos-network --locked --test nu7_readiness \ + private_ -- --ignored --nocapture --test-threads=1 2>&1 | tee nu7-node-test.log + passed=$(grep -cE '^test .* \.\.\. ok$|^ok$' nu7-node-test.log || true) + test "$passed" -eq 2 + + - name: Node logs on failure + if: failure() + working-directory: tests/regtest + run: docker compose --profile nu7-fast logs --tail=200 zebrad-nu7-fast lightwalletd-nu7-fast + cargo-deny: name: Cargo deny (advisories + bans + licenses + sources) runs-on: ubuntu-latest @@ -263,10 +324,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 @@ -275,6 +336,6 @@ jobs: # `--locked` uses the committed imports.lock; no network for fresh # import resolution. Refreshing the imports is a deliberate local - # action (`cargo vet update-imports`) so an upstream rewrite of any + # action (`cargo vet regenerate imports`) so an upstream rewrite of any # imported audits.toml cannot silently change our trust set. - run: cargo vet --locked diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98669aba..df61f3d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,6 +41,10 @@ on: # third-party Action token-exfiltration risk (THREAT_MODEL.md §6.6 T-SC3). permissions: {} +env: + RUSTFLAGS: "" + CARGO_INCREMENTAL: "0" + jobs: build-linux: runs-on: ubuntu-22.04 @@ -54,10 +58,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" # No Swatinem/rust-cache in release builds: a poisoned cache from a PR # run feeding a signed release tag is a worse failure mode than a slow @@ -124,10 +128,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" # Both arches are needed: the universal-apple-darwin bundle lipo-joins # an aarch64 and an x86_64 build into one fat binary. targets: aarch64-apple-darwin, x86_64-apple-darwin @@ -194,10 +198,10 @@ jobs: with: persist-credentials: false - - name: Install Rust 1.88 + - name: Install Rust 1.89 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master@2026-05-27 with: - toolchain: "1.88" + toolchain: "1.89" # No Swatinem/rust-cache in release builds — see Linux job above. diff --git a/CLAUDE.md b/CLAUDE.md index 108d3ce4..fa51e79f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -125,7 +125,7 @@ file produces, so the scan and sweep paths cannot tell the two apart. CLI `--sapling-key-file` (a file, never a flag — a spending key in argv lands in shell history and `ps`); GUI a paste field on the wallet screen. Both are combinable with a wallet file and deduplicate against it. The human-readable prefixes come from -`zcash_protocol::constants`, so there is no unverifiable-constant caveat — +`zcash_keys::constants`, so there is no unverifiable-constant caveat — but the test pinning them to the ZIP-32 literals stays, so an upstream rename cannot silently move Argos off the prefix users hold. Viewing keys (`zxviews…`) are deliberately refused: they would show a balance that cannot @@ -157,8 +157,8 @@ direct recovery path and may produce a separate transaction. Routing (`is_transparent_only` in the CLI): a seedless wallet with Sapling keys takes the imported-account path; one with only transparent keys takes -`transparent_recovery`, because ZIP-316 gives it no UFVK to anchor an -account to. +`transparent_recovery`, because the existing ZIP-316 Revision 0 account format gives it no +UFVK to anchor an account to. Spending imported Sapling does **not** need an upstream change: PCZT is account-id driven and `Signer::sign_sapling` takes a raw `ask`. Only the @@ -180,6 +180,18 @@ or `ps` (T-S6). Wired in `crates/zeck-cli/src/main.rs`; covered by `crates/zeck-cli/tests/wallet_file_cli.rs`, which runs the real binary against the golden fixtures. +### NU7 qualification + +The coordinated NU7 SDK requires Rust 1.89. Keep `RUSTFLAGS=''` and +`CARGO_INCREMENTAL=0` consistent across Cargo invocations. The ordinary +regtest schedule remains pre-NU7; `tests/regtest/zebrad-nu7*.toml` use +independent profiles and state. `nu7_readiness.rs` includes an actual old-SDK +SQLite migration fixture and two ignored live boundary tests. The fast chain +and empty fixtures do not qualify funded supported sweeps or imported Sapling +PCZT. See `docs/qualification/nu7-supported-recovery.md` for the release gate. +Never restore removed Sprout scan, spend, P2P or journal machinery when porting +historical tests or documentation. + ### Test seed (BIP-39 test vector, no real funds) `abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art` diff --git a/Cargo.lock b/Cargo.lock index 84ba833d..e873a01f 100644 --- a/Cargo.lock +++ b/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" @@ -18,6 +29,16 @@ 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.5", +] + [[package]] name = "aes" version = "0.8.4" @@ -25,11 +46,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", - "cipher", + "cipher 0.4.4", "cpufeatures 0.2.17", "zeroize", ] +[[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.0", +] + [[package]] name = "aho-corasick" version = "1.1.4" @@ -99,7 +131,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -110,7 +142,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -148,9 +180,11 @@ dependencies = [ "blake2b_simd", "keepawake", "libc", + "nonempty", "orchard", "pczt", "prost", + "rand 0.10.1", "rand_core 0.6.4", "rusqlite", "rustls", @@ -207,10 +241,10 @@ dependencies = [ name = "argos-wallet-import" version = "1.6.1" dependencies = [ - "aes", + "aes 0.8.4", "bip0039", "blake2b_simd", - "cbc", + "cbc 0.1.2", "crypto_secretbox", "sapling-crypto", "secp256k1", @@ -473,9 +507,9 @@ checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[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", @@ -483,11 +517,9 @@ dependencies = [ "crossbeam-channel", "ff", "group", - "lazy_static", "log", "num_cpus", - "pairing", - "rand_core 0.6.4", + "rand_core 0.10.0", "rayon", "subtle", ] @@ -511,16 +543,15 @@ dependencies = [ [[package]] name = "bip32" -version = "0.6.0-pre.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143f5327f23168716be068f8e1014ba2ea16a6c91e8777bc8927da7b51e1df1f" +checksum = "0271a2fe2a6f05231419e878b5f50152a5a6dbcc60c18855d924892ecc85a33a" dependencies = [ "bs58", - "hmac 0.13.0-pre.4", - "rand_core 0.6.4", - "ripemd 0.2.0-pre.4", + "hmac 0.13.0", + "ripemd 0.2.0", "secp256k1", - "sha2 0.11.0-pre.4", + "sha2 0.11.1", "subtle", "zeroize", ] @@ -600,9 +631,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.11.0-rc.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd016a0ddc7cb13661bf5576073ce07330a693f8608a1320b4e20561cc12cdc" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" dependencies = [ "hybrid-array", ] @@ -640,15 +671,17 @@ dependencies = [ [[package]] name = "bls12_381" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +checksum = "8dbf1ec3bf8807685f626f8232a3838e257ffa71c7d3a7bd716fa06fddf24600" dependencies = [ "ff", "group", + "once_cell", "pairing", - "rand_core 0.6.4", + "rand_core 0.10.0", "subtle", + "zeroize", ] [[package]] @@ -791,7 +824,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]] @@ -837,17 +879,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures 0.2.17", -] - [[package]] name = "chacha20" version = "0.10.2" @@ -855,21 +886,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", + "cipher 0.5.2", "cpufeatures 0.3.0", "rand_core 0.10.0", ] [[package]] name = "chacha20poly1305" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" dependencies = [ - "aead", - "chacha20 0.9.1", - "cipher", - "poly1305", - "zeroize", + "aead 0.6.1", + "chacha20", + "cipher 0.5.2", + "poly1305 0.9.1", ] [[package]] @@ -891,10 +922,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.7", - "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.5", +] + [[package]] name = "clap" version = "4.6.0" @@ -935,6 +977,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" +[[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" @@ -1049,6 +1097,12 @@ 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" @@ -1129,9 +1183,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", ] @@ -1142,10 +1196,10 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d6cf87adf719ddf43a805e92c6870a531aedda35ff640442cbaf8674e141e1" dependencies = [ - "aead", - "cipher", + "aead 0.5.2", + "cipher 0.4.4", "generic-array", - "poly1305", + "poly1305 0.8.0", "salsa20", "subtle", "zeroize", @@ -1207,13 +1261,22 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1" +[[package]] +name = "ctutils" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe3e9d21d39e6f39ff46e03d5b621424f88ee23d8a1672c6bfc9ccc7f2da4f6a" +dependencies = [ + "cmov", +] + [[package]] name = "daggy" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70def8d72740e44d9f676d8dab2c933a236663d86dd24319b57a2bed4d694774" +checksum = "804169db156b21258a2545757336922d93dfa229892c75911a0ad141aa0ff241" dependencies = [ - "petgraph 0.7.1", + "petgraph", ] [[package]] @@ -1397,13 +1460,13 @@ dependencies = [ [[package]] name = "digest" -version = "0.11.0-pre.9" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.11.0-rc.3", - "crypto-common 0.2.0-rc.1", - "subtle", + "block-buffer 0.12.1", + "crypto-common 0.2.2", + "ctutils", ] [[package]] @@ -1424,7 +1487,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1653,7 +1716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1678,9 +1741,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", ] @@ -1714,15 +1777,31 @@ dependencies = [ [[package]] name = "ff" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f" dependencies = [ "bitvec", - "rand_core 0.6.4", + "ff_derive", + "rand_core 0.10.0", "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.117", +] + [[package]] name = "field-offset" version = "0.3.6" @@ -1823,14 +1902,14 @@ dependencies = [ [[package]] name = "fpe" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c4b37de5ae15812a764c958297cfc50f5c010438f60c6ce75d11b802abd404" +checksum = "5045d51a6a5e85e0a18d909eedd270c4d82ad634fee57ba707692fb3b1add5a7" dependencies = [ - "cbc", - "cipher", + "cbc 0.2.1", + "cipher 0.5.2", "libm", - "num-bigint", + "num-bigint 0.5.1", "num-integer", "num-traits", ] @@ -2199,15 +2278,31 @@ dependencies = [ "system-deps", ] +[[package]] +name = "groth16" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb1e0bde2dbacd81474ae216c5dd4901307bd1c75fd26ed49590e88048c8442" +dependencies = [ + "bellman", + "byteorder", + "ff", + "group", + "pairing", + "rand 0.10.1", + "rand_core 0.10.0", + "rayon", +] + [[package]] name = "group" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4" dependencies = [ "ff", "memuse", - "rand_core 0.6.4", + "rand_core 0.10.0", "subtle", ] @@ -2284,9 +2379,9 @@ 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", @@ -2294,9 +2389,8 @@ dependencies = [ "group", "halo2_poseidon", "halo2_proofs", - "lazy_static", "pasta_curves", - "rand 0.8.6", + "rand 0.10.1", "sinsemilla", "subtle", "uint", @@ -2310,9 +2404,9 @@ 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", @@ -2322,18 +2416,19 @@ dependencies = [ [[package]] name = "halo2_proofs" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05713f117155643ce10975e0bee44a274bcda2f4bb5ef29a999ad67c1fa8d4d3" +checksum = "d886268046f1ceedd464c95382a64c7e86520b029b18e02ee92bf94f5120817d" dependencies = [ "blake2b_simd", "ff", "group", "halo2_legacy_pdqsort", - "indexmap 1.9.3", + "indexmap 2.13.0", "maybe-rayon", "pasta_curves", - "rand_core 0.6.4", + "rand 0.10.1", + "rand_core 0.10.0", "tracing", ] @@ -2402,11 +2497,11 @@ dependencies = [ [[package]] name = "hmac" -version = "0.13.0-pre.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" dependencies = [ - "digest 0.11.0-pre.9", + "digest 0.11.3", ] [[package]] @@ -2478,9 +2573,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hybrid-array" -version = "0.2.3" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9" +checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214" dependencies = [ "typenum", ] @@ -2694,9 +2789,9 @@ 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", ] @@ -2756,6 +2851,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inout" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f" +dependencies = [ + "hybrid-array", +] + [[package]] name = "ipnet" version = "2.12.0" @@ -2915,16 +3019,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", + "rand_core 0.10.0", "subtle", + "zeroize", ] [[package]] @@ -3233,7 +3338,7 @@ dependencies = [ "png 0.18.1", "serde", "thiserror 2.0.18", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3309,7 +3414,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3322,6 +3427,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-conv" version = "0.2.2" @@ -3629,11 +3744,11 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orchard" -version = "0.15.3" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b67beade27dbebdbfee0819e23170b0b263dc7b4f558ee936151716baf6e1f" +checksum = "4ae7ceb7b5387bd76cf3c0712f57708795c925cecf097036cedb60b5c3706e8f" dependencies = [ - "aes", + "aes 0.9.3", "bitvec", "blake2b_simd", "corez", @@ -3650,8 +3765,8 @@ dependencies = [ "memuse", "nonempty", "pasta_curves", - "rand 0.8.6", - "rand_core 0.6.4", + "rand 0.10.1", + "rand_core 0.10.0", "reddsa", "serde", "sinsemilla", @@ -3660,6 +3775,7 @@ dependencies = [ "visibility", "zcash_note_encryption", "zcash_spec", + "zeroize", "zip32", ] @@ -3675,9 +3791,9 @@ dependencies = [ [[package]] name = "pairing" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +checksum = "214888e4959a78b6e413c29eef2aae6982f4686b97cc64308c838b641259db02" dependencies = [ "group", ] @@ -3749,17 +3865,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", "lazy_static", - "rand 0.8.6", + "rand 0.10.1", "static_assertions", "subtle", + "zeroize", ] [[package]] @@ -3780,13 +3897,12 @@ dependencies = [ [[package]] name = "pczt" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7d4693dcb3d72f30064e0fdab122292d803bd9325a95b25df08679cf895452f" +checksum = "c6b48fdfdc5c6b58a00514f9b2504fae98f7cde9f741f3477264b411cd69134d" dependencies = [ "blake2b_simd", "bls12_381", - "document-features", "ff", "getset", "jubjub", @@ -3794,17 +3910,19 @@ dependencies = [ "orchard", "pasta_curves", "postcard", - "rand_core 0.6.4", + "rand_core 0.10.0", "redjubjub", "sapling-crypto", "secp256k1", "serde", "serde_with", + "subtle", "zcash_note_encryption", "zcash_primitives", "zcash_protocol", "zcash_script", "zcash_transparent", + "zeroize", ] [[package]] @@ -3813,16 +3931,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap 2.13.0", -] - [[package]] name = "petgraph" version = "0.8.3" @@ -4109,7 +4217,17 @@ checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "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.0", + "universal-hash 0.6.1", ] [[package]] @@ -4280,7 +4398,7 @@ dependencies = [ "itertools", "log", "multimap", - "petgraph 0.8.3", + "petgraph", "prettyplease", "prost", "prost-types", @@ -4376,17 +4494,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + [[package]] name = "rand" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" dependencies = [ - "chacha20 0.10.2", + "chacha20", "getrandom 0.4.2", "rand_core 0.10.0", ] @@ -4401,6 +4529,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -4410,6 +4548,15 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "rand_core" version = "0.10.0" @@ -4418,12 +4565,12 @@ checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" [[package]] name = "rand_distr" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +checksum = "4d431c2703ccf129de4d45253c03f49ebb22b97d6ad79ee3ecfc7e3f4862c1d8" dependencies = [ "num-traits", - "rand 0.8.6", + "rand 0.10.1", ] [[package]] @@ -4454,9 +4601,9 @@ 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", @@ -4464,21 +4611,21 @@ dependencies = [ "hex", "jubjub", "pasta_curves", - "rand_core 0.6.4", + "rand_core 0.10.0", "serde", - "thiserror 1.0.69", + "thiserror 2.0.18", "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.0", "reddsa", - "thiserror 1.0.69", + "thiserror 2.0.18", "zeroize", ] @@ -4634,11 +4781,11 @@ dependencies = [ [[package]] name = "ripemd" -version = "0.2.0-pre.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48cf93482ea998ad1302c42739bc73ab3adc574890c373ec89710e219357579" +checksum = "4dd4211456b4172d7e44261920c25acf07367c4f04bb5f5d54fc21b090d9b159" dependencies = [ - "digest 0.11.0-pre.9", + "digest 0.11.3", ] [[package]] @@ -4682,7 +4829,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4732,7 +4879,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -4746,11 +4893,11 @@ dependencies = [ [[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", @@ -4761,19 +4908,21 @@ dependencies = [ "ff", "fpe", "getset", + "groth16", "group", "hex", "incrementalmerkletree", "jubjub", "lazy_static", "memuse", - "rand 0.8.6", - "rand_core 0.6.4", + "rand 0.10.1", + "rand_core 0.10.0", "redjubjub", "subtle", "tracing", "zcash_note_encryption", "zcash_spec", + "zeroize", "zip32", ] @@ -4830,22 +4979,22 @@ dependencies = [ [[package]] name = "schemerz" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e82960ac11ccabd77d53c933532612079e01205b5873ec5095f4b3426493434" +checksum = "85a66556ccb695e22d08620703a9526806e533de0094fe993896932592ba3a6c" dependencies = [ "daggy", - "indexmap 1.9.3", + "indexmap 2.13.0", "log", - "thiserror 1.0.69", + "thiserror 2.0.18", "uuid", ] [[package]] name = "schemerz-rusqlite" -version = "0.370.0" +version = "0.371.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6df8a13fb3b7914f94ac6579bd5e76b9292f135886e6becc3525f9e5116827" +checksum = "c29c257d3233449db8224f7f0fcf51373b59755aec356d8648dc694804132d60" dependencies = [ "rusqlite", "schemerz", @@ -4860,18 +5009,19 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "secp256k1" -version = "0.29.1" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +checksum = "d7f404a8dab7a7a5a631e741d8699aa9c8e1d689fc26ccf897c7187565490b69" dependencies = [ + "rand 0.9.5", "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.10.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +checksum = "f6b2992d4a3cd244539a7d5d0966aadbe5ca7fb868a5d7e38c29499b9e709bbd" dependencies = [ "cc", ] @@ -5124,13 +5274,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.11.0-pre.4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", - "digest 0.11.0-pre.9", + "cpufeatures 0.3.0", + "digest 0.11.3", ] [[package]] @@ -5144,9 +5294,9 @@ dependencies = [ [[package]] name = "shardtree" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8147447aed7be4736e271825b8c3a4432efb7182e71363169b572371ddef452e" +checksum = "211c5ae6ff1fda9efe2cd8b90737744b3b3989f98740319284946bf110b862ed" dependencies = [ "bitflags 2.11.0", "either", @@ -5184,9 +5334,9 @@ checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" [[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", "pasta_curves", @@ -5224,7 +5374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5800,10 +5950,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -6313,7 +6463,7 @@ dependencies = [ "png 0.18.1", "serde", "thiserror 2.0.18", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -6342,7 +6492,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -6453,6 +6603,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 = "untrusted" version = "0.9.0" @@ -6916,7 +7076,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -7667,9 +7827,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", "bs58", @@ -7681,9 +7841,9 @@ dependencies = [ [[package]] name = "zcash_client_backend" -version = "0.24.0-rc.4" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e019c2adb1eb2c3479603f4556e85c01022723f14ce8837a3bb225cb2af4d3f" +checksum = "27228f279facfd6b9dd015cea88538020c30f87c8a4aa59e8ed85808d81febb5" dependencies = [ "async-trait", "base64 0.22.1", @@ -7708,7 +7868,7 @@ dependencies = [ "percent-encoding", "postcard", "prost", - "rand_core 0.6.4", + "rand_core 0.10.0", "rayon", "sapling-crypto", "secp256k1", @@ -7736,9 +7896,9 @@ dependencies = [ [[package]] name = "zcash_client_sqlite" -version = "0.22.0-rc.4" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a496ad83b77e790bd0ea1013db14961b3ff825550097a2658837dc7e92a23d53" +checksum = "d1d85c3c832c8554da6ed6114c81afef84f7dbb84c2279a3889277a8d2225019" dependencies = [ "bip32", "bitflags 2.11.0", @@ -7752,9 +7912,10 @@ dependencies = [ "maybe-rayon", "nonempty", "orchard", + "pczt", "prost", - "rand 0.8.6", - "rand_core 0.6.4", + "rand 0.10.1", + "rand_core 0.10.0", "rand_distr", "regex", "rusqlite", @@ -7784,9 +7945,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", @@ -7795,9 +7956,9 @@ dependencies = [ [[package]] name = "zcash_keys" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc842e024fe37e52cfd3920826c4a28cc2a023fc9d77351d9c0f310becae3eb7" +checksum = "6e35ad8dafd173b0465e5963b520b241f497d978319faed46547bd81f403fa98" dependencies = [ "bech32", "bip32", @@ -7810,7 +7971,7 @@ dependencies = [ "memuse", "nonempty", "orchard", - "rand_core 0.6.4", + "rand_core 0.10.0", "sapling-crypto", "secrecy", "subtle", @@ -7824,47 +7985,47 @@ 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 0.9.1", + "chacha20", "chacha20poly1305", - "cipher", - "rand_core 0.6.4", + "cipher 0.5.2", + "rand_core 0.10.0", "subtle", ] [[package]] name = "zcash_pool_migration" -version = "0.1.0-rc.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e4169a96a25de216d4a7265fe772003aaeea05ed2566b14cfc0b8146b1f99e" +checksum = "5b5211aea88f920316150527eda23efe419b507d03c8dda9e655bfbf22bfa68d" dependencies = [ + "blake2b_simd", "corez", "getset", "incrementalmerkletree", "libm", "orchard", "pczt", - "rand_core 0.6.4", + "rand_core 0.10.0", "shardtree", "zcash_client_backend", "zcash_keys", "zcash_primitives", "zcash_protocol", + "zip32", ] [[package]] name = "zcash_primitives" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ca4de11896f704ffe6319c2cd7bc8fc6ab31a55cec80d26def15c009d83678" +checksum = "50ad9ffda3d83c35e401b2f914980762f201ab40525cb0aab67b8d91e180e7df" dependencies = [ "blake2b_simd", - "block-buffer 0.11.0-rc.3", "corez", - "crypto-common 0.2.0-rc.1", "document-features", "equihash", "ff", @@ -7874,7 +8035,7 @@ dependencies = [ "memuse", "nonempty", "orchard", - "rand_core 0.6.4", + "rand_core 0.10.0", "redjubjub", "sapling-crypto", "secp256k1", @@ -7888,17 +8049,18 @@ dependencies = [ [[package]] name = "zcash_proofs" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea125021aaa749e966989c7f7aaa18afe2f89474573f5f0dfac8b98083a6d095" +checksum = "f2ec0c92cb3bca94f8d875260b09eaad8f97eb8ebe7b5ca099ad0ae10eb19d84" dependencies = [ "bellman", "blake2b_simd", "bls12_381", "document-features", + "groth16", "group", "jubjub", - "rand_core 0.6.4", + "rand_core 0.10.0", "redjubjub", "sapling-crypto", "tracing", @@ -7908,9 +8070,9 @@ dependencies = [ [[package]] name = "zcash_protocol" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4034db33a1ce58416430e065b01474b958e4649caa3e06e20654683a95149710" +checksum = "266da226b6be42545b9fc299f1def9f5e525764845b8afa874f167155de943ba" dependencies = [ "corez", "document-features", @@ -7921,9 +8083,9 @@ dependencies = [ [[package]] name = "zcash_script" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ef9d04e0434a80b62ad06c5a610557be358ef60a98afa5dbc8ecaf19ad72e7" +checksum = "10106859d08a2a4119af8a0fa8db72afe35647768b562f94b7a2124adad41275" dependencies = [ "bip32", "bitflags 2.11.0", @@ -7947,9 +8109,9 @@ dependencies = [ [[package]] name = "zcash_transparent" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "547c012778bae17f58007731af074d638aa146ab0ecfc120adebf23d049aff6c" +checksum = "eb804d0179500e9543502dd6dfa178826617107897e6fe171241e5b767b7a0dd" dependencies = [ "bip32", "bs58", @@ -7962,7 +8124,6 @@ dependencies = [ "secp256k1", "sha2 0.10.9", "subtle", - "zcash_address", "zcash_encoding", "zcash_protocol", "zcash_script", @@ -8066,22 +8227,23 @@ dependencies = [ [[package]] name = "zip32" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64bf5186a8916f7a48f2a98ef599bf9c099e2458b36b819e393db1c0e768c4b" +checksum = "601ab4bc5f8312fa39f5411e07eb66b538687064c6e936b34eaa78f1e99ebe4d" dependencies = [ "bech32", "blake2b_simd", "memuse", "subtle", "zcash_spec", + "zeroize", ] [[package]] name = "zip321" -version = "0.9.0-rc.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb464491970d9b61889e4f2b7b00fb9f471a33692e5c0de3122fdc575d8067ab" +checksum = "e6960586c9e1a91c734e9175913e22b88f2df11617f1decdefb15dd971ffd383" dependencies = [ "base64 0.22.1", "nom", diff --git a/Cargo.toml b/Cargo.toml index 1ee7da3b..97a7b2eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" version = "1.6.1" license = "MIT OR Apache-2.0" authors = ["The Bootstrap Org Inc"] -rust-version = "1.88" +rust-version = "1.89" repository = "https://github.com/sovright/argos" [workspace.dependencies] @@ -30,22 +30,25 @@ clap = { version = "4.5.53", features = ["derive"] } crypto_secretbox = "0.1.1" dialoguer = "0.12.0" indicatif = "0.18.2" -orchard = "0.15" +nonempty = "0.11" +orchard = "0.16" # Already in the tree, pinned by the librustzcash stack; promoted to a direct # dependency (as `orchard` already is) so transparent-only recovery can name # Sapling payment addresses, anchors, and provers. Adds no new package. -sapling-crypto = { version = "0.7", default-features = false } +sapling-crypto = { version = "0.9", default-features = false } # Already in the tree via zcash_client_backend; promoted to a direct dependency # so the imported-key sweep can drive the PCZT roles. Spending a standalone # Sapling key is impossible through `SpendingKeys`, which takes its Sapling # authority solely from a `UnifiedSpendingKey`; the PCZT signer accepts a raw # spend authorizing key. Adds no new package. -pczt = { version = "0.9.1", default-features = false, features = ["prover", "signer", "tx-extractor", "io-finalizer", "spend-finalizer", "sapling", "orchard", "transparent"] } +pczt = { version = "0.10", default-features = false, features = ["prover", "signer", "tx-extractor", "io-finalizer", "spend-finalizer", "sapling", "orchard", "transparent"] } prost = "0.14.3" rand_core = "0.6.4" +# NU7 SDK randomness; legacy crypto still uses rand_core 0.6. +rand = "0.10" rusqlite = { version = "0.37.0", features = ["backup"] } rustls = { version = "0.23.46", default-features = false, features = ["ring", "logging", "std", "tls12"] } -secp256k1 = "0.29.1" +secp256k1 = "0.33" secrecy = "0.8.0" # Wipes recovered spending material and intermediate derivation state on drop. # Already in the lockfile through the Zcash crates; `derive` supports the @@ -66,28 +69,18 @@ url = "2.5.8" keepawake = "0.6" sha2 = "0.10" uuid = { version = "1.18.1", features = ["serde", "v4"] } -# ─── Zcash protocol stack — Ironwood (NU6.3) ────────────────────────────────── -# -# NU6.3 / Ironwood activates on mainnet at height 3_428_143. Consensus branch -# IDs for that upgrade first appear in zcash_protocol 0.10.0, so anything below -# that line signs sweeps with the NU6.2 branch ID and gets them rejected once -# the chain passes activation. -# -# The wallet crates that expose it — zcash_client_backend / zcash_client_sqlite -# — have no stable release on the 0.10 protocol line yet, only release -# candidates. Those two are pinned with `=` rather than a caret so an RC bump -# upstream cannot silently change what we ship; revisit both pins when 0.24.0 / -# 0.22.0 go final. -zcash_address = "0.13" -zcash_client_backend = { version = "=0.24.0-rc.4", default-features = false, features = ["lightwalletd-tonic-transport", "lightwalletd-tonic-tls-webpki-roots", "orchard", "pczt", "sync", "transparent-inputs", "transparent-key-import"] } -zcash_client_sqlite = { version = "=0.22.0-rc.4", default-features = false, features = ["orchard", "serde", "transparent-inputs", "transparent-key-import"] } -zcash_keys = { version = "0.16", default-features = false, features = ["std", "sapling", "orchard", "transparent-inputs"] } -zcash_primitives = "0.30" -zcash_proofs = { version = "0.30", default-features = false, features = ["bundled-prover"] } -zcash_protocol = "0.10" -zcash_transparent = { version = "0.10", default-features = false, features = ["std", "transparent-inputs"] } +# Coordinated stable NU7 release family (2026-10-21). Keep wallet crates +# pinned together so database and transaction APIs advance coherently. +zcash_address = "0.14" +zcash_client_backend = { version = "=0.25.0", default-features = false, features = ["lightwalletd-tonic-transport", "lightwalletd-tonic-tls-webpki-roots", "orchard", "pczt", "sync", "transparent-inputs", "transparent-key-import"] } +zcash_client_sqlite = { version = "=0.23.0", default-features = false, features = ["orchard", "serde", "transparent-inputs", "transparent-key-import"] } +zcash_keys = { version = "0.17", default-features = false, features = ["std", "sapling", "orchard", "transparent-inputs"] } +zcash_primitives = "0.31" +zcash_proofs = { version = "0.31", default-features = false, features = ["bundled-prover"] } +zcash_protocol = "0.11" +zcash_transparent = { version = "0.11", default-features = false, features = ["std", "transparent-inputs"] } tempfile = "3.20.0" -zip32 = "0.2.1" +zip32 = "0.3" # Optimize cryptographic dependencies in development and tests. [profile.dev.package."*"] diff --git a/README.md b/README.md index 022e5676..f84a1124 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,19 @@ argos --sapling-key-file sapling-keys.txt sweep --destination u1... --dry-run Viewing keys such as `zxviews…` are rejected: they can reveal balances but cannot authorize the sweep Argos is promising. +## Supported recovery at NU7 + +Argos binds reviewed sweeps to the consensus branch and rechecks network tip, +transaction version, expiry and shielded bundle limits before submission or +retry. Large supported sweeps are split into bounded transactions; retain every +reported transaction ID until its outcome is known. An unknown broadcast +outcome stops later recovery work. + +The NU7 qualification suite covers encoding, schedules, database migration and +a separate local block/proxy boundary. A funded rehearsal of supported sweeps +and imported Sapling PCZT remains a release gate; see +[qualification details](docs/qualification/nu7-supported-recovery.md). + ## Sprout after NU7 NU7 disallows version 4 transactions, so remaining Sprout funds are diff --git a/crates/argos-wallet-import/src/identity.rs b/crates/argos-wallet-import/src/identity.rs index 419d4e45..428c275e 100644 --- a/crates/argos-wallet-import/src/identity.rs +++ b/crates/argos-wallet-import/src/identity.rs @@ -2,18 +2,41 @@ //! Failed comparisons return no key material or attacker-controlled text. use sapling_crypto::zip32::ExtendedSpendingKey; -use secp256k1::{PublicKey, Secp256k1, SecretKey}; -use zcash_address::ZcashAddress; +use secp256k1::{PublicKey, SecretKey}; +use zcash_address::{ConversionError, TryFromAddress, ZcashAddress}; use zcash_protocol::consensus::NetworkType; use zcash_transparent::address::TransparentAddress; use crate::{keys::EmbeddedNetwork, secret_bytes::SecretArray}; +// Keep wallet provenance restricted to the legacy transparent address formats. +// NU7 moved address conversion out of zcash_transparent; do not accept a +// unified or transparent-source-only address as an equivalent stored identity. +struct LegacyTransparentAddress(TransparentAddress); + +impl TryFromAddress for LegacyTransparentAddress { + type Error = std::convert::Infallible; + + fn try_from_transparent_p2pkh( + _net: NetworkType, + data: [u8; 20], + ) -> Result> { + Ok(Self(TransparentAddress::PublicKeyHash(data))) + } + + fn try_from_transparent_p2sh( + _net: NetworkType, + data: [u8; 20], + ) -> Result> { + Ok(Self(TransparentAddress::ScriptHash(data))) + } +} + pub(crate) fn transparent_matches_pubkey(secret: &[u8; 32], stored: &[u8]) -> bool { - let Ok(sk) = SecretKey::from_slice(secret) else { + let Ok(sk) = SecretKey::from_secret_bytes(*secret) else { return false; }; - let derived = PublicKey::from_secret_key(&Secp256k1::new(), &sk); + let derived = PublicKey::from_secret_key(&sk); match stored.len() { 33 => derived.serialize().as_slice() == stored, 65 => derived.serialize_uncompressed().as_slice() == stored, @@ -25,15 +48,15 @@ pub(crate) fn transparent_matches_address( secret: &[u8; 32], stored: &str, ) -> Result { - let sk = SecretKey::from_slice(secret).map_err(|_| ())?; - let pubkey = PublicKey::from_secret_key(&Secp256k1::new(), &sk); + let sk = SecretKey::from_secret_bytes(*secret).map_err(|_| ())?; + let pubkey = PublicKey::from_secret_key(&sk); let expected = TransparentAddress::from_pubkey(&pubkey); - let (network, address): (NetworkType, TransparentAddress) = + let (network, address): (NetworkType, LegacyTransparentAddress) = ZcashAddress::try_from_encoded(stored) .map_err(|_| ())? .convert() .map_err(|_| ())?; - if address != expected { + if address.0 != expected { return Err(()); } Ok(match network { diff --git a/crates/argos-wallet-import/src/zwl.rs b/crates/argos-wallet-import/src/zwl.rs index 3a9d9f69..d720643a 100644 --- a/crates/argos-wallet-import/src/zwl.rs +++ b/crates/argos-wallet-import/src/zwl.rs @@ -1396,15 +1396,21 @@ mod tests { #[test] fn truncated_later_tkey_retains_earlier_testnet_identity() { - use secp256k1::{PublicKey, Secp256k1, SecretKey}; + use secp256k1::{PublicKey, SecretKey}; use zcash_protocol::consensus::NetworkType; use zcash_transparent::address::TransparentAddress; let secret = [0x55; TRANSPARENT_SECRET_LEN]; - let public = - PublicKey::from_secret_key(&Secp256k1::new(), &SecretKey::from_slice(&secret).unwrap()); - let address = TransparentAddress::from_pubkey(&public) - .to_zcash_address(NetworkType::Test) + let public = PublicKey::from_secret_key(&SecretKey::from_secret_bytes(secret).unwrap()); + let TransparentAddress::PublicKeyHash(hash) = TransparentAddress::from_pubkey(&public) + else { + panic!("fixture public key must produce P2PKH"); + }; + let address = + ::from_transparent_p2pkh( + NetworkType::Test, + hash, + ) .encode(); let mut first = tkey_hd(0x55); let address_start = 1 + 4 + 1 + 1 + TRANSPARENT_SECRET_LEN + 8; @@ -1586,7 +1592,8 @@ mod tests { fn zkey_hd(extsk_byte: u8) -> Vec { use sapling_crypto::zip32::ExtendedSpendingKey; - let extsk = ExtendedSpendingKey::master(&[extsk_byte; 32]); + let extsk = + ExtendedSpendingKey::master(&[extsk_byte; 32]).expect("valid fixture Sapling key"); let mut extfvk = Vec::new(); #[allow(deprecated)] extsk @@ -1630,14 +1637,21 @@ mod tests { } fn tkey_hd(secret_byte: u8) -> Vec { - use secp256k1::{PublicKey, Secp256k1, SecretKey}; + use secp256k1::{PublicKey, SecretKey}; use zcash_protocol::consensus::NetworkType; use zcash_transparent::address::TransparentAddress; let secret = [secret_byte; TRANSPARENT_SECRET_LEN]; - let sk = SecretKey::from_slice(&secret).unwrap(); - let pubkey = PublicKey::from_secret_key(&Secp256k1::new(), &sk); - let address = TransparentAddress::from_pubkey(&pubkey) - .to_zcash_address(NetworkType::Main) + let sk = SecretKey::from_secret_bytes(secret).unwrap(); + let pubkey = PublicKey::from_secret_key(&sk); + let TransparentAddress::PublicKeyHash(hash) = TransparentAddress::from_pubkey(&pubkey) + else { + panic!("fixture public key must produce P2PKH"); + }; + let address = + ::from_transparent_p2pkh( + NetworkType::Main, + hash, + ) .encode(); let mut v = vec![1u8]; v.extend_from_slice(&u32le(0)); @@ -1689,7 +1703,9 @@ mod tests { assert_eq!(keys.sapling.len(), 1); assert_eq!( keys.sapling[0].extsk.expose_secret(), - &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x11; 32]).to_bytes() + &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x11; 32]) + .expect("valid fixture Sapling key") + .to_bytes() ); assert_ne!(keys.coverage(), crate::keys::ImportCoverage::Complete); assert!(keys.diagnostics.iter().any(|d| matches!(d, @@ -1764,7 +1780,9 @@ mod tests { assert_eq!(keys.sapling.len(), 1, "first zkey lost at cut {cut}"); assert_eq!( keys.sapling[0].extsk.expose_secret(), - &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x12; 32]).to_bytes() + &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x12; 32]) + .expect("valid fixture Sapling key") + .to_bytes() ); } if cut >= first_tkey_end { @@ -1936,7 +1954,9 @@ mod tests { assert_eq!(keys.sapling.len(), 1); assert_eq!( keys.sapling[0].extsk.expose_secret(), - &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0xEF; 32]).to_bytes() + &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0xEF; 32]) + .expect("valid fixture Sapling key") + .to_bytes() ); assert_eq!(keys.sapling[0].provenance, Provenance::HdDerived); @@ -1971,7 +1991,9 @@ mod tests { assert_eq!(keys.sapling.len(), 1); assert_eq!( keys.sapling[0].extsk.expose_secret(), - &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x11; 32]).to_bytes() + &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x11; 32]) + .expect("valid fixture Sapling key") + .to_bytes() ); assert_eq!(keys.transparent.len(), 1); assert_eq!( @@ -2190,7 +2212,8 @@ mod tests { /// spending key is dropped and only `enc_key`/`nonce` remain. fn zkey_standalone_sealed(extsk_byte: u8, key: &[u8; 32], nonce: [u8; NONCE_LEN]) -> Vec { use sapling_crypto::zip32::ExtendedSpendingKey; - let extsk = ExtendedSpendingKey::master(&[extsk_byte; 32]); + let extsk = + ExtendedSpendingKey::master(&[extsk_byte; 32]).expect("valid fixture Sapling key"); let mut extfvk = Vec::new(); #[allow(deprecated)] extsk @@ -2256,7 +2279,9 @@ mod tests { assert_eq!(keys.sapling[0].provenance, Provenance::Standalone); assert_eq!( keys.sapling[0].extsk.expose_secret(), - &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x41; 32]).to_bytes() + &sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x41; 32]) + .expect("valid fixture Sapling key") + .to_bytes() ); assert_eq!(keys.transparent.len(), 1, "{:?}", keys.diagnostics); assert_eq!(keys.transparent[0].provenance, Provenance::Standalone); diff --git a/crates/argos-wallet-import/tests/key_metadata_matches_the_wallet.rs b/crates/argos-wallet-import/tests/key_metadata_matches_the_wallet.rs index cca29d88..797ab807 100644 --- a/crates/argos-wallet-import/tests/key_metadata_matches_the_wallet.rs +++ b/crates/argos-wallet-import/tests/key_metadata_matches_the_wallet.rs @@ -14,7 +14,7 @@ use std::collections::HashMap; use argos_wallet_import::{bdb, keys::ImportedKeys, zcashd}; use sapling_crypto::zip32::ExtendedSpendingKey; -use secp256k1::{PublicKey, Secp256k1, SecretKey}; +use secp256k1::{PublicKey, SecretKey}; use secrecy::{ExposeSecret, SecretString}; const FIXTURE_PASSPHRASE: &str = "argos-test-passphrase"; @@ -60,8 +60,7 @@ fn stored_times( } fn pubkey_record_key(secret: &[u8; 32]) -> Vec { - let secp = Secp256k1::new(); - let pubkey = PublicKey::from_secret_key(&secp, &SecretKey::from_slice(secret).unwrap()); + let pubkey = PublicKey::from_secret_key(&SecretKey::from_secret_bytes(*secret).unwrap()); // `CPubKey` serializes as CompactSize(33) || compressed pubkey. let mut key = vec![33u8]; key.extend_from_slice(&pubkey.serialize()); diff --git a/crates/argos-wallet-import/tests/transparent_key_is_genuine.rs b/crates/argos-wallet-import/tests/transparent_key_is_genuine.rs index e5745207..bd37bebd 100644 --- a/crates/argos-wallet-import/tests/transparent_key_is_genuine.rs +++ b/crates/argos-wallet-import/tests/transparent_key_is_genuine.rs @@ -15,7 +15,7 @@ use argos_wallet_import::{ keys::{ImportCoverage, ImportedKeys}, zcashd, ImportDiagnostic, }; -use secp256k1::{PublicKey, Secp256k1, SecretKey}; +use secp256k1::{PublicKey, SecretKey}; use secrecy::{ExposeSecret, SecretString}; const FIXTURE_PASSPHRASE: &str = "argos-test-passphrase"; @@ -52,9 +52,9 @@ fn stored_pubkeys( } fn derive_pubkey(secret: &[u8; 32]) -> [u8; 33] { - let secp = Secp256k1::new(); - let sk = SecretKey::from_slice(secret).expect("recovered secret must be a valid scalar"); - PublicKey::from_secret_key(&secp, &sk).serialize() + let sk = + SecretKey::from_secret_bytes(*secret).expect("recovered secret must be a valid scalar"); + PublicKey::from_secret_key(&sk).serialize() } fn assert_keys_control_their_pubkeys( diff --git a/crates/zeck-cli/src/main.rs b/crates/zeck-cli/src/main.rs index c1f662a0..f16b5e3a 100644 --- a/crates/zeck-cli/src/main.rs +++ b/crates/zeck-cli/src/main.rs @@ -13,7 +13,7 @@ use std::{ use anyhow::{bail, Context, Result}; use argos_core::{ argos_wallet_import::{self, ImportedKeys}, - derive_accounts, detect_birthday, estimate_birthday_from_date, + derive_accounts, detect_birthday, estimate_birthday_from_date_for_network, imported::{encode_transparent_address, imported_transparent_keys}, transparent_recovery::{ quote_transparent_only, scan_transparent_only, sweep_transparent_only_from_quote, @@ -1013,7 +1013,7 @@ async fn resolve_birthday( eprintln!("✓ {}", result.message); Ok(result.birthday) } else if let Some(date) = &cli.birthday_date { - Ok(estimate_birthday_from_date(date, &cli.lightwalletd_url).await?) + Ok(estimate_birthday_from_date_for_network(date, &cli.lightwalletd_url, network).await?) } else { Ok(cli.birthday_or_default()) } diff --git a/crates/zeck-core/Cargo.toml b/crates/zeck-core/Cargo.toml index 2ec81f35..655c1027 100644 --- a/crates/zeck-core/Cargo.toml +++ b/crates/zeck-core/Cargo.toml @@ -26,10 +26,12 @@ async-trait.workspace = true base64.workspace = true bip0039.workspace = true keepawake.workspace = true +nonempty.workspace = true orchard.workspace = true pczt.workspace = true prost.workspace = true rand_core.workspace = true +rand.workspace = true rusqlite.workspace = true sapling-crypto.workspace = true rustls.workspace = true diff --git a/crates/zeck-core/src/address.rs b/crates/zeck-core/src/address.rs index 1b60ec42..b1280606 100644 --- a/crates/zeck-core/src/address.rs +++ b/crates/zeck-core/src/address.rs @@ -54,7 +54,7 @@ pub fn validate_destination_address( return Err(ZeckError::DestinationMustBeUnified); } - let (address_net, _) = decoded.expect("is_unified implies decode succeeded"); + let (address_net, _, _) = decoded.expect("is_unified implies decode succeeded"); let expected_net = network_type(network); // The regtest harness derives destinations under regtest parameters, so diff --git a/crates/zeck-core/src/address_match_recovery.rs b/crates/zeck-core/src/address_match_recovery.rs index 9e3fcf17..3e41fa0c 100644 --- a/crates/zeck-core/src/address_match_recovery.rs +++ b/crates/zeck-core/src/address_match_recovery.rs @@ -73,7 +73,7 @@ pub fn prepare_match_recovery( verify_public_match(&coordinates, &encoded)?; let mut keys = ImportedKeys::default(); keys.transparent.push(TransparentKey { - secret: Secret::new(secret.secret_bytes()), + secret: Secret::new(secret.to_secret_bytes()), provenance: Provenance::HdDerived, created_at: None, }); @@ -86,12 +86,18 @@ pub fn prepare_match_recovery( coordinates.account )) })?; - let extsk = zcash_keys::keys::sapling::spending_key(seed, network.coin_type(), account); + let extsk = zcash_keys::keys::sapling::spending_key(seed, network.coin_type(), account) + .ok_or_else(|| { + ZeckError::Internal("Sapling spending-key derivation failed".to_owned()) + })?; let dfvk = match coordinates.scope { AddressScope::External => extsk.to_diversifiable_full_viewing_key(), - AddressScope::Internal => { - extsk.derive_internal().to_diversifiable_full_viewing_key() - } + AddressScope::Internal => extsk + .derive_internal() + .ok_or_else(|| { + ZeckError::Internal("Sapling internal-key derivation failed".to_owned()) + })? + .to_diversifiable_full_viewing_key(), }; let address = dfvk.address(coordinates.index.into()).ok_or_else(|| { ZeckError::InvalidConfig("saved Sapling diversifier index is invalid".to_owned()) @@ -126,9 +132,15 @@ pub fn prepare_match_recovery( }; let address = orchard::keys::FullViewingKey::from(&sk).address_at(coordinates.index, scope); - let encoded = zcash_address::unified::Address::try_from_items(vec![ - zcash_address::unified::Receiver::Orchard(address.to_raw_address_bytes()), - ]) + let encoded = zcash_address::unified::Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![zcash_address::unified::Receiver::Orchard( + address.to_raw_address_bytes(), + )] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .map_err(|err| ZeckError::Internal(err.to_string()))? .encode(&match network { ZeckNetwork::Mainnet => zcash_protocol::consensus::NetworkType::Main, @@ -263,7 +275,7 @@ mod tests { .unwrap(); assert_eq!( keys.transparent[0].secret.expose_secret(), - &wanted.secret_bytes() + &wanted.to_secret_bytes() ); assert_eq!(source.match_coordinates().unwrap().index, 19); assert_eq!( @@ -278,9 +290,15 @@ mod tests { let sk = orchard::keys::SpendingKey::from_zip32_seed(&SEED, 1, account).unwrap(); let address = orchard::keys::FullViewingKey::from(&sk) .address_at(23u32, orchard::keys::Scope::External); - let encoded = zcash_address::unified::Address::try_from_items(vec![ - zcash_address::unified::Receiver::Orchard(address.to_raw_address_bytes()), - ]) + let encoded = zcash_address::unified::Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![zcash_address::unified::Receiver::Orchard( + address.to_raw_address_bytes(), + )] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .unwrap() .encode(&zcash_protocol::consensus::NetworkType::Test); let source = prepare_match_recovery( @@ -304,11 +322,13 @@ mod tests { #[test] fn sapling_internal_handoff_rederives_exact_scope_and_index() { let account = AccountId::try_from(4).unwrap(); - let extsk = zcash_keys::keys::sapling::spending_key(&SEED, 133, account); + let extsk = zcash_keys::keys::sapling::spending_key(&SEED, 133, account) + .expect("valid fixture Sapling key"); let (index, address) = (1u32..1000) .find_map(|index| { extsk .derive_internal() + .expect("valid fixture internal key") .to_diversifiable_full_viewing_key() .address(index.into()) .map(|address| (index, address)) diff --git a/crates/zeck-core/src/address_search.rs b/crates/zeck-core/src/address_search.rs index 6476c9f4..884a9b56 100644 --- a/crates/zeck-core/src/address_search.rs +++ b/crates/zeck-core/src/address_search.rs @@ -516,7 +516,7 @@ mod tests { NonHardenedChildIndex::from_index(index).unwrap(), ) .unwrap(); - let pk = secp256k1::PublicKey::from_secret_key(&secp256k1::Secp256k1::new(), &sk); + let pk = secp256k1::PublicKey::from_secret_key(&sk); crate::imported::encode_transparent_address( &TransparentAddress::from_pubkey(&pk), ZeckNetwork::Mainnet, @@ -724,7 +724,7 @@ mod tests { .unwrap(); assert_eq!( imported.transparent[0].secret.expose_secret(), - &expected.secret_bytes(), + &expected.to_secret_bytes(), "the retained match must hand the existing signer its exact nonzero-index key" ); let serialized = serde_json::to_string(&result).unwrap(); diff --git a/crates/zeck-core/src/address_search_shielded.rs b/crates/zeck-core/src/address_search_shielded.rs index b7351ce3..73146d22 100644 --- a/crates/zeck-core/src/address_search_shielded.rs +++ b/crates/zeck-core/src/address_search_shielded.rs @@ -6,7 +6,7 @@ use crate::{ use std::collections::BTreeSet; use zcash_address::unified::{Address as UnifiedAddress, Container, Encoding, Receiver}; use zcash_keys::{encoding::AddressCodec, keys::sapling}; -use zcash_protocol::consensus::{NetworkConstants, NetworkType, MAIN_NETWORK, TEST_NETWORK}; +use zcash_protocol::consensus::{NetworkType, MAIN_NETWORK, TEST_NETWORK}; use zip32::AccountId; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] @@ -23,7 +23,7 @@ pub struct TargetReceivers { impl TargetReceivers { pub fn parse(target: &str, network: ZeckNetwork) -> ZeckResult { let mut receivers = BTreeSet::new(); - if let Ok((actual, ua)) = UnifiedAddress::decode(target) { + if let Ok((actual, _, ua)) = UnifiedAddress::decode(target) { if actual != net(network) { return Err(ZeckError::WrongNetwork { expected: network.label().into(), @@ -45,11 +45,11 @@ impl TargetReceivers { } let address = match network { ZeckNetwork::Mainnet => zcash_keys::encoding::decode_payment_address( - MAIN_NETWORK.hrp_sapling_payment_address(), + zcash_address::constants::hrp_sapling_payment_address(NetworkType::Main), target, ), ZeckNetwork::Testnet => zcash_keys::encoding::decode_payment_address( - TEST_NETWORK.hrp_sapling_payment_address(), + zcash_address::constants::hrp_sapling_payment_address(NetworkType::Test), target, ), }; @@ -86,11 +86,16 @@ impl AccountMatcher { let id = AccountId::try_from(account).map_err(|_| { ZeckError::InvalidConfig(format!("account index {account} is out of range")) })?; - let sapling_sk = sapling::spending_key(seed, network.coin_type(), id); + let sapling_sk = sapling::spending_key(seed, network.coin_type(), id).ok_or_else(|| { + ZeckError::Internal("Sapling spending-key derivation failed".to_owned()) + })?; let orchard_sk = orchard::keys::SpendingKey::from_zip32_seed(seed, network.coin_type(), id) .map_err(|e| ZeckError::Internal(e.to_string()))?; let sapling_internal_fvk = sapling_sk .derive_internal() + .ok_or_else(|| { + ZeckError::Internal("Sapling internal-key derivation failed".to_owned()) + })? .to_diversifiable_full_viewing_key(); Ok(Self { network, @@ -140,9 +145,13 @@ impl AccountMatcher { .receivers .contains(&ShieldedReceiver::Orchard(address.to_raw_address_bytes())) { - let ua = UnifiedAddress::try_from_items(vec![Receiver::Orchard( - address.to_raw_address_bytes(), - )]) + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(address.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .map_err(|e| ZeckError::Internal(e.to_string()))?; out.push(MatchedReceiver { pool: DiscoveryPool::Orchard, @@ -173,9 +182,13 @@ mod tests { let external = m .orchard_fvk .address_at(7u32, orchard::keys::Scope::External); - let ua = UnifiedAddress::try_from_items(vec![Receiver::Orchard( - external.to_raw_address_bytes(), - )]) + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(external.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .unwrap(); let target = TargetReceivers::parse(&ua.encode(&NetworkType::Main), ZeckNetwork::Mainnet).unwrap(); @@ -186,9 +199,13 @@ mod tests { let internal = m .orchard_fvk .address_at(7u32, orchard::keys::Scope::Internal); - let ua = UnifiedAddress::try_from_items(vec![Receiver::Orchard( - internal.to_raw_address_bytes(), - )]) + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(internal.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .unwrap(); let target = TargetReceivers::parse(&ua.encode(&NetworkType::Main), ZeckNetwork::Mainnet).unwrap(); @@ -212,10 +229,16 @@ mod tests { .map(|address| (i, address)) }) .unwrap(); - let ua = UnifiedAddress::try_from_items(vec![ - Receiver::Orchard(orchard.to_raw_address_bytes()), - Receiver::Sapling(sapling.to_bytes()), - ]) + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![ + Receiver::Orchard(orchard.to_raw_address_bytes()), + Receiver::Sapling(sapling.to_bytes()), + ] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .unwrap(); let target = TargetReceivers::parse(&ua.encode(&NetworkType::Main), ZeckNetwork::Mainnet).unwrap(); @@ -231,8 +254,14 @@ mod tests { let (valid, sapling) = (invalid + 1..1000) .find_map(|i| ivk.address_at(i).map(|address| (i, address))) .unwrap(); - let ua = - UnifiedAddress::try_from_items(vec![Receiver::Sapling(sapling.to_bytes())]).unwrap(); + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Sapling(sapling.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .unwrap(); let target = TargetReceivers::parse(&ua.encode(&NetworkType::Main), ZeckNetwork::Mainnet).unwrap(); assert_eq!( @@ -256,9 +285,14 @@ mod tests { let (internal_index, internal_address) = (1u32..1000) .find_map(|i| internal_fvk.to_external_ivk().address_at(i).map(|a| (i, a))) .unwrap(); - let internal_ua = - UnifiedAddress::try_from_items(vec![Receiver::Sapling(internal_address.to_bytes())]) - .unwrap(); + let internal_ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Sapling(internal_address.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .unwrap(); let internal_target = TargetReceivers::parse( &internal_ua.encode(&NetworkType::Main), ZeckNetwork::Mainnet, @@ -280,8 +314,14 @@ mod tests { let a = m .orchard_fvk .address_at(0u32, orchard::keys::Scope::External); - let ua = UnifiedAddress::try_from_items(vec![Receiver::Orchard(a.to_raw_address_bytes())]) - .unwrap(); + let ua = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(a.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .unwrap(); assert!(matches!( TargetReceivers::parse(&ua.encode(&NetworkType::Main), ZeckNetwork::Testnet), Err(ZeckError::WrongNetwork { .. }) diff --git a/crates/zeck-core/src/birthday.rs b/crates/zeck-core/src/birthday.rs index cb41cc48..293e5830 100644 --- a/crates/zeck-core/src/birthday.rs +++ b/crates/zeck-core/src/birthday.rs @@ -35,8 +35,10 @@ const SAPLING_ACTIVATION_DATE: CalendarDate = CalendarDate { }; /// Pre-Blossom block target was 150 s. Used by the offline fallback only. const PRE_BLOSSOM_BLOCK_SECONDS: i64 = 150; -/// Post-Blossom (and current) block target is 75 s. +/// Post-Blossom and pre-NU7 block target is 75 s. const POST_BLOSSOM_BLOCK_SECONDS: i64 = 75; +/// NU7 reduces the target to 25 seconds at its network-specific height. +const POST_NU7_BLOCK_SECONDS: i64 = 25; /// Mainnet Blossom activation: block 653,600 ≈ 2019-12-11. const BLOSSOM_ACTIVATION_HEIGHT: u32 = 653_600; const BLOSSOM_ACTIVATION_DATE: CalendarDate = CalendarDate { @@ -66,30 +68,89 @@ struct CalendarDate { day: u8, } -/// Offline piecewise estimator: 150 s/block from Sapling activation through -/// Blossom (block 653,600), then 75 s/block thereafter. Used as the fallback -/// when lightwalletd is unreachable, and as the round-trip helper below. +/// Consensus spacing at a known height. This never infers activation from a +/// calendar date, including when a local regtest schedule is installed. +fn birthday_block_seconds(network: ZeckNetwork, height: u32) -> i64 { + if crate::nu7::activation_height(network).is_some_and(|activation| height >= activation) { + POST_NU7_BLOCK_SECONDS + } else if height + >= match network { + ZeckNetwork::Mainnet => BLOSSOM_ACTIVATION_HEIGHT, + ZeckNetwork::Testnet => 584_000, + } + { + POST_BLOSSOM_BLOCK_SECONDS + } else { + PRE_BLOSSOM_BLOCK_SECONDS + } +} + +/// Preserve the historical margin, and at least its one-week duration when +/// the target spacing falls to 25 seconds. This is a dating margin, not a +/// transaction-confirmation or finality threshold. +fn date_safety_buffer_blocks(network: ZeckNetwork, height: u32) -> u32 { + DATE_SAFETY_BUFFER_BLOCKS.max( + u32::try_from(7 * DAY_SECONDS / birthday_block_seconds(network, height)) + .unwrap_or(DATE_SAFETY_BUFFER_BLOCKS), + ) +} + +/// Conservative mainnet offline estimate. Historical 150/75-second anchors +/// are retained. An offline clock cannot establish when NU7 actually mined, +/// so dates beyond that historical extrapolation stop before activation +/// rather than guessing a calendar date for the 25-second transition. pub fn estimate_birthday_from_date_offline(date: &str) -> ZeckResult { + estimate_birthday_from_date_offline_for_network(date, ZeckNetwork::Mainnet) +} + +/// Network-aware offline fallback. Testnet has no reliable calendar anchors +/// because its production includes stalls and minimum-difficulty bursts; +/// scanning from Sapling activation is safer than inventing a later birthday. +pub fn estimate_birthday_from_date_offline_for_network( + date: &str, + network: ZeckNetwork, +) -> ZeckResult { let parsed = CalendarDate::parse(date)?; + if network == ZeckNetwork::Testnet { + return Ok(280_000); + } if parsed <= SAPLING_ACTIVATION_DATE { return Ok(SAPLING_ACTIVATION_HEIGHT); } - - if parsed <= BLOSSOM_ACTIVATION_DATE { - let seconds = parsed - .days_since_unix_epoch() - .saturating_sub(SAPLING_ACTIVATION_DATE.days_since_unix_epoch()) - .saturating_mul(DAY_SECONDS); - let blocks = (seconds / PRE_BLOSSOM_BLOCK_SECONDS).max(0) as u32; - return Ok(SAPLING_ACTIVATION_HEIGHT.saturating_add(blocks)); - } - + let (anchor_date, anchor_height, seconds_per_block) = if parsed <= BLOSSOM_ACTIVATION_DATE { + ( + SAPLING_ACTIVATION_DATE, + SAPLING_ACTIVATION_HEIGHT, + PRE_BLOSSOM_BLOCK_SECONDS, + ) + } else { + ( + BLOSSOM_ACTIVATION_DATE, + BLOSSOM_ACTIVATION_HEIGHT, + POST_BLOSSOM_BLOCK_SECONDS, + ) + }; let seconds = parsed .days_since_unix_epoch() - .saturating_sub(BLOSSOM_ACTIVATION_DATE.days_since_unix_epoch()) + .saturating_sub(anchor_date.days_since_unix_epoch()) .saturating_mul(DAY_SECONDS); - let blocks = (seconds / POST_BLOSSOM_BLOCK_SECONDS).max(0) as u32; - Ok(BLOSSOM_ACTIVATION_HEIGHT.saturating_add(blocks)) + let blocks = u32::try_from((seconds / seconds_per_block).max(0)).unwrap_or(u32::MAX); + let mut height = anchor_height.saturating_add(blocks); + let target_time = parsed.days_since_unix_epoch().saturating_mul(DAY_SECONDS); + // Recent dates also use the observed mainnet anchors and their existing + // four-week dating margin. The display estimator's synthetic continuity + // date for NU7 can precede its actual mined timestamp; it must never + // advance a scan past history that the conservative anchors still cover. + if target_time >= MAINNET_HEIGHT_ANCHORS[MAINNET_HEIGHT_ANCHORS.len() - 1].1 { + if let Some(conservative) = height_at_or_before_time(network, target_time) { + height = height.min(conservative); + } + } + Ok( + crate::nu7::activation_height(network).map_or(height, |activation| { + height.min(activation.saturating_sub(1)) + }), + ) } /// Estimate a wallet birthday from a date by binary-searching lightwalletd for @@ -99,9 +160,24 @@ pub fn estimate_birthday_from_date_offline(date: &str) -> ZeckResult { /// A safety margin of ~1 week (`DATE_SAFETY_BUFFER_BLOCKS`) is subtracted so /// we err toward over-scanning rather than missing notes. pub async fn estimate_birthday_from_date(date: &str, lightwalletd_url: &str) -> ZeckResult { + estimate_birthday_from_date_for_network(date, lightwalletd_url, ZeckNetwork::Mainnet).await +} + +/// Estimate against the selected network's live block timestamps. The +/// binary search naturally spans NU7's spacing transition without assigning +/// the upgrade a speculative calendar date. +pub async fn estimate_birthday_from_date_for_network( + date: &str, + lightwalletd_url: &str, + network: ZeckNetwork, +) -> ZeckResult { let parsed = CalendarDate::parse(date)?; + let network_floor = match network { + ZeckNetwork::Mainnet => SAPLING_ACTIVATION_HEIGHT, + ZeckNetwork::Testnet => 280_000, + }; if parsed <= SAPLING_ACTIVATION_DATE { - return Ok(SAPLING_ACTIVATION_HEIGHT); + return Ok(network_floor); } let _ = rustls::crypto::ring::default_provider().install_default(); @@ -110,24 +186,25 @@ pub async fn estimate_birthday_from_date(date: &str, lightwalletd_url: &str) -> let probed = match probe_lightwalletd_endpoints(lightwalletd_url).await { Ok(probe) => probe, - Err(_) => return estimate_birthday_from_date_offline(date), + Err(_) => return estimate_birthday_from_date_offline_for_network(date, network), }; let (mut client, _endpoint, chain_info) = probed; + validate_lightwalletd_network(network, &chain_info)?; let chain_tip = match u32::try_from(chain_info.block_height) { Ok(h) => h, - Err(_) => return estimate_birthday_from_date_offline(date), + Err(_) => return estimate_birthday_from_date_offline_for_network(date, network), }; let sapling_floor = - u32::try_from(chain_info.sapling_activation_height).unwrap_or(SAPLING_ACTIVATION_HEIGHT); + u32::try_from(chain_info.sapling_activation_height).unwrap_or(network_floor); let tip_time = match fetch_block_time(&mut client, chain_tip).await { Ok(t) => t, - Err(_) => return estimate_birthday_from_date_offline(date), + Err(_) => return estimate_birthday_from_date_offline_for_network(date, network), }; if target_unix >= tip_time { return Ok(chain_tip - .saturating_sub(DATE_SAFETY_BUFFER_BLOCKS) + .saturating_sub(date_safety_buffer_blocks(network, chain_tip)) .max(sapling_floor)); } @@ -137,7 +214,7 @@ pub async fn estimate_birthday_from_date(date: &str, lightwalletd_url: &str) -> let mid = lo + (hi - lo) / 2; let mid_time = match fetch_block_time(&mut client, mid).await { Ok(t) => t, - Err(_) => return estimate_birthday_from_date_offline(date), + Err(_) => return estimate_birthday_from_date_offline_for_network(date, network), }; if mid_time < target_unix { lo = mid + 1; @@ -147,36 +224,35 @@ pub async fn estimate_birthday_from_date(date: &str, lightwalletd_url: &str) -> } Ok(lo - .saturating_sub(DATE_SAFETY_BUFFER_BLOCKS) + .saturating_sub(date_safety_buffer_blocks(network, lo)) .max(sapling_floor)) } -/// Inverse of the offline estimator: given a block height, return the -/// approximate calendar date as `YYYY-MM-DD`. +/// Display-only piecewise estimate: historical 150/75-second targets, then +/// 25 seconds from the assigned mainnet NU7 height. The derived continuity +/// anchor is not an observed activation timestamp and is never inverted to +/// determine a post-NU7 scan birthday. /// /// Below Sapling activation it counts back from Sapling at the same 150 s /// target, floored at the mainnet genesis date: a wallet.dat birthday can be /// pre-Sapling, and a date stuck at 2018 beside it would misstate its age. pub fn estimate_date_from_height_offline(height: u32) -> String { - let (anchor_date, anchor_height, block_seconds) = if height <= BLOSSOM_ACTIVATION_HEIGHT { - ( - SAPLING_ACTIVATION_DATE, - SAPLING_ACTIVATION_HEIGHT, - PRE_BLOSSOM_BLOCK_SECONDS, - ) + let seconds = if height <= BLOSSOM_ACTIVATION_HEIGHT { + SAPLING_ACTIVATION_DATE.days_since_unix_epoch() * DAY_SECONDS + + (i64::from(height) - i64::from(SAPLING_ACTIVATION_HEIGHT)) * PRE_BLOSSOM_BLOCK_SECONDS } else { - ( - BLOSSOM_ACTIVATION_DATE, - BLOSSOM_ACTIVATION_HEIGHT, - POST_BLOSSOM_BLOCK_SECONDS, - ) + let pre_nu7_height = crate::nu7::activation_height(ZeckNetwork::Mainnet) + .map_or(height, |activation| height.min(activation)); + let post_nu7_blocks = height.saturating_sub(pre_nu7_height); + BLOSSOM_ACTIVATION_DATE.days_since_unix_epoch() * DAY_SECONDS + + (i64::from(pre_nu7_height) - i64::from(BLOSSOM_ACTIVATION_HEIGHT)) + * POST_BLOSSOM_BLOCK_SECONDS + + i64::from(post_nu7_blocks) * birthday_block_seconds(ZeckNetwork::Mainnet, height) }; - - let delta_blocks = i64::from(height) - i64::from(anchor_height); - let delta_days = (delta_blocks * block_seconds).div_euclid(DAY_SECONDS); - let absolute_days = anchor_date - .days_since_unix_epoch() - .saturating_add(delta_days) + // This date is an approximate display hint, never evidence that NU7 + // activated on a particular date or permission to skip unscanned blocks. + let absolute_days = seconds + .div_euclid(DAY_SECONDS) .max(MAINNET_GENESIS_DATE.days_since_unix_epoch()); CalendarDate::from_days_since_unix_epoch(absolute_days).format() } @@ -280,8 +356,10 @@ pub fn unix_time_now() -> i64 { /// `unix_time`, less a four-week margin. Clamped to at least 1. /// /// Interpolates between [`MAINNET_HEIGHT_ANCHORS`] and extrapolates past the -/// last at [`EXTRAPOLATION_BLOCK_SECONDS`], rounding down throughout. Pure; -/// no network. +/// last at [`EXTRAPOLATION_BLOCK_SECONDS`], rounding down throughout. Keeping +/// this deliberately slow extrapolation after NU7 can only lower the bound +/// relative to the new 25-second target; no upgrade timestamp is guessed. +/// Pure; no network. /// /// `None` on testnet. Testnet's block production has been irregular — /// stalls and minimum-difficulty bursts — so no anchor table there could be @@ -1463,6 +1541,79 @@ mod tests { assert!(!note.contains("around 20")); } + #[test] + fn nu7_birthday_spacing_follows_network_height_not_calendar_date() { + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + assert_eq!(birthday_block_seconds(network, activation - 1), 75); + assert_eq!(birthday_block_seconds(network, activation), 25); + assert_eq!(birthday_block_seconds(network, activation + 1), 25); + } + assert_eq!(birthday_block_seconds(ZeckNetwork::Mainnet, 500_000), 150); + assert_eq!(birthday_block_seconds(ZeckNetwork::Mainnet, 1_000_000), 75); + } + + #[test] + fn nu7_height_date_segment_uses_twenty_five_seconds_and_preserves_history() { + let activation = crate::nu7::activation_height(ZeckNetwork::Mainnet).unwrap(); + let day = |height| { + CalendarDate::parse(&estimate_date_from_height_offline(height)) + .unwrap() + .days_since_unix_epoch() + }; + assert_eq!(day(activation) - day(activation - 1_152), 1); + assert_eq!(day(activation + 3_456) - day(activation), 1); + assert_eq!(day(activation + 6_912) - day(activation), 2); + assert_eq!(estimate_date_from_height_offline(419_200), "2018-10-28"); + assert!(CalendarDate::parse(&estimate_date_from_height_offline(u32::MAX)).is_ok()); + } + + #[test] + fn birthday_margin_keeps_a_week_at_nu7_without_changing_finality_thresholds() { + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + assert_eq!(date_safety_buffer_blocks(network, activation - 1), 8_064); + assert_eq!(date_safety_buffer_blocks(network, activation), 24_192); + assert_eq!(date_safety_buffer_blocks(network, activation + 1), 24_192); + } + assert_eq!(date_safety_buffer_blocks(ZeckNetwork::Mainnet, 1), 8_064); + assert_eq!(birthday_block_seconds(ZeckNetwork::Testnet, 583_999), 150); + assert_eq!(birthday_block_seconds(ZeckNetwork::Testnet, 584_000), 75); + } + + #[test] + fn recent_offline_dates_stay_below_the_observed_anchor_bound() { + let activation = crate::nu7::activation_height(ZeckNetwork::Mainnet).unwrap(); + for height in [activation - 1, activation, activation + 3_456] { + let date = estimate_date_from_height_offline(height); + let timestamp = + CalendarDate::parse(&date).unwrap().days_since_unix_epoch() * DAY_SECONDS; + let conservative = height_at_or_before_time(ZeckNetwork::Mainnet, timestamp).unwrap(); + assert!(estimate_birthday_from_date_offline(&date).unwrap() <= conservative); + } + } + + #[test] + fn offline_dates_never_guess_when_nu7_activated() { + let activation = crate::nu7::activation_height(ZeckNetwork::Mainnet).unwrap(); + for date in ["2030-01-01", "9999-12-31", "2147483647-12-31"] { + assert_eq!( + estimate_birthday_from_date_offline(date).unwrap(), + activation - 1 + ); + } + // Testnet has no reliable calendar anchor; the pool floor is safe. + assert_eq!( + estimate_birthday_from_date_offline_for_network("2030-01-01", ZeckNetwork::Testnet) + .unwrap(), + 280_000 + ); + assert!( + estimate_birthday_from_date_offline_for_network("invalid", ZeckNetwork::Testnet) + .is_err() + ); + } + #[test] fn sapling_activation_date_returns_activation_height() { let h = estimate_birthday_from_date_offline("2018-10-28").unwrap(); diff --git a/crates/zeck-core/src/broadcast/mod.rs b/crates/zeck-core/src/broadcast/mod.rs index b3a88aa4..523e1df1 100644 --- a/crates/zeck-core/src/broadcast/mod.rs +++ b/crates/zeck-core/src/broadcast/mod.rs @@ -39,3 +39,6 @@ pub use submission::*; #[cfg(test)] mod tests; + +// Fresh-tip validation is shared by submission and exact-byte retries. +pub(crate) use submission::validate_retry_at_tip; diff --git a/crates/zeck-core/src/broadcast/observation.rs b/crates/zeck-core/src/broadcast/observation.rs index f22833a6..05c36b87 100644 --- a/crates/zeck-core/src/broadcast/observation.rs +++ b/crates/zeck-core/src/broadcast/observation.rs @@ -52,11 +52,13 @@ pub struct TxObservation { /// arrives second; the destination is fixed by the reviewed request, so no /// value can be redirected. The margin absorbs ordinary tip skew and a short /// reorg around the expiry height, which is why a single configured source -/// suffices. +/// suffices. This is a chain-depth margin, independent of the target block +/// interval; NU7 does not change it into a wall-clock timeout. pub const EXPIRY_MARGIN_BLOCKS: u32 = 20; /// Confirmations a corroborated (independent-pair) Mined transaction needs -/// before Argos tells the user the source keys may be discarded. +/// before Argos tells the user the source keys may be discarded. This is a +/// corroborated chain-depth policy, retained across NU7, not elapsed time. pub const MIN_DISCARD_CONFIRMATIONS: u32 = 10; fn independent_evidence_sources(a: &EndpointTxEvidence, b: &EndpointTxEvidence) -> bool { diff --git a/crates/zeck-core/src/broadcast/submission.rs b/crates/zeck-core/src/broadcast/submission.rs index a9d9763e..d1510d2f 100644 --- a/crates/zeck-core/src/broadcast/submission.rs +++ b/crates/zeck-core/src/broadcast/submission.rs @@ -7,10 +7,14 @@ use zcash_client_backend::proto::service::{ compact_tx_streamer_client::CompactTxStreamerClient, RawTransaction, SendResponse, }; use zcash_primitives::transaction::{Transaction, TxId}; -use zcash_protocol::consensus::BranchId; +use zcash_protocol::consensus::{BlockHeight, BranchId}; use super::{lifecycle::rejection_can_be_definitive, TxLifecycleState, TxObservation}; -use crate::error::{ZeckError, ZeckResult}; +use crate::{ + error::{ZeckError, ZeckResult}, + models::ZeckNetwork, + workspace::consensus_network, +}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "kind", rename_all = "snake_case")] @@ -52,8 +56,17 @@ pub trait BroadcastStore { /// A single raw transaction submission. The caller owns the durable record. #[async_trait] -pub trait TxSubmitter { +pub trait TxSubmitter: Send { async fn send_raw(&mut self, raw: Vec) -> Result; + + /// Fresh evidence from the endpoint that will receive an explicit retry. + /// Ordinary submitters cannot silently authorize old bytes with an unknown + /// height; adapters supporting retry must validate the requested network. + async fn validated_tip(&mut self, _network: ZeckNetwork) -> ZeckResult { + Err(ZeckError::Broadcast( + "cannot establish a fresh network-validated tip for retry; keep the stored transaction bytes and reconcile their status before replanning".into(), + )) + } } pub struct LightwalletdSubmitter<'a> { @@ -62,6 +75,10 @@ pub struct LightwalletdSubmitter<'a> { #[async_trait] impl TxSubmitter for LightwalletdSubmitter<'_> { + async fn validated_tip(&mut self, network: ZeckNetwork) -> ZeckResult { + crate::nu7::validated_tip_from_client(self.client, network).await + } + async fn send_raw(&mut self, raw: Vec) -> Result { self.client .send_transaction(RawTransaction { @@ -180,6 +197,40 @@ pub(crate) fn txid_from_raw(raw_tx: &[u8]) -> ZeckResult { Ok(parsed.txid()) } +/// Check the exact persisted transaction against the candidate next block. +/// V5/V6 retain their format across upgrades, but their encoded branch binds +/// their signatures. Reading old bytes with a new fallback branch cannot +/// change that encoded authority. This check neither mutates nor rebuilds them. +pub(crate) fn validate_retry_at_tip( + raw_tx: &[u8], + network: ZeckNetwork, + tip: u32, +) -> ZeckResult<()> { + let next_height = tip.checked_add(1).filter(|_| tip > 0).ok_or_else(|| { + ZeckError::Broadcast("cannot establish a supported next-block height for retry; keep the stored transaction bytes and reconcile their status before replanning".into()) + })?; + let branch = BranchId::for_height( + &consensus_network(network), + BlockHeight::from_u32(next_height), + ); + let mut cursor = Cursor::new(raw_tx); + let transaction = Transaction::read(&mut cursor, branch).map_err(|err| { + ZeckError::TransactionBuild(format!( + "cannot parse persisted transaction for retry: {err}" + )) + })?; + if cursor.position() != raw_tx.len() as u64 { + return Err(ZeckError::TransactionBuild( + "persisted transaction has trailing bytes".into(), + )); + } + crate::nu7::validate_transaction_for_tip(network, tip, &transaction).map_err(|err| { + ZeckError::Broadcast(format!( + "stored transaction cannot be retried ({err}); keep its exact bytes and reconcile its status before replanning" + )) + }) +} + pub async fn submit_prepared_transaction( store: &mut S, network: &mut N, diff --git a/crates/zeck-core/src/derivation.rs b/crates/zeck-core/src/derivation.rs index 2b485924..6a352ac0 100644 --- a/crates/zeck-core/src/derivation.rs +++ b/crates/zeck-core/src/derivation.rs @@ -168,7 +168,8 @@ fn derive_account( let zip32_index = AccountId::try_from(index) .map_err(|_| ZeckError::InvalidConfig(format!("account index {index} is out of range")))?; - let sapling_extsk = sapling::spending_key(seed, network.coin_type(), zip32_index); + let sapling_extsk = sapling::spending_key(seed, network.coin_type(), zip32_index) + .ok_or_else(|| ZeckError::Internal("Sapling spending-key derivation failed".to_owned()))?; let sapling_address = sapling_extsk .to_diversifiable_full_viewing_key() .default_address() @@ -180,10 +181,16 @@ fn derive_account( let orchard_fvk = orchard::keys::FullViewingKey::from(&orchard_sk); let orchard_address = orchard_fvk.address_at(0u32, orchard::keys::Scope::External); - let unified = UnifiedAddress::try_from_items(vec![ - Receiver::Orchard(orchard_address.to_raw_address_bytes()), - Receiver::Sapling(sapling_address.to_bytes()), - ]) + let unified = UnifiedAddress::try_from_items( + zcash_address::unified::Revision::R0, + vec![ + Receiver::Orchard(orchard_address.to_raw_address_bytes()), + Receiver::Sapling(sapling_address.to_bytes()), + ] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) .map_err(|err| ZeckError::Internal(err.to_string()))?; let child_index = NonHardenedChildIndex::from_index(index).ok_or_else(|| { @@ -281,8 +288,7 @@ pub(crate) fn transparent_address_from_seed( index: u32, ) -> ZeckResult { let secret = legacy_transparent_secret_key_for_account(network, seed, account, scope, index)?; - let public = - secp256k1::PublicKey::from_secret_key(&secp256k1::Secp256k1::signing_only(), &secret); + let public = secp256k1::PublicKey::from_secret_key(&secret); Ok(zcash_transparent::address::TransparentAddress::from_pubkey( &public, )) diff --git a/crates/zeck-core/src/imported.rs b/crates/zeck-core/src/imported.rs index 3383f19b..e24cd0da 100644 --- a/crates/zeck-core/src/imported.rs +++ b/crates/zeck-core/src/imported.rs @@ -12,8 +12,8 @@ //! is account-id driven and accepts raw per-pool keys, which is what makes //! this work at all; see `docs/` for the full argument. +use crate::workspace::WalletRng; use argos_wallet_import::{ImportedKeys, SecretBytes}; -use rand_core::OsRng; use secrecy::ExposeSecret; use zcash_address::unified::{Encoding, Fvk, Ufvk}; use zcash_client_backend::data_api::{ @@ -33,7 +33,7 @@ use crate::{ }; /// The concrete wallet database Argos opens everywhere. -pub type ArgosWalletDb = WalletDb; +pub type ArgosWalletDb = WalletDb; /// Serialized length of a Sapling extended spending key. const EXTSK_LEN: usize = 169; @@ -124,9 +124,14 @@ impl ImportedSaplingSpendingKey { /// only route that keeps this working in a release build. pub fn sapling_ufvk(extsk: &ExtendedSpendingKey) -> ZeckResult { let dfvk = extsk.to_diversifiable_full_viewing_key(); - let ufvk = Ufvk::try_from_items(vec![Fvk::Sapling(dfvk.to_bytes())]).map_err(|err| { - ZeckError::Import(format!("assembling a Sapling-only UFVK failed: {err}")) - })?; + let ufvk = Ufvk::try_from_items( + zcash_address::unified::Revision::R0, + vec![Fvk::Sapling(dfvk.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .map_err(|err| ZeckError::Import(format!("assembling a Sapling-only UFVK failed: {err}")))?; UnifiedFullViewingKey::parse(&ufvk) .map_err(|err| ZeckError::Import(format!("parsing the assembled UFVK failed: {err}"))) } @@ -205,7 +210,7 @@ impl Drop for ImportedTransparentSecret { if let Some(probe) = &self.drop_probe { // rust-secp256k1 deliberately overwrites a SecretKey with the // valid scalar [1; 32], rather than an invalid all-zero scalar. - debug_assert_eq!(self.key.as_ref(), &[1; 32]); + debug_assert_eq!(self.key.as_secret_bytes(), &[1; 32]); probe.store(true, std::sync::atomic::Ordering::SeqCst); } } @@ -277,13 +282,14 @@ impl std::fmt::Debug for ImportedTransparentKey { /// yielding the same address is a fact about the wallet worth surfacing /// rather than silently collapsing. pub fn imported_transparent_keys(keys: &ImportedKeys) -> ZeckResult> { - let secp = secp256k1::Secp256k1::signing_only(); keys.transparent .iter() .map(|key| { - let mut secret = secp256k1::SecretKey::from_slice(key.secret.expose_secret()) - .map_err(|err| ZeckError::Import(format!("malformed transparent key: {err}")))?; - let pubkey = secp256k1::PublicKey::from_secret_key(&secp, &secret); + let mut secret = secp256k1::SecretKey::from_secret_bytes(*key.secret.expose_secret()) + .map_err(|err| { + ZeckError::Import(format!("malformed transparent key: {err}")) + })?; + let pubkey = secp256k1::PublicKey::from_secret_key(&secret); Ok(ImportedTransparentKey::new( &mut secret, TransparentAddress::from_pubkey(&pubkey), @@ -403,13 +409,12 @@ pub fn register_imported_accounts( )); }; - let secp = secp256k1::Secp256k1::signing_only(); let existing = wallet_db .get_transparent_receivers(anchor.wallet_account_id, true, true) .map_err(|err| ZeckError::Wallet(format!("loading transparent receivers: {err}")))?; for imported in imported_transparent_keys(keys)? { - let pubkey = secp256k1::PublicKey::from_secret_key(&secp, imported.secret_key()); + let pubkey = secp256k1::PublicKey::from_secret_key(imported.secret_key()); let address = imported.address; if !existing.contains_key(&address) { @@ -467,16 +472,15 @@ mod tests { Arc, }; - let mut secret = secp256k1::SecretKey::from_slice(&[0x42; 32]).expect("valid fixture key"); - let address = TransparentAddress::from_pubkey(&secp256k1::PublicKey::from_secret_key( - &secp256k1::Secp256k1::signing_only(), - &secret, - )); + let mut secret = + secp256k1::SecretKey::from_secret_bytes([0x42; 32]).expect("valid fixture key"); + let address = + TransparentAddress::from_pubkey(&secp256k1::PublicKey::from_secret_key(&secret)); let probe = Arc::new(AtomicBool::new(false)); let owner = ImportedTransparentKey::with_drop_probe(&mut secret, address, Arc::clone(&probe)); assert_eq!( - secret.as_ref(), + secret.as_secret_bytes(), &[1; 32], "constructor must scrub caller local" ); @@ -548,7 +552,7 @@ mod tests { "an imported Sapling key must not claim an Orchard component" ); assert!( - ufvk.transparent().is_none(), + ufvk.p2pkh().is_none(), "an imported Sapling key must not claim a transparent component" ); } @@ -652,22 +656,23 @@ mod tests { ); } - /// The constraint that bounds what Argos can offer: ZIP-316 forbids a - /// unified container holding only transparent items - /// (`zcash_address/src/kind/unified.rs`, `try_from_items`). A zcashd - /// wallet with transparent keys and no shielded keys therefore has no - /// UFVK, so it cannot be given an account at all. - /// - /// Pinned as a test so that if upstream ever relaxes it, this fails and - /// tells us the transparent-only path just became possible — rather - /// than the limitation quietly outliving its cause. + /// Preserve the Revision 0 container used by existing imported accounts. + /// Revision 0 forbids a transparent-only UFVK; NU7's newer revisions do + /// not change the format of an existing Argos account or its direct + /// transparent recovery route. #[test] - fn a_transparent_only_container_is_still_rejected_upstream() { + fn a_revision_zero_transparent_only_container_is_rejected() { let items: Vec = vec![Fvk::P2pkh([0u8; 65])]; assert!( - Ufvk::try_from_items(items).is_err(), - "ZIP-316 must still forbid a transparent-only UFVK; if this now \ - succeeds, transparent-only wallet import is unblocked" + Ufvk::try_from_items( + zcash_address::unified::Revision::R0, + items + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect() + ) + .is_err(), + "ZIP-316 Revision 0 must reject a transparent-only UFVK" ); } } @@ -808,7 +813,9 @@ mod db_tests { let base = fixture_keys("sprout-plaintext.dat"); let first = parse_sapling_extsk(base.sapling[0].extsk.expose_secret()) .expect("the golden fixture's Sapling key must parse"); - let second = first.derive_child(zip32::ChildIndex::hardened(7)); + let second = first + .derive_child(zip32::ChildIndex::hardened(7)) + .expect("valid fixture child key"); assert_ne!( first.to_bytes(), second.to_bytes(), diff --git a/crates/zeck-core/src/imported_sweep.rs b/crates/zeck-core/src/imported_sweep.rs index e6624cb3..015d0dfb 100644 --- a/crates/zeck-core/src/imported_sweep.rs +++ b/crates/zeck-core/src/imported_sweep.rs @@ -119,26 +119,7 @@ impl From for ProofKeyError { } } -/// Build, prove, sign, and extract a transaction spending every Sapling -/// note in an imported account. -/// -/// Restricted to the Sapling pool deliberately, and not only because that -/// is all an imported zcashd wallet can hold: `create_pczt_from_proposal` -/// accepts single-step proposals only, and a multi-pool sweep is -/// multi-step. Transparent funds on the same account are recovered through -/// `transparent_recovery`, which needs no proposal at all. -/// -/// Does not broadcast. The caller decides that, so a dry run and a real -/// sweep cannot diverge in how the transaction was built. -/// -/// `max_fee_zatoshis` is the user's `--max-fee`, a cap on the whole sweep; -/// `prior_fee_zatoshis` is what this sweep's earlier transactions already -/// paid, and each gate checks the two together. It is enforced twice and -/// never after broadcast: once against the proposal, before any proving -/// work, and once against the fee actually encoded in the extracted -/// transaction. The second is the one that matters — the first is the -/// planner's own arithmetic restated, whereas the second reads what was -/// built. +/// Plan an imported account send-max, including all bounded NU7 batches. pub(crate) fn propose_imported_sapling_sweep

( wallet_db: &mut crate::imported::ArgosWalletDb, params: &P, @@ -148,7 +129,7 @@ pub(crate) fn propose_imported_sapling_sweep

( where P: zcash_protocol::consensus::Parameters + Clone, { - propose_send_max_transfer::<_, _, _, std::convert::Infallible>( + let proposal = propose_send_max_transfer::<_, _, _, std::convert::Infallible>( wallet_db, params, account_id, @@ -161,9 +142,31 @@ where &LockedInputPolicy::Exclude, None, ) - .map_err(|err| ZeckError::TransactionBuild(format!("proposing the Sapling sweep: {err}"))) + .map_err(|err| ZeckError::TransactionBuild(format!("proposing the Sapling sweep: {err}")))?; + crate::nu7_limits::bound_send_max(params, proposal) } +/// Build, prove, sign, and extract one independent imported Sapling transaction. +/// +/// Restricted to the Sapling pool deliberately, and not only because that +/// is all an imported zcashd wallet can hold: `create_pczt_from_proposal` +/// accepts single-step proposals only, and a multi-pool sweep is +/// multi-step. Transparent funds on the same account are recovered through +/// `transparent_recovery`, which needs no proposal at all. +/// +/// Does not broadcast. The caller decides that, so a dry run and a real +/// sweep cannot diverge in how the transaction was built. +/// +/// `max_fee_zatoshis` is the user's `--max-fee`, a cap on the whole sweep; +/// `prior_fee_zatoshis` is what this sweep's earlier transactions already +/// paid, and each gate checks the two together. It is enforced twice and +/// never after broadcast: once against the proposal, before any proving +/// work, and once against the fee actually encoded in the extracted +/// transaction. The second is the one that matters — the first is the +/// planner's own arithmetic restated, whereas the second reads what was +/// built. +/// Large NU7 recovery proposals must use the reviewed service path, which +/// builds and records every bounded batch. #[allow(clippy::too_many_arguments)] pub fn build_imported_sapling_sweep

( wallet_db: &mut crate::imported::ArgosWalletDb, @@ -224,6 +227,8 @@ where propose_imported_sapling_sweep(wallet_db, params, account_id, destination)? }; + crate::nu7_limits::validate_proposal(params, &proposal)?; + // First gate, before proving parameters are put to work. let planned_fee_zatoshis = crate::service::proposal_fee_zatoshis(&proposal)?; if let Some(reviewed) = reviewed_fee_zatoshis { @@ -246,6 +251,8 @@ where >( wallet_db, params, + &zcash_client_backend::util::SystemClock, + &mut crate::workspace::wallet_rng(), account_id, OvkPolicy::Discard, &proposal, @@ -258,7 +265,9 @@ where // derivation would otherwise have provided. Internal notes use the // account's derived internal nsk (ask is unchanged), so classify every PCZT recipient // through the DFVK and fail closed if it is missing or foreign. - let internal_extsk = extsk.derive_internal(); + let internal_extsk = extsk.derive_internal().ok_or_else(|| { + ZeckError::TransactionBuild("Sapling internal-key derivation failed".to_owned()) + })?; let mut spend_scopes = Vec::new(); let pczt = LowLevelSigner::new(pczt) .sign_sapling_with(|_, bundle, _| { @@ -270,8 +279,8 @@ where let proof_keys: Vec<_> = spend_scopes .iter() .map(|scope| match scope { - SaplingSpendScope::External => extsk.expsk.proof_generation_key(), - SaplingSpendScope::Internal => internal_extsk.expsk.proof_generation_key(), + SaplingSpendScope::External => extsk.expsk().proof_generation_key(), + SaplingSpendScope::Internal => internal_extsk.expsk().proof_generation_key(), }) .collect(); bundle @@ -299,7 +308,7 @@ where let mut prover_role = Prover::new(pczt); if prover_role.requires_sapling_proofs() { prover_role = prover_role - .create_sapling_proofs(prover, prover) + .create_sapling_proofs(crate::workspace::wallet_rng(), prover, prover) .map_err(|err| { ZeckError::TransactionBuild(format!("proving the Sapling bundle: {err:?}")) })?; @@ -335,13 +344,13 @@ where let orchard_pk = orchard::circuit::ProvingKey::build(version); prover_role = if needs_ironwood { prover_role - .create_ironwood_proof(&orchard_pk) + .create_ironwood_proof(crate::workspace::wallet_rng(), &orchard_pk) .map_err(|err| { ZeckError::TransactionBuild(format!("proving the Ironwood bundle: {err:?}")) })? } else { prover_role - .create_orchard_proof(&orchard_pk) + .create_orchard_proof(crate::workspace::wallet_rng(), &orchard_pk) .map_err(|err| { ZeckError::TransactionBuild(format!("proving the Orchard bundle: {err:?}")) })? @@ -355,17 +364,19 @@ where .map_err(|err| ZeckError::TransactionBuild(format!("preparing the signer: {err:?}")))?; for index in 0..spend_count { let ask = match spend_scopes.get(index) { - Some(SaplingSpendScope::External) => &extsk.expsk.ask, - Some(SaplingSpendScope::Internal) => &internal_extsk.expsk.ask, + Some(SaplingSpendScope::External) => extsk.expsk().ask(), + Some(SaplingSpendScope::Internal) => internal_extsk.expsk().ask(), None => { return Err(ZeckError::TransactionBuild(format!( "Sapling spend {index} has no verified recipient scope" ))); } }; - signer.sign_sapling(index, ask).map_err(|err| { - ZeckError::TransactionBuild(format!("signing Sapling spend {index}: {err:?}")) - })?; + signer + .sign_sapling(crate::workspace::wallet_rng(), index, ask) + .map_err(|err| { + ZeckError::TransactionBuild(format!("signing Sapling spend {index}: {err:?}")) + })?; } let pczt = signer.finish(); @@ -376,11 +387,13 @@ where let tx = TransactionExtractor::new(pczt) .with_sapling(&spend_vk, &output_vk) .with_orchard(&orchard_vk) - .extract() + .extract(crate::workspace::wallet_rng()) .map_err(|err| { ZeckError::TransactionBuild(format!("extracting the signed transaction: {err:?}")) })?; + crate::nu7_limits::validate_transaction(params, proposal.min_target_height().into(), &tx)?; + // Second gate, on the fee the built transaction actually pays. // // `fee_paid` sums every bundle's value balance, so the ZIP-317 output @@ -479,8 +492,8 @@ fn transaction_fee_zatoshis(tx: &Transaction) -> ZeckResult { /// that silently moved nothing. #[derive(Debug, Clone, Default)] pub struct ImportedSweepOutcome { - /// One record per Sapling account with a prepared transaction, followed - /// by the transparent record when that leg runs. + /// One record per prepared Sapling transaction, including every bounded + /// batch of a large account, followed by the transparent record when run. /// /// A `Vec`, not an `Option`: an imported wallet has one account per /// Sapling key, each with its own notes, and each sweeps separately. @@ -611,6 +624,10 @@ where #[async_trait::async_trait] trait SaplingAccountRunner { + fn batch_count(&self, _account: &crate::imported::ImportedWalletAccount) -> usize { + 1 + } + async fn build_and_submit( &mut self, account: &crate::imported::ImportedWalletAccount, @@ -626,21 +643,23 @@ async fn run_sapling_accounts( runner: &mut R, ) -> ZeckResult<()> { for (display_index, account) in accounts { - let prior_fee = crate::service::at_risk_fee_total(&outcome.transactions)?; - let Some(submission) = runner.build_and_submit(account, prior_fee).await? else { - continue; - }; - if record_sapling_submission(outcome, *display_index, &submission)? { - return Err(ZeckError::Broadcast(format!( + for _ in 0..runner.batch_count(account) { + let prior_fee = crate::service::at_risk_fee_total(&outcome.transactions)?; + let Some(submission) = runner.build_and_submit(account, prior_fee).await? else { + continue; + }; + if record_sapling_submission(outcome, *display_index, &submission)? { + return Err(ZeckError::Broadcast(format!( "Sapling transaction {} may already have reached the network or was retryably refused; reconcile it before any further sweep", submission.txid, ))); - } - if submission.state == TxLifecycleState::Rejected { - return Err(ZeckError::Broadcast(format!( - "the node rejected Sapling transaction {}: {:?}", - submission.txid, submission.disposition, - ))); + } + if submission.state == TxLifecycleState::Rejected { + return Err(ZeckError::Broadcast(format!( + "the node rejected Sapling transaction {}: {:?}", + submission.txid, submission.disposition, + ))); + } } } Ok(()) @@ -656,10 +675,17 @@ struct RealSaplingAccountRunner<'a> { reviewed_sapling_fees: Option<&'a std::collections::HashMap>, planned: Option<&'a ImportedExecutionPlan>, broadcast_log: &'a mut DurableBroadcastLog, + next_batch: std::collections::HashMap, } #[async_trait::async_trait] impl SaplingAccountRunner for RealSaplingAccountRunner<'_> { + fn batch_count(&self, account: &crate::imported::ImportedWalletAccount) -> usize { + self.planned + .and_then(|plan| plan.sapling.get(&account.wallet_account_id)) + .map_or(1, |proposal| proposal.steps().len()) + } + async fn build_and_submit( &mut self, account: &crate::imported::ImportedWalletAccount, @@ -674,6 +700,35 @@ impl SaplingAccountRunner for RealSaplingAccountRunner<'_> { { return Ok(None); } + let batch_index = *self + .next_batch + .get(&account.wallet_account_id) + .unwrap_or(&0); + let batch = self + .planned + .and_then(|plan| plan.sapling.get(&account.wallet_account_id)) + .map(|proposal| { + let total_fee = crate::service::proposal_fee_zatoshis(proposal)?; + if let Some(fees) = self.reviewed_sapling_fees { + let reviewed = fees.get(&account.wallet_account_id).copied().unwrap_or(0); + if reviewed != total_fee { + return Err(ZeckError::FeeQuoteChanged { + reviewed, + current: total_fee, + }); + } + } + // Authorize the full account batch before signing the first step. + if batch_index == 0 { + enforce_cumulative_fee(prior_fee_zatoshis, total_fee, self.max_fee_zatoshis)?; + } + crate::nu7_limits::independent_step(proposal, batch_index) + }) + .transpose()?; + let batch_fee = batch + .as_ref() + .map(crate::service::proposal_fee_zatoshis) + .transpose()?; let built = { let mut wallet_db = crate::workspace::open_wallet_db(self.workspace.wallet_db_path(), self.params)?; @@ -687,19 +742,20 @@ impl SaplingAccountRunner for RealSaplingAccountRunner<'_> { self.prover, self.max_fee_zatoshis, prior_fee_zatoshis, - self.reviewed_sapling_fees - .map(|fees| fees.get(&account.wallet_account_id).copied().unwrap_or(0)), - if let Some(plan) = self.planned { - plan.sapling.get(&account.wallet_account_id) - } else { - None - }, + batch_fee.or_else(|| { + self.reviewed_sapling_fees + .map(|fees| fees.get(&account.wallet_account_id).copied().unwrap_or(0)) + }), + batch.as_ref(), ) }) }; let tx = match built { Ok(tx) => tx, - Err(err) if crate::service::is_insufficient_funds_error(&err.to_string()) => { + Err(err) + if self.planned.is_none() + && crate::service::is_insufficient_funds_error(&err.to_string()) => + { return Ok(None) } Err(err) => return Err(err), @@ -720,7 +776,9 @@ impl SaplingAccountRunner for RealSaplingAccountRunner<'_> { None, ) .await?; - submit_prepared_transaction( + let tip = crate::nu7::validated_tip_from_client(&mut client, self.runtime.network).await?; + crate::nu7::validate_transaction_for_tip(self.runtime.network, tip, &tx)?; + let submission = submit_prepared_transaction( self.broadcast_log, &mut LightwalletdSubmitter { client: &mut client, @@ -728,8 +786,10 @@ impl SaplingAccountRunner for RealSaplingAccountRunner<'_> { prepared, std::time::Duration::from_secs(30), ) - .await - .map(Some) + .await?; + self.next_batch + .insert(account.wallet_account_id, batch_index + 1); + Ok(Some(submission)) } } @@ -1026,7 +1086,8 @@ async fn sweep_imported_wallet_into( } } -/// Sweep every imported Sapling account, one transaction at a time. +/// Sweep every imported Sapling account and all of its reviewed batches, +/// one transaction at a time. /// /// Writes each submission into `outcome` as it happens, so an abort part-way /// through still leaves the caller holding the known txid, fee, and state. @@ -1159,6 +1220,7 @@ async fn sweep_imported_sapling_leg( reviewed_sapling_fees, planned, broadcast_log, + next_batch: Default::default(), }; run_sapling_accounts(&accounts, outcome, &mut runner).await } @@ -1225,11 +1287,11 @@ mod fee_cap_tests { let params = crate::workspace::consensus_network(runtime.network); let mut wallet_db = crate::workspace::open_wallet_db(workspace.wallet_db_path(), params).unwrap(); - let extsk = ExtendedSpendingKey::master(&[1; 32]); + let extsk = ExtendedSpendingKey::master(&[1; 32]).expect("valid fixture Sapling key"); let (_, address) = extsk.default_address(); let destination = ZcashAddress::try_from_encoded(&zcash_keys::encoding::encode_payment_address( - zcash_protocol::constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, + zcash_address::constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, &address, )) .unwrap(); @@ -1386,11 +1448,18 @@ mod fee_cap_tests { }; let destination = { use zcash_address::unified::{Address, Encoding, Receiver}; - let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]); + let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]) + .expect("valid fixture Sapling key"); let (_, payment_address) = extsk.default_address(); - Address::try_from_items(vec![Receiver::Sapling(payment_address.to_bytes())]) - .expect("a Sapling-only unified address is valid under ZIP 316") - .encode(&zcash_protocol::consensus::NetworkType::Main) + Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Sapling(payment_address.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .expect("a Sapling-only unified address is valid under ZIP 316") + .encode(&zcash_protocol::consensus::NetworkType::Main) }; // One zatoshi under the ZIP-317 conventional floor: unsatisfiable by @@ -1456,7 +1525,8 @@ mod registered_account_dedup_tests { #[test] fn duplicate_registered_sapling_uuid_is_swept_once() { let extsk = || { - let parsed = sapling_crypto::zip32::ExtendedSpendingKey::master(&[7u8; 32]); + let parsed = sapling_crypto::zip32::ExtendedSpendingKey::master(&[7u8; 32]) + .expect("valid fixture Sapling key"); crate::imported::ImportedSaplingSpendingKey::from_serialized(&parsed.to_bytes()) .expect("fixture key") }; @@ -1530,6 +1600,99 @@ mod tests { ); } + struct BatchRunner { + results: std::collections::VecDeque>, + prior_fees: Vec, + } + + #[async_trait::async_trait] + impl SaplingAccountRunner for BatchRunner { + fn batch_count(&self, _: &crate::imported::ImportedWalletAccount) -> usize { + 3 + } + async fn build_and_submit( + &mut self, + _: &crate::imported::ImportedWalletAccount, + prior: u64, + ) -> ZeckResult> { + self.prior_fees.push(prior); + self.results + .pop_front() + .expect("only reviewed batches execute") + .map(Some) + } + } + + #[tokio::test] + async fn same_account_batches_stop_on_unknown_and_keep_cumulative_evidence() { + let mut accepted = unknown(); + accepted.txid = TxId::from_bytes([8; 32]); + accepted.state = TxLifecycleState::Pending; + accepted.disposition = SubmissionDisposition::Accepted; + let mut runner = BatchRunner { + results: [ + Ok(accepted), + Ok(unknown()), + Err(ZeckError::Internal("must not execute".to_owned())), + ] + .into(), + prior_fees: vec![], + }; + let account = crate::imported::ImportedWalletAccount { + wallet_account_id: AccountUuid::default(), + sapling_extsk: None, + transparent_addresses: vec![], + }; + let mut outcome = ImportedSweepOutcome::default(); + assert!( + run_sapling_accounts(&[(4, account)], &mut outcome, &mut runner) + .await + .is_err() + ); + assert_eq!(runner.prior_fees, [0, 10_000]); + assert_eq!(runner.results.len(), 1); + assert_eq!(outcome.sapling_transaction_count, 2); + assert!(outcome.followup_blocked); + assert_eq!( + crate::service::at_risk_fee_total(&outcome.transactions).unwrap(), + 20_000 + ); + assert_eq!( + outcome.transactions[0].txid, + Some(TxId::from_bytes([8; 32]).to_string()) + ); + assert_eq!(outcome.transactions[1].source_account, 4); + } + + #[tokio::test] + async fn later_batch_build_failure_retains_earlier_accepted_transaction() { + let mut accepted = unknown(); + accepted.state = TxLifecycleState::Pending; + accepted.disposition = SubmissionDisposition::Accepted; + let mut runner = BatchRunner { + results: [ + Ok(accepted), + Err(ZeckError::TransactionBuild("proof failed".to_owned())), + ] + .into(), + prior_fees: vec![], + }; + let account = crate::imported::ImportedWalletAccount { + wallet_account_id: AccountUuid::default(), + sapling_extsk: None, + transparent_addresses: vec![], + }; + let mut outcome = ImportedSweepOutcome::default(); + assert!( + run_sapling_accounts(&[(4, account)], &mut outcome, &mut runner) + .await + .is_err() + ); + assert_eq!(runner.prior_fees, [0, 10_000]); + assert_eq!(outcome.transactions.len(), 1); + assert_eq!(outcome.transactions[0].status, TxLifecycleState::Pending); + } + fn unknown() -> TxSubmissionResult { TxSubmissionResult { txid: TxId::from_bytes([7; 32]), @@ -1597,9 +1760,9 @@ mod sapling_scope_tests { #[test] fn classifies_external_and_internal_note_authority() { - let extsk = ExtendedSpendingKey::master(&[7u8; 32]); + let extsk = ExtendedSpendingKey::master(&[7u8; 32]).expect("valid fixture Sapling key"); let external = extsk.default_address().1; - let internal_extsk = extsk.derive_internal(); + let internal_extsk = extsk.derive_internal().expect("valid fixture internal key"); let internal = internal_extsk.default_address().1; assert_eq!( @@ -1611,21 +1774,24 @@ mod sapling_scope_tests { SaplingSpendScope::Internal ); assert_ne!( - extsk.expsk.proof_generation_key().nsk, - internal_extsk.expsk.proof_generation_key().nsk, + extsk.expsk().proof_generation_key().nsk(), + internal_extsk.expsk().proof_generation_key().nsk(), "internal Sapling notes require the internal nsk proof authority" ); assert_eq!( - extsk.expsk.ask.to_bytes(), - internal_extsk.expsk.ask.to_bytes(), + extsk.expsk().ask().to_bytes(), + internal_extsk.expsk().ask().to_bytes(), "Sapling internal derivation preserves ask while changing nsk" ); } #[test] fn missing_or_foreign_recipient_fails_closed() { - let extsk = ExtendedSpendingKey::master(&[7u8; 32]); - let stranger = ExtendedSpendingKey::master(&[8u8; 32]).default_address().1; + let extsk = ExtendedSpendingKey::master(&[7u8; 32]).expect("valid fixture Sapling key"); + let stranger = ExtendedSpendingKey::master(&[8u8; 32]) + .expect("valid fixture Sapling key") + .default_address() + .1; assert!(matches!( classify_spend_scope(&extsk, None), Err(ProofKeyError::MissingRecipient) @@ -1698,11 +1864,18 @@ mod routing_tests { // address gate to test anything at all. let destination = { use zcash_address::unified::{Address, Encoding, Receiver}; - let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]); + let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]) + .expect("valid fixture Sapling key"); let (_, payment_address) = extsk.default_address(); - Address::try_from_items(vec![Receiver::Sapling(payment_address.to_bytes())]) - .expect("a Sapling-only unified address is valid under ZIP 316") - .encode(&zcash_protocol::consensus::NetworkType::Main) + Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Sapling(payment_address.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .expect("a Sapling-only unified address is valid under ZIP 316") + .encode(&zcash_protocol::consensus::NetworkType::Main) }; let err = sweep_imported_wallet(&runtime, &keys, &destination, None) diff --git a/crates/zeck-core/src/key_source.rs b/crates/zeck-core/src/key_source.rs index 57aaf427..dde05e0a 100644 --- a/crates/zeck-core/src/key_source.rs +++ b/crates/zeck-core/src/key_source.rs @@ -483,7 +483,7 @@ mod tests { ) .unwrap(); let orchard = |ua: &str| { - let (_, address) = Address::decode(ua).unwrap(); + let (_, _, address) = Address::decode(ua).unwrap(); address .items() .into_iter() diff --git a/crates/zeck-core/src/lib.rs b/crates/zeck-core/src/lib.rs index 382cd7f2..17d71a96 100644 --- a/crates/zeck-core/src/lib.rs +++ b/crates/zeck-core/src/lib.rs @@ -12,6 +12,8 @@ pub mod imported_sweep; pub mod key_source; pub mod lightwalletd; pub mod models; +pub mod nu7; +pub mod nu7_limits; pub mod private_fs; pub mod reconciliation; pub mod wallet_file; @@ -34,6 +36,7 @@ mod test_support; pub use address::validate_destination_address; pub use birthday::{ detect_birthday, detect_wallet_file_birthday, estimate_birthday_from_date, + estimate_birthday_from_date_for_network, estimate_birthday_from_date_offline_for_network, estimate_date_from_height_offline, height_at_or_before_time, unix_time_now, wallet_file_birthday_from_metadata, WalletBirthdaySource, WalletFileBirthday, }; diff --git a/crates/zeck-core/src/lightwalletd.rs b/crates/zeck-core/src/lightwalletd.rs index 565d55d0..93cef44f 100644 --- a/crates/zeck-core/src/lightwalletd.rs +++ b/crates/zeck-core/src/lightwalletd.rs @@ -842,18 +842,18 @@ mod tests { #[cfg(feature = "argos-network")] #[test] - fn network_validation_accepts_regtest_chain_with_feature() { - // With the feature enabled, the regtest chain name is accepted as - // a synonym for testnet, and the Sapling-activation-height check - // is skipped (regtest activates Sapling at height 1, not testnet's - // 280 000). + fn network_validation_requires_local_parameters_for_regtest_height() { + // Enabling the feature alone must not let a server opt out of the + // public testnet height check. Only explicit local parameter setup + // (covered by the separate regtest harness process) permits that. let info = LightdInfo { chain_name: "regtest".to_owned(), sapling_activation_height: 1, ..LightdInfo::default() }; - validate_lightwalletd_network(ZeckNetwork::Testnet, &info) - .expect("regtest chain must be accepted under the argos-network feature"); + let err = validate_lightwalletd_network(ZeckNetwork::Testnet, &info) + .expect_err("a server cannot install local consensus parameters"); + assert!(err.to_string().contains("Sapling activation height")); } #[cfg(feature = "argos-network")] diff --git a/crates/zeck-core/src/nu7.rs b/crates/zeck-core/src/nu7.rs new file mode 100644 index 00000000..aed812aa --- /dev/null +++ b/crates/zeck-core/src/nu7.rs @@ -0,0 +1,307 @@ +//! NU7 activation, fresh network evidence, and signed transaction validation. +//! +//! This is an RPC evidence check, not independent consensus verification. +use std::time::Duration; + +use tonic::transport::Channel; +use zcash_client_backend::proto::{ + compact_formats::CompactBlock, + service::{ + compact_tx_streamer_client::CompactTxStreamerClient, BlockId, ChainSpec, Empty, LightdInfo, + }, +}; +use zcash_protocol::consensus::{BlockHeight, BranchId, NetworkUpgrade, Parameters}; + +use crate::{ + error::{ZeckError, ZeckResult}, + lightwalletd::validate_lightwalletd_network, + models::ZeckNetwork, + workspace::consensus_network, +}; + +pub const MAINNET_ACTIVATION_HEIGHT: u32 = 3_543_405; +pub const TESTNET_ACTIVATION_HEIGHT: u32 = 4_465_026; +const QUERY_TIMEOUT: Duration = Duration::from_secs(15); +const MAX_TIP_AGE: u64 = 30 * 60; +const MAX_FUTURE_TIME: u64 = 5 * 60; + +pub fn activation_height(network: ZeckNetwork) -> Option { + consensus_network(network) + .activation_height(NetworkUpgrade::Nu7) + .map(u32::from) +} + +fn evidence_error(message: impl Into) -> ZeckError { + ZeckError::Lightwalletd(message.into()) +} + +fn validate_tip_evidence( + network: ZeckNetwork, + info: &LightdInfo, + latest: &BlockId, + block: &CompactBlock, + now: u64, +) -> ZeckResult { + validate_lightwalletd_network(network, info)?; + let height = u32::try_from(latest.height) + .map_err(|_| evidence_error("tip height exceeds supported range"))?; + if height == 0 + || block.height != latest.height + || block.hash.len() != 32 + || latest.hash.len() != 32 + || block.hash != latest.hash + { + return Err(evidence_error("tip block height or hash is inconsistent")); + } + let branch = u32::from_str_radix(info.consensus_branch_id.trim().trim_start_matches("0x"), 16) + .map_err(|_| evidence_error("missing or invalid server consensus branch"))?; + let expected: u32 = + BranchId::for_height(&consensus_network(network), BlockHeight::from_u32(height)).into(); + if branch != expected { + return Err(evidence_error( + "server consensus branch does not match tip height", + )); + } + if info.block_height.abs_diff(latest.height) > 12 { + return Err(evidence_error("server metadata and chain tip disagree")); + } + // Explicit process-local regtest setup permits artificially mined timestamps. + #[cfg(feature = "argos-network")] + let local_clock = matches!(network, ZeckNetwork::Testnet) + && crate::workspace::regtest_consensus_params_installed(); + #[cfg(not(feature = "argos-network"))] + let local_clock = false; + let timestamp = u64::from(block.time); + if !local_clock + && (timestamp == 0 + || now.saturating_sub(timestamp) > MAX_TIP_AGE + || timestamp.saturating_sub(now) > MAX_FUTURE_TIME) + { + return Err(evidence_error("tip timestamp is stale or in the future")); + } + Ok(height) +} + +/// Check already-signed bytes against the next inclusion block after a freshly +/// validated tip. Never rebuild or rewrite a transaction to cross an upgrade. +pub(crate) fn validate_transaction_for_tip( + network: ZeckNetwork, + tip: u32, + tx: &zcash_primitives::transaction::Transaction, +) -> ZeckResult<()> { + let candidate = tip.checked_add(1).filter(|_| tip > 0).ok_or_else(|| { + ZeckError::Broadcast("transaction submission requires a usable fresh chain tip".to_owned()) + })?; + let params = consensus_network(network); + let height = BlockHeight::from_u32(candidate); + let branch = BranchId::for_height(¶ms, height); + if !tx.version().valid_in_branch(branch) { + return Err(ZeckError::Broadcast(format!( + "signed transaction version is invalid for the next block's consensus branch {branch:?}; nothing was submitted" + ))); + } + if tx.consensus_branch_id() != branch { + return Err(ZeckError::Broadcast(format!( + "consensus branch changed after transaction construction: signed {:?}, next block {branch:?}; nothing was submitted", + tx.consensus_branch_id() + ))); + } + let expiry = u32::from(tx.expiry_height()); + if expiry != 0 && tip >= expiry { + return Err(ZeckError::Broadcast(format!( + "signed transaction expired at height {expiry}; nothing was submitted" + ))); + } + crate::nu7_limits::validate_transaction(¶ms, height, tx) +} + +/// Bounded check on the existing connection used for transaction submission. +pub async fn validated_tip_from_client( + client: &mut CompactTxStreamerClient, + network: ZeckNetwork, +) -> ZeckResult { + tokio::time::timeout(QUERY_TIMEOUT, async { + let info = client + .get_lightd_info(Empty {}) + .await + .map_err(|e| evidence_error(e.to_string()))? + .into_inner(); + validate_lightwalletd_network(network, &info)?; + let latest = client + .get_latest_block(ChainSpec {}) + .await + .map_err(|e| evidence_error(e.to_string()))? + .into_inner(); + let block = client + .get_block(BlockId { + height: latest.height, + hash: vec![], + }) + .await + .map_err(|e| evidence_error(e.to_string()))? + .into_inner(); + let now = u64::try_from(crate::unix_time_now()) + .map_err(|_| evidence_error("system clock is before the Unix epoch"))?; + validate_tip_evidence(network, &info, &latest, &block, now) + }) + .await + .map_err(|_| evidence_error("fresh tip query timed out"))? +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn published_schedule_matches_sdk() { + assert_eq!( + activation_height(ZeckNetwork::Mainnet), + Some(MAINNET_ACTIVATION_HEIGHT) + ); + assert_eq!( + activation_height(ZeckNetwork::Testnet), + Some(TESTNET_ACTIVATION_HEIGHT) + ); + } + fn signed_fixture( + branch: BranchId, + version: zcash_primitives::transaction::TxVersion, + expiry: u32, + ) -> zcash_primitives::transaction::Transaction { + use zcash_primitives::transaction::{Authorized, TransactionData, TxVersion}; + if version == TxVersion::V6 { + TransactionData::::from_parts_v6( + branch, + 0, + BlockHeight::from_u32(expiry), + None, + None, + None, + None, + ) + .freeze() + .unwrap() + } else { + TransactionData::::from_parts( + version, + branch, + 0, + BlockHeight::from_u32(expiry), + None, + None, + None, + None, + ) + .freeze() + .unwrap() + } + } + + #[test] + fn signed_branch_must_still_match_after_proving_on_both_networks() { + use zcash_primitives::transaction::TxVersion; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = activation_height(network).unwrap(); + for version in [TxVersion::V5, TxVersion::V6] { + let tx = signed_fixture(BranchId::Nu6_3, version, activation + 120); + let mut before = vec![]; + tx.write(&mut before).unwrap(); + assert!(validate_transaction_for_tip(network, activation - 2, &tx).is_ok()); + for tip in [activation - 1, activation, activation + 1] { + assert!(validate_transaction_for_tip(network, tip, &tx) + .unwrap_err() + .to_string() + .contains("branch")); + } + let mut after = vec![]; + tx.write(&mut after).unwrap(); + assert_eq!( + before, after, + "rejecting an obsolete branch preserves the signed evidence" + ); + let current = signed_fixture(BranchId::Nu7, version, activation + 120); + assert!(validate_transaction_for_tip(network, activation - 1, ¤t).is_ok()); + assert!(validate_transaction_for_tip(network, activation, ¤t).is_ok()); + assert!(validate_transaction_for_tip(network, activation + 1, ¤t).is_ok()); + assert!( + validate_transaction_for_tip(network, activation - 2, ¤t).is_err(), + "a reorg across activation also invalidates a new-branch signature" + ); + } + let legacy = signed_fixture(BranchId::Nu6_3, TxVersion::V4, activation + 120); + assert!(validate_transaction_for_tip(network, activation - 1, &legacy).is_err()); + } + } + + #[test] + fn signed_expiry_and_unknown_tips_fail_before_submission() { + use zcash_primitives::transaction::TxVersion; + let activation = MAINNET_ACTIVATION_HEIGHT; + let tx = signed_fixture(BranchId::Nu7, TxVersion::V6, activation + 5); + assert!(validate_transaction_for_tip(ZeckNetwork::Mainnet, activation + 4, &tx).is_ok()); + assert!( + validate_transaction_for_tip(ZeckNetwork::Mainnet, activation + 5, &tx) + .unwrap_err() + .to_string() + .contains("expired") + ); + assert!(validate_transaction_for_tip(ZeckNetwork::Mainnet, 0, &tx).is_err()); + assert!(validate_transaction_for_tip(ZeckNetwork::Mainnet, u32::MAX, &tx).is_err()); + let no_expiry = signed_fixture(BranchId::Nu7, TxVersion::V6, 0); + assert!( + validate_transaction_for_tip(ZeckNetwork::Mainnet, activation + 5, &no_expiry).is_ok() + ); + } + + fn fixture() -> (LightdInfo, BlockId, CompactBlock, u64) { + let height = MAINNET_ACTIVATION_HEIGHT - 10; + let now = 1_800_000_000; + let branch: u32 = BranchId::for_height( + &consensus_network(ZeckNetwork::Mainnet), + BlockHeight::from_u32(height), + ) + .into(); + ( + LightdInfo { + chain_name: "main".into(), + sapling_activation_height: 419_200, + consensus_branch_id: format!("{branch:08x}"), + block_height: u64::from(height), + ..Default::default() + }, + BlockId { + height: u64::from(height), + hash: vec![7; 32], + }, + CompactBlock { + height: u64::from(height), + hash: vec![7; 32], + time: now as u32, + ..Default::default() + }, + now, + ) + } + #[test] + fn fresh_tip_rejects_stale_wrong_network_branch_and_hash() { + let (info, latest, block, now) = fixture(); + assert!(validate_tip_evidence(ZeckNetwork::Mainnet, &info, &latest, &block, now).is_ok()); + assert!(validate_tip_evidence( + ZeckNetwork::Mainnet, + &info, + &latest, + &block, + now + MAX_TIP_AGE + 1 + ) + .is_err()); + assert!(validate_tip_evidence(ZeckNetwork::Testnet, &info, &latest, &block, now).is_err()); + let mut bad = info.clone(); + bad.consensus_branch_id = "ffffffff".into(); + assert!(validate_tip_evidence(ZeckNetwork::Mainnet, &bad, &latest, &block, now).is_err()); + let mut bad = block.clone(); + bad.hash[0] ^= 1; + assert!(validate_tip_evidence(ZeckNetwork::Mainnet, &info, &latest, &bad, now).is_err()); + let mut bad = block; + bad.time = (now + MAX_FUTURE_TIME + 1) as u32; + assert!(validate_tip_evidence(ZeckNetwork::Mainnet, &info, &latest, &bad, now).is_err()); + } +} diff --git a/crates/zeck-core/src/nu7_limits.rs b/crates/zeck-core/src/nu7_limits.rs new file mode 100644 index 00000000..369d464a --- /dev/null +++ b/crates/zeck-core/src/nu7_limits.rs @@ -0,0 +1,981 @@ +//! ZIP 218 transaction limits and lossless batching of recovery proposals. +//! +//! The consensus limits apply to blocks; a transaction must fit by itself. +//! Counts include builder padding, and transparent inputs do not consume this budget. +use nonempty::NonEmpty; +#[allow(deprecated)] +use zcash_client_backend::zip321; +use zcash_client_backend::{ + fees::{StandardFeeRule, TransactionBalance}, + proposal::{Proposal, ShieldedInputs, Step}, +}; +use zcash_primitives::transaction::{ + builder::BundlePadding, components::orchard::bundle_version_for_branch, fees::FeeRule, + Transaction, +}; +use zcash_protocol::{ + consensus::{BlockHeight, BranchId, NetworkUpgrade, Parameters}, + value::Zatoshis, + PoolType, +}; + +use crate::error::{ZeckError, ZeckResult}; + +pub const SAPLING_IO_LIMIT: usize = 300; +pub const ORCHARD_ACTION_LIMIT: usize = 330; +pub const GLOBAL_SHIELDED_LIMIT: usize = 330; + +#[derive(Debug, Default, Clone, Copy)] +pub(crate) struct ShieldedCounts { + pub sapling_spends: usize, + pub sapling_outputs: usize, + pub orchard: usize, + pub ironwood: usize, + pub joinsplits: usize, +} + +impl ShieldedCounts { + fn validate(self) -> ZeckResult<()> { + let sapling = self.sapling_spends.checked_add(self.sapling_outputs); + let total = sapling + .and_then(|n| n.checked_add(self.orchard)) + .and_then(|n| n.checked_add(self.ironwood)) + .and_then(|n| { + self.joinsplits + .checked_mul(2) + .and_then(|j| n.checked_add(j)) + }); + if sapling.is_none_or(|n| n > SAPLING_IO_LIMIT) + || self.orchard > ORCHARD_ACTION_LIMIT + || self.ironwood > ORCHARD_ACTION_LIMIT + || self.joinsplits != 0 + || total.is_none_or(|n| n > GLOBAL_SHIELDED_LIMIT) + { + return Err(ZeckError::TransactionBuild(format!( + "transaction exceeds the NU7 ZIP 218 shielded budget: {self:?}" + ))); + } + Ok(()) + } +} + +fn build_error(error: impl std::fmt::Display) -> ZeckError { + ZeckError::TransactionBuild(format!("planning bounded recovery: {error}")) +} + +fn counts( + params: &P, + height: BlockHeight, + step: &Step, +) -> ZeckResult { + let spends = step.input_count_in_pool(PoolType::SAPLING); + let outputs = + step.output_count_in_pool(PoolType::SAPLING) + step.change_count_in_pool(PoolType::SAPLING); + let sapling = sapling_crypto::builder::BundleType::DEFAULT; + let branch = BranchId::for_height(params, height); + let orchard = bundle_version_for_branch(branch, orchard::ValuePool::Orchard) + .map(|version| step.orchard_action_count(BundlePadding::DEFAULT, version)) + .transpose() + .map_err(build_error)? + .unwrap_or(0); + let ironwood = bundle_version_for_branch(branch, orchard::ValuePool::Ironwood) + .map(|version| step.ironwood_action_count(step.ironwood_bundle_padding(), version)) + .transpose() + .map_err(build_error)? + .unwrap_or(0); + Ok(ShieldedCounts { + sapling_spends: sapling.num_spends(spends).map_err(build_error)?, + sapling_outputs: sapling.num_outputs(spends, outputs).map_err(build_error)?, + orchard, + ironwood, + joinsplits: 0, + }) +} + +pub(crate) fn validate_proposal( + params: &P, + proposal: &Proposal, +) -> ZeckResult<()> { + let height = BlockHeight::from(proposal.min_target_height()); + if params.is_nu_active(NetworkUpgrade::Nu7, height) { + for step in proposal.steps() { + counts(params, height, step)?.validate()?; + } + } + Ok(()) +} + +/// Validate actual serialized bundle sizes, independently of proposal estimates. +pub(crate) fn validate_transaction( + params: &P, + target_height: BlockHeight, + tx: &Transaction, +) -> ZeckResult<()> { + if !params.is_nu_active(NetworkUpgrade::Nu7, target_height) { + return Ok(()); + } + ShieldedCounts { + sapling_spends: tx.sapling_bundle().map_or(0, |b| b.shielded_spends().len()), + sapling_outputs: tx + .sapling_bundle() + .map_or(0, |b| b.shielded_outputs().len()), + orchard: tx.orchard_bundle().map_or(0, |b| b.actions().len()), + ironwood: tx.ironwood_bundle().map_or(0, |b| b.actions().len()), + joinsplits: tx.sprout_bundle().map_or(0, |b| b.joinsplits.len()), + } + .validate() +} + +/// Materialize one independent step for a PCZT builder (which accepts one step). +/// Refuse chained proposals, whose references cannot survive extraction. +pub(crate) fn independent_step( + proposal: &Proposal, + index: usize, +) -> ZeckResult> { + let step = proposal + .steps() + .get(index) + .ok_or_else(|| build_error("missing recovery batch"))?; + if !step.prior_step_inputs().is_empty() { + return Err(build_error( + "recovery batch depends on an earlier transaction", + )); + } + Proposal::multi_step( + *proposal.fee_rule(), + proposal.min_target_height(), + proposal.confirmations_policy(), + NonEmpty::singleton(step.clone()), + ) + .map(|p| p.with_proposed_version(proposal.proposed_version())) + .map_err(build_error) +} + +/// Split a send-max proposal into disjoint, independently spendable transactions. +/// Every selected note is retained. The quoted fee is the sum of all batch fees. +/// Splitting is only required at NU7, and never imposes a transparent-input cap. +/// Send-max has no change; an optional donation is apportioned from the reduced +/// net amount after the additional transaction fees, preserving its fraction. +pub(crate) fn bound_send_max( + params: &P, + proposal: Proposal, +) -> ZeckResult> { + let height = BlockHeight::from(proposal.min_target_height()); + if !params.is_nu_active(NetworkUpgrade::Nu7, height) + || validate_proposal(params, &proposal).is_ok() + { + return Ok(proposal); + } + let original = proposal.steps().first(); + // An exactly balanced donation split still carries a zero-valued change + // output (the SDK's change strategy emits one when change is zero). It + // holds no value, and the batches below are built without change, so it + // is dropped. Any real change would be value no batch accounts for. + let has_real_change = original + .balance() + .proposed_change() + .iter() + .any(|change| change.value() != Zatoshis::ZERO); + if proposal.steps().len() != 1 + || !original.transparent_inputs().is_empty() + || !original.prior_step_inputs().is_empty() + || has_real_change + || original.transaction_request().payments().is_empty() + || original.transaction_request().payments().len() > 2 + { + return Err(build_error( + "oversized recovery proposal is not an independent send-max", + )); + } + let notes = original + .shielded_inputs() + .ok_or_else(|| build_error("send-max has no selected notes"))? + .notes(); + // A batch with 298 notes plus the mandatory two Sapling outputs fits the + // Sapling budget. Other pools' padded outputs still fit the global budget. + // Balance batch lengths to avoid leaving an uneconomic one-note tail. + let batch_count = notes.len().div_ceil(SAPLING_IO_LIMIT - 2); + let batch_size = notes.len() / batch_count; + let larger_batches = notes.len() % batch_count; + let payments: Vec<_> = original.transaction_request().payments().values().collect(); + let original_net: u64 = payments.iter().try_fold(0u64, |sum, p| { + sum.checked_add(u64::from( + p.amount() + .ok_or_else(|| build_error("payment has no amount"))?, + )) + .ok_or_else(|| build_error("payment amount overflow")) + })?; + if original_net == 0 { + return Err(build_error("send-max payment amount is zero")); + } + // Distribute fee-paying value, not just note counts. Contiguous chunks + // can strand near-marginal notes in a batch with no value for output + // padding even when the complete wallet can pay every batch's fees. + // Stable value ordering and index tie-breaks make review deterministic. + let mut notes: Vec<_> = notes.iter().cloned().collect(); + notes.sort_by_key(|note| std::cmp::Reverse(u64::from(note.note().value()))); + let mut batches = vec![Vec::new(); batch_count]; + let mut available = std::collections::BinaryHeap::new(); + for index in 0..batch_count { + available.push(std::cmp::Reverse((0u64, 0usize, index))); + } + for note in notes { + let std::cmp::Reverse((surplus, count, index)) = available + .pop() + .expect("batch capacity covers every selected note"); + let surplus = surplus + .checked_add(u64::from(note.note().value()).saturating_sub(5_000)) + .ok_or_else(|| build_error("batch fee-paying value overflow"))?; + batches[index].push(note); + let capacity = batch_size + usize::from(index < larger_batches); + if count + 1 < capacity { + available.push(std::cmp::Reverse((surplus, count + 1, index))); + } + } + let mut steps = Vec::new(); + for chunk in batches { + let inputs = + ShieldedInputs::from_parts(NonEmpty::from_vec(chunk.clone()).expect("nonempty chunk")); + let gross: u64 = chunk.iter().try_fold(0u64, |sum, n| { + sum.checked_add(u64::from(n.note().value())) + .ok_or_else(|| build_error("input value overflow")) + })?; + // A balanced candidate preserves the recipient/pool structure, letting + // the SDK count version-specific padding before computing the real fee. + let make_step = |fee: Zatoshis| -> ZeckResult> { + let net = gross + .checked_sub(u64::from(fee)) + .filter(|n| *n > 0) + .ok_or_else(|| build_error("recovery batch does not cover its ZIP 317 fee"))?; + let mut remaining = net; + let mut batch_payments = Vec::new(); + for (i, payment) in payments.iter().enumerate() { + let amount = if i + 1 == payments.len() { + remaining + } else { + ((u128::from(net) + * u128::from(u64::from(payment.amount().expect("checked amount")))) + / u128::from(original_net)) as u64 + }; + remaining -= amount; + batch_payments.push( + zip321::Payment::new( + payment.recipient_address().clone(), + Some(Zatoshis::from_u64(amount).map_err(build_error)?), + payment.memo().cloned(), + payment.label().cloned(), + payment.message().cloned(), + payment.other_params().to_vec(), + ) + .map_err(build_error)?, + ); + } + Step::from_parts( + &[], + zip321::TransactionRequest::new(batch_payments).map_err(build_error)?, + original.payment_pools().clone(), + vec![], + Some(inputs.clone()), + original.anchor_height(), + vec![], + TransactionBalance::new(vec![], fee).map_err(build_error)?, + false, + params.is_nu_active(NetworkUpgrade::Nu6_3, height), + ) + .map_err(build_error) + }; + let candidate = make_step(Zatoshis::ZERO)?; + let count = counts(params, height, &candidate)?; + count.validate()?; + let fee = proposal + .fee_rule() + .fee_required( + params, + height, + [], + [], + count.sapling_spends, + count.sapling_outputs, + count.orchard, + count.ironwood, + ) + .map_err(build_error)?; + steps.push(make_step(fee)?); + } + let bounded = Proposal::multi_step( + *proposal.fee_rule(), + proposal.min_target_height(), + proposal.confirmations_policy(), + NonEmpty::from_vec(steps).expect("selected notes"), + ) + .map_err(build_error)? + .with_proposed_version(proposal.proposed_version()); + validate_proposal(params, &bounded)?; + Ok(bounded) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn sapling_proposal(note_count: usize, height: BlockHeight) -> Proposal { + sapling_values_proposal(&vec![100_000; note_count], height, None) + } + + fn sapling_values_proposal( + values: &[u64], + height: BlockHeight, + destination: Option, + ) -> Proposal { + let note_count = values.len(); + use zcash_client_backend::{ + data_api::wallet::ConfirmationsPolicy, + wallet::{Note, ReceivedNote}, + }; + let key = sapling_crypto::zip32::ExtendedSpendingKey::master(&[7; 32]).unwrap(); + let (_, address) = key.default_address(); + let recipient = zcash_address::ZcashAddress::try_from_encoded( + &zcash_keys::encoding::encode_payment_address( + zcash_address::constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, + &address, + ), + ) + .unwrap(); + let recipient = destination.unwrap_or(recipient); + let output_pool = if recipient.can_receive_as(PoolType::ORCHARD) { + PoolType::IRONWOOD + } else { + PoolType::SAPLING + }; + let notes: Vec<_> = (0..note_count) + .map(|i| { + ReceivedNote::from_parts( + i as u32, + zcash_primitives::transaction::TxId::from_bytes([9; 32]), + i as u16, + Note::Sapling(sapling_crypto::Note::from_parts( + address, + sapling_crypto::value::NoteValue::from_raw(values[i]), + sapling_crypto::Rseed::AfterZip212([3; 32]), + )), + zip32::Scope::External, + (i as u64).into(), + Some(height - 10), + None, + ) + }) + .collect(); + let fee = 5_000 + * (note_count.max(2) as u64 + + if output_pool == PoolType::IRONWOOD { + 2 + } else { + 0 + }); + let request = zip321::TransactionRequest::new(vec![zip321::Payment::new( + recipient, + Some(Zatoshis::from_u64(values.iter().sum::() - fee).unwrap()), + Some(zcash_protocol::memo::MemoBytes::empty()), + None, + None, + vec![], + ) + .unwrap()]) + .unwrap(); + Proposal::single_step( + request, + [(0, output_pool)].into(), + vec![], + Some(ShieldedInputs::from_parts( + NonEmpty::from_vec(notes).unwrap(), + )), + height - 3, + TransactionBalance::new(vec![], Zatoshis::from_u64(fee).unwrap()).unwrap(), + StandardFeeRule::Zip317, + height.into(), + ConfirmationsPolicy::MIN, + false, + true, + ) + .unwrap() + } + + // SDK 0.25 represents both Orchard and Ironwood notes with Note::Orchard; + // the stored value pool, not the enum variant, determines their input pool. + fn multi_pool_proposal( + pool_counts: [usize; 3], + height: BlockHeight, + ) -> Proposal { + use orchard::{ + keys::{FullViewingKey, SpendingKey}, + note::{NoteVersion, RandomSeed, Rho}, + }; + use zcash_client_backend::{ + data_api::wallet::ConfirmationsPolicy, + wallet::{Note, ReceivedNote}, + }; + let params = zcash_protocol::consensus::MAIN_NETWORK; + let usk = zcash_keys::keys::UnifiedSpendingKey::from_seed( + ¶ms, + &[11; 32], + zip32::AccountId::ZERO, + ) + .unwrap(); + let recipient = usk + .to_unified_full_viewing_key() + .default_address(zcash_keys::keys::UnifiedAddressRequest::AllAvailableKeys) + .unwrap() + .0; + let recipient = + zcash_address::ZcashAddress::try_from_encoded(&recipient.encode(¶ms)).unwrap(); + let sapling_key = sapling_crypto::zip32::ExtendedSpendingKey::master(&[7; 32]).unwrap(); + let (_, sapling_address) = sapling_key.default_address(); + let orchard_key = SpendingKey::from_bytes([0x2a; 32]).unwrap(); + let orchard_address = + FullViewingKey::from(&orchard_key).address_at(0u32, zip32::Scope::External); + let rho = Rho::from_bytes(&[0; 32]).unwrap(); + let mut notes = Vec::new(); + for (pool_index, note_count) in pool_counts.into_iter().enumerate() { + for _ in 0..note_count { + let id = notes.len() as u32; + let mut seed = [0x1b; 32]; + seed[..4].copy_from_slice(&id.to_le_bytes()); + let note = if pool_index == 0 { + Note::Sapling(sapling_crypto::Note::from_parts( + sapling_address, + sapling_crypto::value::NoteValue::from_raw(100_000), + sapling_crypto::Rseed::AfterZip212(seed), + )) + } else { + let (version, pool) = if pool_index == 1 { + (NoteVersion::V2, orchard::ValuePool::Orchard) + } else { + (NoteVersion::V3, orchard::ValuePool::Ironwood) + }; + // Retry deterministic seeds when their commitment is invalid. + let note = (0u32..) + .find_map(|attempt| { + seed[4..8].copy_from_slice(&attempt.to_le_bytes()); + let rseed = RandomSeed::from_bytes(seed, &rho).into_option()?; + orchard::Note::from_parts( + orchard_address, + orchard::value::NoteValue::from_raw(100_000), + rho, + rseed, + version, + ) + .into_option() + }) + .unwrap(); + Note::Orchard { note, pool } + }; + notes.push(ReceivedNote::from_parts( + id, + zcash_primitives::transaction::TxId::from_bytes([9; 32]), + id as u16, + note, + zip32::Scope::External, + (id as u64).into(), + Some(height - 10), + None, + )); + } + } + let [sapling, orchard, ironwood] = pool_counts; + let sapling_actions = if sapling == 0 { 0 } else { sapling.max(2) }; + let orchard_actions = if orchard == 0 { 0 } else { orchard.max(2) }; + let fee = 5_000 * (sapling_actions + orchard_actions + ironwood.max(2)) as u64; + let gross = notes.len() as u64 * 100_000; + let request = zip321::TransactionRequest::new(vec![zip321::Payment::new( + recipient, + Some(Zatoshis::from_u64(gross - fee).unwrap()), + Some(zcash_protocol::memo::MemoBytes::empty()), + None, + None, + vec![], + ) + .unwrap()]) + .unwrap(); + Proposal::single_step( + request, + [(0, PoolType::IRONWOOD)].into(), + vec![], + Some(ShieldedInputs::from_parts( + NonEmpty::from_vec(notes).unwrap(), + )), + height - 3, + TransactionBalance::new(vec![], Zatoshis::from_u64(fee).unwrap()).unwrap(), + StandardFeeRule::Zip317, + height.into(), + ConfirmationsPolicy::MIN, + false, + params.is_nu_active(NetworkUpgrade::Nu6_3, height), + ) + .unwrap() + } + + fn assert_multi_pool_batches( + original: &Proposal, + bounded: &Proposal, + expected_pool_counts: [usize; 3], + ) -> u64 { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = BlockHeight::from(bounded.min_target_height()); + validate_proposal(¶ms, bounded).unwrap(); + let original_step = original.steps().first(); + let original_payment = &original_step.transaction_request().payments()[&0]; + let mut selected: std::collections::BTreeMap<_, _> = original_step + .shielded_inputs() + .unwrap() + .notes() + .iter() + .map(|n| (*n.internal_note_id(), n)) + .collect(); + let mut observed_pool_counts = [0; 3]; + let mut total_fee = 0; + let mut total_output = 0; + for (index, step) in bounded.steps().iter().enumerate() { + let independent = independent_step(bounded, index).unwrap(); + validate_proposal(¶ms, &independent).unwrap(); + assert_eq!(independent.steps().len(), 1); + let mut step_gross = 0; + for note in step.shielded_inputs().unwrap().notes() { + assert!( + selected.remove(note.internal_note_id()) == Some(note), + "each selected note and its pool must be preserved exactly once" + ); + step_gross += u64::from(note.note().value()); + } + let pools = [PoolType::SAPLING, PoolType::ORCHARD, PoolType::IRONWOOD]; + let step_inputs = pools.map(|pool| step.input_count_in_pool(pool)); + for (observed, count) in observed_pool_counts.iter_mut().zip(step_inputs) { + *observed += count; + } + let [sapling, orchard, ironwood] = step_inputs; + let expected_sapling_spends = if sapling == 0 { 0 } else { sapling.max(1) }; + let expected_sapling_outputs = if sapling == 0 { 0 } else { 2 }; + let expected_orchard = if orchard == 0 { 0 } else { orchard.max(2) }; + let expected_ironwood = ironwood.max(2); + let padded = counts(¶ms, height, step).unwrap(); + assert_eq!(padded.sapling_spends, expected_sapling_spends); + assert_eq!(padded.sapling_outputs, expected_sapling_outputs); + assert_eq!(padded.orchard, expected_orchard); + assert_eq!(padded.ironwood, expected_ironwood); + assert!(padded.sapling_spends + padded.sapling_outputs <= SAPLING_IO_LIMIT); + assert!(padded.orchard <= ORCHARD_ACTION_LIMIT); + assert!(padded.ironwood <= ORCHARD_ACTION_LIMIT); + assert!( + padded.sapling_spends + padded.sapling_outputs + padded.orchard + padded.ironwood + <= GLOBAL_SHIELDED_LIMIT + ); + assert!(step.prior_step_inputs().is_empty()); + assert!(step.balance().proposed_change().is_empty()); + assert_eq!(step.payment_pools(), original_step.payment_pools()); + assert_eq!(step.output_count_in_pool(PoolType::IRONWOOD), 1); + assert_eq!(step.output_count_in_pool(PoolType::ORCHARD), 0); + let payment = &step.transaction_request().payments()[&0]; + assert_eq!( + payment.recipient_address(), + original_payment.recipient_address() + ); + assert_eq!(payment.memo(), original_payment.memo()); + let fee = u64::from(step.balance().fee_required()); + let expected_fee = 5_000 + * (expected_sapling_spends.max(expected_sapling_outputs) + + expected_orchard + + expected_ironwood) as u64; + assert_eq!(fee, expected_fee); + let output = u64::from(payment.amount().unwrap()); + assert_eq!(output + fee, step_gross); + total_output += output; + total_fee += fee; + } + assert!(selected.is_empty(), "no selected note may be dropped"); + assert_eq!(observed_pool_counts, expected_pool_counts); + assert_eq!( + total_output + total_fee, + expected_pool_counts.iter().sum::() as u64 * 100_000 + ); + assert_eq!( + crate::service::proposal_fee_zatoshis(bounded).unwrap(), + total_fee + ); + total_fee + } + + #[test] + fn orchard_only_recovery_counts_ironwood_output_padding_and_retains_notes() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let original = multi_pool_proposal([0, 329, 0], height); + let initial = counts(¶ms, height, original.steps().first()).unwrap(); + assert_eq!((initial.orchard, initial.ironwood), (329, 2)); + assert!(initial.orchard <= ORCHARD_ACTION_LIMIT); + assert!(validate_proposal(¶ms, &original).is_err()); + let bounded = bound_send_max(¶ms, original.clone()).unwrap(); + assert_eq!(bounded.steps().len(), 2); + assert_eq!( + assert_multi_pool_batches(&original, &bounded, [0, 329, 0]), + (329 + 4) * 5_000 + ); + } + + #[test] + fn ironwood_only_recovery_retains_pool_and_prices_every_batch() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let original = multi_pool_proposal([0, 0, 331], height); + let initial = counts(¶ms, height, original.steps().first()).unwrap(); + assert_eq!((initial.orchard, initial.ironwood), (0, 331)); + assert!(validate_proposal(¶ms, &original).is_err()); + let bounded = bound_send_max(¶ms, original.clone()).unwrap(); + assert_eq!(bounded.steps().len(), 2); + assert_eq!( + assert_multi_pool_batches(&original, &bounded, [0, 0, 331]), + 331 * 5_000 + ); + } + + #[test] + fn mixed_pool_recovery_splits_global_overflow_without_losing_pool_identity() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let original = multi_pool_proposal([100, 100, 129], height); + let initial = counts(¶ms, height, original.steps().first()).unwrap(); + assert_eq!( + ( + initial.sapling_spends, + initial.sapling_outputs, + initial.orchard, + initial.ironwood + ), + (100, 2, 100, 129) + ); + // Every individual pool fits; only the padded global total (331) overflows. + assert!(initial.sapling_spends + initial.sapling_outputs <= SAPLING_IO_LIMIT); + assert!(initial.orchard <= ORCHARD_ACTION_LIMIT); + assert!(initial.ironwood <= ORCHARD_ACTION_LIMIT); + assert!(validate_proposal(¶ms, &original).is_err()); + let bounded = bound_send_max(¶ms, original.clone()).unwrap(); + assert_eq!(bounded.steps().len(), 2); + for step in bounded.steps() { + for pool in [PoolType::SAPLING, PoolType::ORCHARD, PoolType::IRONWOOD] { + assert!(step.input_count_in_pool(pool) > 0); + } + } + assert_eq!( + assert_multi_pool_batches(&original, &bounded, [100, 100, 129]), + 329 * 5_000 + ); + } + + #[test] + fn real_multi_pool_proposals_observe_padded_limits_at_nu7_activation() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let activation = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + for pool_counts in [[0, 328, 0], [0, 0, 330], [100, 100, 128]] { + let original = multi_pool_proposal(pool_counts, activation); + let bounded = bound_send_max(¶ms, original.clone()).unwrap(); + assert_eq!(bounded.steps().len(), 1); + assert_multi_pool_batches(&original, &bounded, pool_counts); + } + for pool_counts in [[0, 329, 0], [0, 0, 331], [100, 100, 129]] { + let original = multi_pool_proposal(pool_counts, activation - 1); + assert!(validate_proposal(¶ms, &original).is_ok()); + let bounded = bound_send_max(¶ms, original.clone()).unwrap(); + assert_eq!(bounded.steps().len(), 1); + assert!( + bounded.steps().first().shielded_inputs().unwrap().notes() + == original.steps().first().shielded_inputs().unwrap().notes() + ); + assert_eq!( + bounded.steps().first().balance(), + original.steps().first().balance() + ); + } + } + + #[test] + fn large_recovery_retains_every_input_and_prices_every_batch() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let proposal = sapling_proposal(901, height); + assert!(validate_proposal(¶ms, &proposal).is_err()); + let bounded = bound_send_max(¶ms, proposal).unwrap(); + assert_eq!(bounded.steps().len(), 4); + validate_proposal(¶ms, &bounded).unwrap(); + let mut ids: Vec<_> = bounded + .steps() + .iter() + .flat_map(|s| { + s.shielded_inputs() + .unwrap() + .notes() + .iter() + .map(|n| *n.internal_note_id()) + }) + .collect(); + ids.sort_unstable(); + assert_eq!(ids, (0..901).collect::>()); + let mut total = 0u64; + for (index, step) in bounded.steps().iter().enumerate() { + let independent = independent_step(&bounded, index).unwrap(); + assert_eq!(independent.steps().len(), 1); + let fee = u64::from(step.balance().fee_required()); + assert_eq!( + fee, + step.shielded_inputs().unwrap().notes().len() as u64 * 5_000 + ); + let payment = step.transaction_request().payments().get(&0).unwrap(); + assert!(payment.memo().is_some()); + total += u64::from(payment.amount().unwrap()) + fee; + } + assert_eq!(total, 901 * 100_000); + } + + #[test] + fn batching_distributes_value_to_pay_cross_pool_output_padding() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let usk = zcash_keys::keys::UnifiedSpendingKey::from_seed( + ¶ms, + &[11; 32], + zip32::AccountId::ZERO, + ) + .unwrap(); + let recipient = usk + .to_unified_full_viewing_key() + .default_address(zcash_keys::keys::UnifiedAddressRequest::AllAvailableKeys) + .unwrap() + .0; + let recipient = + zcash_address::ZcashAddress::try_from_encoded(&recipient.encode(¶ms)).unwrap(); + let mut values = vec![5_001; 299]; + values[0] = 100_000; + values[1] = 100_000; + let proposal = sapling_values_proposal(&values, height, Some(recipient)); + let bounded = bound_send_max(¶ms, proposal).unwrap(); + assert_eq!(bounded.steps().len(), 2); + let mut accounted = 0; + for step in bounded.steps() { + assert_eq!( + step.shielded_inputs() + .unwrap() + .notes() + .iter() + .filter(|n| u64::from(n.note().value()) == 100_000) + .count(), + 1 + ); + assert_eq!(step.payment_pools()[&0], PoolType::IRONWOOD); + accounted += u64::from(step.transaction_request().payments()[&0].amount().unwrap()) + + u64::from(step.balance().fee_required()); + } + assert_eq!(accounted, values.iter().sum::()); + } + + /// A two-payment donation split over 901 notes at NU7 activation. With + /// `change` set, the balance carries one Sapling change output of that + /// value, taken from the recipient's payment so the proposal balances. + fn donation_split_proposal( + change: Option, + ) -> (Proposal, u64, zip321::Payment) { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let height = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + let template = sapling_proposal(901, height); + let step = template.steps().first(); + let payment = step.transaction_request().payments().get(&0).unwrap(); + let net = u64::from(payment.amount().unwrap()); + let donation = net / 10; + let make_payment = |amount| { + zip321::Payment::new( + payment.recipient_address().clone(), + Some(Zatoshis::from_u64(amount).unwrap()), + payment.memo().cloned(), + None, + None, + vec![], + ) + .unwrap() + }; + let original = Proposal::single_step( + zip321::TransactionRequest::new(vec![ + make_payment(donation), + make_payment(net - donation - change.unwrap_or(0)), + ]) + .unwrap(), + [(0, PoolType::SAPLING), (1, PoolType::SAPLING)].into(), + vec![], + step.shielded_inputs().cloned(), + step.anchor_height().unwrap(), + TransactionBalance::new( + change + .map(|value| { + zcash_client_backend::fees::ChangeValue::sapling( + Zatoshis::from_u64(value).unwrap(), + None, + ) + }) + .into_iter() + .collect(), + step.balance().fee_required(), + ) + .unwrap(), + StandardFeeRule::Zip317, + height.into(), + template.confirmations_policy(), + false, + true, + ) + .unwrap(); + (original, donation, payment.clone()) + } + + fn assert_donation_preserved( + bounded: &Proposal, + donation: u64, + payment: &zip321::Payment, + ) { + let mut donated = 0; + let mut delivered = 0; + for step in bounded.steps() { + let payments = step.transaction_request().payments(); + donated += u64::from(payments[&0].amount().unwrap()); + delivered += u64::from(payments[&1].amount().unwrap()); + assert_eq!(payments[&1].memo(), payment.memo()); + assert_eq!( + payments[&1].recipient_address(), + payment.recipient_address() + ); + } + assert_eq!(donated, donation); + assert_eq!( + donated + delivered + crate::service::proposal_fee_zatoshis(bounded).unwrap(), + 901 * 100_000 + ); + } + + #[test] + fn bounded_batches_preserve_donation_and_recipient_memos() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let (original, donation, payment) = donation_split_proposal(None); + let bounded = bound_send_max(¶ms, original).unwrap(); + assert_donation_preserved(&bounded, donation, &payment); + } + + /// The real donation split comes from `propose_transfer`, whose change + /// strategy emits a zero-valued change output when the transaction + /// balances exactly. Refusing it would leave every oversized sweep with + /// a donation unproposable after NU7. + #[test] + fn zero_valued_change_from_a_balanced_donation_split_is_batched() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let (original, donation, payment) = donation_split_proposal(Some(0)); + let bounded = bound_send_max(¶ms, original) + .expect("zero-valued change carries no value and must not block batching"); + assert!(bounded.steps().len() > 1); + assert_donation_preserved(&bounded, donation, &payment); + } + + /// Real change is value the batches would not account for, so it is + /// still refused. + #[test] + fn nonzero_change_still_refuses_batching() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let (original, _, _) = donation_split_proposal(Some(1)); + assert!(bound_send_max(¶ms, original).is_err()); + } + + #[test] + fn activation_boundary_changes_batching_without_dropping_notes() { + let params = zcash_protocol::consensus::MAIN_NETWORK; + let activation = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + assert_eq!( + bound_send_max(¶ms, sapling_proposal(299, activation - 1)) + .unwrap() + .steps() + .len(), + 1 + ); + assert_eq!( + bound_send_max(¶ms, sapling_proposal(298, activation)) + .unwrap() + .steps() + .len(), + 1 + ); + assert_eq!( + bound_send_max(¶ms, sapling_proposal(299, activation)) + .unwrap() + .steps() + .len(), + 2 + ); + } + + #[test] + fn pool_and_combined_boundaries_include_padding() { + assert!(ShieldedCounts { + sapling_spends: 298, + sapling_outputs: 2, + ..Default::default() + } + .validate() + .is_ok()); + assert!(ShieldedCounts { + sapling_spends: 299, + sapling_outputs: 2, + ..Default::default() + } + .validate() + .is_err()); + assert!(ShieldedCounts { + orchard: 330, + ..Default::default() + } + .validate() + .is_ok()); + assert!(ShieldedCounts { + orchard: 331, + ..Default::default() + } + .validate() + .is_err()); + assert!(ShieldedCounts { + sapling_spends: 298, + sapling_outputs: 2, + orchard: 30, + ..Default::default() + } + .validate() + .is_ok()); + assert!(ShieldedCounts { + sapling_spends: 298, + sapling_outputs: 2, + orchard: 31, + ..Default::default() + } + .validate() + .is_err()); + assert!(ShieldedCounts { + orchard: 200, + ironwood: 200, + ..Default::default() + } + .validate() + .is_err()); + assert!(ShieldedCounts { + joinsplits: 1, + ..Default::default() + } + .validate() + .is_err()); + assert!(ShieldedCounts { + sapling_spends: usize::MAX, + sapling_outputs: 2, + ..Default::default() + } + .validate() + .is_err()); + } +} diff --git a/crates/zeck-core/src/reconciliation.rs b/crates/zeck-core/src/reconciliation.rs index f3499bf3..e2106723 100644 --- a/crates/zeck-core/src/reconciliation.rs +++ b/crates/zeck-core/src/reconciliation.rs @@ -7,8 +7,9 @@ use zcash_primitives::transaction::TxId; use crate::{ broadcast::{ - observe_transaction, resubmit_prepared_transaction, BroadcastStore, DurableBroadcastLog, - SubmissionDisposition, TxObservation, TxObservationState, TxObserver, TxSubmitter, + observe_transaction, resubmit_prepared_transaction, validate_retry_at_tip, BroadcastStore, + DurableBroadcastLog, SubmissionDisposition, TxObservation, TxObservationState, TxObserver, + TxSubmitter, }, error::{ZeckError, ZeckResult}, models::{TxLifecycleState, ZeckNetwork}, @@ -244,6 +245,13 @@ pub async fn retry_unknown_transaction( .latest(txid) .ok_or_else(|| ZeckError::Storage(format!("missing prepared transaction {txid}")))? .prepared; + // Observation alone cannot authorize a send: its sources may be lagging + // or unavailable. Ask the submission endpoint for fresh network-validated + // evidence, then check the branch encoded in these exact durable bytes. + let tip = submitter.validated_tip(network).await.map_err(|err| { + ZeckError::Broadcast(format!("cannot validate the retry chain tip ({err}); keep the stored transaction bytes and reconcile their status before replanning")) + })?; + validate_retry_at_tip(&stored.raw_tx, network, tip)?; let submitted = resubmit_prepared_transaction(log, submitter, &stored, deadline).await?; Ok(ReconciledTransaction { txid: txid.to_string(), @@ -297,6 +305,119 @@ mod tests { } } + struct RetryTipSubmitter { + network: ZeckNetwork, + tip: Option, + sent: Vec>, + tip_queries: usize, + } + + impl RetryTipSubmitter { + fn new(network: ZeckNetwork, tip: Option) -> Self { + Self { + network, + tip, + sent: Vec::new(), + tip_queries: 0, + } + } + + fn nu5() -> Self { + use zcash_protocol::consensus::{NetworkUpgrade, Parameters}; + let network = ZeckNetwork::Testnet; + let tip = crate::workspace::consensus_network(network) + .activation_height(NetworkUpgrade::Nu5) + .unwrap(); + Self::new(network, Some(u32::from(tip))) + } + } + + #[async_trait] + impl crate::broadcast::TxSubmitter for RetryTipSubmitter { + async fn validated_tip(&mut self, network: ZeckNetwork) -> ZeckResult { + assert_eq!(network, self.network); + self.tip_queries += 1; + self.tip + .ok_or_else(|| crate::ZeckError::Lightwalletd("fresh tip unavailable".into())) + } + + async fn send_raw( + &mut self, + raw: Vec, + ) -> Result { + self.sent.push(raw); + Ok(zcash_client_backend::proto::service::SendResponse { + error_code: 0, + error_message: String::new(), + }) + } + } + + struct UnavailableObserver(ZeckNetwork); + + #[async_trait] + impl TxObserver for UnavailableObserver { + async fn observe( + &mut self, + network: ZeckNetwork, + _txid: TxId, + expiry: Option, + ) -> ZeckResult { + assert_eq!(network, self.0); + Ok(observe_transaction(Vec::new(), expiry)) + } + } + + fn prepared_for_branch( + version: zcash_primitives::transaction::TxVersion, + branch: zcash_protocol::consensus::BranchId, + expiry: u32, + ) -> PreparedTransaction { + use zcash_primitives::transaction::{Authorized, TransactionData, TxVersion}; + use zcash_protocol::consensus::BlockHeight; + let transaction = if version == TxVersion::V6 { + TransactionData::::from_parts_v6( + branch, + 0, + BlockHeight::from_u32(expiry), + None, + None, + None, + None, + ) + } else { + TransactionData::::from_parts( + version, + branch, + 0, + BlockHeight::from_u32(expiry), + None, + None, + None, + None, + ) + } + .freeze() + .unwrap(); + let mut raw_tx = Vec::new(); + transaction.write(&mut raw_tx).unwrap(); + PreparedTransaction { + txid: transaction.txid(), + raw_tx, + fee_zatoshis: 10_000, + expiry_height: Some(expiry), + } + } + + fn nu5_retry_prepared() -> PreparedTransaction { + let tip = RetryTipSubmitter::nu5().tip.unwrap(); + prepared_for_branch( + zcash_primitives::transaction::TxVersion::V5, + zcash_protocol::consensus::BranchId::Nu5, + tip + 200, + ) + } + fn evidence(operator: &str, height: Option, in_block: bool) -> EndpointTxEvidence { EndpointTxEvidence { operator_id: operator.to_owned(), @@ -877,12 +998,234 @@ mod tests { } #[tokio::test] - async fn explicit_unknown_retry_sends_only_the_stored_transaction() { + async fn exact_retry_rejects_prior_branch_at_nu7_without_mutating_durable_bytes() { + use zcash_primitives::transaction::TxVersion; + use zcash_protocol::consensus::BranchId; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + for version in [TxVersion::V5, TxVersion::V6] { + // A future expiry does not make a prior-branch signature valid. + let tx = prepared_for_branch(version, BranchId::Nu6_3, activation + 100); + for tip in [activation - 2, activation - 1, activation] { + for state in [ + TxLifecycleState::NotSubmitted, + TxLifecycleState::SubmissionUnknown, + ] { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("broadcasts-v1.jsonl"); + let mut log = DurableBroadcastLog::open(&path).unwrap(); + log.persist_prepared(&tx).unwrap(); + if state == TxLifecycleState::SubmissionUnknown { + log.transition(tx.txid, state, None, None).unwrap(); + } + let before = std::fs::read(&path).unwrap(); + let mut observer = UnavailableObserver(network); + let mut submitter = RetryTipSubmitter::new(network, Some(tip)); + let result = super::retry_unknown_transaction( + &mut log, + &mut observer, + &mut submitter, + network, + tx.txid, + Duration::from_secs(1), + ) + .await; + assert_eq!(submitter.tip_queries, 1); + if tip < activation - 1 { + assert_eq!(result.unwrap().status, TxLifecycleState::Pending); + assert_eq!(submitter.sent, vec![tx.raw_tx.clone()]); + } else { + let err = result.unwrap_err().to_string(); + assert!(err.contains("branch") && err.contains("reconcile"), "{err}"); + assert!(submitter.sent.is_empty()); + assert_eq!(log.latest(tx.txid).unwrap().state, state); + assert_eq!(std::fs::read(&path).unwrap(), before); + } + assert_eq!(log.latest(tx.txid).unwrap().prepared, tx); + } + } + } + } + } + + #[tokio::test] + async fn exact_retry_accepts_current_nu7_branch_and_rejects_retired_v4() { + use zcash_primitives::transaction::TxVersion; + use zcash_protocol::consensus::BranchId; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + for (version, branch, allowed) in [ + (TxVersion::V5, BranchId::Nu7, true), + (TxVersion::V6, BranchId::Nu7, true), + (TxVersion::V4, BranchId::Nu6_3, false), + ] { + let tx = prepared_for_branch(version, branch, activation + 100); + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("broadcasts-v1.jsonl"); + let mut log = DurableBroadcastLog::open(&path).unwrap(); + log.persist_prepared(&tx).unwrap(); + let before = std::fs::read(&path).unwrap(); + let mut observer = UnavailableObserver(network); + let mut submitter = RetryTipSubmitter::new(network, Some(activation - 1)); + let result = super::retry_unknown_transaction( + &mut log, + &mut observer, + &mut submitter, + network, + tx.txid, + Duration::from_secs(1), + ) + .await; + assert_eq!( + result.is_ok(), + allowed, + "{network:?} {version:?}: {result:?}" + ); + if allowed { + assert_eq!(submitter.sent, vec![tx.raw_tx.clone()]); + } else { + assert!(submitter.sent.is_empty()); + assert_eq!(std::fs::read(&path).unwrap(), before); + assert_eq!( + log.latest(tx.txid).unwrap().state, + TxLifecycleState::NotSubmitted + ); + } + assert_eq!(log.latest(tx.txid).unwrap().prepared, tx); + } + } + } + + #[tokio::test] + async fn exact_retry_fails_closed_on_unknown_or_unsupported_height() { + use zcash_primitives::transaction::TxVersion; + use zcash_protocol::consensus::BranchId; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + let tx = prepared_for_branch(TxVersion::V6, BranchId::Nu6_3, activation + 100); + for tip in [None, Some(0), Some(u32::MAX)] { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("broadcasts-v1.jsonl"); + let mut log = DurableBroadcastLog::open(&path).unwrap(); + log.persist_prepared(&tx).unwrap(); + let before = std::fs::read(&path).unwrap(); + let mut observer = UnavailableObserver(network); + let mut submitter = RetryTipSubmitter::new(network, tip); + let result = super::retry_unknown_transaction( + &mut log, + &mut observer, + &mut submitter, + network, + tx.txid, + Duration::from_secs(1), + ) + .await; + assert!(result.is_err()); + assert!(submitter.sent.is_empty()); + assert_eq!(std::fs::read(&path).unwrap(), before); + assert_eq!(log.latest(tx.txid).unwrap().prepared, tx); + assert_eq!( + log.latest(tx.txid).unwrap().state, + TxLifecycleState::NotSubmitted + ); + } + } + } + + #[tokio::test] + async fn exact_retry_uses_encoded_expiry_and_retains_expired_transaction_status() { + use zcash_primitives::transaction::TxVersion; + use zcash_protocol::consensus::BranchId; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).unwrap(); + for tip in [activation + 9, activation + 10, activation + 11] { + let mut tx = prepared_for_branch(TxVersion::V6, BranchId::Nu7, activation + 10); + // Durable metadata cannot override the expiry inside signed bytes. + tx.expiry_height = Some(activation + 100); + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("broadcasts-v1.jsonl"); + let mut log = DurableBroadcastLog::open(&path).unwrap(); + log.persist_prepared(&tx).unwrap(); + log.transition(tx.txid, TxLifecycleState::SubmissionUnknown, None, None) + .unwrap(); + let before = std::fs::read(&path).unwrap(); + let mut observer = UnavailableObserver(network); + let mut submitter = RetryTipSubmitter::new(network, Some(tip)); + let result = super::retry_unknown_transaction( + &mut log, + &mut observer, + &mut submitter, + network, + tx.txid, + Duration::from_secs(1), + ) + .await; + if tip < activation + 10 { + assert_eq!(result.unwrap().status, TxLifecycleState::Pending); + assert_eq!(submitter.sent, vec![tx.raw_tx.clone()]); + } else { + let err = result.unwrap_err().to_string(); + assert!( + err.contains("expired") && err.contains("reconcile"), + "{err}" + ); + assert!(submitter.sent.is_empty()); + assert_eq!(std::fs::read(&path).unwrap(), before); + assert_eq!( + log.latest(tx.txid).unwrap().state, + TxLifecycleState::SubmissionUnknown + ); + } + assert_eq!(log.latest(tx.txid).unwrap().prepared, tx); + } + } + } + + #[tokio::test] + async fn explicit_retry_without_validated_tip_retains_bytes_and_does_not_send() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("broadcasts-v1.jsonl"); let tx = prepared(); let mut log = DurableBroadcastLog::open(&path).unwrap(); log.persist_prepared(&tx).unwrap(); + log.transition(tx.txid, TxLifecycleState::SubmissionUnknown, None, None) + .unwrap(); + let before = std::fs::read(&path).unwrap(); + let mut observer = ScriptedObserver(VecDeque::from([observe_transaction( + Vec::new(), + tx.expiry_height, + )])); + // The ordinary submission adapter supplies no fresh validated height. + let mut submitter = AcceptingSubmitter::default(); + let result = super::retry_unknown_transaction( + &mut log, + &mut observer, + &mut submitter, + ZeckNetwork::Testnet, + tx.txid, + Duration::from_secs(1), + ) + .await; + assert!( + result.is_err(), + "an unknown tip must prevent exact-byte retry" + ); + assert!(submitter.0.is_empty()); + assert_eq!(std::fs::read(&path).unwrap(), before); + assert_eq!(log.latest(tx.txid).unwrap().prepared, tx); + assert_eq!( + log.latest(tx.txid).unwrap().state, + TxLifecycleState::SubmissionUnknown + ); + } + + #[tokio::test] + async fn explicit_unknown_retry_sends_only_the_stored_transaction() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("broadcasts-v1.jsonl"); + let tx = nu5_retry_prepared(); + let mut log = DurableBroadcastLog::open(&path).unwrap(); + log.persist_prepared(&tx).unwrap(); log.transition(tx.txid, TxLifecycleState::SubmissionUnknown, None, None) .unwrap(); let absent = observe_transaction( @@ -890,7 +1233,7 @@ mod tests { tx.expiry_height, ); let mut observer = ScriptedObserver(VecDeque::from([absent])); - let mut submitter = AcceptingSubmitter::default(); + let mut submitter = RetryTipSubmitter::nu5(); let result = super::retry_unknown_transaction( &mut log, &mut observer, @@ -901,7 +1244,7 @@ mod tests { ) .await .unwrap(); - assert_eq!(submitter.0, vec![tx.raw_tx]); + assert_eq!(submitter.sent, vec![tx.raw_tx]); assert_eq!(result.status, TxLifecycleState::Pending); drop(log); assert_eq!( @@ -952,7 +1295,7 @@ mod tests { async fn prepared_before_submission_crash_retries_only_stored_bytes() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("broadcasts-v1.jsonl"); - let tx = prepared(); + let tx = nu5_retry_prepared(); let mut log = DurableBroadcastLog::open(&path).unwrap(); log.persist_prepared(&tx).unwrap(); let absent = observe_transaction( @@ -960,7 +1303,7 @@ mod tests { tx.expiry_height, ); let mut observer = ScriptedObserver(VecDeque::from([absent])); - let mut submitter = AcceptingSubmitter::default(); + let mut submitter = RetryTipSubmitter::nu5(); let result = super::retry_unknown_transaction( &mut log, &mut observer, @@ -971,7 +1314,7 @@ mod tests { ) .await .unwrap(); - assert_eq!(submitter.0, vec![tx.raw_tx]); + assert_eq!(submitter.sent, vec![tx.raw_tx]); assert_eq!(result.status, TxLifecycleState::Pending); drop(log); assert_eq!( diff --git a/crates/zeck-core/src/regtest_funding.rs b/crates/zeck-core/src/regtest_funding.rs index bc03c4be..8912eb32 100644 --- a/crates/zeck-core/src/regtest_funding.rs +++ b/crates/zeck-core/src/regtest_funding.rs @@ -254,6 +254,8 @@ pub async fn transfer_from_treasury( let txids = create_proposed_transactions::<_, _, Infallible, _, Infallible, _>( &mut wallet_db, ¶ms, + &zcash_client_backend::util::SystemClock, + &mut crate::workspace::wallet_rng(), &prover, &prover, &SpendingKeys::new(usk, HashMap::new()), diff --git a/crates/zeck-core/src/sapling_key.rs b/crates/zeck-core/src/sapling_key.rs index 136a2f8f..681d2c91 100644 --- a/crates/zeck-core/src/sapling_key.rs +++ b/crates/zeck-core/src/sapling_key.rs @@ -15,9 +15,9 @@ use argos_wallet_import::{ImportedKeys, Provenance, SaplingKey}; use secrecy::Secret; +use zcash_keys::constants; use zcash_keys::encoding::{decode_extended_spending_key, AddressCodec}; use zcash_keys::keys::sapling::ExtendedSpendingKey; -use zcash_protocol::constants; use crate::{ error::{ZeckError, ZeckResult}, @@ -216,8 +216,8 @@ pub fn merge_standalone_sapling_keys( #[cfg(test)] mod tests { use super::*; + use zcash_keys::constants; use zcash_keys::encoding::encode_extended_spending_key; - use zcash_protocol::constants; /// The prefixes users actually type, pinned against ZIP-32 §5.6.3.1. /// An upstream rename must break a test, not a recovery. @@ -235,6 +235,7 @@ mod tests { fn a_key() -> ExtendedSpendingKey { sapling_crypto::zip32::ExtendedSpendingKey::master(&[7u8; 32]) + .expect("valid fixture Sapling key") } #[test] @@ -385,7 +386,8 @@ mod tests { use secrecy::ExposeSecret; fn encoded_key(seed: [u8; 32], network: ZeckNetwork) -> String { - let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed); + let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed) + .expect("valid fixture Sapling key"); encode_extended_spending_key( match network { ZeckNetwork::Mainnet => constants::mainnet::HRP_SAPLING_EXTENDED_SPENDING_KEY, @@ -489,7 +491,8 @@ mod tests { } fn imported_sapling_key(seed: [u8; 32]) -> SaplingKey { - let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed); + let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed) + .expect("valid fixture Sapling key"); SaplingKey { extsk: Secret::new(extsk.to_bytes().to_vec()), provenance: Provenance::Standalone, diff --git a/crates/zeck-core/src/scan.rs b/crates/zeck-core/src/scan.rs index cc5b9899..9c2b3271 100644 --- a/crates/zeck-core/src/scan.rs +++ b/crates/zeck-core/src/scan.rs @@ -6,8 +6,8 @@ use std::{ }, }; +use crate::workspace::WalletRng; use async_trait::async_trait; -use rand_core::OsRng; use rusqlite::{params, Connection, OptionalExtension}; use rustls::crypto::ring::default_provider; use secrecy::ExposeSecret; @@ -1094,7 +1094,10 @@ fn select_mixed_sapling( let index = AccountId::try_from(zip32_index).map_err(|_| { ZeckError::InvalidConfig(format!("account index {zip32_index} is out of range")) })?; - let extsk = zcash_keys::keys::sapling::spending_key(seed, network.coin_type(), index); + let extsk = zcash_keys::keys::sapling::spending_key(seed, network.coin_type(), index) + .ok_or_else(|| { + ZeckError::Internal("Sapling spending-key derivation failed".to_owned()) + })?; sapling_seen.insert(extsk.to_diversifiable_full_viewing_key().to_bytes()); } } @@ -1272,7 +1275,7 @@ async fn register_mixed_keys( ZeckError::Internal("mixed wallet has no account to watch transparent keys".to_owned()) })? .wallet_account_id; - let secp = secp256k1::Secp256k1::signing_only(); + let existing = wallet_db .get_transparent_receivers(anchor_id, true, true) .map_err(|err| ZeckError::Wallet(format!("loading mixed transparent receivers: {err}")))?; @@ -1280,7 +1283,7 @@ async fn register_mixed_keys( for &key_index in &selected_transparent { let key = &resolved[key_index]; if !existing.contains_key(&key.address) { - let pubkey = secp256k1::PublicKey::from_secret_key(&secp, key.secret_key()); + let pubkey = secp256k1::PublicKey::from_secret_key(key.secret_key()); wallet_db .import_standalone_transparent_pubkey(anchor_id, pubkey) .map_err(|err| { @@ -2107,7 +2110,7 @@ async fn import_accounts_into( } async fn import_accounts_into_wallet( - wallet_db: &mut WalletDb, + wallet_db: &mut WalletDb, seed: &[u8; 64], birthday: &AccountBirthday, transparent_mode: &TransparentImportMode<'_>, @@ -4258,6 +4261,7 @@ mod tests { argos_wallet_import::SaplingKey { extsk: secrecy::Secret::new( sapling_crypto::zip32::ExtendedSpendingKey::master(&[seed; 32]) + .expect("valid fixture Sapling key") .to_bytes() .to_vec(), ), @@ -4510,9 +4514,8 @@ mod tests { bytes[102..106].copy_from_slice(&1u32.to_le_bytes()); // Replace the writer's HD secret/address pair with a distinct // public no-funds standalone key, retaining writer field layout. - let secret = secp256k1::SecretKey::from_slice(&[0x42; 32]).unwrap(); - let pubkey = - secp256k1::PublicKey::from_secret_key(&secp256k1::Secp256k1::new(), &secret); + let secret = secp256k1::SecretKey::from_secret_bytes([0x42; 32]).unwrap(); + let pubkey = secp256k1::PublicKey::from_secret_key(&secret); let address = crate::imported::encode_transparent_address( &zcash_transparent::address::TransparentAddress::from_pubkey(&pubkey), ZeckNetwork::Mainnet, @@ -4740,8 +4743,10 @@ mod tests { seed.expose_secret(), ZeckNetwork::Mainnet.coin_type(), AccountId::try_from(0).unwrap(), - ); - let separate = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x71; 32]); + ) + .expect("valid fixture Sapling key"); + let separate = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x71; 32]) + .expect("valid fixture Sapling key"); for bytes in [ hd_key.to_bytes().to_vec(), hd_key.to_bytes().to_vec(), @@ -5179,7 +5184,7 @@ mod tests { db_path, consensus_network(config.network), SystemClock, - rand_core::OsRng, + crate::workspace::wallet_rng(), ) .expect("WalletDb::for_path should succeed"); @@ -5280,9 +5285,13 @@ mod tests { { let cache = MemoryBlockCache::new(); - let mut wallet_db = - WalletDb::for_path(&wallet_db_path, network, SystemClock, rand_core::OsRng) - .expect("wallet_db"); + let mut wallet_db = WalletDb::for_path( + &wallet_db_path, + network, + SystemClock, + crate::workspace::wallet_rng(), + ) + .expect("wallet_db"); // Prime the wallet's commitment-tree state and chain tip — the // same calls that `zcash_client_backend::sync` issues before @@ -5340,7 +5349,7 @@ mod tests { workspace2.wallet_db_path(), network, SystemClock, - rand_core::OsRng, + crate::workspace::wallet_rng(), ) .expect("wallet_db reopen"); @@ -5555,7 +5564,7 @@ mod tests { rusqlite::Connection, crate::workspace::ArgosParams, SystemClock, - rand_core::OsRng, + crate::workspace::WalletRng, > { crate::workspace::open_wallet_db( self.workspace.wallet_db_path(), diff --git a/crates/zeck-core/src/service.rs b/crates/zeck-core/src/service.rs index 30de59f2..0df022f6 100644 --- a/crates/zeck-core/src/service.rs +++ b/crates/zeck-core/src/service.rs @@ -157,8 +157,12 @@ fn execution_donation_address(network: crate::models::ZeckNetwork) -> String { } /// The concrete wallet database type used throughout the execution path. -type SweepWalletDb = - WalletDb; +type SweepWalletDb = WalletDb< + rusqlite::Connection, + crate::workspace::ArgosParams, + SystemClock, + crate::workspace::WalletRng, +>; type HdSweepProposal = zcash_client_backend::proposal::Proposal; type ImportedSweepProposal = zcash_client_backend::proposal::Proposal; @@ -362,14 +366,17 @@ fn canonical_proposal( let mut bytes = Vec::with_capacity(encoded.len() + 64); bytes.extend_from_slice(&(encoded.len() as u64).to_le_bytes()); bytes.extend_from_slice(&encoded); - let version = proposal.proposed_version().unwrap_or_else(|| { - let branch = zcash_protocol::consensus::BranchId::for_height( - &consensus_network(network), - BlockHeight::from_u32(proposal.min_target_height().into()), - ); - zcash_primitives::transaction::TxVersion::suggested_for_branch(branch) - }); + let branch = zcash_protocol::consensus::BranchId::for_height( + &consensus_network(network), + BlockHeight::from_u32(proposal.min_target_height().into()), + ); + let version = proposal + .proposed_version() + .unwrap_or_else(|| zcash_primitives::transaction::TxVersion::suggested_for_branch(branch)); bytes.extend_from_slice(&version.header().to_le_bytes()); + // NU6.3 and NU7 both use V6. Bind the consensus branch independently + // of version, including when an explicit version was proposed. + bytes.extend_from_slice(&u32::from(branch).to_le_bytes()); // The public protobuf intentionally omits the wallet's local note ID and // transparent script/owner. Bind those too: they are consumed by signing. bytes.extend_from_slice(&(proposal.steps().len() as u64).to_le_bytes()); @@ -3054,8 +3061,7 @@ fn build_exact_sweep_proposal( fee_zatoshis: fee, net_zatoshis: net, donation_zatoshis: donation, - note: "Exact ZIP-317 send-max proposal from spendable shielded notes." - .to_owned(), + note: format!("Exact ZIP-317 send-max proposal; {} bounded transaction(s) recover all selected shielded notes.", proposal.steps().len()), memo: Some(memo_text.clone()), }); legs.push(ExactSweepLeg::HdSend { @@ -3109,7 +3115,7 @@ fn build_exact_sweep_proposal( fee_zatoshis: fee, net_zatoshis: net, donation_zatoshis: 0, - note: "Exact ZIP-317 imported Sapling proposal.".to_owned(), + note: format!("Exact ZIP-317 imported Sapling proposal; {} bounded transaction(s) recover all selected notes.", proposal.steps().len()), memo: None, }); legs.push(ExactSweepLeg::ImportedSapling { @@ -3727,10 +3733,9 @@ async fn execute_sweep_for_session( let transparent_account = legacy_transparent_account_key_from_seed(runtime.network, &seed)?; let network = consensus_network(runtime.network); let prover = LocalTxProver::bundled(); - // Sum of the donation outputs actually broadcast (0 when a per-account - // donation was below the floor or its split fell back). Reported on the - // outcome so the completion screen shows the true donated total rather than - // the proposal's estimate. + // Donation outputs of mined or still-at-risk transactions, including + // partial batches and lost submission replies. Unsent and definitively + // rejected/expired transactions contribute nothing. let mut total_donation_zatoshis = 0u64; let mut follow_up_review_required = false; let mut results = Vec::new(); @@ -3839,21 +3844,15 @@ async fn execute_sweep_for_session( lightwalletd_url: runtime.lightwalletd_url.as_str(), confirmation_sources: &runtime.confirmation_sources, }; - let (_fee, account_donation) = execute_send_max_step( + execute_send_max_step( &mut ctx, tracked_account, &usk, proposal, *donation_zatoshis, + &mut total_donation_zatoshis, ) .await?; - total_donation_zatoshis = total_donation_zatoshis - .checked_add(account_donation) - .ok_or_else(|| { - ZeckError::Internal( - "donation total overflowed the supported range".to_owned(), - ) - })?; } _ => unreachable!("hd_leg_plan returns only HD legs"), } @@ -4062,6 +4061,7 @@ async fn execute_shielding_step( ctx.workspace.wallet_db_path(), consensus_network(ctx.network), )?; + crate::nu7_limits::validate_proposal(&consensus_network(ctx.network), proposal)?; let fee_zatoshis = proposal_fee_zatoshis(proposal)?; require_fee_matches(ctx.reviewed_fee_zatoshis, fee_zatoshis)?; let fee_through_shield = checked_fee_total(ctx.prior_fee_zatoshis, fee_zatoshis)?; @@ -4072,6 +4072,8 @@ async fn execute_shielding_step( let txids = create_proposed_transactions::<_, _, Infallible, _, Infallible, _>( &mut wallet_db, &consensus_network(ctx.network), + &SystemClock, + &mut crate::workspace::wallet_rng(), ctx.prover, ctx.prover, &SpendingKeys::new(usk.clone(), standalone_keys), @@ -4389,6 +4391,22 @@ fn propose_hd_send_max( donation_proposal_or_fallback(split_result, max_proposal, donation, account_index) }; + let proposal = crate::nu7_limits::bound_send_max(&consensus_network(network), proposal)?; + let donation_zatoshis = if donation_zatoshis > 0 { + proposal.steps().iter().try_fold(0u64, |sum, step| { + checked_fee_total( + sum, + step.transaction_request() + .payments() + .get(&0) + .and_then(|payment| payment.amount()) + .map(u64::from) + .unwrap_or(0), + ) + })? + } else { + 0 + }; Ok(Some((proposal, donation_zatoshis))) } @@ -4398,12 +4416,14 @@ async fn execute_send_max_step( usk: &UnifiedSpendingKey, proposal: &ImportedSweepProposal, donation_zatoshis: u64, -) -> ZeckResult<(u64, u64)> { + total_donation_zatoshis: &mut u64, +) -> ZeckResult { let mut wallet_db = open_wallet_db( ctx.workspace.wallet_db_path(), consensus_network(ctx.network), )?; + crate::nu7_limits::validate_proposal(&consensus_network(ctx.network), proposal)?; let fee_zatoshis = proposal_fee_zatoshis(proposal)?; require_fee_matches(ctx.reviewed_fee_zatoshis, fee_zatoshis)?; enforce_max_fee( @@ -4414,6 +4434,8 @@ async fn execute_send_max_step( let txids = create_proposed_transactions::<_, _, Infallible, _, Infallible, _>( &mut wallet_db, &consensus_network(ctx.network), + &SystemClock, + &mut crate::workspace::wallet_rng(), ctx.prover, ctx.prover, &SpendingKeys::from_unified_spending_key(usk.clone()), @@ -4424,17 +4446,84 @@ async fn execute_send_max_step( ) .map_err(|err| ZeckError::TransactionBuild(format!("creating sweep transaction: {err}")))?; - broadcast_transactions( + let txids: Vec<_> = txids.into_iter().collect(); + if txids.len() != proposal.steps().len() { + return Err(ZeckError::TransactionBuild( + "constructed transaction count does not match reviewed recovery batches".to_owned(), + )); + } + // The SDK returns transactions in proposal-step order. Bind each donation + // to its actual txid before submitting, rather than counting the whole + // account only after every batch succeeds. + let donations = txids + .iter() + .zip(proposal.steps()) + .map(|(txid, step)| { + let amount = if donation_zatoshis == 0 { + 0 + } else { + step.transaction_request() + .payments() + .get(&0) + .and_then(|payment| payment.amount()) + .map(u64::from) + .unwrap_or(0) + }; + (txid.to_string(), amount) + }) + .collect::>(); + let planned_donation = donations + .values() + .try_fold(0u64, |sum, amount| checked_fee_total(sum, *amount))?; + if planned_donation != donation_zatoshis { + return Err(ZeckError::TransactionBuild( + "constructed batch donations do not match the reviewed total".to_owned(), + )); + } + let first_result = ctx.results.len(); + let broadcast_result = broadcast_transactions( ctx, &mut wallet_db, tracked_account.derived.index, - txids.into_iter().collect(), + txids, "sweep", fee_zatoshis, ) - .await?; + .await; + // Account for every retained result before propagating a later failure. + // Unknown replies are at risk just like their fees; rejected or expired + // transactions cannot carry a donation onto the chain. + complete_send_max_broadcast( + total_donation_zatoshis, + &donations, + &ctx.results[first_result..], + broadcast_result, + )?; + + Ok(fee_zatoshis) +} - Ok((fee_zatoshis, donation_zatoshis)) +fn complete_send_max_broadcast( + total: &mut u64, + donations: &HashMap, + results: &[TxBroadcastResult], + broadcast_result: ZeckResult<()>, +) -> ZeckResult<()> { + record_submitted_donations(total, donations, results)?; + broadcast_result +} + +fn record_submitted_donations( + total: &mut u64, + donations: &HashMap, + results: &[TxBroadcastResult], +) -> ZeckResult<()> { + *total = results + .iter() + .filter(|result| result.status.fee_is_at_risk()) + .filter_map(|result| result.txid.as_ref().and_then(|txid| donations.get(txid))) + .try_fold(*total, |sum, amount| checked_fee_total(sum, *amount))?; + Ok(()) } pub(crate) fn proposal_fee_zatoshis( @@ -5993,13 +6082,13 @@ mod tests { }; let signer_map = standalone_transparent_signing_keys(&tracked, &account_key).unwrap(); assert_eq!(signer_map.len(), coordinates.len()); - let secp = secp256k1::Secp256k1::signing_only(); + for coordinate in coordinates { let secrets = signer_map .get(&coordinate.address) .expect("coordinate signer"); assert_eq!(secrets.len(), 1); - let public = secp256k1::PublicKey::from_secret_key(&secp, &secrets[0]); + let public = secp256k1::PublicKey::from_secret_key(&secrets[0]); assert_eq!( zcash_transparent::address::TransparentAddress::from_pubkey(&public), coordinate.address @@ -7135,9 +7224,15 @@ mod tests { let sk = orchard::keys::SpendingKey::from_bytes([7u8; 32]).unwrap(); let fvk = orchard::keys::FullViewingKey::from(&sk); let address = fvk.address_at(0u32, orchard::keys::Scope::External); - Address::try_from_items(vec![Receiver::Orchard(address.to_raw_address_bytes())]) - .unwrap() - .encode(&zcash_protocol::consensus::NetworkType::Main) + Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(address.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .unwrap() + .encode(&zcash_protocol::consensus::NetworkType::Main) } #[tokio::test] @@ -9858,7 +9953,8 @@ mod propose_workspace_guard_tests { .unwrap(); assert!(!root.exists()); let registry_path = - super::network_broadcast_log_path(tempdir.path(), ZeckNetwork::Testnet).unwrap(); + super::network_broadcast_log_path(&artifact_data_dir(&tempdir), ZeckNetwork::Testnet) + .unwrap(); let log = DurableBroadcastLog::open(registry_path).unwrap(); assert_eq!(log.latest(txid).unwrap().prepared.raw_tx, vec![91, 92]); drop((primary, secondary)); @@ -10374,7 +10470,9 @@ pub(crate) mod leg_fee_pin_tests { lightwalletd_url: "https://127.0.0.1:1", confirmation_sources: &[], }; - let result = execute_send_max_step(&mut ctx, &tracked, &usk, &proposal, 0).await; + let mut donated = 0; + let result = + execute_send_max_step(&mut ctx, &tracked, &usk, &proposal, 0, &mut donated).await; assert!( matches!( result, @@ -10520,6 +10618,49 @@ pub(crate) mod leg_fee_pin_tests { ); } + #[test] + fn same_version_nu7_branch_change_invalidates_review_on_both_networks() { + use zcash_primitives::transaction::TxVersion; + use zcash_protocol::consensus::{BranchId, NetworkUpgrade, Parameters}; + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let params = consensus_network(network); + let activation = params.activation_height(NetworkUpgrade::Nu7).unwrap(); + assert_eq!( + BranchId::for_height(¶ms, activation - 1), + BranchId::Nu6_3 + ); + assert_eq!( + TxVersion::suggested_for_branch(BranchId::Nu6_3), + TxVersion::V6 + ); + assert_eq!( + TxVersion::suggested_for_branch(BranchId::Nu7), + TxVersion::V6 + ); + let template = offline_proposal::(10_000); + for explicit in [None, Some(TxVersion::V6)] { + let at = |height: BlockHeight| { + Proposal::multi_step( + *template.fee_rule(), + height.into(), + template.confirmations_policy(), + template.steps().clone(), + ) + .unwrap() + .with_proposed_version(explicit) + }; + assert_ne!( + canonical_proposal(&at(activation - 1), network), + canonical_proposal(&at(activation), network) + ); + assert_eq!( + canonical_proposal(&at(activation), network), + canonical_proposal(&at(activation + 1), network) + ); + } + } + } + #[test] fn a_reviewed_leg_without_an_executable_account_fails_closed() { let plan = plan_with_leg_fee(10_000); @@ -10550,23 +10691,67 @@ mod leg_gating_tests { use crate::models::ZeckNetwork; use zcash_client_backend::proto::service::SendResponse; + fn nu5_height() -> u32 { + use zcash_protocol::consensus::{NetworkUpgrade, Parameters}; + u32::from( + consensus_network(ZeckNetwork::Mainnet) + .activation_height(NetworkUpgrade::Nu5) + .unwrap(), + ) + } + fn prepared(expiry: u32) -> PreparedTransaction { - crate::test_support::empty_v5_prepared(expiry, 10_000) + crate::test_support::empty_v5_prepared(nu5_height() + expiry, 10_000) + } + + fn pre_nu7_prepared(expiry: u32) -> PreparedTransaction { + use zcash_primitives::transaction::{Authorized, TransactionData}; + let tx = TransactionData::::from_parts_v6( + zcash_protocol::consensus::BranchId::Nu6_3, + 0, + BlockHeight::from_u32(expiry), + None, + None, + None, + None, + ) + .freeze() + .unwrap(); + let mut raw_tx = vec![]; + tx.write(&mut raw_tx).unwrap(); + PreparedTransaction { + txid: tx.txid(), + raw_tx, + fee_zatoshis: 10_000, + expiry_height: Some(expiry), + } } #[derive(Default)] struct Node { sent: Vec>, lose_reply_for: Option>, + reject_for: Option>, + tips: VecDeque, } #[async_trait::async_trait] impl TxSubmitter for Node { + async fn validated_tip(&mut self, _network: ZeckNetwork) -> ZeckResult { + Ok(self.tips.pop_front().unwrap_or_else(|| nu5_height() + 100)) + } + async fn send_raw(&mut self, raw: Vec) -> Result { self.sent.push(raw.clone()); if self.lose_reply_for.as_ref() == Some(&raw) { return Err(tonic::Status::unavailable("GoAway")); } + if self.reject_for.as_ref() == Some(&raw) { + return Ok(SendResponse { + error_code: -26, + error_message: "invalid proof".to_owned(), + }); + } Ok(SendResponse { error_code: 0, error_message: String::new(), @@ -10574,6 +10759,205 @@ mod leg_gating_tests { } } + #[tokio::test(start_paused = true)] + async fn activation_after_proving_refuses_exact_bytes_before_persisting_or_sending() { + let activation = crate::nu7::MAINNET_ACTIVATION_HEIGHT; + let prepared = pre_nu7_prepared(activation + 120); + let retained = prepared.clone(); + let dir = tempfile::tempdir().unwrap(); + let mut log = DurableBroadcastLog::open(dir.path().join("broadcasts-v1.jsonl")).unwrap(); + let mut node = Node { + tips: [activation - 1].into(), + ..Node::default() + }; + let mut observer = Observer(HashMap::new()); + let mut results = vec![]; + let error = submit_and_confirm_batch( + vec![prepared.clone()], + 0, + "sweep", + &mut results, + &mut log, + &mut node, + &mut observer, + ZeckNetwork::Mainnet, + &mut |_, _| Ok(()), + ) + .await + .unwrap_err(); + assert!(error.to_string().contains("branch")); + assert!(node.sent.is_empty()); + assert!(results.is_empty()); + assert!(log.latest(prepared.txid).is_none()); + assert_eq!( + prepared, retained, + "refusal does not replace signed bytes or invent a lifecycle state" + ); + } + + #[tokio::test(start_paused = true)] + async fn activation_between_batch_submissions_preserves_the_first_result() { + let activation = crate::nu7::MAINNET_ACTIVATION_HEIGHT; + let first = pre_nu7_prepared(activation + 120); + let second = pre_nu7_prepared(activation + 121); + let dir = tempfile::tempdir().unwrap(); + let mut log = DurableBroadcastLog::open(dir.path().join("broadcasts-v1.jsonl")).unwrap(); + let mut node = Node { + tips: [activation - 2, activation - 1].into(), + ..Node::default() + }; + let mut observer = Observer(HashMap::new()); + let mut results = vec![]; + assert!(submit_and_confirm_batch( + vec![first.clone(), second.clone()], + 0, + "sweep", + &mut results, + &mut log, + &mut node, + &mut observer, + ZeckNetwork::Mainnet, + &mut |_, _| Ok(()) + ) + .await + .is_err()); + assert_eq!(node.sent, vec![first.raw_tx.clone()]); + assert_eq!(results.len(), 1); + assert_eq!( + results[0].txid.as_deref(), + Some(first.txid.to_string().as_str()) + ); + assert_eq!( + log.latest(first.txid).unwrap().prepared.raw_tx, + first.raw_tx + ); + assert!(log.latest(second.txid).is_none()); + } + + #[tokio::test(start_paused = true)] + async fn later_batch_failure_retains_submitted_batch_donations() { + let activation = crate::nu7::MAINNET_ACTIVATION_HEIGHT; + for first_mined in [false, true] { + for stop in ["activation", "rejected", "unknown"] { + let first = pre_nu7_prepared(activation + 120); + let second = pre_nu7_prepared(activation + 121); + // Each constructed batch has its own reviewed donation output. + let donations = HashMap::from([ + (first.txid.to_string(), 25_000), + (second.txid.to_string(), 30_000), + ]); + let dir = tempfile::tempdir().unwrap(); + let mut log = + DurableBroadcastLog::open(dir.path().join("broadcasts-v1.jsonl")).unwrap(); + let mut node = Node { + tips: [ + activation - 2, + if stop == "activation" { + activation - 1 + } else { + activation - 2 + }, + ] + .into(), + lose_reply_for: (stop == "unknown").then(|| second.raw_tx.clone()), + reject_for: (stop == "rejected").then(|| second.raw_tx.clone()), + ..Node::default() + }; + let mut observer = Observer(if first_mined { + HashMap::from([(first.txid, default_operator_mined(activation - 3))]) + } else { + HashMap::new() + }); + let mut results = vec![]; + let result = submit_and_confirm_batch( + vec![first.clone(), second.clone()], + 0, + "sweep", + &mut results, + &mut log, + &mut node, + &mut observer, + ZeckNetwork::Mainnet, + &mut |_, _| Ok(()), + ) + .await; + assert!(result.is_err(), "{stop}"); + let original_error = result.as_ref().unwrap_err().to_string(); + // Exercise the production completion path: account for retained + // results even while returning the original later-batch error. + let mut total_donation = 7_000; + let result = + complete_send_max_broadcast(&mut total_donation, &donations, &results, result); + assert_eq!(result.as_ref().unwrap_err().to_string(), original_error); + let outcome = + assemble_sweep_outcome(results, vec![], total_donation, result).unwrap(); + assert!(outcome.error.is_some()); + assert_eq!( + outcome.transactions[0].txid.as_deref(), + Some(first.txid.to_string().as_str()) + ); + assert_eq!( + outcome.transactions[0].status, + if first_mined { + TxLifecycleState::MinedSingleSource + } else { + TxLifecycleState::Pending + } + ); + assert_eq!( + outcome.total_donation_zatoshis, + 7_000 + 25_000 + if stop == "unknown" { 30_000 } else { 0 }, + "{stop}, first_mined={first_mined}" + ); + assert_eq!( + outcome.transactions.len(), + if stop == "activation" { 1 } else { 2 } + ); + if stop == "activation" { + assert!(log.latest(second.txid).is_none()); + } else { + assert_eq!( + outcome.transactions[1].status, + if stop == "unknown" { + TxLifecycleState::SubmissionUnknown + } else { + TxLifecycleState::Rejected + } + ); + } + } + } + } + + #[test] + fn donation_accounting_ignores_unsubmitted_expired_rejected_and_unrelated_results() { + let txid = "reviewed-batch".to_owned(); + let donations = HashMap::from([(txid.clone(), 25_000)]); + let mut results: Vec<_> = [ + TxLifecycleState::NotSubmitted, + TxLifecycleState::Expired, + TxLifecycleState::Rejected, + ] + .into_iter() + .map(|status| TxBroadcastResult { + source_account: 0, + txid: Some(txid.clone()), + status, + fee_zatoshis: 10_000, + detail: String::new(), + confirmed_height: None, + safe_to_discard: false, + }) + .collect(); + let mut unrelated = results[0].clone(); + unrelated.status = TxLifecycleState::Mined; + unrelated.txid = Some("another-leg".to_owned()); + results.push(unrelated); + let mut total = 7_000; + record_submitted_donations(&mut total, &donations, &results).unwrap(); + assert_eq!(total, 7_000); + } + /// The default configuration: zec.rocks and na.zec.rocks, one operator. fn default_operator_mined(height: u32) -> TxObservation { crate::broadcast::observe_transaction( @@ -10770,7 +11154,7 @@ mod leg_gating_tests { mod zip317_fee_fidelity_tests { use super::*; use crate::models::ZeckNetwork; - use rand_core::OsRng; + use crate::workspace::wallet_rng; use sapling_crypto as sapling; use zcash_client_backend::fees::{ChangeStrategy, ChangeValue}; use zcash_primitives::transaction::{ @@ -10820,6 +11204,11 @@ mod zip317_fee_fidelity_tests { .compute_balance::<_, u32>( &network, height.into(), + height, + &zcash_client_backend::data_api::anchor_retention::PoolMigrationParams::new( + zcash_protocol::zip318::BlockSpacing::UNIFORM, + zcash_client_backend::data_api::anchor_retention::AnchorRetentionInterval::ZIP_318, + ), &[] as &[Infallible], &[] as &[zcash_transparent::bundle::TxOut], &( @@ -10830,7 +11219,7 @@ mod zip317_fee_fidelity_tests { &zcash_client_backend::fees::orchard::EmptyBundleView, &zcash_client_backend::fees::orchard::EmptyBundleView, None, - &(), + &zcash_client_backend::data_api::ChangeReceivers::new(true, true, None), ) .expect("change strategy prices the sweep"); assert!( @@ -10843,7 +11232,8 @@ mod zip317_fee_fidelity_tests { let quoted = u64::from(balance.fee_required()); // Build the same transaction for real. - let extsk = sapling::zip32::ExtendedSpendingKey::master(&[7; 32]); + let extsk = sapling::zip32::ExtendedSpendingKey::master(&[7; 32]) + .expect("valid fixture Sapling key"); let (_, address) = extsk.default_address(); let fvk = extsk.to_diversifiable_full_viewing_key().fvk().clone(); let notes = note_values @@ -10893,7 +11283,7 @@ mod zip317_fee_fidelity_tests { &zcash_transparent::builder::TransparentSigningSet::new(), &[extsk], &[], - OsRng, + wallet_rng(), &prover, &prover, &FeeRule::standard(), @@ -10945,11 +11335,12 @@ mod zip317_fee_fidelity_tests { use crate::transparent_recovery::tests_support::utxo; let network = consensus_network(ZeckNetwork::Mainnet); let height = network.activation_height(NetworkUpgrade::Nu5).unwrap() + 10_000; - let mut secret = secp256k1::SecretKey::from_slice(&[0x24; 32]).unwrap(); - let public = secp256k1::PublicKey::from_secret_key(&secp256k1::Secp256k1::new(), &secret); + let mut secret = secp256k1::SecretKey::from_secret_bytes([0x24; 32]).unwrap(); + let public = secp256k1::PublicKey::from_secret_key(&secret); let address = zcash_transparent::address::TransparentAddress::from_pubkey(&public); let key = crate::imported::ImportedTransparentKey::new(&mut secret, address); let recipient = sapling::zip32::ExtendedSpendingKey::master(&[9; 32]) + .expect("valid fixture Sapling key") .default_address() .1; let prover = LocalTxProver::bundled(); diff --git a/crates/zeck-core/src/service/confirmation.rs b/crates/zeck-core/src/service/confirmation.rs index f44f10cb..4bd30298 100644 --- a/crates/zeck-core/src/service/confirmation.rs +++ b/crates/zeck-core/src/service/confirmation.rs @@ -8,7 +8,7 @@ pub(super) async fn broadcast_transactions( rusqlite::Connection, crate::workspace::ArgosParams, SystemClock, - rand_core::OsRng, + crate::workspace::WalletRng, >, account_index: u32, txids: Vec, @@ -31,6 +31,12 @@ pub(super) async fn broadcast_transactions( rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY, ) .map_err(|err| ZeckError::Wallet(format!("opening wallet fee records: {err}")))?; + let target_height = wallet_db + .chain_height() + .map_err(|err| ZeckError::Wallet(format!("reading broadcast target height: {err}")))? + .ok_or_else(|| ZeckError::Wallet("broadcast requires a scanned chain height".to_owned()))? + + 1; + let params = consensus_network(ctx.network); let mut prepared = Vec::with_capacity(txids.len()); for txid in txids { let tx = wallet_db @@ -42,6 +48,7 @@ pub(super) async fn broadcast_transactions( )) })?; + crate::nu7_limits::validate_transaction(¶ms, target_height, &tx)?; let mut tx_bytes = Vec::new(); tx.write(&mut tx_bytes).map_err(|err| { ZeckError::TransactionBuild(format!("serializing transaction {txid}: {err}")) @@ -147,6 +154,10 @@ where ))); } for tx in prepared { + // Proving and earlier batch confirmations may cross an activation or + // expiry. Recheck every exact transaction immediately before journaling. + let tip = submitter.validated_tip(network).await?; + crate::broadcast::validate_retry_at_tip(&tx.raw_tx, network, tip)?; let txid = tx.txid; let fee_zatoshis = tx.fee_zatoshis; let expiry_height = tx.expiry_height; diff --git a/crates/zeck-core/src/transparent_recovery.rs b/crates/zeck-core/src/transparent_recovery.rs index 52920930..9333a7eb 100644 --- a/crates/zeck-core/src/transparent_recovery.rs +++ b/crates/zeck-core/src/transparent_recovery.rs @@ -590,7 +590,7 @@ where SP: sapling::prover::SpendProver, OP: sapling::prover::OutputProver, { - use rand_core::OsRng; + use crate::workspace::wallet_rng; use zcash_primitives::transaction::{ builder::{BuildConfig, Builder, BundlePadding}, fees::zip317::FeeRule, @@ -675,13 +675,14 @@ where // needs no account. &[], &[], - OsRng, + wallet_rng(), spend_prover, output_prover, &fee_rule, ) .map_err(|err| ZeckError::Wallet(format!("building the sweep transaction: {err:?}")))?; + crate::nu7_limits::validate_transaction(params, target_height, result.transaction())?; Ok(result.transaction().clone()) } @@ -740,7 +741,9 @@ pub(crate) fn check_transparent_fee( /// Blocks the chain may advance between a CLI quote and its execution. The /// transaction is built at the execute-time height, so it carries a full /// expiry window from then; this bound only limits how stale the reviewed -/// UTXO set and fee may be. It is half the default expiry delta. +/// UTXO set and fee may be. This chain-drift bound is independent of the +/// transaction expiry delta and remains 20 at NU7; its expected elapsed +/// lifetime becomes shorter with 25-second blocks. pub const TRANSPARENT_QUOTE_MAX_AGE_BLOCKS: u32 = 20; /// A quote stays executable while the consensus branch (and so the @@ -925,6 +928,10 @@ pub(crate) async fn sweep_transparent_only_reviewed( fee_zatoshis: plan.fee_zatoshis, expiry_height: Some(u32::from(tx.expiry_height())), }; + // Proving can span a consensus boundary; the signed transaction must still + // be mineable at the next block before any prepared record or network send. + let tip = crate::nu7::validated_tip_from_client(&mut client, network).await?; + crate::nu7::validate_transaction_for_tip(network, tip, &tx)?; Ok(Some( submit_transparent_prepared( store, @@ -1156,11 +1163,23 @@ mod sweep_tests { )); } + #[test] + fn nu7_activation_invalidates_direct_quotes_on_both_networks() { + for network in [ZeckNetwork::Mainnet, ZeckNetwork::Testnet] { + let activation = crate::nu7::activation_height(network).expect("NU7 schedule"); + assert!(matches!( + require_quote_height_current(network, activation - 1, activation), + Err(ZeckError::StaleSweepProposal(_)) + )); + assert!(require_quote_height_current(network, activation, activation + 1).is_ok()); + } + } + #[tokio::test] async fn reviewed_transparent_fee_is_checked_against_the_built_plan_before_network() { use crate::broadcast::DurableBroadcastLog; - let mut secret = secp256k1::SecretKey::from_slice(&[0x42; 32]).unwrap(); + let mut secret = secp256k1::SecretKey::from_secret_bytes([0x42; 32]).unwrap(); let key = crate::imported::ImportedTransparentKey::new(&mut secret, addr(1)); let utxos = vec![utxo(addr(1), 1_000_000, 9)]; let built = plan_sweep(&MAIN_NETWORK, height(), &utxos) @@ -1423,11 +1442,18 @@ mod destination_tests { pub(super) fn unified_address_for(network: zcash_protocol::consensus::NetworkType) -> String { use zcash_address::unified::{Address, Encoding, Receiver}; - let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]); + let extsk = sapling_crypto::zip32::ExtendedSpendingKey::master(&[0x7u8; 32]) + .expect("valid fixture Sapling key"); let (_, payment_address) = extsk.default_address(); - let ua = Address::try_from_items(vec![Receiver::Sapling(payment_address.to_bytes())]) - .expect("a Sapling-only unified address is valid under ZIP 316"); + let ua = Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Sapling(payment_address.to_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .expect("a Sapling-only unified address is valid under ZIP 316"); ua.encode(&network) } @@ -1525,9 +1551,15 @@ mod seedless_destination_tests { let sk = orchard::keys::SpendingKey::from_bytes([7u8; 32]).expect("a valid spending key"); let fvk = orchard::keys::FullViewingKey::from(&sk); let address = fvk.address_at(0u32, orchard::keys::Scope::External); - Address::try_from_items(vec![Receiver::Orchard(address.to_raw_address_bytes())]) - .expect("an Orchard-only unified address is valid under ZIP 316") - .encode(&zcash_protocol::consensus::NetworkType::Main) + Address::try_from_items( + zcash_address::unified::Revision::R0, + vec![Receiver::Orchard(address.to_raw_address_bytes())] + .into_iter() + .map(zcash_address::unified::Uitem::Data) + .collect(), + ) + .expect("an Orchard-only unified address is valid under ZIP 316") + .encode(&zcash_protocol::consensus::NetworkType::Main) } fn with_transparent_key() -> argos_wallet_import::ImportedKeys { diff --git a/crates/zeck-core/src/workspace.rs b/crates/zeck-core/src/workspace.rs index 82d42817..f8f0550b 100644 --- a/crates/zeck-core/src/workspace.rs +++ b/crates/zeck-core/src/workspace.rs @@ -3,7 +3,7 @@ use std::{ path::{Path, PathBuf}, }; -use rand_core::OsRng; +use rand::{rand_core::UnwrapErr, rngs::SysRng}; use secrecy::{SecretString, SecretVec}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; @@ -20,6 +20,12 @@ use crate::{ private_fs::{self, PrivateOpenMode}, }; +/// OS-backed CSPRNG for the NU7 SDK; fails closed if system entropy is unavailable. +pub(crate) type WalletRng = UnwrapErr; +pub(crate) fn wallet_rng() -> WalletRng { + UnwrapErr(SysRng) +} + /// Filename for the per-workspace session metadata sidecar. Lives next to /// `wallet.sqlite` inside the workspace root. pub const SESSION_FILE_NAME: &str = "session.json"; @@ -65,12 +71,12 @@ pub(crate) struct WalletDbRebuild { impl WalletDbRebuild { pub(crate) fn wallet_db( &mut self, - ) -> WalletDb<&mut rusqlite::Connection, ArgosParams, SystemClock, OsRng> { + ) -> WalletDb<&mut rusqlite::Connection, ArgosParams, SystemClock, WalletRng> { WalletDb::from_connection( &mut self.connection, consensus_network(self.network), SystemClock, - OsRng, + wallet_rng(), ) } } @@ -321,7 +327,7 @@ impl RecoveryWorkspace { &mut connection, consensus_network(network), SystemClock, - OsRng, + wallet_rng(), ); init_wallet_db(&mut wallet_db, Some(SecretVec::new(seed.to_vec()))).map_err(|err| { ZeckError::Wallet(format!("initializing an in-memory wallet rebuild: {err}")) @@ -529,6 +535,7 @@ pub fn regtest_local_network() -> LocalNetwork { nu6_1: h, nu6_2: h, nu6_3: h, + nu7: None, } } @@ -548,6 +555,7 @@ impl ArgosParams { nu6_1: h, nu6_2: h, nu6_3: h, + nu7: None, }) } } @@ -978,18 +986,23 @@ fn open_tuned_wallet_connection(path: &Path) -> Result ZeckResult> { +) -> ZeckResult> { open_wallet_db(path, network) } pub(crate) fn open_wallet_db( path: &Path, network: ArgosParams, -) -> ZeckResult> { +) -> ZeckResult> { let conn = open_tuned_wallet_connection(path).map_err(|err| { ZeckError::Storage(format!("opening wallet database {}: {err}", path.display())) })?; - Ok(WalletDb::from_connection(conn, network, SystemClock, OsRng)) + Ok(WalletDb::from_connection( + conn, + network, + SystemClock, + wallet_rng(), + )) } /// On-disk metadata describing a scan session. Written next to the wallet @@ -1342,8 +1355,12 @@ fn try_build_incomplete_row( fn read_synced_height(wallet_db_path: &Path, network: ZeckNetwork) -> Option { let connection = open_wallet_connection_for_listing(wallet_db_path).ok()?; rusqlite::vtab::array::load_module(&connection).ok()?; - let wallet_db = - WalletDb::from_connection(connection, consensus_network(network), SystemClock, OsRng); + let wallet_db = WalletDb::from_connection( + connection, + consensus_network(network), + SystemClock, + wallet_rng(), + ); let summary = wallet_db .get_wallet_summary(ConfirmationsPolicy::MIN) .ok() diff --git a/crates/zeck-core/tests/common/standalone_transparent.rs b/crates/zeck-core/tests/common/standalone_transparent.rs index 6ed2e232..ce4d7d14 100644 --- a/crates/zeck-core/tests/common/standalone_transparent.rs +++ b/crates/zeck-core/tests/common/standalone_transparent.rs @@ -32,7 +32,7 @@ pub fn imported_transparent_key( let mut keys = ImportedKeys::default(); keys.transparent.push(TransparentKey { - secret: Secret::new(secret.secret_bytes()), + secret: Secret::new(secret.to_secret_bytes()), provenance: Provenance::Standalone, created_at: None, }); @@ -47,7 +47,7 @@ pub fn imported_transparent_key( /// Derive the standalone key through the same path the importer uses, so /// the funder and the test cannot disagree about the address. pub fn standalone_transparent_key() -> argos_core::imported::ImportedTransparentKey { - let mut secret = secp256k1::SecretKey::from_slice(&STANDALONE_TRANSPARENT_SECRET) + let mut secret = secp256k1::SecretKey::from_secret_bytes(STANDALONE_TRANSPARENT_SECRET) .expect("the standalone test key is a valid secp256k1 scalar"); imported_transparent_key(&mut secret) } diff --git a/crates/zeck-core/tests/nu7_readiness.rs b/crates/zeck-core/tests/nu7_readiness.rs new file mode 100644 index 00000000..fe0d6c0e --- /dev/null +++ b/crates/zeck-core/tests/nu7_readiness.rs @@ -0,0 +1,420 @@ +//! NU7 qualification. Parser fixtures contain no inputs, outputs or funds; +//! they prove wire compatibility, not consensus acceptance or spendability. +use std::io::Cursor; +use zcash_primitives::transaction::{Transaction, TxVersion}; +use zcash_protocol::consensus::{BlockHeight, BranchId, Network, NetworkUpgrade, Parameters}; + +const NU7_BRANCH: u32 = 0x7719_0ad9; +const REGTEST_NU7_HEIGHT: u32 = 32_500; + +#[test] +fn production_networks_select_the_real_nu7_branch_at_activation() { + for (network, activation) in [ + (Network::MainNetwork, 3_543_405), + (Network::TestNetwork, 4_465_026), + ] { + assert_eq!( + network.activation_height(NetworkUpgrade::Nu7), + Some(activation.into()) + ); + assert_eq!( + u32::from(BranchId::for_height(&network, (activation - 1).into())), + 0x37a5_165b + ); + for height in [activation, activation + 1] { + assert_eq!( + u32::from(BranchId::for_height(&network, height.into())), + NU7_BRANCH + ); + } + assert!(!TxVersion::V4.valid_in_branch(BranchId::Nu7)); + assert!(TxVersion::V5.valid_in_branch(BranchId::Nu7)); + assert!(TxVersion::V6.valid_in_branch(BranchId::Nu7)); + } +} + +#[test] +fn actual_builder_uses_40_block_expiry_before_nu7_and_120_after() { + use zcash_primitives::transaction::builder::{BuildConfig, Builder, BundlePadding}; + for (network, activation) in [ + (Network::MainNetwork, 3_543_405_u32), + (Network::TestNetwork, 4_465_026_u32), + ] { + for (target, delta) in [ + (activation - 1, 40), + (activation, 120), + (activation + 1, 120), + ] { + let builder = Builder::new( + network, + target.into(), + BuildConfig::Standard { + sapling_anchor: None, + orchard_anchor: None, + ironwood_anchor: None, + orchard_padding: BundlePadding::DEFAULT, + ironwood_padding: BundlePadding::DEFAULT, + }, + ); + assert_eq!( + builder.expiry_height(), + BlockHeight::from_u32(target + delta) + ); + // The supported explicit override remains authoritative. + assert_eq!( + builder + .with_expiry_height((target + 7).into()) + .expiry_height(), + BlockHeight::from_u32(target + 7) + ); + } + } +} + +/// Creation and serialization support is necessary for imported Sapling, +/// but an empty PCZT does not establish signing or node acceptance. +#[test] +fn pczt_creator_and_encoding_preserve_the_real_nu7_branch() { + let created = + pczt::roles::creator::Creator::new(NU7_BRANCH, REGTEST_NU7_HEIGHT + 120, 1, None, None) + .unwrap() + .build() + .unwrap(); + assert_eq!(*created.global().consensus_branch_id(), NU7_BRANCH); + assert_eq!(*created.global().tx_version(), 6); + let encoded = created.serialize().unwrap(); + let parsed = pczt::Pczt::parse(&encoded).unwrap(); + assert_eq!(*parsed.global().consensus_branch_id(), NU7_BRANCH); + assert_eq!(*parsed.global().expiry_height(), REGTEST_NU7_HEIGHT + 120); + assert!(pczt::roles::creator::Creator::new( + 0xffff_ffff, + REGTEST_NU7_HEIGHT + 120, + 1, + None, + None + ) + .is_err()); +} + +/// Independent literal wire encoding: overwintered version, version group, +/// embedded branch, lock time, expiry, then empty bundle counts. In particular +/// NU7 does not append an experimental ZIP 233 amount to the v6 header. +fn empty_wire_transaction(version: TxVersion, branch: u32) -> Vec { + let (header, group, bundle_counts) = match version { + TxVersion::V5 => (0x8000_0005_u32, 0x26a7_270a_u32, 5), + TxVersion::V6 => (0x8000_0006_u32, 0xd884_b698_u32, 6), + _ => unreachable!(), + }; + let mut bytes = Vec::new(); + for field in [header, group, branch, 0, REGTEST_NU7_HEIGHT + 120] { + bytes.extend_from_slice(&field.to_le_bytes()); + } + bytes.resize(bytes.len() + bundle_counts, 0); + bytes +} + +#[test] +fn nu7_v5_and_v6_wire_bytes_parse_and_roundtrip_without_placeholder_branch() { + for version in [TxVersion::V5, TxVersion::V6] { + let bytes = empty_wire_transaction(version, NU7_BRANCH); + let mut reader = Cursor::new(&bytes); + // v5/v6 carry their own branch. A historical caller hint must not + // override that branch or silently reinterpret a future transaction. + let parsed = + Transaction::read(&mut reader, BranchId::Canopy).expect("NU7 wire transaction"); + assert_eq!(reader.position(), bytes.len() as u64); + assert_eq!(parsed.version(), version); + assert_eq!(u32::from(parsed.consensus_branch_id()), NU7_BRANCH); + assert_eq!( + parsed.expiry_height(), + BlockHeight::from_u32(REGTEST_NU7_HEIGHT + 120) + ); + assert!(parsed.sprout_bundle().is_none()); + let mut roundtrip = Vec::new(); + parsed.write(&mut roundtrip).unwrap(); + assert_eq!(roundtrip, bytes); + assert!(Transaction::read( + &empty_wire_transaction(version, 0xffff_ffff)[..], + BranchId::Nu7 + ) + .is_err()); + assert!(Transaction::read(&bytes[..bytes.len() - 1], BranchId::Nu7).is_err()); + } +} + +#[cfg(feature = "argos-network")] +fn qualified_params_at(height: u32) -> argos_core::workspace::ArgosParams { + let mut local = argos_core::workspace::regtest_local_network(); + local.nu7 = Some(height.into()); + argos_core::workspace::ArgosParams::Regtest(local) +} + +#[cfg(feature = "argos-network")] +#[test] +fn qualified_schedule_crosses_nu7_without_changing_legacy_fixtures() { + use argos_core::workspace::ArgosParams; + assert_eq!( + ArgosParams::regtest_all_active().activation_height(NetworkUpgrade::Nu7), + None + ); + for height in [ + REGTEST_NU7_HEIGHT - 1, + REGTEST_NU7_HEIGHT, + REGTEST_NU7_HEIGHT + 1, + ] { + assert_eq!( + u32::from(BranchId::for_height( + &qualified_params_at(REGTEST_NU7_HEIGHT), + height.into() + )), + if height < REGTEST_NU7_HEIGHT { + 0x37a5_165b + } else { + NU7_BRANCH + } + ); + } +} + +#[cfg(feature = "argos-network")] +#[test] +fn wallet_account_and_scan_queue_survive_reopen_across_activation() { + use rand::{rand_core::UnwrapErr, rngs::SysRng}; + use secrecy::SecretVec; + use zcash_client_backend::data_api::{ + chain::ChainState, AccountBirthday, WalletRead, WalletWrite, + }; + use zcash_client_sqlite::{util::SystemClock, wallet::init::init_wallet_db, WalletDb}; + use zcash_primitives::block::BlockHash; + + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("wallet.sqlite"); + let params = qualified_params_at(REGTEST_NU7_HEIGHT); + let seed = SecretVec::new(vec![0x42; 64]); // public synthetic identity, no value + let account_id = { + let mut db = WalletDb::for_path(&path, params, SystemClock, UnwrapErr(SysRng)).unwrap(); + init_wallet_db(&mut db, Some(SecretVec::new(vec![0x42; 64]))).unwrap(); + let birthday = AccountBirthday::from_parts( + ChainState::empty((REGTEST_NU7_HEIGHT - 2).into(), BlockHash([0; 32])), + None, + ); + let (account, _) = db + .create_account("NU7 reopen qualification", &seed, &birthday, None) + .unwrap(); + db.update_chain_tip((REGTEST_NU7_HEIGHT - 1).into()) + .unwrap(); + account + }; + for tip in [REGTEST_NU7_HEIGHT, REGTEST_NU7_HEIGHT + 1] { + let mut db = WalletDb::for_path(&path, params, SystemClock, UnwrapErr(SysRng)).unwrap(); + init_wallet_db(&mut db, Some(SecretVec::new(vec![0x42; 64]))).unwrap(); + db.update_chain_tip(tip.into()).unwrap(); + assert_eq!(db.get_account_ids().unwrap(), vec![account_id]); + assert!(db.get_account(account_id).unwrap().is_some()); + assert!(!db.suggest_scan_ranges().unwrap().is_empty()); + } +} + +/// This fixture was created by the released Argos pre-NU7 SDK family, not by +/// the SDK under test. Copy first: the retained fixture must never be migrated +/// in place. See tests/regtest/legacy-wallet-db/README.md for reproduction. +#[test] +fn pre_nu7_database_migrates_without_losing_account_or_scan_work() { + use rand::{rand_core::UnwrapErr, rngs::SysRng}; + use secrecy::SecretVec; + use zcash_client_backend::data_api::{Account, WalletRead, WalletWrite}; + use zcash_client_sqlite::{util::SystemClock, wallet::init::init_wallet_db, WalletDb}; + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("legacy-wallet.sqlite"); + std::fs::write( + &path, + include_bytes!("../../../tests/regtest/legacy-wallet-db/pre-nu7.sqlite"), + ) + .unwrap(); + let before = rusqlite::Connection::open(&path).unwrap(); + let migrations_before: u64 = before + .query_row("SELECT count(*) FROM schemer_migrations", [], |r| r.get(0)) + .unwrap(); + let original_ufvk: String = before + .query_row("SELECT ufvk FROM accounts", [], |r| r.get(0)) + .unwrap(); + let original_uuid: Vec = before + .query_row("SELECT uuid FROM accounts", [], |r| r.get(0)) + .unwrap(); + assert_eq!(migrations_before, 57, "retained pre-NU7 schema fixture"); + drop(before); + let mut db = + WalletDb::for_path(&path, Network::TestNetwork, SystemClock, UnwrapErr(SysRng)).unwrap(); + init_wallet_db(&mut db, Some(SecretVec::new(vec![0x42; 64]))).unwrap(); + let ids = db.get_account_ids().unwrap(); + assert_eq!(ids.len(), 1); + let account = db.get_account(ids[0]).unwrap().unwrap(); + assert_eq!(account.name(), Some("pre-NU7 public fixture")); + let ufvk_before_reopen = account + .ufvk() + .unwrap() + .encode(&Network::TestNetwork) + .unwrap(); + assert_eq!(ufvk_before_reopen, original_ufvk); + assert!(!db.suggest_scan_ranges().unwrap().is_empty()); + db.update_chain_tip(BlockHeight::from_u32(4_465_027)) + .unwrap(); + drop(db); + let after = rusqlite::Connection::open(&path).unwrap(); + let migrations_after: u64 = after + .query_row("SELECT count(*) FROM schemer_migrations", [], |r| r.get(0)) + .unwrap(); + assert!(migrations_after >= migrations_before); + assert_eq!( + after + .query_row("SELECT uuid FROM accounts", [], |r| r.get::<_, Vec>(0)) + .unwrap(), + original_uuid + ); + assert_eq!( + after + .query_row("PRAGMA integrity_check", [], |r| r.get::<_, String>(0)) + .unwrap(), + "ok" + ); + drop(after); + let mut db = + WalletDb::for_path(&path, Network::TestNetwork, SystemClock, UnwrapErr(SysRng)).unwrap(); + init_wallet_db(&mut db, Some(SecretVec::new(vec![0x42; 64]))).unwrap(); + assert_eq!(db.get_account_ids().unwrap(), ids); + assert_eq!( + db.get_account(ids[0]) + .unwrap() + .unwrap() + .ufvk() + .unwrap() + .encode(&Network::TestNetwork) + .unwrap(), + ufvk_before_reopen + ); +} + +#[cfg(feature = "argos-network")] +fn private_node_rpc(method: &str, params: serde_json::Value) -> serde_json::Value { + // Fixed endpoint: this qualification test can never select a public node. + let output = std::process::Command::new("curl") + .args([ + "--fail", + "--silent", + "--show-error", + "--max-time", + "120", + "-H", + "Content-Type: application/json", + "--data", + ]) + .arg( + serde_json::json!({"jsonrpc":"2.0", "id":1, "method":method, "params":params}) + .to_string(), + ) + .arg("http://127.0.0.1:18262") + .output() + .expect("curl installed"); + assert!( + output.status.success(), + "private node {method}: {}", + String::from_utf8_lossy(&output.stderr) + ); + let reply: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap(); + assert!(reply["error"].is_null(), "{method}: {reply}"); + reply["result"].clone() +} + +/// A live gate, never counted as a funded sweep or PCZT acceptance test. +/// The node must accept and mine synthetic regtest coinbase blocks across +/// the real configured consensus boundary. This is not a funded sweep. +#[cfg(feature = "argos-network")] +#[test] +#[ignore = "requires nu7-fast profile at height 9..11; mines any missing private blocks through 11"] +fn private_node_mines_and_parses_before_at_after_nu7() { + use zcash_primitives::block::Block; + const FAST_ACTIVATION: u32 = 10; + let initial_tip = private_node_rpc("getblockcount", serde_json::json!([])) + .as_u64() + .unwrap() as u32; + assert!((FAST_ACTIVATION - 1..=FAST_ACTIVATION + 1).contains(&initial_tip), + "run ARGOS_NU7_PROFILE=fast tests/regtest/nu7.sh before first; this test never rewinds or deletes retained state"); + for height in [FAST_ACTIVATION - 1, FAST_ACTIVATION, FAST_ACTIVATION + 1] { + if height > initial_tip { + private_node_rpc("generate", serde_json::json!([1])); + } + let info = private_node_rpc("getblockchaininfo", serde_json::json!([])); + assert_eq!(info["chain"], "test"); // Zebra uses the test chain name for Regtest. + assert_eq!( + info["upgrades"]["77190ad9"]["activationheight"], + FAST_ACTIVATION + ); + assert_eq!(info["blocks"], height.max(initial_tip)); + let hash = private_node_rpc("getblockhash", serde_json::json!([height])); + let hex = private_node_rpc("getblock", serde_json::json!([hash, 0])); + let hex = hex.as_str().unwrap(); + let raw: Vec<_> = (0..hex.len()) + .step_by(2) + .map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap()) + .collect(); + let mut cursor = Cursor::new(&raw); + let block = Block::read(&mut cursor, &qualified_params_at(FAST_ACTIVATION)) + .expect("real node block parses"); + assert_eq!(cursor.position(), raw.len() as u64); + assert!(!block.vtx().is_empty()); + let expected_branch = if height < FAST_ACTIVATION { + 0x37a5_165b + } else { + NU7_BRANCH + }; + for tx in block.vtx() { + assert_eq!(u32::from(tx.consensus_branch_id()), expected_branch); + } + eprintln!("[nu7-node] accepted block height={height} branch={expected_branch:08x} transactions={}", block.vtx().len()); + } +} + +/// The proxy gate is separate from block acceptance so an emulator/runtime +/// failure cannot erase the node's independently retained boundary evidence. +#[cfg(feature = "argos-network")] +#[tokio::test] +#[ignore = "requires nu7-fast node at height 11 and private proxy on 9087 or native 9088"] +async fn private_proxy_serves_the_accepted_nu7_compact_block() { + use zcash_client_backend::proto::service::{ + compact_tx_streamer_client::CompactTxStreamerClient, BlockId, Empty, + }; + let endpoint = std::env::var("ARGOS_NU7_LIGHTWALLETD_URL") + .unwrap_or_else(|_| "http://127.0.0.1:9087".to_owned()); + assert!( + matches!( + endpoint.as_str(), + "http://127.0.0.1:9087" | "http://127.0.0.1:9088" + ), + "qualification only permits the dedicated private proxy endpoints" + ); + let mut client = CompactTxStreamerClient::connect(endpoint) + .await + .expect("private lightwalletd proxy"); + for attempt in 0..30 { + let info = client.get_lightd_info(Empty {}).await.unwrap().into_inner(); + if info.block_height >= 11 { + assert_eq!(info.consensus_branch_id.to_lowercase(), "77190ad9"); + let block = client + .get_block(BlockId { + height: 10, + hash: vec![], + }) + .await + .unwrap() + .into_inner(); + assert_eq!(block.height, 10); + eprintln!( + "[nu7-proxy] served NU7 compact block height={} branch={}", + block.height, info.consensus_branch_id + ); + return; + } + assert!(attempt < 29, "private proxy did not ingest NU7 blocks"); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + } +} diff --git a/crates/zeck-core/tests/regtest_integration.rs b/crates/zeck-core/tests/regtest_integration.rs index b36a9829..85911ee3 100644 --- a/crates/zeck-core/tests/regtest_integration.rs +++ b/crates/zeck-core/tests/regtest_integration.rs @@ -4331,8 +4331,12 @@ async fn internal_sapling_match_recovers_and_sweeps_mined_note() { let seed = candidate_seed(&phrase, &SecretString::new(String::new())).unwrap(); let account_index = 4u32; let account = zip32::AccountId::try_from(account_index).unwrap(); - let extsk = zcash_keys::keys::sapling::spending_key(seed.expose_secret(), 1, account); - let internal_dfvk = extsk.derive_internal().to_diversifiable_full_viewing_key(); + let extsk = zcash_keys::keys::sapling::spending_key(seed.expose_secret(), 1, account) + .expect("valid fixture Sapling key"); + let internal_dfvk = extsk + .derive_internal() + .expect("valid fixture internal key") + .to_diversifiable_full_viewing_key(); let (address_index, internal_address) = (1u32..100) .find_map(|index| { internal_dfvk @@ -4497,8 +4501,12 @@ async fn imported_multi_action_quote_matches_built_transaction_fee() { let seed = candidate_seed(&phrase, &SecretString::new(String::new())).unwrap(); let account_index = 4u32; let account = zip32::AccountId::try_from(account_index).unwrap(); - let extsk = zcash_keys::keys::sapling::spending_key(seed.expose_secret(), 1, account); - let internal_dfvk = extsk.derive_internal().to_diversifiable_full_viewing_key(); + let extsk = zcash_keys::keys::sapling::spending_key(seed.expose_secret(), 1, account) + .expect("valid fixture Sapling key"); + let internal_dfvk = extsk + .derive_internal() + .expect("valid fixture internal key") + .to_diversifiable_full_viewing_key(); let (address_index, internal_address) = (1u32..100) .find_map(|index| { internal_dfvk diff --git a/crates/zeck-core/tests/zcashd_seed_covers_stored_keys.rs b/crates/zeck-core/tests/zcashd_seed_covers_stored_keys.rs index 0090dc29..313595bb 100644 --- a/crates/zeck-core/tests/zcashd_seed_covers_stored_keys.rs +++ b/crates/zeck-core/tests/zcashd_seed_covers_stored_keys.rs @@ -107,11 +107,13 @@ fn every_stored_key_is_a_legacy_account_derivation_of_the_seed() { // counter: a missing, extra, or duplicated key all fail. Compared // with `assert!` rather than `assert_eq!` so a failure does not // print spending keys. - let master = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed); + let master = sapling_crypto::zip32::ExtendedSpendingKey::master(&seed) + .expect("valid fixture Sapling key"); let mut derived_sapling: Vec> = (0..counters.sapling) .map(|i| { let path = [32, COIN_TYPE, LEGACY_ACCOUNT, i].map(ChildIndex::hardened); sapling_crypto::zip32::ExtendedSpendingKey::from_path(&master, &path) + .expect("valid fixture Sapling path") .to_bytes() .to_vec() }) @@ -143,14 +145,14 @@ fn every_stored_key_is_a_legacy_account_derivation_of_the_seed() { account .derive_external_secret_key(child(i)) .unwrap() - .secret_bytes() + .to_secret_bytes() }) .collect(); derived_transparent.extend((0..counters.t_internal).map(|i| { account .derive_internal_secret_key(child(i)) .unwrap() - .secret_bytes() + .to_secret_bytes() })); let mut stored: Vec<[u8; 32]> = keys .transparent @@ -172,7 +174,8 @@ fn every_stored_key_is_a_legacy_account_derivation_of_the_seed() { let hd_zero = sapling_crypto::zip32::ExtendedSpendingKey::from_path( &master, &[32, COIN_TYPE, 0].map(ChildIndex::hardened), - ); + ) + .expect("valid fixture Sapling path"); assert!(!keys .sapling .iter() diff --git a/docs/qualification/nu7-supported-recovery.md b/docs/qualification/nu7-supported-recovery.md new file mode 100644 index 00000000..16346c84 --- /dev/null +++ b/docs/qualification/nu7-supported-recovery.md @@ -0,0 +1,71 @@ +# NU7 supported-recovery qualification + +This change carries supported transparent, Sapling, Orchard and Ironwood +recovery onto the NU7 SDK after Sprout removal. It does not restore Sprout +spending, scanning, P2P or artifact reconciliation. + +## What the qualification layers establish + +| Layer | Evidence required | Limit | +|---|---|---| +| Offline `nu7_readiness` | Production activation/branch constants; v5/v6 wire round trips; actual builder expiry; PCZT branch serialization; local schedule/reopen; old-SDK database migration | Empty transactions and accounts contain no funds and do not prove signing or node acceptance. | +| Fast live `nu7-fast` profile | Zebra accepts blocks 9, 10 and 11; complete blocks parse with the expected embedded branch; lightwalletd serves NU7 compact block 10 | Synthetic coinbase blocks at activation 10 do not qualify a funded sweep or PCZT; ZIP 212 is not enforced. | +| Full live `nu7` profile | Prepared supported balances; actual accepted and mined recovery transactions around activation 32,500, including imported Sapling PCZT | Remains a release gate until executed and recorded against this branch. | + +Run commands, private endpoints, native proxy fallback and chain-state handling +are in [the harness guide](../../tests/regtest/README.md#dedicated-nu7-qualification). +The profiles have independent volumes and bind published ports only to loopback. +`nu7.sh` refuses to rewind/delete existing state and never funds a wallet. + +## Retained source and fixture provenance + +The harness pins the same official artifacts as the source NU7 qualification: + +- [Zebra v7.0.0](https://github.com/ZcashFoundation/zebra/releases/tag/v7.0.0), image + `zfnd/zebra:7.0.0@sha256:a70d2be8ffef3a4b6e37355724e36a0e6c1838e46baa28bfb216739f00cf2d34`. + Preserve needed older node volumes before upgrading: Zebra 7 migrates state + to v29, which Zebra 6 cannot reopen. +- [lightwalletd v0.6.0](https://github.com/zcash/lightwalletd/releases/tag/v0.6.0), image + `electriccoinco/lightwalletd:v0.6.0@sha256:abc8199dae800e050415a3459f71c7850aeefeb1ca6a681e9b9eda7249ce8613`. + The image is amd64-only; the native fallback uses the official tag commit + `e7436d2adb9ab5828eb8a27de534e16218841fc2`. +- [The old-SDK SQLite fixture](../../tests/regtest/legacy-wallet-db/README.md) + has SHA-256 `51bce8f9dc545187702cf1b4bb5e32277a18a0182002836c53fdb289ed7df328`. + Tests copy it before migration and preserve the original. It holds one + synthetic public account, scan work and no funds. + +These pins are retained from PR #291, not a claim that upstream registries or +release metadata were independently refreshed for this carry-forward. + +## Current execution and outstanding gate + +On 2026-11-06 the local Docker CLI was present, but both configured daemon +sockets (`default` and `desktop-linux`) were unavailable. The Docker Compose +plugin was also absent. No `zebrad` or `lightwalletd` executable was on PATH. +The existing lightwalletd checkout was at `d35b141d8801e6ff251aeb906158a220ddff2201`, +not the pinned NU7 fallback revision, and had no root binary. The live boundary +tests were therefore not executed during qualification-file preparation. +Historical successful runs on the superseded branch are not current-branch +validation evidence. CI has a dedicated NU7-only live block/proxy job. + +**The funded full-height supported sweep/PCZT rehearsal remains unexecuted and +is a release gate.** The funding helper installs the ordinary pre-NU7 local +schedule and shares a treasury at `$TMPDIR/argos-regtest-treasury`. A rehearsal +must isolate `TMPDIR`, prepare its treasury near genesis, install the qualified +NU7 schedule in post-activation funding/test processes, and observe actual +mined supported-pool recoveries and imported Sapling PCZT transactions. Merely +starting the full profile or migrating an empty database cannot satisfy it. +No release, real-wallet funding or mainnet spending is authorized here. + +## Local carry-forward results + +The Rust 1.89 workspace suite passed 1,120 tests with no failures; 40 cases +requiring harness/network setup were ignored. Seven offline NU7 qualification +tests passed, including migration of the old-SDK database fixture. Strict +all-target/all-feature Clippy, formatting, dependency advisories and locked +cargo-vet passed. GUI validation passed 189 Node tests and 26 layout tests each +in Chromium and WebKit. Independent runtime review identified partial-batch +donation underreporting; its fix passed a regression that fails when the old +error-ordering behavior is deliberately restored. New real Orchard, Ironwood +and mixed-pool proposal tests preserve notes, budgets and fees across batches. +These local results do not satisfy the funded gate above. diff --git a/docs/superpowers/plans/2026-11-06-nu7-supported-recovery.md b/docs/superpowers/plans/2026-11-06-nu7-supported-recovery.md new file mode 100644 index 00000000..afc03fdf --- /dev/null +++ b/docs/superpowers/plans/2026-11-06-nu7-supported-recovery.md @@ -0,0 +1,41 @@ +# NU7 Supported Recovery Implementation Plan + +> **For agentic workers:** Use the approved dynamic workflow, with independent file scopes and a whole-branch review. + +**Goal:** Port non-Sprout NU7 readiness from PR #291 onto current main and open a validated follow-up PR. +**Architecture:** Reuse the reviewed algorithms and tests from 850697b; adapt them to e5e0fe4 without reverting later security fixes. Extract generic NU7 validation from the old Sprout-oriented module. +**Tech Stack:** Rust 1.89, coordinated Zcash SDK, Tauri/JavaScript, Zebra/lightwalletd qualification. +**Spec:** `docs/superpowers/specs/2026-11-06-nu7-supported-recovery.md` + +## Global constraints +Use `RUSTFLAGS='' CARGO_INCREMENTAL=0 cargo +1.89 ...` consistently. Preserve the primary dirty checkout. Root owns Cargo builds/lockfiles; parallel workers do not compete for target locks. Never restore removed Sprout/P2P paths. No release or funded mainnet action. + +## Review focus +- Old wallet database and key identity fixtures survive the SDK migration. +- Multiple supported batches retain notes, exact fees, donations and partial failure evidence. +- Signed bytes and reviewed authority cannot cross branch or expiry changes. +- Birthday network mismatch/offline fallback never silently skips recoverable history. +- Sprout-only/mixed wallets and TOS/storage behavior remain as established by #301. + +## Tasks +- [x] SDK/API migration: root ports manifest and retained leaf API changes, resolves lock without downgrading main security fixes, updates exact vet policy; validate workspace check, historical fixtures and migration test. +- [x] Runtime: port nu7/nu7_limits, service/imported sweep, submission/reconciliation and workspace/scan changes with their boundary/fee/partial-success/retry tests. Extract generic validation; no Sprout availability API. +- [x] Birthday and GUI/CLI: port network-aware date handling and supported reviewed-intent/frontend checks; preserve current TOS and removal regressions. Run targeted then full GUI tests. +- [x] Qualification: port NU7 fixture/profiles/scripts and CI/release Rust floor, current docs; validate YAML/scripts and offline/live tests where available. Record funded rehearsal gap. +- [ ] Integration: format, full Rust tests, strict all-feature Clippy, GUI/layout, deny/vet and diff checks; independently review final diff, fix blockers with regressions, commit/push/open PR and follow current-head CI. + +## Evidence and decisions +- Baseline: e5e0fe4 merges reviewed 5b39f2d; all 18 PR status entries succeeded immediately before merge. +- User approved the five-part carry-forward scope after #301 merged. Existing approval is the implementation handoff; no additional plan confirmation needed. + +- Dependency policy: retained aes 0.9.3 and ctutils 0.4.6 from #291 rather than expanding exemptions to newly resolved patches. Refreshed imported audits cover the remaining patch upgrades; cargo-vet succeeds without new patch exemptions. + +## Local validation at PR preparation +- Rust 1.89 workspace all-feature suite: 1,120 passed, zero failed, 40 harness/network cases ignored. Includes 7 offline NU7 qualification tests and old-SDK migration. +- Strict workspace/all-target/all-feature Clippy, formatting and diff checks passed. +- Node GUI: 189 passed. Layout: 26 Chromium and 26 WebKit tests passed. +- cargo-deny passed; locked cargo-vet passed (201 fully audited, 20 partially audited, 533 exemptions under existing policy). Audit tooling normalized four publisher comments without changing trust. +- Independent Astra runtime review found partial-batch donation underreporting. Fixed per-tx accounting before error propagation, with a six-scenario regression and explicit excluded-status coverage. Temporarily restoring error-first behavior fails the regression (7,000 versus 32,000); restored implementation passes. +- Added real Orchard, Ironwood and mixed-pool proposals checking exact selected-note preservation, pool identity, padded limits, fees and output accounting. All pass. +- GUI birthday responses are discarded if network/endpoint/date changes in flight; stale all-feature test fixtures were aligned to current local-consensus and authenticated-directory behavior. +- CI/Compose/actionlint/shell/fixture/controller checks passed. Current-commit hosted CI and the live node/proxy boundary job are checked on the follow-up PR. Funded sweep/PCZT rehearsal remains outside these results and is a release gate. diff --git a/docs/superpowers/specs/2026-11-06-nu7-supported-recovery.md b/docs/superpowers/specs/2026-11-06-nu7-supported-recovery.md new file mode 100644 index 00000000..8ceb53da --- /dev/null +++ b/docs/superpowers/specs/2026-11-06-nu7-supported-recovery.md @@ -0,0 +1,15 @@ +# NU7 supported recovery after Sprout removal + +## Scope +Carry the supported-recovery parts of PR #291 (850697b) onto merged PR #301 (e5e0fe4). Keep transparent, Sapling, Orchard and Ironwood recovery compatible with NU7. Do not restore Sprout spending, inspection machinery, P2P, journals, UI or dependency-only proving code. + +## Requirements +- Upgrade the coordinated SDK family to backend 0.25, SQLite 0.23, protocol 0.11, primitives/proofs 0.31, keys 0.17, PCZT 0.10, Orchard 0.16, Sapling 0.9 and Rust 1.89. Preserve newer security fixes from main and exact-version cargo-vet policy. +- Bind reviewed proposals to consensus branch; validate fresh network tip, transaction version, branch, expiry and actual padded shielded bundle limits before every submission and exact-byte retry. Keep signed bytes and prior outcomes unchanged when validation fails. +- Bound send-max transactions to Sapling IO <=300 and combined shielded budget <=330. Preserve all selected notes, recipient/memo/donation accounting, aggregate fee authorization and partial-success evidence. Refuse to continue on unknown broadcast outcome. +- Use network-aware birthday estimation, conservative offline bounds and NU7 spacing without reducing the historical safety margin. Retain existing depth policies except upstream scanner rollback retention needed by the SDK. +- Preserve #301 TOS ordering, supported-only fingerprints, Sprout count/notice behavior and private filesystem protections. +- Port migration fixtures, boundary/regression tests, independent NU7 profiles and CI. Do not claim empty fixtures or coinbase/proxy tests prove funded recovery. + +## Qualification boundary +Run all feasible local unit/integration, GUI, strict Clippy, dependency and workflow checks; run independent review and PR CI. A funded full-height rehearsal covering supported sweeps and imported Sapling PCZT remains a release gate until actually executed and recorded. No release or mainnet spending is authorized by this change. diff --git a/gui/src-tauri/src/commands.rs b/gui/src-tauri/src/commands.rs index 849a494b..a91766c9 100644 --- a/gui/src-tauri/src/commands.rs +++ b/gui/src-tauri/src/commands.rs @@ -8,7 +8,8 @@ use std::{ use crate::reviewed_intent::{WalletReviewId, WalletReviewRegistry}; use argos_core::{ - detect_birthday as zeck_detect_birthday, estimate_birthday_from_date as estimate_birthday, + detect_birthday as zeck_detect_birthday, + estimate_birthday_from_date_for_network as estimate_birthday, list_incomplete_sessions as zeck_list_incomplete_sessions, parse_workspace_keying, validate_destination_address, validate_mnemonic_words, BirthdayDetectResult, IncompleteSession, RecoveryService, ReviewedSweepProposal, ScanConfig, ScanHandle, SweepOutcome, SweepProposalId, @@ -1083,9 +1084,11 @@ pub async fn estimate_birthday_from_date( app: AppHandle, date: String, lightwalletd_url: String, + network: Option, ) -> Result { ensure_tos_accepted(&app)?; - estimate_birthday(&date, &lightwalletd_url) + let network = parse_wallet_network(network.as_deref().unwrap_or("mainnet"))?; + estimate_birthday(&date, &lightwalletd_url, network) .await .map_err(|err| err.to_string()) } diff --git a/gui/src/main.js b/gui/src/main.js index f75bbf22..77fd3c61 100644 --- a/gui/src/main.js +++ b/gui/src/main.js @@ -1041,8 +1041,9 @@ function updateScanEstimate() { } } -// Piecewise height→date (Sapling 150 s/block until Blossom @ 653,600, -// then 75 s/block). Mirrors crates/argos-core/src/birthday.rs and lets us +// Approximate height→date with historical 150/75-second timing, then +// 25 seconds from each network's NU7 height. Calendar estimates never decide +// whether a transaction may spend. This lets us // give the user instant round-trip feedback as they type a height. const SAPLING_ACTIVATION_HEIGHT_JS = 419_200; const SAPLING_ACTIVATION_DATE_JS = Date.UTC(2018, 9, 28); // Oct 28 2018 @@ -1050,13 +1051,15 @@ const BLOSSOM_ACTIVATION_HEIGHT_JS = 653_600; const BLOSSOM_ACTIVATION_DATE_JS = Date.UTC(2019, 11, 11); // Dec 11 2019 const PRE_BLOSSOM_BLOCK_SECONDS = 150; const POST_BLOSSOM_BLOCK_SECONDS = 75; +const POST_NU7_BLOCK_SECONDS = 25; +const NU7_ACTIVATION_HEIGHTS_JS = { mainnet: 3_543_405, testnet: 4_465_026 }; // Below Sapling it counts back at the same 150 s, floored at the genesis // date: a wallet.dat birthday can be pre-Sapling, and a hint stuck at 2018 // beside it would misstate the wallet's age. const MAINNET_GENESIS_DATE_JS = Date.UTC(2016, 9, 28); // Oct 28 2016 -function approxDateFromHeight(height) { +function approxDateFromHeight(height, network = "mainnet") { if (!Number.isFinite(height)) { return new Date(SAPLING_ACTIVATION_DATE_JS); } @@ -1069,6 +1072,12 @@ function approxDateFromHeight(height) { anchorMs = BLOSSOM_ACTIVATION_DATE_JS; anchorHeight = BLOSSOM_ACTIVATION_HEIGHT_JS; blockSeconds = POST_BLOSSOM_BLOCK_SECONDS; + const activation = NU7_ACTIVATION_HEIGHTS_JS[network]; + if (activation != null && height >= activation) { + anchorMs += (activation - anchorHeight) * POST_BLOSSOM_BLOCK_SECONDS * 1000; + anchorHeight = activation; + blockSeconds = POST_NU7_BLOCK_SECONDS; + } } return new Date( Math.max(MAINNET_GENESIS_DATE_JS, anchorMs + (height - anchorHeight) * blockSeconds * 1000), @@ -1094,7 +1103,7 @@ function updateBirthdayHint() { setBirthdayHint("", ""); return; } - const approx = formatApproxMonth(approxDateFromHeight(height)); + const approx = formatApproxMonth(approxDateFromHeight(height, $("network-select").value)); setBirthdayHint(`Block ${height.toLocaleString()} ≈ ${approx}.`, ""); } @@ -1159,8 +1168,14 @@ async function runBirthdayAutodetect() { // Phase-2 detection can run for minutes. If the user opens another wallet // or edits the seed meanwhile, the result belongs to the old source. const generation = walletOpenGeneration; + const probe = { + lightwalletdUrl: $("lightwalletd-url").value.trim(), + network: $("network-select").value, + }; const isCurrent = () => generation === walletOpenGeneration && + probe.network === $("network-select").value && + probe.lightwalletdUrl === $("lightwalletd-url").value.trim() && (source.kind === "wallet" || seedInput.value.trim() === seedVal); $("birthday-autodetect").disabled = true; $("birthday-estimate").disabled = true; @@ -1172,10 +1187,6 @@ async function runBirthdayAutodetect() { }); try { - const probe = { - lightwalletdUrl: $("lightwalletd-url").value.trim(), - network: $("network-select").value, - }; const result = source.kind === "wallet" ? await invoke("detect_birthday_from_wallet_file", { @@ -1187,14 +1198,14 @@ async function runBirthdayAutodetect() { }) : await invoke("detect_birthday", { ...probe, seed: seedVal.toLowerCase() }); if (!isCurrent()) { - setBirthdayHint("Auto-detect result discarded: the wallet or seed changed while it ran.", ""); + setBirthdayHint("Auto-detect result discarded: the recovery source or network settings changed while it ran.", ""); return; } $("birthday-height").value = result.birthday; invalidateScanAuthority(); birthdayTouched = true; updateScanEstimate(); - const approx = formatApproxMonth(approxDateFromHeight(result.birthday)); + const approx = formatApproxMonth(approxDateFromHeight(result.birthday, probe.network)); setBirthdayHint(birthdayDetectHint(result, approx), "success"); } catch (err) { if (isCurrent()) setBirthdayHint(`✗ Auto-detect failed: ${err}`, "error"); @@ -1213,25 +1224,31 @@ $("birthday-estimate").addEventListener("click", async () => { setBirthdayHint("Pick a date first.", "error"); return; } + const request = { + date: dateVal, + network: $("network-select").value, + lightwalletdUrl: $("lightwalletd-url").value.trim(), + }; + const isCurrent = () => request.date === $("birthday-date").value && + request.network === $("network-select").value && + request.lightwalletdUrl === $("lightwalletd-url").value.trim(); $("birthday-estimate").disabled = true; setBirthdayHint("Looking up block height for that date…", ""); setStatus("config-status", "", ""); try { - const height = await invoke("estimate_birthday_from_date", { - date: dateVal, - lightwalletdUrl: $("lightwalletd-url").value.trim(), - }); + const height = await invoke("estimate_birthday_from_date", request); + if (!isCurrent()) return; $("birthday-height").value = height; invalidateScanAuthority(); birthdayTouched = true; updateScanEstimate(); - const approx = formatApproxMonth(approxDateFromHeight(height)); + const approx = formatApproxMonth(approxDateFromHeight(height, $("network-select").value)); setBirthdayHint( - `✓ Birthday set to block ${Number(height).toLocaleString()} (≈ ${approx}, with ~1 week safety margin).`, + `✓ Birthday set to block ${Number(height).toLocaleString()} (≈ ${approx}, with a conservative safety margin).`, "success", ); } catch (err) { - setBirthdayHint(`✗ Estimate failed: ${err}`, "error"); + if (isCurrent()) setBirthdayHint(`✗ Estimate failed: ${err}`, "error"); } finally { $("birthday-estimate").disabled = false; } diff --git a/site/guide.html b/site/guide.html index 6a843d35..3e2f46b1 100644 --- a/site/guide.html +++ b/site/guide.html @@ -197,6 +197,14 @@

6. Complete

+
+

Supported recovery at NU7

+

Argos checks the current consensus branch, transaction expiry and shielded + bundle limits before submitting or retrying a supported sweep. Large recoveries + may produce several transactions. Keep every reported transaction ID until its + outcome is known; an unknown broadcast outcome stops later recovery work.

+
+

Sprout after NU7

NU7 disallows version 4 transactions, the only format supporting Sprout diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 58fb87bc..b53fb55c 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -363,7 +363,7 @@ end = "2027-06-26" [[trusted.hyper-rustls]] criteria = "safe-to-deploy" -user-id = 2751 # Joe Birr-Pixton (ctz) +user-id = 2751 start = "2019-03-16" end = "2027-06-26" @@ -442,7 +442,7 @@ notes = "PR #248 publisher trust for objc2-user-notifications 0.3.2; bounded to [[trusted.openssl-probe]] criteria = "safe-to-deploy" -user-id = 4556 # Dirkjan Ochtman (djc) +user-id = 4556 start = "2025-12-29" end = "2027-06-26" @@ -490,13 +490,13 @@ end = "2027-06-23" [[trusted.rustls-native-certs]] criteria = "safe-to-deploy" -user-id = 4556 # Dirkjan Ochtman (djc) +user-id = 4556 start = "2023-06-14" end = "2027-06-26" [[trusted.rustls-platform-verifier]] criteria = "safe-to-deploy" -user-id = 4556 # Dirkjan Ochtman (djc) +user-id = 4556 start = "2024-12-18" end = "2027-06-26" diff --git a/supply-chain/config.toml b/supply-chain/config.toml index 32f336b3..445e0c29 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -25,14 +25,35 @@ url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml" [imports.zcash] url = "https://raw.githubusercontent.com/zcash/librustzcash/main/supply-chain/audits.toml" +[policy."glib:0.18.5"] +audit-as-crates-io = false + +[policy."phf_generator:0.8.0"] +audit-as-crates-io = false + +[[exemptions.addchain]] +version = "0.3.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.aead]] version = "0.5.2" criteria = "safe-to-deploy" +[[exemptions.aead]] +version = "0.6.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.aes]] version = "0.8.4" criteria = "safe-to-deploy" +[[exemptions.aes]] +version = "0.9.3" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.aho-corasick]] version = "1.1.4" criteria = "safe-to-deploy" @@ -145,6 +166,11 @@ criteria = "safe-to-deploy" version = "0.6.0-pre.1" criteria = "safe-to-deploy" +[[exemptions.bip32]] +version = "0.6.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.bitflags]] version = "2.11.0" criteria = "safe-to-deploy" @@ -169,6 +195,11 @@ criteria = "safe-to-deploy" version = "0.11.0-rc.3" criteria = "safe-to-deploy" +[[exemptions.block-buffer]] +version = "0.12.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.block-padding]] version = "0.3.3" criteria = "safe-to-deploy" @@ -177,6 +208,16 @@ criteria = "safe-to-deploy" version = "1.6.2" criteria = "safe-to-deploy" +[[exemptions.borsh]] +version = "1.8.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.borsh-derive]] +version = "1.8.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.bounded-vec]] version = "0.9.0" criteria = "safe-to-deploy" @@ -225,6 +266,11 @@ criteria = "safe-to-deploy" version = "0.1.2" criteria = "safe-to-deploy" +[[exemptions.cbc]] +version = "0.2.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.cc]] version = "1.2.58" criteria = "safe-to-deploy" @@ -245,10 +291,20 @@ criteria = "safe-to-deploy" version = "0.10.1" criteria = "safe-to-deploy" +[[exemptions.chacha20poly1305]] +version = "0.11.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.chrono]] version = "0.4.44" criteria = "safe-to-deploy" +[[exemptions.cipher]] +version = "0.5.2" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.clap]] version = "4.6.0" criteria = "safe-to-deploy" @@ -265,6 +321,11 @@ criteria = "safe-to-deploy" version = "1.1.0" criteria = "safe-to-deploy" +[[exemptions.cmov]] +version = "0.5.4" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.colorchoice]] version = "1.0.5" criteria = "safe-to-deploy" @@ -301,6 +362,11 @@ criteria = "safe-to-deploy" version = "0.25.0" criteria = "safe-to-deploy" +[[exemptions.cpubits]] +version = "0.1.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.cpufeatures]] version = "0.2.17" criteria = "safe-to-deploy" @@ -337,6 +403,11 @@ criteria = "safe-to-deploy" version = "0.2.0-rc.1" criteria = "safe-to-deploy" +[[exemptions.crypto-common]] +version = "0.2.2" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.crypto_secretbox]] version = "0.1.1" criteria = "safe-to-deploy" @@ -345,6 +416,11 @@ criteria = "safe-to-deploy" version = "0.2.9" criteria = "safe-to-deploy" +[[exemptions.ctutils]] +version = "0.4.6" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.curve25519-dalek]] version = "4.1.3" criteria = "safe-to-deploy" @@ -357,6 +433,11 @@ criteria = "safe-to-deploy" version = "0.8.1" criteria = "safe-to-deploy" +[[exemptions.daggy]] +version = "0.9.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.darling]] version = "0.20.11" criteria = "safe-to-deploy" @@ -422,6 +503,11 @@ criteria = "safe-to-deploy" version = "0.11.0-pre.9" criteria = "safe-to-deploy" +[[exemptions.digest]] +version = "0.11.3" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.dirs]] version = "6.0.0" criteria = "safe-to-deploy" @@ -515,6 +601,21 @@ notes = "Update for RUSTSEC-2026-0221. Review backlog; this exemption is not a s version = "0.5.4" criteria = "safe-to-deploy" +[[exemptions.f4jumble]] +version = "0.1.2" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.ff]] +version = "0.14.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.ff_derive]] +version = "0.14.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.field-offset]] version = "0.3.6" criteria = "safe-to-deploy" @@ -643,6 +744,16 @@ criteria = "safe-to-deploy" version = "0.18.0" criteria = "safe-to-deploy" +[[exemptions.groth16]] +version = "0.2.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.group]] +version = "0.14.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.gtk]] version = "0.18.2" criteria = "safe-to-deploy" @@ -675,6 +786,11 @@ criteria = "safe-to-deploy" version = "0.13.0-pre.4" criteria = "safe-to-deploy" +[[exemptions.hmac]] +version = "0.13.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.html5ever]] version = "0.29.1" criteria = "safe-to-deploy" @@ -699,6 +815,11 @@ criteria = "safe-to-deploy" version = "0.2.3" criteria = "safe-to-deploy" +[[exemptions.hybrid-array]] +version = "0.4.10" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.hyper]] version = "1.9.0" criteria = "safe-to-deploy" @@ -751,6 +872,11 @@ criteria = "safe-to-deploy" version = "2.3.0" criteria = "safe-to-deploy" +[[exemptions.incrementalmerkletree-testing]] +version = "0.4.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.indexmap]] version = "1.9.3" criteria = "safe-to-deploy" @@ -771,6 +897,11 @@ criteria = "safe-to-deploy" version = "0.1.4" criteria = "safe-to-deploy" +[[exemptions.inout]] +version = "0.2.5" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.ipnet]] version = "2.12.0" criteria = "safe-to-deploy" @@ -955,6 +1086,11 @@ criteria = "safe-to-deploy" version = "0.4.6" criteria = "safe-to-deploy" +[[exemptions.num-bigint]] +version = "0.5.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.num_cpus]] version = "1.17.0" criteria = "safe-to-deploy" @@ -1007,10 +1143,6 @@ criteria = "safe-to-deploy" version = "5.3.5" criteria = "safe-to-deploy" -[[exemptions.orchard]] -version = "0.15.3" -criteria = "safe-to-deploy" - [[exemptions.ordered-stream]] version = "0.2.0" criteria = "safe-to-deploy" @@ -1047,9 +1179,10 @@ criteria = "safe-to-deploy" version = "0.9.1" criteria = "safe-to-deploy" -[[exemptions.petgraph]] -version = "0.7.1" +[[exemptions.pczt]] +version = "0.10.0" criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." [[exemptions.petgraph]] version = "0.8.3" @@ -1140,6 +1273,11 @@ criteria = "safe-to-deploy" version = "0.8.0" criteria = "safe-to-deploy" +[[exemptions.poly1305]] +version = "0.9.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.portable-atomic]] version = "1.13.1" criteria = "safe-to-deploy" @@ -1172,6 +1310,11 @@ criteria = "safe-to-deploy" version = "0.5.20+deprecated" criteria = "safe-to-deploy" +[[exemptions.proptest]] +version = "1.12.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.prost]] version = "0.14.3" criteria = "safe-to-deploy" @@ -1196,6 +1339,11 @@ criteria = "safe-to-deploy" version = "22.0.0" criteria = "safe-to-deploy" +[[exemptions.quick-error]] +version = "1.2.3" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.quick-xml]] version = "0.41.0" criteria = "safe-to-deploy" @@ -1213,6 +1361,16 @@ criteria = "safe-to-deploy" version = "0.7.0" criteria = "safe-to-deploy" +[[exemptions.rand]] +version = "0.9.5" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.rand_xorshift]] +version = "0.5.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.redox_syscall]] version = "0.5.18" criteria = "safe-to-deploy" @@ -1257,6 +1415,11 @@ criteria = "safe-to-deploy" version = "0.2.0-pre.4" criteria = "safe-to-deploy" +[[exemptions.ripemd]] +version = "0.2.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.rusqlite]] version = "0.37.0" criteria = "safe-to-deploy" @@ -1281,6 +1444,11 @@ criteria = "safe-to-deploy" version = "1.0.22" criteria = "safe-to-deploy" +[[exemptions.rusty-fork]] +version = "0.3.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.salsa20]] version = "0.10.2" criteria = "safe-to-deploy" @@ -1305,6 +1473,16 @@ criteria = "safe-to-deploy" version = "0.8.22" criteria = "safe-to-deploy" +[[exemptions.schemerz]] +version = "0.3.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.schemerz-rusqlite]] +version = "0.371.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.scopeguard]] version = "1.2.0" criteria = "safe-to-deploy" @@ -1377,6 +1555,11 @@ criteria = "safe-to-deploy" version = "0.11.0-pre.4" criteria = "safe-to-deploy" +[[exemptions.sha2]] +version = "0.11.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.shell-words]] version = "1.1.1" criteria = "safe-to-deploy" @@ -1701,6 +1884,11 @@ criteria = "safe-to-deploy" version = "0.5.1" criteria = "safe-to-deploy" +[[exemptions.universal-hash]] +version = "0.6.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.url]] version = "2.5.8" criteria = "safe-to-deploy" @@ -1757,6 +1945,11 @@ criteria = "safe-to-deploy" version = "0.2.0" criteria = "safe-to-deploy" +[[exemptions.wait-timeout]] +version = "0.2.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.walkdir]] version = "2.5.0" criteria = "safe-to-deploy" @@ -2105,10 +2298,65 @@ criteria = "safe-to-deploy" version = "4.3.2" criteria = "safe-to-deploy" +[[exemptions.zcash_address]] +version = "0.14.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_client_backend]] +version = "0.25.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_client_sqlite]] +version = "0.23.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_keys]] +version = "0.17.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_note_encryption]] +version = "0.5.1" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.zcash_pool_migration]] version = "0.1.0-rc.3" criteria = "safe-to-deploy" +[[exemptions.zcash_pool_migration]] +version = "0.2.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_primitives]] +version = "0.31.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_proofs]] +version = "0.31.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_protocol]] +version = "0.11.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_script]] +version = "0.6.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zcash_transparent]] +version = "0.11.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.zerocopy]] version = "0.8.48" criteria = "safe-to-deploy" @@ -2141,6 +2389,16 @@ criteria = "safe-to-deploy" version = "0.11.3" criteria = "safe-to-deploy" +[[exemptions.zip32]] +version = "0.3.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + +[[exemptions.zip321]] +version = "0.10.0" +criteria = "safe-to-deploy" +notes = "NU7 SDK migration: exact-version exemption; source audit remains outstanding." + [[exemptions.zvariant]] version = "5.10.1" criteria = "safe-to-deploy" diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 99df3a5a..e3c93992 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -2,15 +2,15 @@ # cargo-vet imports lock [[publisher.bellman]] -version = "0.14.0" -when = "2023-03-20" +version = "0.15.0" +when = "2026-09-26" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" [[publisher.bls12_381]] -version = "0.8.0" -when = "2023-02-27" +version = "0.9.1" +when = "2026-11-05" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" @@ -64,8 +64,8 @@ user-login = "str4d" user-name = "Jack Grigg" [[publisher.fpe]] -version = "0.6.1" -when = "2023-04-13" +version = "0.7.0" +when = "2026-09-30" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" @@ -78,8 +78,8 @@ user-login = "str4d" user-name = "Jack Grigg" [[publisher.halo2_gadgets]] -version = "0.5.0" -when = "2026-06-03" +version = "0.6.0" +when = "2026-09-29" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" @@ -92,36 +92,29 @@ user-login = "daira" user-name = "Daira-Emma Hopwood" [[publisher.halo2_poseidon]] -version = "0.1.0" -when = "2024-12-16" +version = "0.2.0" +when = "2026-09-29" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" [[publisher.halo2_proofs]] -version = "0.3.2" -when = "2025-12-04" +version = "0.4.1" +when = "2026-10-27" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" -[[publisher.hyper-rustls]] -version = "0.27.10" -when = "2026-09-20" -user-id = 2751 -user-login = "ctz" -user-name = "Joe Birr-Pixton" - [[publisher.incrementalmerkletree]] -version = "0.8.2" -when = "2025-02-01" +version = "0.9.0" +when = "2026-09-30" user-id = 169181 user-login = "nuttycom" user-name = "Kris Nuttycombe" [[publisher.jubjub]] -version = "0.10.0" -when = "2023-02-28" +version = "0.11.1" +when = "2026-09-23" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" @@ -181,37 +174,37 @@ user-id = 36629 user-login = "madsmtm" user-name = "Mads Marquart" -[[publisher.openssl-probe]] -version = "0.2.1" -when = "2026-01-20" -user-id = 4556 -user-login = "djc" -user-name = "Dirkjan Ochtman" +[[publisher.orchard]] +version = "0.16.0" +when = "2026-09-30" +user-id = 169181 +user-login = "nuttycom" +user-name = "Kris Nuttycombe" [[publisher.pairing]] -version = "0.23.0" -when = "2022-12-06" +version = "0.24.1" +when = "2026-11-04" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" [[publisher.pasta_curves]] -version = "0.5.1" -when = "2023-03-02" +version = "0.6.1" +when = "2026-10-09" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" [[publisher.reddsa]] -version = "0.5.1" -when = "2023-07-12" +version = "0.6.1" +when = "2026-09-25" user-id = 159631 user-login = "conradoplg" user-name = "Conrado" [[publisher.redjubjub]] -version = "0.8.0" -when = "2025-02-18" +version = "0.9.0" +when = "2026-09-25" user-id = 159631 user-login = "conradoplg" user-name = "Conrado" @@ -230,30 +223,9 @@ user-id = 209038 user-login = "cpu" user-name = "Daniel McCarney" -[[publisher.rustls-native-certs]] -version = "0.8.4" -when = "2026-06-01" -user-id = 4556 -user-login = "djc" -user-name = "Dirkjan Ochtman" - -[[publisher.rustls-platform-verifier]] -version = "0.6.2" -when = "2025-10-22" -user-id = 4556 -user-login = "djc" -user-name = "Dirkjan Ochtman" - -[[publisher.rustls-platform-verifier-android]] -version = "0.1.1" -when = "2024-07-29" -user-id = 209038 -user-login = "cpu" -user-name = "Daniel McCarney" - [[publisher.sapling-crypto]] -version = "0.7.0" -when = "2026-04-21" +version = "0.9.0" +when = "2026-09-30" user-id = 169181 user-login = "nuttycom" user-name = "Kris Nuttycombe" @@ -273,15 +245,15 @@ user-login = "str4d" user-name = "Jack Grigg" [[publisher.secp256k1]] -version = "0.29.1" -when = "2024-09-06" +version = "0.33.1" +when = "2026-08-29" user-id = 1588 user-login = "apoelstra" user-name = "Andrew Poelstra" [[publisher.secp256k1-sys]] -version = "0.10.1" -when = "2024-09-11" +version = "0.14.1" +when = "2026-08-29" user-id = 1588 user-login = "apoelstra" user-name = "Andrew Poelstra" @@ -294,15 +266,15 @@ user-login = "tony-iqlusion" user-name = "Tony Arcieri (iqlusion)" [[publisher.shardtree]] -version = "0.7.1" -when = "2026-07-17" +version = "0.8.0" +when = "2026-09-30" user-id = 169181 user-login = "nuttycom" user-name = "Kris Nuttycombe" [[publisher.sinsemilla]] -version = "0.1.0" -when = "2024-12-14" +version = "0.2.0" +when = "2026-09-25" user-id = 6289 user-login = "str4d" user-name = "Jack Grigg" @@ -379,13 +351,6 @@ version = "0.244.0" when = "2026-01-06" trusted-publisher = "github:bytecodealliance/wasm-tools" -[[publisher.webpki-root-certs]] -version = "1.0.10" -when = "2026-10-19" -user-id = 209038 -user-login = "cpu" -user-name = "Daniel McCarney" - [[publisher.wit-bindgen]] version = "0.51.0" when = "2026-01-12" @@ -438,8 +403,8 @@ user-login = "nuttycom" user-name = "Kris Nuttycombe" [[publisher.zcash_encoding]] -version = "0.4.0" -when = "2026-04-24" +version = "0.5.0" +when = "2026-07-24" user-id = 169181 user-login = "nuttycom" user-name = "Kris Nuttycombe" @@ -1004,6 +969,15 @@ criteria = "safe-to-deploy" delta = "0.1.3 -> 0.2.0" notes = "Nothing out of the ordinary, a typical major version update and nothing awry." +[[audits.bytecode-alliance.audits.unarray]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "0.1.4" +notes = """ +Crate is sound, albeit leaky, and not actively malicious. Probably not the best +crate to use in practice but it's suitable for testing dependencies. +""" + [[audits.bytecode-alliance.audits.utf-8]] who = "Chris Fallin " criteria = "safe-to-deploy" @@ -1094,6 +1068,12 @@ criteria = "safe-to-deploy" delta = "0.15.4 -> 0.17.0" notes = "No notable changes" +[[audits.embark-studios.audits.cfg_aliases]] +who = "Johan Andersson " +criteria = "safe-to-deploy" +version = "0.1.1" +notes = "No unsafe usage or ambient capabilities" + [[audits.embark-studios.audits.convert_case]] who = "Johan Andersson " criteria = "safe-to-deploy" @@ -2105,6 +2085,11 @@ who = "David Cook " criteria = "safe-to-deploy" delta = "0.9.2 -> 0.10.0" +[[audits.isrg.audits.rand_chacha]] +who = "David Cook " +criteria = "safe-to-deploy" +delta = "0.3.1 -> 0.9.0" + [[audits.isrg.audits.rand_core]] who = "David Cook " criteria = "safe-to-deploy" @@ -2120,6 +2105,16 @@ who = "David Cook " criteria = "safe-to-deploy" delta = "0.9.5 -> 0.10.0" +[[audits.isrg.audits.rand_distr]] +who = "David Cook " +criteria = "safe-to-deploy" +delta = "0.4.3 -> 0.5.1" + +[[audits.isrg.audits.rand_distr]] +who = "David Cook " +criteria = "safe-to-deploy" +delta = "0.5.1 -> 0.6.0" + [[audits.isrg.audits.rayon]] who = "Brandon Pitman " criteria = "safe-to-deploy" @@ -2286,12 +2281,12 @@ notes = "All code written or reviewed by Manish" aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" [[audits.mozilla.wildcard-audits.utf8_iter]] -who = "Makoto Kato " +who = "Henri Sivonen " criteria = "safe-to-deploy" user-id = 4484 # Henri Sivonen (hsivonen) start = "2022-04-19" -end = "2024-06-16" -notes = "Maintained by Henri Sivonen who works at Mozilla." +end = "2027-10-30" +notes = "I wrote this crate." aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" [[audits.mozilla.audits.adler2]] @@ -2380,6 +2375,24 @@ criteria = "safe-to-deploy" delta = "0.6.0 -> 0.8.0" aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" +[[audits.mozilla.audits.bit-set]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.8.0 -> 0.9.1" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.bit-set]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.9.1 -> 0.10.0" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.bit-set]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.10.0 -> 0.11.1" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + [[audits.mozilla.audits.bit-vec]] who = "Aria Beingessner " criteria = "safe-to-deploy" @@ -2399,6 +2412,18 @@ criteria = "safe-to-deploy" delta = "0.7.0 -> 0.8.0" aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" +[[audits.mozilla.audits.bit-vec]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.8.0 -> 0.9.1" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.bit-vec]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.9.1 -> 0.10.1" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + [[audits.mozilla.audits.block2]] who = "Andy Leiserson " criteria = "safe-to-deploy" @@ -2406,6 +2431,19 @@ version = "0.6.2" notes = "Contains unsafe code to interoperate with the ObjC runtime." aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" +[[audits.mozilla.audits.cfg_aliases]] +who = "Alex Franchuk " +criteria = "safe-to-deploy" +delta = "0.1.1 -> 0.2.1" +notes = "Very minor changes." +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.cfg_aliases]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.2.1 -> 0.2.2" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + [[audits.mozilla.audits.core-graphics-types]] who = "Teodor Tanasoaia " criteria = "safe-to-deploy" @@ -2425,6 +2463,12 @@ criteria = "safe-to-deploy" delta = "0.1.3 -> 0.2.0" aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" +[[audits.mozilla.audits.core_detect]] +who = "Henri Sivonen " +criteria = "safe-to-deploy" +version = "1.0.0" +aggregated-from = "https://raw.githubusercontent.com/mozilla-firefox/firefox/main/supply-chain/audits.toml" + [[audits.mozilla.audits.cssparser]] who = "Emilio Cobos Álvarez " criteria = "safe-to-deploy" diff --git a/tests/gui/birthday_autodetect_source.test.cjs b/tests/gui/birthday_autodetect_source.test.cjs index 2e77eb7e..1132fac8 100644 --- a/tests/gui/birthday_autodetect_source.test.cjs +++ b/tests/gui/birthday_autodetect_source.test.cjs @@ -218,3 +218,22 @@ test("a cleared-passphrase wallet never reaches the backend", async () => { assert.equal(called, false); assert.match(h.hints.at(-1).text, /passphrase/); }); + +test("auto-detection drops a result when the network or endpoint changes", async () => { + for (const [id, value] of [ + ["network-select", "testnet"], + ["lightwalletd-url", "https://changed.example"], + ]) { + const h = harness({ + walletFile: null, + seed: "abandon art", + invoke: async () => { + h.els.get(id).value = value; + return { birthday: 999 }; + }, + }); + await h.run(); + assert.equal(h.els.has("birthday-height"), false, id); + assert.match(h.hints.at(-1).text, /discarded/); + } +}); diff --git a/tests/gui/network_birthday_default.test.cjs b/tests/gui/network_birthday_default.test.cjs index 06871c80..5ee808ba 100644 --- a/tests/gui/network_birthday_default.test.cjs +++ b/tests/gui/network_birthday_default.test.cjs @@ -74,3 +74,48 @@ test("manual and matched network changes both synchronize an untouched birthday" /syncUntouchedBirthdayToNetwork\(snapshot\.network\)/, ); }); + +function estimateHarness(network, afterRequest = () => {}) { + const elements = new Map(); + let click; + const $ = (id) => { + if (!elements.has(id)) elements.set(id, { value: '', addEventListener(event, callback) { click = callback; } }); + return elements.get(id); + }; + $('network-select').value = network; + $('birthday-date').value = '2030-01-01'; + $('lightwalletd-url').value = 'https://fixture.example'; + const calls = []; + const ctx = vm.createContext({ $, birthdayTouched: false, setBirthdayHint() {}, setStatus() {}, + invalidateScanAuthority() {}, updateScanEstimate() {}, formatApproxMonth: () => 'Jan 2030', + approxDateFromHeight: () => new Date(), + invoke: async (command, args) => { calls.push({command, args}); afterRequest($); return 123456; }, + }); + const start = source.indexOf('$("birthday-estimate").addEventListener("click"'); + const end = source.indexOf('async function validateDestination()', start); + vm.runInContext(source.slice(start, end), ctx); + return { $, calls, run: () => click() }; +} + +test('date estimation sends the selected network explicitly to the backend', async () => { + for (const network of ['mainnet', 'testnet']) { + const h = estimateHarness(network); + await h.run(); + assert.equal(h.calls[0].command, 'estimate_birthday_from_date'); + assert.equal(h.calls[0].args.network, network); + assert.equal(h.$('birthday-height').value, 123456); + } +}); + +test('date estimates from an earlier network, endpoint, or date cannot overwrite the current birthday', async () => { + for (const [id, value] of [ + ['network-select', 'testnet'], + ['lightwalletd-url', 'https://changed.example'], + ['birthday-date', '2020-01-01'], + ]) { + const h = estimateHarness('mainnet', $ => { $(id).value = value; }); + h.$('birthday-height').value = '280000'; + await h.run(); + assert.equal(h.$('birthday-height').value, '280000', id); + } +}); diff --git a/tests/gui/nu7_readiness.test.cjs b/tests/gui/nu7_readiness.test.cjs new file mode 100644 index 00000000..8f843a6c --- /dev/null +++ b/tests/gui/nu7_readiness.test.cjs @@ -0,0 +1,33 @@ +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const vm = require('node:vm'); +const source = fs.readFileSync('gui/src/main.js', 'utf8'); +function declaration(name) { + const bareStart = source.indexOf(`function ${name}(`); + const start = source.slice(bareStart - 6, bareStart) === "async " ? bareStart - 6 : bareStart; + assert.notEqual(start, -1, name); + return source.slice(start, source.indexOf('\n}\n', start) + 3); +} +const timingStart = source.indexOf('const SAPLING_ACTIVATION_HEIGHT_JS'); +const timingEnd = source.indexOf('function approxDateFromHeight('); +const timing = vm.runInNewContext(source.slice(timingStart, timingEnd) + '\n' + + declaration('approxDateFromHeight') + '; approxDateFromHeight', {}); +test('mainnet and testnet estimates retain 75 second timing before NU7 and use 25 seconds at their activation', () => { + for (const [network, activation] of [['mainnet', 3543405], ['testnet', 4465026]]) { + const at = timing(activation, network).getTime(); + assert.equal(at - timing(activation - 1, network).getTime(), 75000); + assert.equal(timing(activation + 1, network).getTime() - at, 25000); + assert.equal(timing(activation + 100, network).getTime() - at, 2500000); + } +}); + +test('height estimates remain finite for u32 bounds and retain historical 150 second timing', () => { + assert.equal(timing(500001).getTime() - timing(500000).getTime(), 150000); + assert.equal(timing(1000001).getTime() - timing(1000000).getTime(), 75000); + for (const network of ['mainnet', 'testnet']) { + assert.ok(Number.isFinite(timing(0, network).getTime())); + assert.ok(Number.isFinite(timing(4294967295, network).getTime())); + assert.ok(timing(4294967295, network).getTime() > timing(4294967294, network).getTime()); + } +}); diff --git a/tests/regtest/README.md b/tests/regtest/README.md index decef71a..d1e1845c 100644 --- a/tests/regtest/README.md +++ b/tests/regtest/README.md @@ -6,11 +6,11 @@ fund-recovery flow against a real Zcash node — scan, sweep, broadcast, resume — in scenarios that aren't reachable from pure unit tests (GoAway frames mid scan, hostile compact blocks, mid-scan crashes, reorgs, etc.). -The harness is **opt-in** and **never runs in CI**: +The funded recovery harness is **opt-in**. CI separately runs the short, +independent NU7 block/proxy boundary profile described below: - The integration tests are tagged `#[ignore]` so default `cargo test` skips them. -- Booting a regtest stack on every PR would inflate CI runtime past the cache - TTL and is not worth it for tests this rarely fail. +- The full funded chain is prepared locally; CI does not mine its ZIP 212 preparation height. - Contributors run this locally before merging changes to scan/sweep logic. ## What boots @@ -26,11 +26,13 @@ so a zcashd chain can never activate Ironwood (NU6.3), and the post-activation sweep path is untestable on it by construction. Zebra implements NU6.3 with per-upgrade configurable Regtest activation heights. -Both images are pinned (`zfnd/zebra:6.2.3`, `electriccoinco/lightwalletd:v0.5.1`) -rather than tracking `latest`: the activation heights and consensus rules under -test are version-sensitive, and a silently updated node would change what the -tests mean. lightwalletd v0.5.1 is the first release carrying the Ironwood -compact-block fields the client backend expects to decode. +Both images are pinned by release tag and image digest (`zfnd/zebra:7.0.0`, +`electriccoinco/lightwalletd:v0.6.0`), rather than tracking `latest`: activation +heights and consensus rules under test are version-sensitive. lightwalletd +preserves the Ironwood compact-block fields the client backend expects. The +ordinary recovery chain deliberately omits NU7 activation and matches +`ArgosParams::regtest_all_active()`. The `fixtures` profile retains zcashd +v6.20.0 solely to generate wallet-import fixtures. Both bound to **loopback only**. Never expose these ports — the regtest RPC credentials are well-known and a remote miner with control of those ports @@ -111,8 +113,8 @@ height. Do **not** try to fix the subsidy with `pre_blossom_halving_interval` in `zebrad-regtest.toml`. Zebra accepts the key on Regtest and ignores it — -`Parameters::new_regtest` hardcodes the interval. Measured against the pinned -v6.2.3 with it set to 1,000,000: 6.25 ZEC at height 1, 5.96e-6 at 6,000, 0.0 +`Parameters::new_regtest` hardcodes the interval. Measured against the former +v6.2.3 pin with it set to 1,000,000: 6.25 ZEC at height 1, 5.96e-6 at 6,000, 0.0 at 32,400, identical to the default. **The treasury cannot be topped up.** Its own funding is coinbase, so whatever @@ -166,7 +168,8 @@ Both flags are required: Without `--features argos-network`, the integration test file is gated out by `#![cfg(feature = "argos-network")]` and compiles to an empty test -binary. CI runs the default form only. +binary. CI runs the feature-enabled local fake-lightwalletd cases; real-node +cases remain ignored except for the separate NU7 boundary job. Each integration test prints a `[regtest]` header noting the harness URL it connected to, so a mid-test failure is easy to attribute to the stack vs to @@ -287,3 +290,102 @@ filter `automatic_transparent_range_recovers_low_and_high_indices`. It funds account-0 receive indices 7 and 997, scans one shielded account with the default transparent range, and checks that the mined sweep consumes both addresses' UTXOs. The explicit range must survive resume before sweeping. + + +## Dedicated NU7 qualification + +The `nu7` profile has independent state, RPC `127.0.0.1:18252`, and +lightwalletd `127.0.0.1:9077`. Its NU7 activation is **32,500**, matching +`qualified_params_at(32_500)` in `nu7_readiness.rs`. Earlier upgrades activate at 1. +The height is after ZIP 212 enforcement at 32,257 so PCZT experiments can be +performed on either side. Mining to that height can take over an hour. + +For a quick branch-boundary check, `nu7-fast` uses a separate volume, +activation height **10**, RPC `127.0.0.1:18262`, and lightwalletd +`127.0.0.1:9087`. ZIP 212 is not enforced at this height; it provides no PCZT +qualification evidence. + +```sh +cd tests/regtest +docker compose --profile nu7-fast up -d zebrad-nu7-fast lightwalletd-nu7-fast +ARGOS_NU7_PROFILE=fast ./nu7.sh before # mines exactly to height 9 +cd ../.. +CARGO_INCREMENTAL=0 RUSTFLAGS='' \ + cargo +1.89 test -p argos-core --features argos-network --locked --test nu7_readiness \ + private_ -- --ignored --nocapture --test-threads=1 +``` + +The node test starts at height 9 and mines blocks 10 and 11. A repeat run +at height 10 or 11 reuses the accepted blocks and mines only any missing +block through 11; it never rewinds or deletes state. It parses the actual +node's complete serialized blocks and checks every embedded transaction's +branch before, at, and after activation. The separate proxy test requires +lightwalletd to report branch `77190ad9` and serve compact block 10. This is actual +node acceptance of synthetic regtest coinbase blocks, **not evidence of +funded transparent, Sapling, Orchard, Ironwood, or PCZT sweep acceptance**. +Those recovery gates require separately prepared synthetic regtest balances +and observed mined sweep transactions on the full profile. + +For the full profile, use `docker compose --profile nu7 up -d zebrad-nu7 +lightwalletd-nu7` and `./nu7.sh before` to stop at 32,499. `./nu7.sh at` and +`./nu7.sh after` are explicit manual controls for either profile; set +`ARGOS_NU7_PROFILE=fast` to address the fast profile. The node test supports +reusing the three retained boundary blocks while the tip remains at 9-11. +The controller refuses to rewind or delete an existing chain. Use separate, +intentionally created volumes for repeated boundary rehearsals. It always +addresses a fixed private loopback RPC, never a public endpoint. It performs +no funding and never starts a VM automatically. + +Offline qualification runs without Docker: + +```sh +CARGO_INCREMENTAL=0 RUSTFLAGS='' \ + cargo +1.89 test -p argos-core --features argos-network --locked --test nu7_readiness +``` + +These tests pin both production activation heights and branch `77190ad9`, +parse independently encoded empty v5/v6 wire transactions, reject placeholder +branches/truncation, preserve the real branch through PCZT creation/encoding, +check the actual builder's 40/120-block expiry behavior, preserve the legacy +regtest schedule, and reopen a +persisted account across the local activation. The retained pre-NU7 SQLite +fixture additionally verifies migration from the old SDK family and a second +reopen; see [fixture reproduction](legacy-wallet-db/README.md). Empty parser +fixtures and empty wallet databases hold no notes or spendable value. + +The pinned release/image provenance and current qualification limits are recorded +in [NU7 supported-recovery qualification](../../docs/qualification/nu7-supported-recovery.md). +No historical test output from the superseded Sprout branch is current evidence +for this branch. + +### Native lightwalletd fallback on Apple Silicon + +The official lightwalletd image is amd64-only. If emulation fails, build a +native proxy in a separate checkout of the official +[v0.6.0 tag](https://github.com/zcash/lightwalletd/tree/v0.6.0), commit +`e7436d2adb9ab5828eb8a27de534e16218841fc2`: + +```sh +git clone --branch v0.6.0 --depth 1 https://github.com/zcash/lightwalletd.git /private/tmp/argos-nu7-lightwalletd +cd /private/tmp/argos-nu7-lightwalletd +test "$(git rev-parse HEAD)" = e7436d2adb9ab5828eb8a27de534e16218841fc2 +go build -o lightwalletd . +./lightwalletd --no-tls-very-insecure --grpc-bind-addr=127.0.0.1:9088 \ + --rpchost=127.0.0.1 --rpcport=18262 \ + --rpcuser=argos-regtest --rpcpassword=argos-regtest \ + --data-dir=/private/tmp/argos-nu7-native-proxy-data --log-file=/dev/stdout +``` + +Keep the fast Zebra profile running; stop the emulated proxy if it is failing. +From the Argos repository root, select the permitted native loopback endpoint: + +```sh +ARGOS_NU7_LIGHTWALLETD_URL=http://127.0.0.1:9088 \ + CARGO_INCREMENTAL=0 RUSTFLAGS='' \ + cargo +1.89 test -p argos-core --features argos-network --locked --test nu7_readiness \ + private_ -- --ignored --nocapture --test-threads=1 +``` + +The test refuses arbitrary proxy endpoints. Record the actual Go version, +source revision and output when using this fallback. Building a native proxy +or accepting synthetic coinbase blocks does not satisfy the funded gate. diff --git a/tests/regtest/docker-compose.yml b/tests/regtest/docker-compose.yml index 4d2d289b..e65b59bd 100644 --- a/tests/regtest/docker-compose.yml +++ b/tests/regtest/docker-compose.yml @@ -31,7 +31,7 @@ services: # Pinned, not `latest`: the harness's activation heights and the Ironwood # consensus rules it exercises are version-sensitive, and a silently # updated node would change what the tests mean. - image: zfnd/zebra:6.2.3 + image: zfnd/zebra:7.0.0@sha256:a70d2be8ffef3a4b6e37355724e36a0e6c1838e46baa28bfb216739f00cf2d34 container_name: argos-zebrad-regtest restart: "no" # Only bound to loopback — never publish regtest RPC to a non-loopback @@ -59,11 +59,11 @@ services: - "start" lightwalletd-regtest: - # v0.5.1 is the first release carrying the Ironwood compact-block fields: + # v0.6.0 preserves the Ironwood compact-block fields: # `ChainMetadata.ironwoodCommitmentTreeSize`, and `CompactBlock` field 1 # (`protoVersion`) reserved after removal. Both match what - # zcash_client_backend 0.24 expects to decode. - image: electriccoinco/lightwalletd:v0.5.1 + # zcash_client_backend 0.25 expects to decode. + image: electriccoinco/lightwalletd:v0.6.0@sha256:abc8199dae800e050415a3459f71c7850aeefeb1ca6a681e9b9eda7249ce8613 # Published for linux/amd64 only — there is no arm64 manifest — so Apple # Silicon runs it under emulation. Acceptable because lightwalletd is a # thin gRPC proxy; the consensus work happens in zebrad, which does have a @@ -97,6 +97,81 @@ services: - "--data-dir=/var/lib/lightwalletd" - "--log-file=/dev/stdout" + # Independent NU7 qualification chain. Its state and ports never overlap + # the ordinary recovery or wallet-import fixtures. + zebrad-nu7: + profiles: ["nu7"] + image: zfnd/zebra:7.0.0@sha256:a70d2be8ffef3a4b6e37355724e36a0e6c1838e46baa28bfb216739f00cf2d34 + container_name: argos-zebrad-nu7 + restart: "no" + ports: + - "127.0.0.1:18252:18232" + volumes: + - ./zebrad-nu7.toml:/etc/zebrad/zebrad.toml:ro + - zebrad-nu7-data:/var/lib/zebrad + environment: + CONFIG_FILE_PATH: /etc/zebrad/zebrad.toml + ZEBRA_STATE__CACHE_DIR: /var/lib/zebrad + command: ["zebrad", "start"] + + lightwalletd-nu7: + profiles: ["nu7"] + image: electriccoinco/lightwalletd:v0.6.0@sha256:abc8199dae800e050415a3459f71c7850aeefeb1ca6a681e9b9eda7249ce8613 + platform: linux/amd64 + container_name: argos-lightwalletd-nu7 + restart: "no" + depends_on: [zebrad-nu7] + ports: + - "127.0.0.1:9077:9067" + volumes: + - lwd-nu7-data:/var/lib/lightwalletd + command: + - "--no-tls-very-insecure" + - "--grpc-bind-addr=0.0.0.0:9067" + - "--rpchost=zebrad-nu7" + - "--rpcport=18232" + - "--rpcuser=argos-regtest" + - "--rpcpassword=argos-regtest" + - "--data-dir=/var/lib/lightwalletd" + - "--log-file=/dev/stdout" + + # Fast boundary-only profile; no ZIP 212 / funded-PCZT claim. + zebrad-nu7-fast: + profiles: ["nu7-fast"] + image: zfnd/zebra:7.0.0@sha256:a70d2be8ffef3a4b6e37355724e36a0e6c1838e46baa28bfb216739f00cf2d34 + container_name: argos-zebrad-nu7-fast + restart: "no" + ports: + - "127.0.0.1:18262:18232" + volumes: + - ./zebrad-nu7-fast.toml:/etc/zebrad/zebrad.toml:ro + - zebrad-nu7-fast-data:/var/lib/zebrad + environment: + CONFIG_FILE_PATH: /etc/zebrad/zebrad.toml + ZEBRA_STATE__CACHE_DIR: /var/lib/zebrad + command: ["zebrad", "start"] + + lightwalletd-nu7-fast: + profiles: ["nu7-fast"] + image: electriccoinco/lightwalletd:v0.6.0@sha256:abc8199dae800e050415a3459f71c7850aeefeb1ca6a681e9b9eda7249ce8613 + platform: linux/amd64 + container_name: argos-lightwalletd-nu7-fast + restart: "no" + depends_on: [zebrad-nu7-fast] + ports: + - "127.0.0.1:9087:9067" + volumes: + - lwd-nu7-fast-data:/var/lib/lightwalletd + command: + - "--no-tls-very-insecure" + - "--grpc-bind-addr=0.0.0.0:9067" + - "--rpchost=zebrad-nu7-fast" + - "--rpcport=18232" + - "--rpcuser=argos-regtest" + - "--rpcpassword=argos-regtest" + - "--data-dir=/var/lib/lightwalletd" + - "--log-file=/dev/stdout" + # Fixture generation only. NOT part of the regtest stack. # # zcashd is EOL and cannot activate Ironwood (NU6.3), so it is useless @@ -117,3 +192,7 @@ services: volumes: zebrad-data: lwd-data: + zebrad-nu7-data: + lwd-nu7-data: + zebrad-nu7-fast-data: + lwd-nu7-fast-data: diff --git a/tests/regtest/legacy-wallet-db/.gitignore b/tests/regtest/legacy-wallet-db/.gitignore new file mode 100644 index 00000000..3556c79b --- /dev/null +++ b/tests/regtest/legacy-wallet-db/.gitignore @@ -0,0 +1,3 @@ +# Public synthetic pre-upgrade schema fixture; not a user's wallet database. +!pre-nu7.sqlite +/target/ diff --git a/tests/regtest/legacy-wallet-db/Cargo.lock b/tests/regtest/legacy-wallet-db/Cargo.lock new file mode 100644 index 00000000..7a47cd4a --- /dev/null +++ b/tests/regtest/legacy-wallet-db/Cargo.lock @@ -0,0 +1,2682 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common 0.1.7", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" + +[[package]] +name = "argos-legacy-wallet-db-fixture" +version = "0.0.0" +dependencies = [ + "rand_core", + "secrecy", + "zcash_client_backend", + "zcash_client_sqlite", + "zcash_primitives", + "zcash_protocol", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bech32" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" + +[[package]] +name = "bellman" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171" +dependencies = [ + "bitvec", + "blake2s_simd", + "byteorder", + "crossbeam-channel", + "ff", + "group", + "lazy_static", + "log", + "num_cpus", + "pairing", + "rand_core", + "rayon", + "subtle", +] + +[[package]] +name = "bip32" +version = "0.6.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143f5327f23168716be068f8e1014ba2ea16a6c91e8777bc8927da7b51e1df1f" +dependencies = [ + "bs58", + "hmac", + "rand_core", + "ripemd 0.2.0-pre.4", + "secp256k1", + "sha2 0.11.0-pre.4", + "subtle", + "zeroize", +] + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79834656f71332577234b50bfc009996f7449e0c056884e6a02492ded0ca2f3" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee29928bad1e3f94c9d1528da29e07a1d3d04817ae8332de1e8b846c8439f4b3" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.11.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd016a0ddc7cb13661bf5576073ce07330a693f8608a1320b4e20561cc12cdc" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff", + "group", + "pairing", + "rand_core", + "subtle", +] + +[[package]] +name = "bounded-vec" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09dc0086e469182132244e9b8d313a0742e1132da43a08c24b9dd3c18e0faf3a" +dependencies = [ + "thiserror 2.0.18", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2 0.10.9", + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + +[[package]] +name = "cc" +version = "1.2.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common 0.1.7", + "inout", + "zeroize", +] + +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.18", +] + +[[package]] +name = "constant_time_eq" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" + +[[package]] +name = "corez" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4df6f98652d30167eaeea34d77b730e07c8caba6df17bd4551842b9b8da01deb" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "daggy" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70def8d72740e44d9f676d8dab2c933a236663d86dd24319b57a2bed4d694774" +dependencies = [ + "petgraph 0.7.1", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +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", + "subtle", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "equihash" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306286e8dcc39ab3dfceb74c792ce8baffdab90591321d3ffaae64829734c37f" +dependencies = [ + "blake2b_simd", + "corez", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "f4jumble" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d42773cb15447644d170be20231a3268600e0c4cea8987d013b93ac973d3cf7" +dependencies = [ + "blake2b_simd", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fpe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c4b37de5ae15812a764c958297cfc50f5c010438f60c6ce75d11b802abd404" +dependencies = [ + "cbc", + "cipher", + "libm", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", +] + +[[package]] +name = "getset" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf0fc11e47561d47397154977bc219f4cf809b2974facc3ccb3b89e2436f912" +dependencies = [ + "proc-macro-error2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "memuse", + "rand_core", + "subtle", +] + +[[package]] +name = "halo2_gadgets" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2a697cad929f706b7987fe804ad57d43622cd37463ba7e4d662a926fdcfea3" +dependencies = [ + "arrayvec", + "bitvec", + "ff", + "group", + "halo2_poseidon", + "halo2_proofs", + "lazy_static", + "pasta_curves", + "rand", + "sinsemilla", + "subtle", + "uint", +] + +[[package]] +name = "halo2_legacy_pdqsort" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47716fe1ae67969c5e0b2ef826f32db8c3be72be325e1aa3c1951d06b5575ec5" + +[[package]] +name = "halo2_poseidon" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa3da60b81f02f9b33ebc6252d766f843291fb4d2247a07ae73d20b791fc56f" +dependencies = [ + "bitvec", + "ff", + "group", + "pasta_curves", +] + +[[package]] +name = "halo2_proofs" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05713f117155643ce10975e0bee44a274bcda2f4bb5ef29a999ad67c1fa8d4d3" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2_legacy_pdqsort", + "indexmap 1.9.3", + "maybe-rayon", + "pasta_curves", + "rand_core", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.13.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58" +dependencies = [ + "digest 0.11.0-pre.9", +] + +[[package]] +name = "hybrid-array" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9" +dependencies = [ + "typenum", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "incrementalmerkletree" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30821f91f0fa8660edca547918dc59812893b497d07c1144f326f07fdd94aba9" +dependencies = [ + "either", +] + +[[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.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "jubjub" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" +dependencies = [ + "bitvec", + "bls12_381", + "ff", + "group", + "rand_core", + "subtle", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.184" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libsqlite3-sys" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litrs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "memuse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "nanorand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nonempty" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "549e471b99ccaf2f89101bec68f4d244457d5a95a9c3d0672e9564124397741d" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "orchard" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b67beade27dbebdbfee0819e23170b0b263dc7b4f558ee936151716baf6e1f" +dependencies = [ + "aes", + "bitvec", + "blake2b_simd", + "corez", + "ff", + "fpe", + "getset", + "group", + "halo2_gadgets", + "halo2_poseidon", + "halo2_proofs", + "hex", + "incrementalmerkletree", + "lazy_static", + "memuse", + "nonempty", + "pasta_curves", + "rand", + "rand_core", + "reddsa", + "serde", + "sinsemilla", + "subtle", + "tracing", + "visibility", + "zcash_note_encryption", + "zcash_spec", + "zip32", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + +[[package]] +name = "pczt" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7d4693dcb3d72f30064e0fdab122292d803bd9325a95b25df08679cf895452f" +dependencies = [ + "blake2b_simd", + "bls12_381", + "document-features", + "ff", + "getset", + "jubjub", + "nonempty", + "orchard", + "pasta_curves", + "postcard", + "rand_core", + "redjubjub", + "sapling-crypto", + "secp256k1", + "serde", + "serde_with", + "zcash_note_encryption", + "zcash_primitives", + "zcash_protocol", + "zcash_script", + "zcash_transparent", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap 2.13.0", +] + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap 2.13.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "petgraph 0.8.3", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "reddsa" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78a5191930e84973293aa5f532b513404460cd2216c1cfb76d08748c15b40b02" +dependencies = [ + "blake2b_simd", + "byteorder", + "group", + "hex", + "jubjub", + "pasta_curves", + "rand_core", + "serde", + "thiserror 1.0.69", + "zeroize", +] + +[[package]] +name = "redjubjub" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b0ac1bc6bb3696d2c6f52cff8fba57238b81da8c0214ee6cd146eb8fde364e" +dependencies = [ + "rand_core", + "reddsa", + "thiserror 1.0.69", + "zeroize", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "ripemd" +version = "0.2.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48cf93482ea998ad1302c42739bc73ab3adc574890c373ec89710e219357579" +dependencies = [ + "digest 0.11.0-pre.9", +] + +[[package]] +name = "rusqlite" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", + "time", + "uuid", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "sapling-crypto" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d70756ede56b5e4dd417979777bd87ddb83dfcbd0815dbf8175a9920537f8a0" +dependencies = [ + "aes", + "bellman", + "bitvec", + "blake2b_simd", + "blake2s_simd", + "bls12_381", + "corez", + "document-features", + "ff", + "fpe", + "getset", + "group", + "hex", + "incrementalmerkletree", + "jubjub", + "lazy_static", + "memuse", + "rand", + "rand_core", + "redjubjub", + "subtle", + "tracing", + "zcash_note_encryption", + "zcash_spec", + "zip32", +] + +[[package]] +name = "schemerz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e82960ac11ccabd77d53c933532612079e01205b5873ec5095f4b3426493434" +dependencies = [ + "daggy", + "indexmap 1.9.3", + "log", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "schemerz-rusqlite" +version = "0.370.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6df8a13fb3b7914f94ac6579bd5e76b9292f135886e6becc3525f9e5116827" +dependencies = [ + "rusqlite", + "schemerz", + "uuid", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_with" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "381b283ce7bc6b476d903296fb59d0d36633652b633b27f64db4fb46dcbfc3b9" +dependencies = [ + "base64", + "chrono", + "hex", + "serde_core", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6d4e30573c8cb306ed6ab1dca8423eec9a463ea0e155f45399455e0368b27e0" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.11.0-pre.9", +] + +[[package]] +name = "shardtree" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8147447aed7be4736e271825b8c3a4432efb7182e71363169b572371ddef452e" +dependencies = [ + "bitflags", + "either", + "incrementalmerkletree", + "tracing", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "sinsemilla" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d268ae0ea06faafe1662e9967cd4f9022014f5eeb798e0c302c876df8b7af9c" +dependencies = [ + "group", + "pasta_curves", + "subtle", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tonic-build" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1882ac3bf5ef12877d7ed57aad87e75154c11931c2ba7e6cde5e22d63522c734" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tonic-prost-build" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3144df636917574672e93d0f56d7edec49f90305749c668df5101751bb8f95a" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn", + "tempfile", + "tonic-build", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common 0.1.7", + "subtle", +] + +[[package]] +name = "uuid" +version = "1.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac8b6f42ead25368cf5b098aeb3dc8a1a2c05a3eee8a9a1a68c640edbfc79d9" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "visibility" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "which" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" +dependencies = [ + "libc", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zcash_address" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a854b28c07dba372f4410ea8ad62b4bf7d5c2bf8be32fc4b31bc0db6521a975" +dependencies = [ + "bech32", + "bs58", + "corez", + "f4jumble", + "zcash_encoding", + "zcash_protocol", +] + +[[package]] +name = "zcash_client_backend" +version = "0.24.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e019c2adb1eb2c3479603f4556e85c01022723f14ce8837a3bb225cb2af4d3f" +dependencies = [ + "base64", + "bech32", + "bip32", + "bls12_381", + "bs58", + "byteorder", + "document-features", + "flume", + "getset", + "group", + "hex", + "incrementalmerkletree", + "memuse", + "nonempty", + "orchard", + "pasta_curves", + "percent-encoding", + "prost", + "rand_core", + "rayon", + "sapling-crypto", + "secp256k1", + "secrecy", + "shardtree", + "subtle", + "time", + "tonic-prost-build", + "tracing", + "which", + "zcash_address", + "zcash_encoding", + "zcash_keys", + "zcash_note_encryption", + "zcash_primitives", + "zcash_protocol", + "zcash_script", + "zcash_transparent", + "zip32", + "zip321", +] + +[[package]] +name = "zcash_client_sqlite" +version = "0.22.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a496ad83b77e790bd0ea1013db14961b3ff825550097a2658837dc7e92a23d53" +dependencies = [ + "bip32", + "bitflags", + "bs58", + "byteorder", + "document-features", + "group", + "hex", + "incrementalmerkletree", + "jubjub", + "maybe-rayon", + "nonempty", + "orchard", + "prost", + "rand", + "rand_core", + "rand_distr", + "regex", + "rusqlite", + "sapling-crypto", + "schemerz", + "schemerz-rusqlite", + "secp256k1", + "secrecy", + "serde", + "shardtree", + "static_assertions", + "subtle", + "time", + "tracing", + "uuid", + "zcash_address", + "zcash_client_backend", + "zcash_encoding", + "zcash_keys", + "zcash_pool_migration", + "zcash_primitives", + "zcash_protocol", + "zcash_script", + "zcash_transparent", + "zip32", +] + +[[package]] +name = "zcash_encoding" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1440921903cdb86133fb9e2fe800be488015db2939a30bedb413078a1acb0306" +dependencies = [ + "corez", + "hex", + "nonempty", +] + +[[package]] +name = "zcash_keys" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc842e024fe37e52cfd3920826c4a28cc2a023fc9d77351d9c0f310becae3eb7" +dependencies = [ + "bech32", + "bip32", + "blake2b_simd", + "bls12_381", + "bs58", + "corez", + "document-features", + "group", + "memuse", + "nonempty", + "orchard", + "rand_core", + "sapling-crypto", + "secrecy", + "subtle", + "tracing", + "zcash_address", + "zcash_encoding", + "zcash_protocol", + "zcash_transparent", + "zip32", +] + +[[package]] +name = "zcash_note_encryption" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77efec759c3798b6e4d829fcc762070d9b229b0f13338c40bf993b7b609c2272" +dependencies = [ + "chacha20", + "chacha20poly1305", + "cipher", + "rand_core", + "subtle", +] + +[[package]] +name = "zcash_pool_migration" +version = "0.1.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e4169a96a25de216d4a7265fe772003aaeea05ed2566b14cfc0b8146b1f99e" +dependencies = [ + "corez", + "getset", + "incrementalmerkletree", + "libm", + "orchard", + "pczt", + "rand_core", + "shardtree", + "zcash_client_backend", + "zcash_keys", + "zcash_primitives", + "zcash_protocol", +] + +[[package]] +name = "zcash_primitives" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ca4de11896f704ffe6319c2cd7bc8fc6ab31a55cec80d26def15c009d83678" +dependencies = [ + "blake2b_simd", + "block-buffer 0.11.0-rc.3", + "corez", + "crypto-common 0.2.0-rc.1", + "document-features", + "equihash", + "ff", + "hex", + "incrementalmerkletree", + "jubjub", + "memuse", + "nonempty", + "orchard", + "rand_core", + "redjubjub", + "sapling-crypto", + "secp256k1", + "sha2 0.10.9", + "zcash_encoding", + "zcash_note_encryption", + "zcash_protocol", + "zcash_script", + "zcash_transparent", +] + +[[package]] +name = "zcash_protocol" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4034db33a1ce58416430e065b01474b958e4649caa3e06e20654683a95149710" +dependencies = [ + "corez", + "document-features", + "hex", + "memuse", + "zcash_encoding", +] + +[[package]] +name = "zcash_script" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6ef9d04e0434a80b62ad06c5a610557be358ef60a98afa5dbc8ecaf19ad72e7" +dependencies = [ + "bip32", + "bitflags", + "bounded-vec", + "hex", + "ripemd 0.1.3", + "secp256k1", + "sha1", + "sha2 0.10.9", + "thiserror 2.0.18", +] + +[[package]] +name = "zcash_spec" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded3f58b93486aa79b85acba1001f5298f27a46489859934954d262533ee2915" +dependencies = [ + "blake2b_simd", +] + +[[package]] +name = "zcash_transparent" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "547c012778bae17f58007731af074d638aa146ab0ecfc120adebf23d049aff6c" +dependencies = [ + "bip32", + "bs58", + "corez", + "document-features", + "getset", + "hex", + "nonempty", + "ripemd 0.1.3", + "secp256k1", + "sha2 0.10.9", + "subtle", + "zcash_address", + "zcash_encoding", + "zcash_protocol", + "zcash_script", + "zcash_spec", + "zip32", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zip32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64bf5186a8916f7a48f2a98ef599bf9c099e2458b36b819e393db1c0e768c4b" +dependencies = [ + "bech32", + "blake2b_simd", + "memuse", + "subtle", + "zcash_spec", +] + +[[package]] +name = "zip321" +version = "0.9.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb464491970d9b61889e4f2b7b00fb9f471a33692e5c0de3122fdc575d8067ab" +dependencies = [ + "base64", + "nom", + "percent-encoding", + "zcash_address", + "zcash_protocol", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/tests/regtest/legacy-wallet-db/Cargo.toml b/tests/regtest/legacy-wallet-db/Cargo.toml new file mode 100644 index 00000000..3f32bbe8 --- /dev/null +++ b/tests/regtest/legacy-wallet-db/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "argos-legacy-wallet-db-fixture" +version = "0.0.0" +edition = "2021" +publish = false +[workspace] +[dependencies] +rand_core = "=0.6.4" +secrecy = "=0.8.0" +zcash_client_backend = { version = "=0.24.0-rc.4", default-features = false, features = ["orchard", "transparent-inputs", "transparent-key-import"] } +zcash_client_sqlite = { version = "=0.22.0-rc.4", default-features = false, features = ["orchard", "serde", "transparent-inputs", "transparent-key-import"] } +zcash_protocol = "=0.10.1" +zcash_primitives = "=0.30.0" diff --git a/tests/regtest/legacy-wallet-db/README.md b/tests/regtest/legacy-wallet-db/README.md new file mode 100644 index 00000000..c5174944 --- /dev/null +++ b/tests/regtest/legacy-wallet-db/README.md @@ -0,0 +1,47 @@ +# Pre-NU7 SQLite migration fixture + +`pre-nu7.sqlite` is an empty wallet database generated by the SDK versions in +Argos's pre-upgrade lockfile (PR #290), not by the NU7 SDK under test: + +- `zcash_client_backend 0.24.0-rc.4` +- `zcash_client_sqlite 0.22.0-rc.4` +- `zcash_primitives 0.30.0`, `zcash_protocol 0.10.1` +- Rust 1.88 (fixture generation only; the NU7 project uses Rust 1.89) + +The seed is public synthetic **64 bytes of `0x42`**, with one testnet account +named `pre-NU7 public fixture`, birthday 4,465,025 and recorded tip 4,465,025. +The prior chain state uses empty commitment trees and an all-zero block hash; +this is a schema/account fixture, not chain evidence. It contains no received +notes, UTXOs, transactions or funds, and no network requests are made. + +Retained fixture SHA-256: + +``` +51bce8f9dc545187702cf1b4bb5e32277a18a0182002836c53fdb289ed7df328 +``` + +It has 57 rows in `schemer_migrations`; `PRAGMA integrity_check` returns `ok`. +The generator's lockfile is retained. Account UUIDs and creation timestamps +are intentionally not deterministic, so regenerated SQLite bytes will have a +different checksum while preserving the same semantic fixture. Never replace +this fixture with a database produced by the SDK being tested. + +From the repository root, write a new output path (the generator refuses to +overwrite an existing database): + +```sh +RUSTC_WRAPPER='' CARGO_INCREMENTAL=0 RUSTFLAGS='' \ + CARGO_TARGET_DIR=/private/tmp/argos-pre-nu7-fixture-target \ + cargo +1.88 run --offline --locked --manifest-path tests/regtest/legacy-wallet-db/Cargo.toml \ + -- /private/tmp/argos-legacy-wallet-new.sqlite +``` + +The old fixture generator deliberately uses its own target, outside the NU7 +build lane. The reproduction command bypasses optional compiler wrappers for +this historical SDK build; it does not change production project settings. + +`pre_nu7_database_migrates_without_losing_account_or_scan_work` copies this +fixture to a temporary directory, runs the new SDK initializer, checks account +identity and scan work, advances the recorded tip across NU7, checks SQLite +integrity, then closes and opens it again. The retained fixture is never +migrated in place. diff --git a/tests/regtest/legacy-wallet-db/pre-nu7.sqlite b/tests/regtest/legacy-wallet-db/pre-nu7.sqlite new file mode 100644 index 00000000..dc3d442b Binary files /dev/null and b/tests/regtest/legacy-wallet-db/pre-nu7.sqlite differ diff --git a/tests/regtest/legacy-wallet-db/src/main.rs b/tests/regtest/legacy-wallet-db/src/main.rs new file mode 100644 index 00000000..eb5b7d39 --- /dev/null +++ b/tests/regtest/legacy-wallet-db/src/main.rs @@ -0,0 +1,32 @@ +//! Generates only a synthetic, empty pre-NU7 wallet database. No network access. +use rand_core::OsRng; +use secrecy::SecretVec; +use zcash_client_backend::data_api::{chain::ChainState, AccountBirthday, WalletWrite}; +use zcash_client_sqlite::{util::SystemClock, wallet::init::init_wallet_db, WalletDb}; +use zcash_primitives::block::BlockHash; +use zcash_protocol::consensus::{BlockHeight, Network}; + +fn main() { + let destination = std::env::args().nth(1).expect("output database path"); + assert!( + !std::path::Path::new(&destination).exists(), + "refuse to overwrite a database" + ); + let mut db = + WalletDb::for_path(&destination, Network::TestNetwork, SystemClock, OsRng).unwrap(); + init_wallet_db(&mut db, Some(SecretVec::new(vec![0x42; 64]))).unwrap(); + let birthday = AccountBirthday::from_parts( + ChainState::empty(BlockHeight::from_u32(4_465_024), BlockHash([0; 32])), + None, + ); + db.create_account( + "pre-NU7 public fixture", + &SecretVec::new(vec![0x42; 64]), + &birthday, + Some("synthetic-0x42-not-a-wallet"), + ) + .unwrap(); + db.update_chain_tip(BlockHeight::from_u32(4_465_025)) + .unwrap(); + println!("created empty pre-NU7 SDK database at {destination}"); +} diff --git a/tests/regtest/nu7.sh b/tests/regtest/nu7.sh new file mode 100755 index 00000000..579af53a --- /dev/null +++ b/tests/regtest/nu7.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Explicit phase controller for the independent NU7 profile. No funding, keys, +# public networks, automatic VM startup, or destructive resets. +set -euo pipefail +case "${ARGOS_NU7_PROFILE:-full}" in + full) readonly URL=http://127.0.0.1:18252; readonly ACTIVATION=32500 ;; + fast) readonly URL=http://127.0.0.1:18262; readonly ACTIVATION=10 ;; + *) echo 'ARGOS_NU7_PROFILE must be full or fast' >&2; exit 2 ;; +esac +rpc() { + curl --fail --silent --show-error --max-time 120 -H 'Content-Type: application/json' \ + --data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"$1\",\"params\":${2:-[]}}" "$URL" \ + | python3 -c 'import json,sys; r=json.load(sys.stdin); assert not r.get("error"),r; print(json.dumps(r["result"]))' +} +height() { rpc getblockcount; } +case "${1:-status}" in + status) rpc getblockchaininfo; exit 0 ;; + before) target=$((ACTIVATION - 1)) ;; + at) target=$ACTIVATION ;; + after) target=$((ACTIVATION + 1)) ;; + *) echo 'usage: nu7.sh [status|before|at|after]' >&2; exit 2 ;; +esac +current=$(height) +if ((current > target)); then + echo "tip $current is already past requested height $target; refusing to rewind/delete state" >&2 + exit 1 +fi +while ((current < target)); do + count=$((target - current)); ((count <= 500)) || count=500 + rpc generate "[$count]" >/dev/null + next=$(height) + ((next > current && next <= target)) || { echo "unexpected mining progress $current -> $next" >&2; exit 1; } + current=$next + printf '[nu7] height %s / %s\n' "$current" "$target" +done +rpc getblockchaininfo diff --git a/tests/regtest/setup.sh b/tests/regtest/setup.sh index 2d8f17a8..f92d131c 100755 --- a/tests/regtest/setup.sh +++ b/tests/regtest/setup.sh @@ -151,9 +151,9 @@ log "Ironwood (NU6.3) present in the chain's upgrade set" # ── Build the funding helper ─────────────────────────────────────────────── log "building argos-regtest-funder ..." -( cd "$REPO_ROOT" && cargo build -q -p argos-core --features argos-network --bin argos-regtest-funder ) \ +( cd "$REPO_ROOT" && CARGO_INCREMENTAL=0 RUSTFLAGS='' cargo +1.89 build -q -p argos-core --features argos-network --bin argos-regtest-funder ) \ || die "failed to build argos-regtest-funder" -FUNDER="$REPO_ROOT/target/debug/argos-regtest-funder" +FUNDER="${CARGO_TARGET_DIR:-$REPO_ROOT/target}/debug/argos-regtest-funder" readonly FUNDER [ -x "$FUNDER" ] || die "funder binary missing at $FUNDER" @@ -217,7 +217,11 @@ log "mining to height $ZIP212_HEIGHT for ZIP 212 enforcement (needed by the PCZT while :; do height="$(zrpc getblockcount | sed -e 's/.*"result":\([0-9]*\).*/\1/')" [ "$height" -ge "$ZIP212_HEIGHT" ] && break - zrpc generate '[500]' >/dev/null 2>&1 || sleep 2 + # Stop exactly at the ZIP 212 preparation height. A final full 500-block + # batch could cross the dedicated full-profile NU7 boundary at 32,500. + remaining=$((ZIP212_HEIGHT - height)) + batch=$((remaining < 500 ? remaining : 500)) + zrpc generate "[$batch]" >/dev/null 2>&1 || sleep 2 done # ── Clear Zebra's gossip backlog ─────────────────────────────────────────── diff --git a/tests/regtest/zebrad-nu7-fast.toml b/tests/regtest/zebrad-nu7-fast.toml new file mode 100644 index 00000000..fdb59eaf --- /dev/null +++ b/tests/regtest/zebrad-nu7-fast.toml @@ -0,0 +1,35 @@ +# Private NU7 qualification only. Never use a public network or real wallet. +# Matches qualified_params_at(10) in nu7_readiness.rs. +# Fast branch-boundary gate only; ZIP 212 is not yet enforced. +[network] +network = "Regtest" + +[network.testnet_parameters.activation_heights] +BeforeOverwinter = 1 +Overwinter = 1 +Sapling = 1 +Blossom = 1 +Heartwood = 1 +Canopy = 1 +NU5 = 1 +NU6 = 1 +"NU6.1" = 1 +"NU6.2" = 1 +"NU6.3" = 1 +NU7 = 10 + +[state] +ephemeral = false +# CACHE_DIR is supplied by Compose so the entrypoint creates/chowns it. + +[rpc] +listen_addr = "0.0.0.0:18232" +# Host publication is restricted to loopback in Compose. +enable_cookie_auth = false + +[mining] +# Public all-zoo/vote BIP-39 test vector; synthetic regtest coins only. +miner_address = "tmFzBQeQYURQartF8tcvECq1minSJwyERe2" + +[tracing] +use_color = false diff --git a/tests/regtest/zebrad-nu7.toml b/tests/regtest/zebrad-nu7.toml new file mode 100644 index 00000000..9feac915 --- /dev/null +++ b/tests/regtest/zebrad-nu7.toml @@ -0,0 +1,35 @@ +# Private NU7 qualification only. Never use a public network or real wallet. +# Matches qualified_params_at(32500) in nu7_readiness.rs. +# Past ZIP 212 enforcement, for full funded recovery qualification. +[network] +network = "Regtest" + +[network.testnet_parameters.activation_heights] +BeforeOverwinter = 1 +Overwinter = 1 +Sapling = 1 +Blossom = 1 +Heartwood = 1 +Canopy = 1 +NU5 = 1 +NU6 = 1 +"NU6.1" = 1 +"NU6.2" = 1 +"NU6.3" = 1 +NU7 = 32500 + +[state] +ephemeral = false +# CACHE_DIR is supplied by Compose so the entrypoint creates/chowns it. + +[rpc] +listen_addr = "0.0.0.0:18232" +# Host publication is restricted to loopback in Compose. +enable_cookie_auth = false + +[mining] +# Public all-zoo/vote BIP-39 test vector; synthetic regtest coins only. +miner_address = "tmFzBQeQYURQartF8tcvECq1minSJwyERe2" + +[tracing] +use_color = false diff --git a/tests/regtest/zebrad-regtest.toml b/tests/regtest/zebrad-regtest.toml index a614e021..cf072014 100644 --- a/tests/regtest/zebrad-regtest.toml +++ b/tests/regtest/zebrad-regtest.toml @@ -47,6 +47,8 @@ NU6 = 1 "NU6.1" = 1 "NU6.2" = 1 "NU6.3" = 1 +# NU7 is deliberately omitted. Zebra replaces the activation map with these +# explicit entries, so the ordinary fixture chain remains pre-NU7. [state] # Persistent, not ephemeral: setup.sh is idempotent and re-runnable, and the