This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 856
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
crate-zkevm-circuits
Issues related to the zkevm-circuits workspace member
label
Nov 23, 2022
Draft
CPerezz
force-pushed
the
keccak_challenge_api
branch
from
November 24, 2022 11:29
58b991f
to
65ca05b
Compare
👋 Comment on this pull request with |
Currently, halo2 prevents the user from adding `Advice<PhaseN>` columns if no column of the previous phase was defined before. Since the first thing we need are the `Challenges` and these are placed with `Phase2` we no longer can compile the code. Therefore, a dummy column is added so that halo2 does not complain. This should be solved in the future if the challenge API polishes this.
This introduces the challenge API inclusion into the Keccak Bit implementation. This carries 2 different challenges. one for the inputs and another for the table-exposed value. The changes consists on: 1- Swap the meta.advice_column for meta.advice_column_in(SecondPhase). 2- Replace the randomnes hardcoded now in the circuit by the Challenges. Including it in the configure and witness_generation functions. 3- Test with a custom Challenges which has a fixed value.
I made an effort to migrate `Part<F>` and `PartValue<F>` to use the `Value<F>` halo2 API. But since the struct doesn't implement `PartialEq` it's challenging to do it. As I do need to operate with it quite a lot. Also, there's another caveat which is that it feels really tricky to extract the byte representation from a `Value<F>`. It feels like if you're cheating to the API constrantly (using `.map()` to gain access to the underlying F so that you can do extra things with it such as decompose it into bytes). For these reasons, right now `extract_field` was added. An issue will be filled to track the tech-debt left here and pay it once we maybe we add the required functionalities to `halo2::Value<F>`.
Now that all the three keccak implementations use the challenge API, it's time to update the SuperCircuit to adapt to these new APIs.
CPerezz
force-pushed
the
keccak_challenge_api
branch
from
November 28, 2022 13:28
65ca05b
to
d064ec9
Compare
CPerezz
changed the title
[WIP] Keccak Challenge-API integration
Keccak Challenge-API integration
Nov 28, 2022
github-actions
bot
added
crate-circuit-benchmarks
Issues related to the circuit-benchmarks workspace member
T-bench
Type: benchmark improvements
labels
Nov 28, 2022
This was referenced Nov 28, 2022
han0110
approved these changes
Nov 29, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work! Only left some minor comments.
Comment on lines
+190
to
+194
let mut value_f = F::zero(); | ||
value.map(|f| { | ||
value_f = f; | ||
f | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could reuse extract_field
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix this in #948
CPerezz
added a commit
that referenced
this pull request
Dec 1, 2022
* feat: Integrate KeccakPackedMulti with Challenge-API * fix: Clippy lints * fix: Pay #925 tech debt * remove: Keccak packed implementation * remove: Keccak-bit implementation * change: Export KeccakPackedConfig as KeccakConfig * remove: Benchmarks of discarted keccak impls
jonathanpwang
pushed a commit
to jonathanpwang/zkevm-circuits
that referenced
this pull request
Dec 29, 2022
* remove: Unnedeed TODO * Change: Port Keccak table from F to Value * Fix: Add dummy advice colum to prevent Phase error Currently, halo2 prevents the user from adding `Advice<PhaseN>` columns if no column of the previous phase was defined before. Since the first thing we need are the `Challenges` and these are placed with `Phase2` we no longer can compile the code. Therefore, a dummy column is added so that halo2 does not complain. This should be solved in the future if the challenge API polishes this. * feat: Port KeccakBit impl to challenge API This introduces the challenge API inclusion into the Keccak Bit implementation. This carries 2 different challenges. one for the inputs and another for the table-exposed value. The changes consists on: 1- Swap the meta.advice_column for meta.advice_column_in(SecondPhase). 2- Replace the randomnes hardcoded now in the circuit by the Challenges. Including it in the configure and witness_generation functions. 3- Test with a custom Challenges which has a fixed value. * feat: Integrate KeccakPackedMulti with Challenge-API * feat: Migrate keccak-packed circuit to Challenge-API * fix: Add `extract_field` to utils I made an effort to migrate `Part<F>` and `PartValue<F>` to use the `Value<F>` halo2 API. But since the struct doesn't implement `PartialEq` it's challenging to do it. As I do need to operate with it quite a lot. Also, there's another caveat which is that it feels really tricky to extract the byte representation from a `Value<F>`. It feels like if you're cheating to the API constrantly (using `.map()` to gain access to the underlying F so that you can do extra things with it such as decompose it into bytes). For these reasons, right now `extract_field` was added. An issue will be filled to track the tech-debt left here and pay it once we maybe we add the required functionalities to `halo2::Value<F>`. * update: Adapt SuperCircuit to new keccak APIs Now that all the three keccak implementations use the challenge API, it's time to update the SuperCircuit to adapt to these new APIs. * fix: Clippy lints * fix: Update benchmarks and set hardcoded input length * chore: Conditionally add an empty column before Challenge generation in tests
jonathanpwang
pushed a commit
to jonathanpwang/zkevm-circuits
that referenced
this pull request
Dec 29, 2022
…ns#948) * feat: Integrate KeccakPackedMulti with Challenge-API * fix: Clippy lints * fix: Pay privacy-scaling-explorations#925 tech debt * remove: Keccak packed implementation * remove: Keccak-bit implementation * change: Export KeccakPackedConfig as KeccakConfig * remove: Benchmarks of discarted keccak impls
GopherJ
pushed a commit
to dompute/zkevm-circuits
that referenced
this pull request
Sep 13, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
crate-circuit-benchmarks
Issues related to the circuit-benchmarks workspace member
crate-zkevm-circuits
Issues related to the zkevm-circuits workspace member
T-bench
Type: benchmark improvements
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces the challenge API inclusion into the all three different Keccak circuit implementations. Resolves: #751
This introduces 2 different challenges. One for the inputs and another for the table-exposed value.
The changes consists on:
1- Swap the meta.advice_column for meta.advice_column_in(SecondPhase).
2- Replace the randomnes, which is hardcoded now in the circuit by the Challenges.
Including it in the configure and witness_generation functions.
3- Test with a custom Challenges which has a fixed value.
From this work, two main issues/tech-debt derive.
SuperCircuit
is using now the slowest and worst performant of the 3 keccak implementations. So I ported the three so that we can run benchmarks for them with the SuperCircuit which will help to decide which one we keep and which ones we remove to reduce code manteinance.After a discussion with @Brechtpd on this topic, we both agreed that
multi-packed
approach should be the one to keep. But I think is worth a benchmark before we take that path removing the two other implementations from the repo.Tech-debt issues generated from this PR:
Value<F>
API #942