Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keccak] Padding Validation #445

Merged
merged 11 commits into from
May 17, 2022
Merged

[Keccak] Padding Validation #445

merged 11 commits into from
May 17, 2022

Conversation

ChihChengLiang
Copy link
Collaborator

Problem

Adding the input padding validation to keccak

Spec privacy-scaling-explorations/zkevm-specs#161

@github-actions github-actions bot added the crate-keccak Issues related to the keccak workspace member label Apr 8, 2022
@ChihChengLiang ChihChengLiang force-pushed the padding-validation branch 2 times, most recently from 298925c to ec8f05b Compare April 14, 2022 18:12
@ChihChengLiang ChihChengLiang force-pushed the padding-validation branch 3 times, most recently from 4695ebc to a3e477b Compare May 9, 2022 22:33
@ChihChengLiang ChihChengLiang marked this pull request as ready for review May 9, 2022 22:36
@ChihChengLiang ChihChengLiang requested a review from a team as a code owner May 9, 2022 22:36
@ChihChengLiang ChihChengLiang requested review from CPerezz and removed request for a team May 9, 2022 22:36
@ChihChengLiang ChihChengLiang changed the title [WIP][Keccak] Padding Validation [Keccak] Padding Validation May 9, 2022
Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

Some concerns regarding the usage of Selector for the various cases we have in the padding.

The rest looks good. But will do a second review round once the Selector ussage issue is resolved.

Nice job with that BTW @ChihChengLiang 🎉

let q_enable = meta.selector();
meta.create_gate("build word", |meta| {
let q_enable = meta.query_selector(q_enable);
let byte = meta.query_advice(byte, Rotation::cur());
Copy link
Member

Choose a reason for hiding this comment

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

Can't we reduce 1 column here by using Rotation::next?

Copy link
Member

Choose a reason for hiding this comment

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

So that in word we have:

  • Prev: word_prev
  • Cur: word_cur
  • Next: byte

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are using the byte column from PaddingConfig. We don't create a new column for byte.

The gate looks like this:

byte (from PaddingConfig) word
byte1 byte1
byte2 256 * byte1 + byte2
... ...
byte8 256^7 *byte1 + 256^6 *byte2 + ... + byte8

In your proposed way, what would the gate look like?

Copy link
Member

Choose a reason for hiding this comment

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

I meant that in the Rotation::next of word column we can add the byte one.
But anyway, I don;t think this matters much now. Let's just merge and focus on finishing the entire thing. And then we can move on into optimizations or details.

keccak256/src/circuit/padding.rs Show resolved Hide resolved
keccak256/src/circuit/padding.rs Show resolved Hide resolved
keccak256/src/circuit/padding.rs Outdated Show resolved Hide resolved
keccak256/src/circuit/padding.rs Outdated Show resolved Hide resolved
@ChihChengLiang ChihChengLiang force-pushed the padding-validation branch 2 times, most recently from 4990abe to bbe0543 Compare May 16, 2022 15:22
Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

LGTM!

Let's file an issue for the Byte RLC which is commented out as missing, and merge this! :)

Nice job @ChihChengLiang 🎉

@ChihChengLiang ChihChengLiang merged commit 4688a33 into main May 17, 2022
@CPerezz CPerezz deleted the padding-validation branch November 30, 2022 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate-keccak Issues related to the keccak workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants