1. 引言
bytecode proof可帮助EVM proof,使得bytecode更易于访问(bytecode以其code hash来标识)。bytecode中的每个byte可通过其在该bytecode中的位置来访问。同时标注了一个flag来标识该byte 是一个opcode 还是 给前一PUSH指令的data。
2. Bytecode Circuit Layout ColumnDescriptionq_first
1
on the first row, else 0
q_last
1
on the last row, else 0
hash
The keccak hash of the bytecodetag
Tag indicates whether value
is a byte or length of the bytecodeindex
The position of the byte in the bytecodevalue
The byte data for the current position, or length of the bytecodeis_code
1
if the byte is code, 0
if the byte is PUSH datapush_data_left
The number of PUSH data bytes that still follow the current rowhash_rlc
The accumulator containing the current and previous byteshash_length
The bytecode lengthbyte_push_size
The number of bytes pushed for the current byteis_final
1
if the current byte is the last byte of the bytecode, else 0
padding
1
if the current row is padding, else 0
push_data_left_inv
The inverse of push_data_left
(IsZeroChip
helper)push_table.byte
Push Table: A byte valuepush_table.push_size
Push Table: The number of bytes pushed for this byte as opcode
3. Push lookup table
push lookup table用于find how many bytes an opcode pushes,用于探测哪个byte是code,哪个byte不是code。
由于会对每个byte进行lookup,该table也可间接用于range check the byte inputs。
ByteNum bytes pushed[0, OpcodeId::PUSH1]0
[OpcodeId::PUSH1, OpcodeId::PUSH32][1..32]
[OpcodeId::PUSH32, 256]0
3.1 Circuit behavior
该circuit 以通过设置tag = Length
添加bytecode length的行 开始,然后自位置0开始,遍历该bytecode的所有bytes。
[1] zkevm-specs Bytecode Proof