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

Add base conversion lookup table #215

Merged
merged 17 commits into from
Dec 23, 2021
Merged

Add base conversion lookup table #215

merged 17 commits into from
Dec 23, 2021

Conversation

ChihChengLiang
Copy link
Collaborator

Fix #211

TODO

@github-actions github-actions bot added the crate-keccak Issues related to the keccak workspace member label Dec 2, 2021
keccak256/src/gates/state_conversion.rs Outdated Show resolved Hide resolved
keccak256/src/gates/state_conversion.rs Outdated Show resolved Hide resolved
@CPerezz
Copy link
Member

CPerezz commented Dec 16, 2021

@ChihChengLiang feel free to ask for a new review when is ready! :)

Will wait until you ask.

@ChihChengLiang
Copy link
Collaborator Author

sure, I'm still on the flag and the selector. Will ask for a rereview once complete.

@ChihChengLiang ChihChengLiang force-pushed the use-table-column branch 3 times, most recently from 999c834 to 0f74dc9 Compare December 22, 2021 08:18
@ChihChengLiang ChihChengLiang mentioned this pull request Dec 22, 2021
@ChihChengLiang ChihChengLiang changed the base branch from main to use-table-col-2 December 22, 2021 08:26
@ChihChengLiang ChihChengLiang marked this pull request as ready for review December 22, 2021 08:28
@ChihChengLiang ChihChengLiang changed the base branch from use-table-col-2 to main December 22, 2021 09:46
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. But would like to see @therealyingtong 's opinion on the if/else containing constraints.

keccak256/src/gates/base_conversion.rs Outdated Show resolved Hide resolved
Comment on lines +147 to +158
if offset == 0 {
// bind first acc to first coef
region
.constrain_equal(input_acc_cell, input_coef_cell)?;
region.constrain_equal(
output_acc_cell,
output_coef_cell,
)?;
} else if offset == input_coefs.len() - 1 {
region.constrain_equal(input_acc_cell, input.0)?;
return Ok((output_acc_cell, output_acc));
}
Copy link
Member

Choose a reason for hiding this comment

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

There's a length missmatch here. 2 constraints in one branch of the if and 1 in the else.

Could you confirm if this is an issue @therealyingtong ??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This branches on the offset. Just want a difference on offset 0 and the last offset.

I think what might matter is how can we be sure the prover and the verifier can drive the same number of rows. The answer is they should have exactly bi.slice_count() rows. input_coefs.len() == output_coefs.len() == bi.slice_count(). But not sure how to express that here is better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Branching on the offset looks good to me, since we can deterministically compute that.

keccak256/src/gates/state_conversion.rs Outdated Show resolved Hide resolved
keccak256/src/gates/tables.rs Outdated Show resolved Hide resolved
keccak256/src/gates/tables.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@therealyingtong therealyingtong left a comment

Choose a reason for hiding this comment

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

LGTM

keccak256/src/gates/base_conversion.rs Outdated Show resolved Hide resolved
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! Brillian job @ChihChengLiang 😄

@ChihChengLiang
Copy link
Collaborator Author

Thank you @CPerezz and @therealyingtong for the review!

@ChihChengLiang ChihChengLiang merged commit dc23337 into main Dec 23, 2021
@CPerezz CPerezz deleted the use-table-column branch December 23, 2021 09:58
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.

keccak: Implement base9_to_base13 conversion gadget
3 participants