feat: add blake3 extension #2351
Draft
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.
[Draft] feat: BLAKE3 VM Extension
Summary
Adds a BLAKE3 hashing extension to OpenVM, following the existing extension architecture pattern (SHA256, Keccak). The extension provides accelerated BLAKE3 hashing for guest programs via a custom RISC-V instruction.
Architecture
Guest Layer (
extensions/blake3/guest)opcode=0x0b,funct3=0b100,funct7=0x02zkvm_blake3_implfor guest programsTranspiler (
extensions/blake3/transpiler)0x330Circuit (
extensions/blake3/circuit)Blake3VmExecutor: Runtime execution, produces recordsBlake3VmFiller: Trace generation from execution recordsBlake3VmAir: Constraints wrapping p3-blake3-air compression + VM integrationKnown Limitation
This implementation does not produce standard BLAKE3 hashes.
The circuit uses
p3-blake3-airwhich has hardcoded compression parameters:counterblock_lenflagsThis is by design in p3-blake3-air—it's intended as an internal ZK primitive for Plonky3 (FRI, Merkle trees), not for user-facing BLAKE3 hashing.
Impact: The hash output from this extension will not match the standard
blake3crate for any input.Path Forward
To achieve standard BLAKE3 compatibility:
counter,block_len,flagsas witness inputs rather than deriving from batch metadataThe VM integration in this PR (executor, filler, memory bus, execution bridge) is reusable—only the core compression AIR needs replacement.
Testing
test_blake3_matches_standard- Intentionally fails to document the incompatibilityChecklist