Expand description
BLAKE3 compression codegen for Bitcoin Script.
Port of packages/runar-compiler/src/passes/blake3-codegen.ts.
emit_blake3_compress: [chainingValue(32 BE), block(64 BE)] -> [hash(32 BE)] emit_blake3_hash: [message(<=64 BE)] -> [hash(32 BE)]
Architecture (same as sha256.rs):
- All 32-bit words stored as 4-byte little-endian during computation.
- LE additions via BIN2NUM/NUM2BIN (13 ops per add32).
- Byte-aligned rotations (16, 8) via SPLIT/SWAP/CAT on LE (4 ops).
- Non-byte-aligned rotations (12, 7) via LE->BE->rotrBE->BE->LE (31 ops).
- BE<->LE conversion only at input unpack and output pack.
Stack layout during rounds: [m0..m15, v0..v15] (all LE 4-byte values) v15 at TOS (depth 0), v0 at depth 15, m15 at depth 16, m0 at depth 31.
Functions§
- emit_
blake3_ compress - Emit BLAKE3 single-block compression in Bitcoin Script. Stack on entry: […, chainingValue(32 BE), block(64 BE)] Stack on exit: […, hash(32 BE)] Net depth: -1
- emit_
blake3_ hash - Emit BLAKE3 hash for a message up to 64 bytes. Stack on entry: […, message(<=64 BE)] Stack on exit: […, hash(32 BE)] Net depth: 0