Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo in test vector comment #15

Closed
riastradh opened this issue Jan 11, 2020 · 1 comment
Closed

Typo in test vector comment #15

riastradh opened this issue Jan 11, 2020 · 1 comment

Comments

@riastradh
Copy link

The comment in test_vectors.json says:

For derive_key, the test input is used as the input key, and the context string is 'BLAKE3 2019-12-27 16:29:52 example context'.

"_comment": "Each test is an input length and three outputs, one for each of the hash, keyed_hash, and derive_key modes. The input in each case is filled with a 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The key used with keyed_hash is the 32-byte ASCII string given in the 'key' field below. For derive_key, the test input is used as the input key, and the context string is 'BLAKE3 2019-12-27 16:29:52 example context'. (As good practice for following the security requirements of derive_key, test runners should make that context string a hardcoded constant, and we do not provided it in machine-readable form.) Outputs are encoded as hexadecimal. Each case is an extended output, and implementations should also check that the first 32 bytes match their default-length output.",

However, the test vectors were actually computed with the context string BLAKE3 2019-12-27 16:29:52 test vectors context. Citations:

pub const TEST_CONTEXT: &str = "BLAKE3 2019-12-27 16:29:52 test vectors context";

let mut derive_key_out = [0; OUTPUT_LEN];
blake3::Hasher::new_derive_key(TEST_CONTEXT)
.update(&input)
.finalize_xof()
.fill(&mut derive_key_out);

By following the source code rather than the comment, I am able to reproduce the test vectors with my independent implementation of BLAKE3.

@oconnor663
Copy link
Member

UGGGH, I can't believe I messed this up. Thank you for catching it. Will update the comment immediately.

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

No branches or pull requests

2 participants