Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

refactor: remove keccak constants from aggregator#752

Merged
lispc merged 39 commits into
developfrom
refactor/aggregator-keccak-constants
Aug 17, 2023
Merged

refactor: remove keccak constants from aggregator#752
lispc merged 39 commits into
developfrom
refactor/aggregator-keccak-constants

Conversation

@darth-cy
Copy link
Copy Markdown

@darth-cy darth-cy commented Aug 10, 2023

Description

This PR removes keccak constants from the aggregator and make it agnostic to the internal parameters of the keccak circuit.

Issue Link

Closes #744

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Rationale

The internal shape of keccak is dependent on a singular KECCAK_ROW env variable which allocates an amount of rows for each inner round of the f-box for keccak. The aggregator should be agnostic to this internal configuration.

How Has This Been Tested?

Run and pass aggregator tests with KECCAK_ROW variable ranging from 9-32.

@darth-cy darth-cy self-assigned this Aug 10, 2023
@zhenfeizhang zhenfeizhang self-requested a review August 10, 2023 17:21
@darth-cy darth-cy marked this pull request as ready for review August 15, 2023 01:05
@darth-cy darth-cy requested a review from lispc August 15, 2023 01:30
Comment thread aggregator/src/util.rs
Comment thread aggregator/src/util.rs
Comment thread aggregator/src/util.rs
Comment thread aggregator/src/core.rs Outdated
Comment thread zkevm-circuits/src/keccak_circuit.rs Outdated
Comment thread zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs Outdated
Copy link
Copy Markdown

@zhenfeizhang zhenfeizhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs
Comment thread zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs Outdated
@lispc
Copy link
Copy Markdown

lispc commented Aug 16, 2023

i tested with KECCAK_ROWS=50, then column will be 29.

Besides i also updated the test serial_keccak_circuit_unusable_rows.

@zhenfeizhang
Copy link
Copy Markdown

i tested with KECCAK_ROWS=20, then column will be 29.

Besides i also updated the test serial_keccak_circuit_unusable_rows.

[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post states:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 2
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post absorb:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 1
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 4
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post padding:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 1
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 7
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post theta:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 3
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 13
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post rho/pi:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 13
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 46
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post chi:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 11
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 48
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] - Post squeeze:
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Lookups: 1
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Columns: 51
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Degree: 4
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Minimum rows: 69
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Total Lookups: 30
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] Total Columns: 51
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] num unused cells: 171
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size absorb: 11
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size theta: 7
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size theta c: 7
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size theta t: 9
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size rho/pi: 8
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] part_size chi base: 8
[2023-08-16T12:02:19Z DEBUG zkevm_circuits::keccak_circuit] uniform part sizes: [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]

seems like for KECCAK_ROWS=20 I got Total Columns: 51

@lispc
Copy link
Copy Markdown

lispc commented Aug 16, 2023

Oh sorry i mean KECCAK_ROWS 50

kunxian-xia and others added 10 commits August 16, 2023 08:17
…ircuit) (#778)

* calculate num_l1_msgs and num_l2_txs in tx circuit

* fix

* fmt and clippy

* fix: non-last tx requires next is calldata

* add NumAllTxs in block table and copy it from pi to block table

* add lookup for NumAllTxs in tx circuit

* clippy

* add block num diff check to avoid two real block have same num

* clippy

* address comments
…S auditors (#572)

* fix finding 3 (#575)

* Fix zellic finding 4 (#576)

* fix finding 3 (#575)

* fix finding 4

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* add range check on diffs (#586)

* Fix finding 10 (#578)

* fix finding 3 (#575)

* fix finding 10

* Fix finding 13 (#579)

* fix finding 3 (#575)

* fix finding 13

* Fix zellic finding 14 (#580)

* fix finding 3 (#575)

* fix finding 14

* Fix zellic finding 5 (#584)

* fix finding 3 (#575)

* fix finding 5

* refine comments

* fmt

* Fix finding 17 (#602)

* add q_last

* fix

* add more diff range check

* fix finding 7 (#625)

* tx_id = 1 when sm starts

* Fix finding 11 : use length for rlc in rlp table (#719)

* fix: use tag_bytes_rlc and tag_length to copy tag's bytes around

* fix lookup input for Len & RLC & GasCost fields in tx circuit

* refactor

* fix

* refactor

* fix col phase issue

* refactor bytes_rlc type

* Fix the bugs in Tx & PI circuits reported by Zellic & KALOS auditors (#612)

* lookup chain_id to RLP table

* fix finding 22 (#614)

* fix finding 21 (#613)

* fix finding 23 (#618)

* fix finding 26 (#622)

* fix finding 28 (#624)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix finding 29 (#623)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* enforce is_final is true at the last row and fix RLC related vul (#735)

* Fix finding 30  (#733)

* enforce all txs in a block are included in the tx table

* clippy

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* Fix Zellic / Kalos finding25 (#619)

* fix finding 25

* add comment

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix conflicts

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>

* use q_first instead

* fmt

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>
@lispc lispc merged commit 1d190ba into develop Aug 17, 2023
@lispc lispc deleted the refactor/aggregator-keccak-constants branch August 17, 2023 02:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: remove hard-coded Keccak constants in aggregator

4 participants