Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7340991
Make it possible to generate testnet test vectors for ZIP 320 addresses.
nuttycom May 16, 2024
db9c9b9
Merge pull request #99 from nuttycom/zip_0320_testnet_tv
nuttycom Jul 22, 2024
580dc95
Add Orchard ZIP 32 test vectors
str4d Oct 1, 2024
346740a
Modify the `regenerate` script to be more user-friendly.
nuttycom Oct 1, 2024
bff71ae
Generate test vectors for orchard_zip32
nuttycom Oct 1, 2024
5b76d4b
Merge pull request #102 from zcash/orchard-zip32
nuttycom Oct 24, 2024
ff8eb51
Extract ZIP 32 hardened-only key derivation from Orchard
str4d Nov 2, 2024
f80ca40
Add test vectors for ZIP 32 arbitrary key derivation
str4d Nov 2, 2024
53cc8e2
Merge pull request #103 from zcash/arbitrary-key-derivation
str4d Nov 13, 2024
4505cb8
Improve the ZIP 32 arbitrary key derivation test vectors
str4d Nov 13, 2024
2a08204
Add ZIP 32 arbitrary key derivation test vector to ZIP 32 account
str4d Nov 13, 2024
1ac6808
Merge pull request #104 from zcash/improve-arbitrary-key-tvs
str4d Nov 15, 2024
ced24bc
Update authors.
daira Feb 17, 2025
9dc587d
Update Rust output to use `const`.
daira Feb 17, 2025
92f2ff2
Refactor output to allow (but not yet use) `&'static [T]` and the cas…
daira Feb 17, 2025
7de2348
Use `&'static` arrays in `zip_0032_arbitrary` Rust test vectors.
daira Feb 20, 2025
0f20d79
Update `CKDh` to match ZIP 32 changes.
daira Feb 20, 2025
cbfe5ed
Add test vectors for `zip_0032_registered`.
daira Feb 20, 2025
ba707b1
Merge pull request #105 from daira/add-registered-test-vectors
str4d Feb 20, 2025
218372b
Merge branch 'master' into merge_master_20250408
ConstanceBeguier Apr 8, 2025
c79cd3a
Merge branch 'zsa1' into merge_master_20250408
ConstanceBeguier Apr 24, 2025
483e640
Run rustfmt on generated rust files
ConstanceBeguier May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/test_vectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ jobs:
kind: ['rust', 'json', 'zcash']
include:
- kind: 'rust'
extension: 'rs'
name: 'Rust'
- kind: 'json'
extension: 'json'
name: 'JSON'
- kind: 'zcash'
extension: 'json'
name: 'Bitcoin-flavoured JSON'
fail-fast: false

Expand All @@ -40,7 +37,7 @@ jobs:
run: poetry install --no-root

- name: Regenerate test vectors
run: ./regenerate.sh ${{ matrix.kind }} ${{ matrix.extension }}
run: ./regenerate.sh ${{ matrix.kind }} all

- name: Verify there are no changes
run: git diff; git ls-files --others --exclude-standard; test -z "$(git status --porcelain)"
76 changes: 42 additions & 34 deletions poetry.lock

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

