Skip to main content

Module hasher

Module hasher 

Source
Expand description

The verifier’s hasher: one BLAKE3 lane for every record in flight.

§The problem

Besides the chain steps, checking a signature takes 29 BLAKE3 compressions, in three independent strands:

StrandCompressionsDepends on
A: digest, then Merkle levels 0..61 + 7, one after the otherthe loaded record
C0: commitment chunk 0 (blocks 0..15), then the parent16 + 1all chain ends; the parent also needs C1
C1: commitment chunk 1 (blocks 16..19)4all chain ends

Inside a strand every compression needs the one before it, 33 cycles earlier. One record alone would leave the lane idle most of the time.

§The idea: interleave many records

The lane accepts one compression per clock from any record. Every clock the scheduler looks at all 64 contexts, finds the strands whose next compression may start, and issues the oldest record’s (C0 before C1 before A within a record). With about 20 records in flight the lane is busy 29 out of every 35 cycles, which matches the chain lanes’ 35-cycle period.

  cycle t      t+1               t+2   t+3                  t+4        t+32       t+33
  pick ──▶ read header/CV RAMs, ──▶ ··· ─▶ build the block ─▶ BLAKE3 ─··─▶ result ─▶ CV write,
  (ctx,       ask chains for row               (row arrives)     28 stages             compare,
  strand)                                                                              digits

§Storage per context

RAMRowsWritten by
header0 digest block pk_hash ‖ nonce ‖ message; 1 sib0 ‖ pk_hash; 2 sib1 ‖ sib2; 3 sib3 ‖ sib4; 4 sib5 ‖ sib6the loader
checkroot ‖ pk_hash (the two values results are compared with)the loader
CV m, CV 0, CV 1the running chaining value of strands A, C0, C1results

§Results

  • The digest’s 64 output bytes become the 68 digits (low 2 bits of each byte, then the base-4 checksum Σ(3 − d)), sent to the chain block.
  • Merkle level 6’s output is compared with the commitment’s root.
  • The parent’s output is compared with pk_hash.

A context is HasherOutput::done after both comparisons; its two answers are HasherOutput::merkle_ok and HasherOutput::chains_ok.

Structs§

CheckWrite
The two values a context’s results are compared with.
HasherInput
Inputs of the hasher.
HasherOutput
Outputs of the hasher.
HeaderWrite
One header-RAM row write (ctx·8 + row).
Loaded
A record is fully loaded: strand A may start.
VerifyHasher
The hasher: one BLAKE3 lane, its scheduler, and the per-context RAMs.

Functions§

digits_kernel
The 68 digits of a digest output: low 2 bits of bytes 0..64, then the base-4 checksum Σ (3 − d) = 192 − Σ d, least significant digit first.
first_set_kernel
Lowest set bit of 64, as (found, index), in two levels of eight.
index_bit_kernel
Bit level of a 7-bit key index (the side of the running hash).
oldest_first_kernel
First set bit at or after start (wrapping), as (found, index).
verify_hasher_kernel
The hasher’s logic.