L1MessagesHasher
L1MessagesHasher PI
Input
pub struct LinearHasherInputData<F: SmallField> {
pub queue_state: QueueState<F, QUEUE_STATE_WIDTH>,
}Output
pub struct LinearHasherOutputData<F: SmallField> {
pub keccak256_hash: [UInt8<F>; 32],
}FSM Input and FSM Output
() // this circuit has big capacity, so we don't need several instancesMain circuit logic
It takes a queue of L1 messages and hash everything with keccak.
The main logic is implemented in linear_hasher_entry_point function here.
It can be spited into 3 parts:
First part
Firstly, we allocate the “input” part of PI (start flag, Input and FSM Input):
Also, we do some checks for them and allocate empty hash state:
Main part
This part is the main one. We run a loop with some limit, where on each iteration we try to pop the next element from the queue, if it’s not empty.
Then we absorb it to the buffer, and if it’s full we run a round function.
If this element was the last one, we create a padding and run a round function.
Final part
Firstly, we verify that the queue is empty now.
Then we compute the final hash and create an output.
Finally, we compute a commitment to PI and allocate it as witness variables.
Last updated