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
  • 10 public

10 public · Changes

Page history
public hash compression authored May 24, 2024 by geruiwang's avatar geruiwang
Show whitespace changes
Inline Side-by-side
Showing with 33 additions and 0 deletions
+33 -0
  • zkevm-docs/10-public.markdown zkevm-docs/10-public.markdown +33 -0
  • No files found.
zkevm-docs/10-public.markdown
View page @ b224d72a
......@@ -151,3 +151,36 @@ code_size hi的值应该为0,因为EVM的硬性要求(code size均不超过
| tag | tx_idx_or_number_diff | value[0] | values[1] | values[2] | values[3] |
| :------: | :-------------------: | :----------: | :----------: | :----------: | :----------: |
| CodeSize | 0 | code_addr hi | code_addr lo | code_size hi | code_size lo |
## 2024年5月更新
上述所有列都变为 `Column<Advice>` 。
### 问题1
如何输入公开数据到zk电路里?
解决方法:将上述所有列所有行进行哈希。将哈希值作为 `Column<Instance>`,仅需1列。2行,存`hash_hi,lo`。
### 问题2
上述有6列,怎么做哈希?
解决方法:假设6列的值都是u8,那将6列按列连接起来成为一个u8的数组进行哈希。我们的KeccakTable是用输入的RLC进行lookup的。注意到,连接起来的数组的CONCAT_RLC = R^5 RLC[0] + R^4 RLC[1] + R^3 RLC[2] + R^2 RLC[3] + R^1 RLC[4] + RLC[5]。其中RLC[]是六列分别的RLC。R是用于RLC的随机数r的length次方。length是整个Public table的有效数据在u8表示下的长度。
因此步骤是:
1. 将原来table的数值转化成u8(见下段)
2. 建一列cnt,从0开始数。建一列length,所有值都是最终的length。
3. 求得6列的RLC(需要新一列记录rlc累加值)
4. 求得随机数r的length次方(需要新一列记录次方的累计值)
5. 求CONCAT_RLC
6. 使用length,CONCAT_RLC向KeccakTable进行lookup,得到hash的hi,lo(在新建的一个或两个`Column<Advice>`中,新建的两个列,可以每行都是hash的hi,lo). lookup条件cnt==length-1
7. 使用equal约束,`Column<Advice>`中的hash和`Column<Instance>`中的hash相等。
### 问题3
怎么将原来table的数值转化成u8?
解决方法:上述的value都是在U128范围内的,因此,原来table的一个数值可以变为16个u8数值。那么原来table的一列就要新建一列,原来的一列中的一行的value,在新列中要占用16行。
再新建一列ring_16,以15,14...1,0这样循环。在ring_16==0时,对新列中16行和原来列的1行的value进行约束,证明16个u8拼成了一个value。
这样,原来table的两行之间,要插入15行的填充行,填充行没有任何意义。lookup也要加上ring_16,且lookup时ring_16=0。
我们原来table有6列,因此需要进行6次这样的操作。
\ No newline at end of file
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号