Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

fix: Correct soundness bug in keccak circuit #1019

Closed
wants to merge 2 commits into from
Closed

Conversation

CPerezz
Copy link
Member

@CPerezz CPerezz commented Jan 2, 2023

Once Keccak was migrated to the Challenge API in #925, there was a column containing data_rlcs which was getting stored values that were the result of an RLC.

Therefore, this swaps the data_rlcs colum Phase to SecondPhase.

Resolves: #1016

@CPerezz CPerezz requested a review from Brechtpd January 2, 2023 09:16
@github-actions github-actions bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Jan 2, 2023
Once Keccak was migrated to the Challenge API in #925, there was a column
containing `data_rlcs` which was getting stored values that were the
result of an RLC.

Therefore, this swaps the `data_rlcs` colum Phase to `SecondPhase`.

Resolves: #1016
}

pub(crate) fn query_cell_at_pos(
pub(crate) fn query_cell_at_pos<P: Phase>(
Copy link
Member

@ed255 ed255 Jan 2, 2023

Choose a reason for hiding this comment

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

It's not clear to me that this function will always return a cell belonging to a column at phase. Notice the path when column_idx < self.columns.len(), the phase parameter is ignored, and we don't know which is the phase of self.columns[column_idx].

AFAIK, the cell manager here returns cells in this order (assume height = 3)

Col1 Col2 Col3
0 3 6
1 4 7
2 5 8

The queries 0, 3 and 6 cause the meta.advice_column_in(phase). And the rest of the queries will reuse the column at whichever phase was chosen before.

I think the cell manager needs to be duplicated. One cell manager for phase1, one cell manager for phase2. Each one will create columns in the corresponding phase. And then cells for data_rlcs will be allocated with cell_manager_phase2.query_cell(meta), where as the rest of the cells will be queried with cell_manager_phase1.query_cell(meta).

@lispc
Copy link
Collaborator

lispc commented Jan 17, 2023

Hi @CPerezz is the pr (almost) done?we may consider directly pick this patch to our fork to make a super circuit with real non mock challenge api

@CPerezz
Copy link
Member Author

CPerezz commented Jan 17, 2023

@lispc indeed this work was left aside as it implies a significant refactor. And we prefer to pospone it until we have the hi-lo specs ready.
So that we can evaluate how worth is to update this or refactor specs directly.

The issue in here is that duplicating the cellmanager isn't enough. THerefore we need to make deep changes on how the circuit is coded to allow this to work propperly.

@ed255 ed255 added the wontfix This will not be worked on label Jan 23, 2023
@ed255
Copy link
Member

ed255 commented Jan 23, 2023

I've added the wontfix label following this comment #1016 (comment)

@aguzmant103 aguzmant103 closed this Mar 2, 2023
@aguzmant103
Copy link
Member

Closed in favor a future PR that Scroll team will send

noel2004 pushed a commit to noel2004/zkevm-circuits that referenced this pull request Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-zkevm-circuits Issues related to the zkevm-circuits workspace member wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keccak Challenge API Soundness Bug
4 participants