Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
zkevm-circuits
zkevm-circuits
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

  • zkp
  • zkevm-circuitszkevm-circuits
  • Wiki
    • Zkevm docs
  • 11 fixed

11 fixed · Changes

Page history
correct fixed doc authored Apr 24, 2024 by sen0324's avatar sen0324
Show whitespace changes
Inline Side-by-side
Showing with 8 additions and 10 deletions
+8 -10
  • zkevm-docs/11-fixed.markdown zkevm-docs/11-fixed.markdown +8 -10
  • No files found.
zkevm-docs/11-fixed.markdown
View page @ 37d3fcc9
......@@ -2,12 +2,12 @@
Fixed circuit是在电路初始化阶段预先向fixed_table填入一些cell数据,在后续电路运行过程中进行lookup查表操作;
当前fixed_table填入了几种类型的数据:1. evm opcode的信息,2. 8bit范围内数据的与、或、异或操作结果,3. 10bit、16bit可表示的全量的数据,用于数据的范围证明。注意,10bit数据我们的数据是1-1024,不是0-1023。16bit数据是0-65535。
当前fixed_table填入了几种类型的数据:1. evm opcode的信息,2. 8bit范围内数据的与、或操作结果,3. 10bit、16bit可表示的全量的数据,用于数据的范围证明。注意,10bit数据我们的数据是1-1024,不是0-1023。16bit数据是0-65535。
## Witness、Column设计
在Witness中为不同场景预先生成一行行(Row)数据,将它们填入Fixed Table中作为lookup查询的去向,优化在电路运算过程常见的计算场景(如:8bit范围的与、或、异或运算);且在零知识证明中,实现范围比较功能有点困难,因为无法直接进行大小比较。为了在零知识证明中实现范围比较,通常需要使用额外的技巧和方法,如进行查表,预先将一段范围的数据填入表中,范围比较时将数据查表,如果在表中,则表示数据在指定范围。
在Witness中为不同场景预先生成一行行(Row)数据,将它们填入Fixed Table中作为lookup查询的去向,优化在电路运算过程常见的计算场景(如:8bit范围的与、或运算);且在零知识证明中,实现范围比较功能有点困难,因为无法直接进行大小比较。为了在零知识证明中实现范围比较,通常需要使用额外的技巧和方法,如进行查表,预先将一段范围的数据填入表中,范围比较时将数据查表,如果在表中,则表示数据在指定范围。
```Rust
pub struct Row {
......@@ -23,7 +23,6 @@ pub enum Tag {
U16,
And,
Or,
Xor,
Bytecode,
}
......@@ -32,18 +31,18 @@ pub enum Tag {
#### Row的设计如下
**tag**字段的不同场景
1. 数据标识,对LogicAnd、LogicOr、LogicXor、Bytecode等类型,使用下列定义Tag::And、Or、Xor、Bytecode
1. 数据标识,对LogicAnd、LogicOr、Bytecode等类型,使用下列定义Tag::And、Or、Bytecode
2. 对于10bit、16bit的范围的数据,Tag列未使用,填入U16作为Tag默认值<br/>
**value_0**字段
1. And, Or, Xor操作中需要两个操作数,标识左边的操作数
1. And, Or操作中需要两个操作数,标识左边的操作数
2. Bytecode类型中标识 evm opcode
3. 16bit范围的数据查找表,标识一个[0..1<<16-1]范围的数据<br/>
**value_1**字段
1. And, Or, Xor操作中需要两个操作数,标识右边的操作数
1. And, Or操作中需要两个操作数,标识右边的操作数
2. Bytecode类型中对于Push类型的操作码,标识push到栈上的字节数,其它类型的操作码数值为0
3. 10bit范围的数据查找表,该字段赋值为固定的`U10_TAG` <br/>
**value_2**字段
1. And, Or, Xor操作的计算结果
1. And, Or操作的计算结果
2. Bytecode类型中如果Push到栈上的数据大于15则改值为1,其它情况为0。即为Push的is_high。
3. 10bit范围的数据查找表,标识一个[1..1<<10]范围的数据
......@@ -61,7 +60,6 @@ pub enum Tag {
| Or | ...| ...| ...|
| Or | 255 | 0 | 255 |
| Or | 255 | 1 | 255 |
| Xor | ...| ...| ...|
| Bytecode | MLOAD | 0 | 0 |
| Bytecode | PUSH1 | 1 | 0|
| Bytecode | PUSH30 | 30 | 1|
......@@ -75,7 +73,7 @@ pub enum Tag {
## 使用
Fixed Circuit电路填写预定义的值到Fixed Table后,可以使用在其它电路的后续lookup查表操作中,例如:用来实现一些数值的范围证明(证明数值在u10, u16范围),或一些逻辑运算操作(And, Or, Xor);下面给出范围约束的示例:
Fixed Circuit电路填写预定义的值到Fixed Table后,可以使用在其它电路的后续lookup查表操作中,例如:用来实现一些数值的范围证明(证明数值在u10, u16范围),或一些逻辑运算操作(And, Or);下面给出范围约束的示例:
State Circuit记录了栈上、内存操作的动态,当约束栈上元素时需要校验元素指向栈的指针,因为EVM中栈上的元素最多可以有1024个,指向栈的索引范围必须在u10;EVM的内存状态中操作是以byte为单位的,因此约束内存元素时所指向的值在u8范围。
......
Clone repository
  • basics
    • evm
    • halo2
  • code notes
    • binary_number_with_real_selector
    • how to use macro
    • simple_lt
    • simple_lt_word
  • Home
  • image
  • zkevm docs
    • 1 introduction
    • 10 public
    • 11 fixed
    • 12 exp
    • 13 keccak
    • 14 comparisons
    • 15 differences
View All Pages

Copyright © 2024 ChainWeaver Org. All Rights Reserved. 版权所有。

京ICP备2023035722号-3

京公网安备 11010802044225号