15 changes: 11 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
description = "Zcash test vectors"
authors = [
"Jack Grigg <jack@z.cash>",
"Daira Hopwood <daira@jacaranda.org>",
"ying tong <yingtong@z.cash>",
"Daira-Emma Hopwood <daira@jacaranda.org>",
"Ying Tong Lai <yingtong@ethereum.org>",
"Taylor Hornby <taylor@defuse.ca>",
"Kris Nuttycombe <kris@electriccoin.co>",
"Simon <simon@bitcartel.com>",
Expand All @@ -21,9 +21,13 @@ classifiers = [
"Private :: Do Not Upload",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
python = "^3.8"
numpy = "1.23.3"
python = "^3.9"
numpy = "1.26.4"
chacha20poly1305 = "0.0.3"
cryptography = "38.0.1"
secp256k1 = "0.14.0"
Expand All @@ -37,6 +41,8 @@ f4jumble_long = "zcash_test_vectors.f4jumble:long_test_vectors"
unified_address = "zcash_test_vectors.unified_address:main"
unified_full_viewing_keys = "zcash_test_vectors.unified_full_viewing_keys:main"
unified_incoming_viewing_keys = "zcash_test_vectors.unified_incoming_viewing_keys:main"
zip_0032_registered = "zcash_test_vectors.zip_0032:registered_key_derivation_tvs"
zip_0032_arbitrary = "zcash_test_vectors.zip_0032:arbitrary_key_derivation_tvs"
zip_0143 = "zcash_test_vectors.zip_0143:main"
zip_0243 = "zcash_test_vectors.zip_0243:main"
zip_0244 = "zcash_test_vectors.zip_0244:main"
Expand Down Expand Up @@ -65,6 +71,7 @@ orchard_note_encryption = "zcash_test_vectors.orchard.note_encryption:main"
orchard_poseidon = "zcash_test_vectors.orchard.poseidon:main"
orchard_poseidon_hash = "zcash_test_vectors.orchard.poseidon:hash_test_vectors"
orchard_sinsemilla = "zcash_test_vectors.orchard.sinsemilla:main"
orchard_zip32 = "zcash_test_vectors.orchard.zip32:main"

# OrchardZSA test vectors
orchard_zsa_asset_base="zcash_test_vectors.orchard_zsa.asset_base:main"
Expand Down
124 changes: 88 additions & 36 deletions regenerate.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,93 @@
#!/usr/bin/env bash

tv_scripts=(
bip_0032
f4jumble
f4jumble_long
orchard_empty_roots
orchard_generators
orchard_group_hash
orchard_key_components
orchard_map_to_curve
orchard_merkle_tree
orchard_note_encryption
orchard_poseidon
orchard_poseidon_hash
orchard_sinsemilla
orchard_zsa_asset_base
orchard_zsa_issuance_auth_sig
orchard_zsa_key_components
orchard_zsa_note_encryption
sapling_generators
sapling_key_components
sapling_note_encryption
sapling_signatures
sapling_zip32
sapling_zip32_hard
unified_address
unified_full_viewing_keys
unified_incoming_viewing_keys
zip_0143
zip_0243
zip_0244
orchard_zsa_digests
zip_0316
zip_0320)
case "$1" in
"rust" )
gen_types=(rust)
;;
"zcash" )
gen_types=(zcash)
;;
"json")
gen_types=(json)
;;
"all")
gen_types=(rust zcash json)
;;
*)
echo "Unexpected generation type: $1"
exit 1
;;
esac

for generator in "${tv_scripts[@]}"
case "$2" in
"all" )
tv_scripts=(
bip_0032
f4jumble
f4jumble_long
orchard_empty_roots
orchard_generators
orchard_group_hash
orchard_key_components
orchard_map_to_curve
orchard_merkle_tree
orchard_note_encryption
orchard_poseidon
orchard_poseidon_hash
orchard_sinsemilla
orchard_zsa_asset_base
orchard_zsa_issuance_auth_sig
orchard_zsa_key_components
orchard_zsa_note_encryption
orchard_zip32
sapling_generators
sapling_key_components
sapling_note_encryption
sapling_signatures
sapling_zip32
sapling_zip32_hard
unified_address
unified_full_viewing_keys
unified_incoming_viewing_keys
zip_0032_registered
zip_0032_arbitrary
zip_0143
zip_0243
zip_0244
orchard_zsa_digests
zip_0316
zip_0320)
;;
*)
tv_scripts=($2)
;;
esac

for gen_type in "${gen_types[@]}"
do
echo "# $generator"
poetry run $generator -t $1 >test-vectors/$1/$generator.$2
echo "Generating $gen_type test vectors..."
case "$gen_type" in
"rust" )
extension="rs"
;;
"zcash" )
extension="json"
;;
"json")
extension="json"
;;
esac

for generator in "${tv_scripts[@]}"
do
echo "# $generator"
poetry run $generator -t $gen_type >test-vectors/$gen_type/$generator.$extension
done

