Expose keyed Blake2b and Blake3 hash builtins - #150
Merged
Conversation
Lower the hash builtins to their script-engine opcodes, require fixed-size Blake3 keys, and add documentation, highlighting, typing, and execution tests.
someone235
requested changes
Jul 19, 2026
| // TODO: Consider requiring byte[] data for all hash builtins so callers | ||
| // must make their serialization choices explicit; numeric values currently | ||
| // hash their minimally encoded Script-number bytes. | ||
| "blake3WithKey" => &[("data", "*"), ("key", "byte[32]")], |
Contributor
There was a problem hiding this comment.
I think it's better to replace * with byte[]
|
|
||
| for (arg, (arg_name, expected_type_name)) in args.iter().zip(expected_args) { | ||
| for (arg, &(arg_name, expected_type_name)) in args.iter().zip(expected_args) { | ||
| if expected_type_name == "*" { |
Contributor
There was a problem hiding this comment.
After applying prev comment, you can revert this change
this currently deviates from other hash fns, but they are expected to catch up to this behavior, hence no need to introduce a temp wild card "*" mechanism
someone235
approved these changes
Jul 19, 2026
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.
Adds direct compiler support for:
All return
byte[32]and lower to the corresponding script-engine opcodes. The existingblake2bbuiltin is documented alongside them.Type details:
blake2bbehavior and may be any stack value. Callers remain responsible for serialization; numeric values use minimally encoded Script-number bytes (see TODO instatic_check.rs)byte[], up to the engine’s 64-byte limit.byte[32]. A dynamicbyte[]requires an explicitbyte[32](key)cast.Tests compare the compiled builtins against reference Blake2b and Blake3 implementations and execute the resulting scripts.