MerkleCRH

Message decomposition

is used in the hash function. The input to is:

where:

  • ,
  • ,
  • ,

with and are allowed to be non-canonical -bit encodings.

We break these inputs into the following MessagePieces:

are constrained by the to be bits, bits, and bits respectively.

In a custom gate, we check this message decomposition by enforcing the following constraints:


  1. , the index-1 running sum output of , is copied into the gate. has been constrained by the to be bits. We recover the subpieces using : is loaded into a fixed column at each layer of the hash. It is used both as a gate selector, and to fix the value of . We check that

Note: The reason for using instead of is that when (hashing two leaves). We cannot have a zero-valued selector, since a constraint gated by a zero-valued selector is never checked.


  1. , the index-1 running sum output of , is copied into the gate. has been constrained by the to be bits. We witness the subpieces outside this gate, and constrain them each to be bits. Inside the gate, we check that We also recover the subpiece using :

We have now derived or witnessed every subpiece, and range-constrained every subpiece:

  • ( bits), derived as ;
  • ( bits), equal to ;
  • ( bits), derived as ;
  • ( bits) is witnessed and constrained outside the gate;
  • ( bits) is witnessed and constrained outside the gate;
  • is constrained to equal , and we use them to reconstruct the original field element inputs:

Circuit components

The Orchard circuit spans advice columns while the chip only uses advice columns. We distribute the path hashing evenly across two chips to make better use of the available circuit area. Since the output from the previous layer hash is copied into the next layer hash, we maintain continuity even when moving from one chip to the other.