if [ "$gen_type" = "rust" ]; then
echo "Running rustfmt on generated Rust files..."
rustfmt --edition 2021 test-vectors/rust/*.rs
fi

echo "Finished $gen_type."
Comment thread
ConstanceBeguier marked this conversation as resolved.
done
8 changes: 8 additions & 0 deletions test-vectors/json/orchard_zip32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
["From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/orchard_zip32.py"],
["sk, c, xsk, fp"],
["7eee3c1017870990a3dd6891b82f80be8976c1e7dc20d60817a5e88e8b2cd4b8", "ab8b7a00509ef20e469b5292b61d474b7cffcb1657924cda720250ae40526677", "000000000000000000ab8b7a00509ef20e469b5292b61d474b7cffcb1657924cda720250ae405266777eee3c1017870990a3dd6891b82f80be8976c1e7dc20d60817a5e88e8b2cd4b8", "ff4cda5002c8d182058807b84e616b6d339e1bbeecea01650568d891a438e706"],
["98d703fcb40504c95b3b6ed10ecd50082cff97dfd1dd9aa0913c78f977c962af", "6a041dfb9cfebee97cb1854fdc481cc04f02c9577aa6f13b2c445b80a9669a22", "01ff4cda50010000806a041dfb9cfebee97cb1854fdc481cc04f02c9577aa6f13b2c445b80a9669a2298d703fcb40504c95b3b6ed10ecd50082cff97dfd1dd9aa0913c78f977c962af", "32bbdc921d066f235dc93e913b8fe1fd5b9f7f6a13d56f18ec0d3620d1f7b9a6"],
["99afd8894baad58784d0ec08f5148ee2c2a17b2b294b08ef9e0a0cf14bcc0920", "6da8b57a36c77ad6412a9dc0115f12aced0ee01c402a0cf0a507cb17fc7bbd1d", "0232bbdc92020000806da8b57a36c77ad6412a9dc0115f12aced0ee01c402a0cf0a507cb17fc7bbd1d99afd8894baad58784d0ec08f5148ee2c2a17b2b294b08ef9e0a0cf14bcc0920", "36a57c4fc5b8b4a3d62f22a5500878f393856b7ecce771ad597ca964b98637d9"],
["96439ea348a4b2ce4ec7beb4543c70274c8f76495d60c5fa5f018b68f3c32367", "b196e9b5809d76577a8944c3f8c8a83f93f0c8f5ace6e7bc9ce4396c034d93fe", "0336a57c4f03000080b196e9b5809d76577a8944c3f8c8a83f93f0c8f5ace6e7bc9ce4396c034d93fe96439ea348a4b2ce4ec7beb4543c70274c8f76495d60c5fa5f018b68f3c32367", "be1a1b661d2ca319822a32550d6dc488b6571e0cd781d5078b8f7ba366ddd368"]
]
11 changes: 11 additions & 0 deletions test-vectors/json/zip_0032_arbitrary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
["From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0032_arbitrary.py"],
["context_string, seed, ikm, path, sk, c"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "125a63617368207465737420766563746f727320000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", [], "e9da8806409dc3c3ebd1fc2a71c879c13dd7aa93ede803bf1a83414b9d3b158a", "65a748f2905f7a8aab9f3d02f1b26c3d65c82994ce59a086d4c651d8a81cec51"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483649], "e8409aaa832cc2378f2badeb77150562153742fee876dcf4783a6ccd119da66a", "cc084922a0ead2da5338bd82200a1946bc8585b8d9ee416df6a09a71ab0e5b58"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483649, 2147483650], "464f90a364cff805fee93a85b72f4894ce4e1358dcdc1e61a3d430301c60910e", "f9d2544a5528ae6bd9f036f42f9f05d83dff507aeb2a8141af11d9f167e221ae"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483649, 2147483650, 2147483651], "fc4b6e93b0e42f7a762ca0c6522ccd1045cab506b372452af7306c87389ab62c", "e89bf2ed73f5e0887542e36793fac82c508ab5d99198578227b241fbac198429"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483680], "c430c4defd03d7578b2bb09e58135cdd1d7b7c975f01a890847ee0b5c468bc98", "0f473789fe7d5585b79ad5f7e0a469d9a30146647764485150db78d7209dcb30"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483680, 2147483781], "43e5484679fdfa0f6176ae86795d0d44c40e149ef4ba1b0e2ebd883c71f49187", "db42c3b725f32459b2cf8215418b8e8f8e7b1b3f4aba2f5b5e8129e6f0575784"],
["5a63617368207465737420766563746f7273", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", null, [2147483680, 2147483781, 2147483648], "bf60078362a09234fcbc6bf6c8a87bde9fc73776bf93f37adbcc439a85574a9a", "2b657e08f67a570c53b9ed30611e6a2f822662b4887a8cfb469e9d0d9817011a"]
]
Loading