Skip to content

Improve the ZIP 32 arbitrary key derivation test vectors#104

Merged
str4d merged 2 commits into
masterfrom
improve-arbitrary-key-tvs
Nov 15, 2024
Merged

Improve the ZIP 32 arbitrary key derivation test vectors#104
str4d merged 2 commits into
masterfrom
improve-arbitrary-key-tvs

Conversation

@str4d
Copy link
Copy Markdown
Contributor

@str4d str4d commented Nov 13, 2024

When using them, I forgot that bytes(range(32)) doesn't generate an all-zeroes seed of length 32, so I was using the wrong seed with the test vectors and they were failing. We now embed that seed in the test vectors, along with the context string (to make it clear that there is no trailing null byte) and the IKM (which is what clued me into the seed being wrong).

When using them, I forgot that `bytes(range(32))` doesn't generate an
all-zeroes seed of length 32, so I was using the wrong seed with the
test vectors and they were failing. We now embed that seed in the test
vectors, along with the context string (to make it clear that there is
no trailing null byte) and the IKM (which is what clued me into the seed
being wrong).
Copy link
Copy Markdown
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK with doc suggestion


keys = [m, m_1h, m_1h_2h, m_1h_2h_3h]
# Derive a path matching Zcash mainnet account index 0.
m_32h = m.child(hardened(32))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it would be nice to link to https://zips.z.cash/zip-0032#key-path-levels here. Also I note that ZIP 32 doesn't explicitly mention coin type 133 in this section, it probably should.

["e8409aaa832cc2378f2badeb77150562153742fee876dcf4783a6ccd119da66a", "cc084922a0ead2da5338bd82200a1946bc8585b8d9ee416df6a09a71ab0e5b58"],
["464f90a364cff805fee93a85b72f4894ce4e1358dcdc1e61a3d430301c60910e", "f9d2544a5528ae6bd9f036f42f9f05d83dff507aeb2a8141af11d9f167e221ae"],
["fc4b6e93b0e42f7a762ca0c6522ccd1045cab506b372452af7306c87389ab62c", "e89bf2ed73f5e0887542e36793fac82c508ab5d99198578227b241fbac198429"]
["context_string, seed, ikm, path, sk, c"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@str4d str4d merged commit 1ac6808 into master Nov 15, 2024
@str4d str4d deleted the improve-arbitrary-key-tvs branch November 15, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants