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
    • 4 core
  • core add

core add · Changes

Page history
core doc authored Jan 04, 2024 by jonathanXu's avatar jonathanXu
Hide whitespace changes
Inline Side-by-side
Showing with 5 additions and 44 deletions
+5 -44
  • zkevm-docs/4-core/core-add.markdown zkevm-docs/4-core/core-add.markdown +5 -44
  • No files found.
zkevm-docs/4-core/core-add.markdown
View page @ abf38103
......@@ -52,12 +52,9 @@ cnt=1,vers[16]~vers[23]的位置用来存进栈顶的值stack_push。
### 门约束
1. Auxiliary字段约束(state_stamp、stack_pointer、log_stamp、read_only)
2. Stack Value约束(tag、state_stamp、 call_id、stack_pointer、is_write)
3. lookup_value约束:lookup_stack_pop_b = stack_top0(栈顶的值需要和lookup_stack_pop_b相等)
4. lookup_value约束:lookup_stack_pop_a = stack_top1 (弹出一个值后,栈顶的值需要和lookup_stack_pop_a相等)
5. lookup_value约束:lookup_stack_push = stack_top1(存进一个值后,栈顶的元素需要和lookup_stack_push相等)
6. lookup_value约束:arithmetic_operand_b = lookup_stack_pop_b,arithmetic_operand_a = lookup_stack_pop_a,arithmetic_operand_push = lookup_stack_push(这里对三个操作数的hi,lo进行约束,需要和state lookup里的值相等)
7. 当前的OPCODE=ADD
8. arithmetic tag = ADD
3. lookup_value约束:arithmetic_operand_b = lookup_stack_pop_b,arithmetic_operand_a = lookup_stack_pop_a,arithmetic_operand_push = lookup_stack_push(这里对三个操作数的hi,lo进行约束,需要和state lookup里的值相等)
4. 当前的OPCODE=ADD
5. arithmetic tag = ADD
参考如下代码:
......@@ -106,47 +103,11 @@ fn get_constraints(
### LookUp约束
cnt=2的vers[0]~vers[8]的位置用来存放操作数的信息。
来源:core
去向:arithmetic
参考代码如下:
```Rust
fn gen_witness(&self, trace: &GethExecStep, current_state: &mut WitnessExecHelper) -> Witness {
assert_eq!(trace.op, OpcodeId::ADD);
let (stack_pop_a, a) = current_state.get_pop_stack_row_value(&trace);
let (stack_pop_b, b) = current_state.get_pop_stack_row_value(&trace);
let (arithmetic, result) = operation::add::gen_witness(vec![a, b]);
let stack_push = current_state.get_push_stack_row(trace, result[0]);
let mut core_row_2 = current_state.get_core_row_without_versatile(&trace, 2);
core_row_2.insert_arithmetic_lookup(&arithmetic);
let mut core_row_1 = current_state.get_core_row_without_versatile(&trace, 1);
core_row_1.insert_state_lookups([&stack_pop_a, &stack_pop_b, &stack_push]);
let core_row_0 = ExecutionState::ADD.into_exec_state_core_row(
trace,
current_state,
NUM_STATE_HI_COL,
NUM_STATE_LO_COL,
);
Witness {
core: vec![core_row_2, core_row_1, core_row_0],
state: vec![stack_pop_b, stack_pop_a, stack_push],
arithmetic,
..Default::default()
}
}
```
#### get_lookups
这里的lookup类型为LookupEntry::State和LookupEntry::Arithmetic。
这里的四个lookup, 类型为LookupEntry::State和LookupEntry::Arithmetic, 具体可以参考Witness Core Row部分的说明。
参考代码如下:
......
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号