-
Notifications
You must be signed in to change notification settings - Fork 33
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
Unify the computation of digests and challenges in different folding schemes #94
base: main
Are you sure you want to change the base?
Unify the computation of digests and challenges in different folding schemes #94
Conversation
…`PoseidonTranscript{Var}`
Note that now `absorb_point` only supports hashing points whose BaseField is equal to the sponge's field
f21957b
to
d5c1e5f
Compare
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.
This is great! Very nice!
Unifying the transcripts and hashes and polishing the absorbs of points and nonnative elements was a pending task!
Really like the approach of extending the arkworks Sponge trait.
Also, as with your previous PRs, thanks a lot for all the good comments/docs along the code, they are very insightful!
Just a couple of small questions.
pub trait AbsorbNonNative<F: PrimeField> { | ||
/// Converts the object into field elements that can be absorbed by a `CryptographicSponge`. | ||
/// Append the list to `dest` | ||
fn to_native_sponge_field_elements(&self, dest: &mut Vec<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.
One question, I've tried to find where the to_native_sponge_field_elements
is used and haven't succeed (other than structs implementing the method to implement the AbsorbNonNative
trait). The usages of the AbsorbNonNative
trait that I've found use the one that returns the Vec<F>
instead of modifying a given dest
input value.
Does the AbsorbNonNative
have the method with the dest
param in order to match the native Absorb
trait, which internally uses a similar method from arkworks (also modifying the dest
param)?
I observed that in Nova, we compute the challenges and digests by manually constructing the input vectors to
CRH{Var}::evaluate
, while in ProtoGalaxy, we haveProtoGalaxyTranscript
for absorbing the inputs to a sponge.It would be beneficial to unify the way we derive challenges and digests in different folding schemes, and thus I created this PR and made several changes in challenge generation and digest computation. Notably,
PoseidonTranscript{Var}
, the wrappers ofPoseidonSponge{Var}
, are removed. Instead,PoseidonSponge{Var}
now implements theTranscript{Var}
traits directly and supports both digest computation and challenge generation.PoseidonSponge{Var}
for both purposes. One still needs to create two separate instances, e.g.,sponge
andtranscript
, for digest computation and challenge generation respectively.Transcript{Var}
traits now allow absorbing any non-native values (e.g., integers, points, CycleFold instances), as long as they implementAbsorbNonNative{Gadget}
.Transcript{Var}::absorb_point
method now is solely for absorbing native points (i.e., those whose base field is also the sponge's field), so someabsorb_point
calls are replaced withabsorb_nonnative
.CommittedInstance{Var}::hash
and{CycleFold}ChallengeGadget::get_challenge_{native, gadget}
now use the absorb methods provided byPoseidonSponge{Var}
andTranscript{Var}
.ProtoGalaxyTranscript
is removed in favor of implementingAbsorb{Gadget}
forCommittedInstance{Var}
.Yet, as this PR focuses on code quality and does not introduce bug fixes or new functionalities, we can lower the priority of merging it.