Repository navigation
Add BLAKE3 keyed, derive-key and 64-byte XOF modes - #259
Merged
RobinLinus merged 2 commits intoOct 16, 2026
Merged
Conversation
The short direct-u4 BLAKE3 profile only produced the unkeyed digest. Keyed and derive-key modes differ from unkeyed hashing only in the root compression's input chaining value and one flag, so with a key or context fixed when the script is generated they cost the same as unkeyed hashing. Derive-key contexts must be hardcoded, so the context phase runs on the host and only the material phase is in Script. The first 64 bytes of the XOF stream are the complete root compression output. Its second half, state[i+8] ^ cv[i], was already computed and then dropped; returning it needs no extra compression. blake3_short_mode_compute_script exposes all three modes with 16-, 32- or 64-byte output. Unkeyed scripts are unchanged. Tests check the official extended vectors and every length up to 32 against the blake3 crate under the strict stack limit, plus malformed inputs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Several negative results overstated what was impossible or costly: - NR-060 and the XOF record claimed a 64-byte output needs an extra compression; it is the complete root output. - NR-069 and the keyed record claimed keyed mode changes witness shape and routing; with a fixed key it only changes constants. - NR-061 claimed derive-key must duplicate the compression schedule; the hardcoded context phase can run on the host. - NR-071 called the u4 MSB lookup dominated, but it is six bytes smaller; it is a bytes-for-stack tradeoff. Record the new measurements, close OP-024, OP-025 and OP-028, add the catalog configurations, and remove a duplicated merge remnant in NR-042. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several negative results in
knowledge/negative-results/claimed things were impossible or costly when they are not. This PR implements three of them and corrects the records.v[i+8] ^ cv[i], was already computed and dropped. Returning it needs no extra compression.New API:
blake3_short_mode_compute_script(len, Blake3Mode, output_len)for messages up to 32 bytes, with 16-, 32- or 64-byte output.Measurements (32-byte message
00 01 ... 1f)All rows use 64 checked u4 data items and zero hint items. The peak is the strict combined stack peak, including the output verifier.
Script size varies slightly with the key; an all-
0x42key gives 59,557. Evidence isdifferentially-validated; deployment isunclassified.Still not implemented
A fixed key is visible in the revealed leaf.
Test plan
cargo test --locked -- --skip fields::(all pass; existing BLAKE3 metric snapshots unchanged)python3 tools/kb.py validateblake3crateblake3_short_mode_metrics_are_current🤖 Generated with Claude Code