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
  • 13 keccak

13 keccak · Changes

Page history
feat: update docs --story=1019296 authored Aug 01, 2024 by chenxuanhui's avatar chenxuanhui
Show whitespace changes
Inline Side-by-side
Showing with 18 additions and 9 deletions
+18 -9
  • zkevm-docs/13-keccak.markdown zkevm-docs/13-keccak.markdown +18 -9
  • No files found.
zkevm-docs/13-keccak.markdown
View page @ 0812eb1d
使用开源的Keccak子电路,链接:https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/b8ae7af639af035a6ad5081716012ee2ea48e7cb/zkevm-circuits/src/keccak_circuit.rs,版本为commit:
本项目使用开源的Keccak子电路,链接:https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/b8ae7af639af035a6ad5081716012ee2ea48e7cb/zkevm-circuits/src/keccak_circuit.rs,版本为commit:
```
commit b8ae7af639af035a6ad5081716012ee2ea48e7cb
Author: Eduard S <eduardsanou@posteo.net>
......@@ -10,23 +11,31 @@ Date: Thu May 4 16:35:02 2023 +0200
本文主要介绍开源代码如何使用,如何接入。
## Keccak 电路简介
https://github.com/privacy-scaling-explorations/zkevm-circuits 的 Keccak子电路用于证明一个输入字节串和输入的Keccak哈希的对应关系。在其他电路里,需要使用三个变量 (input_rlc, input_len, output_rlc),进行向Keccak子电路的lookup,来验证这三个变量的对应关系。具体的输入、哈希的计算由Keccak内部实现,本项目不做改动。
在 `https://github.com/privacy-scaling-explorations/zkevm-circuits` 的 Keccak 子电路用于证明一个输入字节串和输入的 Keccak 哈希之间的对应关系。在其他电路里,需要使用三个变量(`input_rlc`, `input_len`, `output_rlc`)向 Keccak 子电路进行查表(lookup),以验证这三个变量的对应关系。具体的输入和哈希的计算由 Keccak 内部实现,本项目不做改动。
RLC即随机线性组合,计算RLC需要使用随机值 Challenge.
RLC(随机线性组合,Random Linear Combination)计算 RLC 需要使用随机值 Challenge。
## zkevm中的使用
在某电路(例如Core)里,遇到要验证Keccak的时候,首先由此电路负责将输入的RLC、哈希的RLC算好,然后将输入的RLC、哈希的RLC、输入的长度这三个变量(input_rlc, input_len, output_rlc),进行向Keccak子电路的lookup。
在某电路(例如 Core 电路)中,如果需要验证 Keccak 哈希,首先由此电路负责将输入的 RLC、哈希的 RLC 算好,然后将输入的 RLC、哈希的 RLC、输入的长度这三个变量(`input_rlc`, `input_len`, `output_rlc`)向 Keccak 子电路进行查表lookup。
计算RLC可由一个RLC子电路实现,可以类似Copy子电路。也可以直接由Copy子电路实现。子电路需要提供Challenge,由更新后的SubCircuit接口的synthesize函数提供。
计算 RLC 可以由一个 RLC 子电路实现,也可以由 Copy 子电路直接实现。子电路需要提供 Challenge,由更新后的 `SubCircuit` 接口的 `synthesize` 函数提供。
## 开源代码接入
将 keccak_circuit.rs 和 其子目录接入此项目。将其依赖的其他工具类代码等,也接入进来。然后将KeccakCircuit接入SuperCircuit。
**导入 Keccak 子电路代码**:
- 将 `keccak_circuit.rs` 和其子目录中的代码接入此项目。
- 将其依赖的其他工具类代码也接入进来。
**将 Keccak 子电路接入 SuperCircuit**:
- 将 Keccak 子电路集成到 SuperCircuit 中。
- 确保 SuperCircuit 能够调用 Keccak 子电路并进行相应的查表操作。
## 好处
(选做)Bytecode子电路的所有列可以不用公开了。只需公开code hash。通过对Witness中的Bytecode计算hash,检查是否与code hash一致,来验证Bytecode正确性。
通过对 Witness 中的 Bytecode 计算哈希,并检查是否与 code hash 一致,可以验证 Bytecode 的正确性。这样,Bytecode 子电路的所有列可以不用公开了,只需公开 code hash。
## 202405更新
## 本项目的更新
通过对代码的改动,output_rlc变为了output_hi, output_lo。即输出哈希值的高128位、低128位。
\ No newline at end of file
在原有设计中,`output_rlc` 表示 Keccak 哈希值的随机线性组合。为了更好地处理哈希值,代码进行了改动,将 `output_rlc` 拆分为 `output_hi` 和 `output_lo`,分别表示哈希值的高 128 位和低 128 位。
\ 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号