This repository contains Noir primitives necessary for
- RLP decoding in the form of look-up table construction
- Ethereum state and storage proof verification (or verification of any trie proof involving 32-byte long keys)
A Rust crate is also provided for the purpose of data preprocessing and reproducibility of some of the examples provided (cf. Rust component).
The following subsections elaborate on potential use-cases, which are centred around RLP list decoding and storage and state trie proof verification. Though the methods here do not cover other interesting trie proof verification use-cases, e.g. the case of variable key length, the building blocks are provided. For more information, consult lib/src/rlp.nr
and lib/src/lib.nr
.
MAX_LEN_IN_BYTES
represents the maximum permissible byte length of the length of an RLP payload and is set to 2. This is required for technical reasons and implies that the decoding functions below are only applicable to payloads of byte length less than2^16
.STRING
andLIST
form an enum representing the string and list type respectively.
To streamline RLP decoding, two types are provided:
RLP_Header
represents an RLP header and has fields for the offset of the RLP payload (offset: Field
), the byte length of the payload (length: Field
) and the data type of the payload (data_type: Field
), i.e. whether the payload represents a sequence of bytes (STRING
) or a list of elements (LIST
), i.e. the concatenation of RLP-encoded bytes.RLP_List<NUM_FIELDS>
represents a decoded RLP list in the form of a look-up table. It has fields for the offsets of the elements of this list (offset: [Field; NUM_FIELDS]
), their byte lengths (length: [Field; NUM_FIELDS]
), their data types (data_type: [Field; NUM_FIELDS]
) and the number of elements in the list (num_fields: Field
).NUM_FIELDS
should be chosen large enough so thatnum_fields <= NUM_FIELDS
.