appliedzkp zkevm中的Bytecode Proof

Posted mutourend

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了appliedzkp zkevm中的Bytecode Proof相关的知识,希望对你有一定的参考价值。

1. 引言

bytecode proof可帮助EVM proof,使得bytecode更易于访问(bytecode以其code hash来标识)。bytecode中的每个byte可通过其在该bytecode中的位置来访问。同时标注了一个flag来标识该byte 是一个opcode 还是 给前一PUSH指令的data。

2. Bytecode Circuit Layout

ColumnDescription
q_first1 on the first row, else 0
q_last1 on the last row, else 0
hashThe keccak hash of the bytecode
tagTag indicates whether value is a byte or length of the bytecode
indexThe position of the byte in the bytecode
valueThe byte data for the current position, or length of the bytecode
is_code1 if the byte is code, 0 if the byte is PUSH data
push_data_leftThe number of PUSH data bytes that still follow the current row
hash_rlcThe accumulator containing the current and previous bytes
hash_lengthThe bytecode length
byte_push_sizeThe number of bytes pushed for the current byte
is_final1 if the current byte is the last byte of the bytecode, else 0
padding1 if the current row is padding, else 0
push_data_left_invThe inverse of push_data_left (IsZeroChip helper)
push_table.bytePush Table: A byte value
push_table.push_sizePush 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

以上是关于appliedzkp zkevm中的Bytecode Proof的主要内容,如果未能解决你的问题,请参考以下文章

appliedzkp的zkevm概览

appliedzkp zkevm(11)中的EVM Proof

appliedzkp的zkevm定制化Proof System

appliedzkp的zkevm(12)State Proof

appliedzkp的zkevmBus mapping

appliedzkp的zkevmWord Encoding