CodeDecommitter
CodeDecommitter PI
Input
pub struct CodeDecommitterInputData<F: SmallField> {
pub memory_queue_initial_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub sorted_requests_queue_initial_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
}Output
pub struct CodeDecommitterOutputData<F: SmallField> {
pub memory_queue_final_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
}FSM Input and FSM Output
pub struct CodeDecommitterFSMInputOutput<F: SmallField> {
pub internal_fsm: CodeDecommittmentFSM<F>,
pub decommittment_requests_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub memory_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
}
pub struct CodeDecommittmentFSM<F: SmallField> {
pub sha256_inner_state: [UInt32<F>; 8], // 8 uint32 words of internal sha256 state
pub hash_to_compare_against: UInt256<F>,
pub current_index: UInt32<F>,
pub current_page: UInt32<F>,
pub timestamp: UInt32<F>,
pub num_rounds_left: UInt16<F>,
pub length_in_bits: UInt32<F>,
pub state_get_from_queue: Boolean<F>,
pub state_decommit: Boolean<F>,
pub finished: Boolean<F>,
}Main circuit logic
This circuit takes a queue of decommit requests for DecommitSorter circuit. For each decommit request, it checks that the linear hash of all opcodes will be equal to this hash that is stored in the decommit request. Also, it writes code to the corresponding memory page. Briefly, it unpacks the queue from the opcode and updates the memory queue and check correctness.
First part
The circuit begins with allocating input part of the PI.
We chose what memory_queue state and decommitments_queue state to continue to work with.
We do the same with inner FSM part.
Main part
Here’s the part, where all the main logic is implemented. Firstly, we take a new decommit request if the queue is not empty yet.
Then we update the state of the circuit.
Then we create two write memory queries and push them to memory queue.
Now we create a new input for hash to be absorbed.
And absorb it to current state.
Also, we update current state.
Finally, we check the hash if necessary.
Final part
Now we update PI output parts and compute a commitment. Then we allocate it as public variables.
Last updated