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

Feature/sumcheck #40

Merged
merged 37 commits into from
Dec 15, 2023
Merged

Feature/sumcheck #40

merged 37 commits into from
Dec 15, 2023

Conversation

dmpierre
Copy link
Collaborator

@dmpierre dmpierre commented Nov 28, 2023

edited before merging

We want folding_schemes to have a sum-check implementation generic over hash functions.

To achieve this, we re-use hyperplonk's sumcheck implementation. To be able to make it generic over any hash, we tweak it to be generic over our own Transcript trait (not the one found in hyperplonk).

This PR:

  1. re-defines SumCheck, SumCheckProver and SumCheckVerifier traits to be generic over a CurveGroup, with prove and verify methods generic over folding_schemes::Transcript.
  2. sets the IOPProverState and IOPVerifier states to be generic over a CurveGroup.

Also, we change hyperplonk calls to its transcript object when re-implementing the prove and verify method cited above:

  1. transcript.append_serializable_element becomes transcript.absorb (example) or transcript.absorb_vec when needed (example).
  2. transcript.get_and_append_challenge becomes transcript.get_challenge (example)

The main disadvantage from taking this route is codebase inflation. However, we gain the short-term ability to have a somewhat robust and generic sum-check implementation. Still, although practical, it seems like a temporary implementation which might be re-evaluated in the future (e.g. implementing our own sum-check from scratch, hyperplonk's implementation might have possible low-hanging optimizations).

@dmpierre dmpierre linked an issue Nov 28, 2023 that may be closed by this pull request
@dmpierre
Copy link
Collaborator Author

hypernova working with poseidon based transcript here

@CPerezz
Copy link
Member

CPerezz commented Nov 30, 2023

Is this ready for review @dmpierre ?

@CPerezz CPerezz self-requested a review November 30, 2023 12:41
@dmpierre dmpierre requested a review from arnaucube November 30, 2023 14:09
@dmpierre
Copy link
Collaborator Author

Is this ready for review @dmpierre ?

Yes thanks! Forgot to assign, so just added Arnau as well

@dmpierre
Copy link
Collaborator Author

dmpierre commented Dec 1, 2023

Added a raw sum-check implementation in the meantime, might help to get rid of hyperplonk altogether. Started benchmarking it. I will be working on optimizing this over the next few days. Would be happy to hear your thoughts!

Copy link
Collaborator

@arnaucube arnaucube left a comment

Choose a reason for hiding this comment

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

Great! Thanks for this!! I've reviewed all except for sum_check_unstable.rs, left some proposals.

src/sum_check.rs Outdated Show resolved Hide resolved
src/utils/espresso/sum_check/mod.rs Outdated Show resolved Hide resolved
src/utils/espresso/sum_check/mod.rs Outdated Show resolved Hide resolved
src/utils/espresso/sum_check/verifier.rs Outdated Show resolved Hide resolved
@CPerezz
Copy link
Member

CPerezz commented Dec 4, 2023

@arnaucube pinged me about code duplication. So I'll save time and review once the changes have been addressed!

Could you ping once done @dmpierre ??

@dmpierre
Copy link
Collaborator Author

dmpierre commented Dec 6, 2023

@arnaucube pinged me about code duplication. So I'll save time and review once the changes have been addressed!

Could you ping once done @dmpierre ??

I think we are getting closer! We eventually go for implementing a more generic trait over hyperplonk directly.

Keeping our own sum-check implementation for later since it will require additional work on top of it if we want to use it - things like removing the dependency to VirtualPolynomial, scattered in quite a few key places (we will have to re-implement some strategic polynomial subroutines to do that).

@dmpierre dmpierre requested a review from arnaucube December 6, 2023 15:00
@dmpierre dmpierre requested a review from arnaucube December 7, 2023 14:04
Cargo.toml Show resolved Hide resolved
Copy link
Collaborator

@arnaucube arnaucube left a comment

Choose a reason for hiding this comment

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

Nice work @dmpierre ! ^^
Just left a question about some absorbs in the transcript that I'm not sure about.

.unwrap();
let gamma_scalar = C::ScalarField::from_le_bytes_mod_order(b"gamma");
transcript.absorb(&gamma_scalar);
let gamma: C::ScalarField = transcript.get_challenge();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not an expert on transcripts, so not sure about this, but if these strings are not essential maybe we could skip them so in-circuit don't add extra constraints?

The reasoning would be that we are already absorbing the value of the computed challenge, and we're interested into absorbing the values computed through the protocol to prevent the prover from 'choosing' the 'random challenges' obtainted, but some hardcoded strings would not affect that, and furthermore, later when we reproduce the transcript in-circuit, absorbing strings would add extra constraints (although a small amount).
Maybe the 'absorbing the string' tradition comes from Merlin (https://merlin.cool , used by the transcript from the Espresso impl), which allows to use strings as kind of separators when absorbing values into the transcript.
I've skimmed through the Merlin docs but didn't find a reason for absorbing the strings, but again, I'm not sure about this, so posting this as a question for others here. (tagging @CPerezz and @han0110 who might have more insight here)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's like a domain separator for the underlying hash function, zcash/halo2 does the same thing, so I guess it'd be a good practice.

But I also don't understand the theoretical part, and not sure where convention this comes from.

@arnaucube arnaucube requested a review from han0110 December 9, 2023 07:52
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.

Nice work!

Some suggestions left.

Cargo.toml Outdated Show resolved Hide resolved
src/folding/hypernova/nimfs.rs Show resolved Hide resolved
src/folding/hypernova/nimfs.rs Outdated Show resolved Hide resolved
src/folding/hypernova/nimfs.rs Outdated Show resolved Hide resolved
src/utils/espresso/sum_check/mod.rs 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!

Thanks for this work!

@dmpierre dmpierre added this pull request to the merge queue Dec 15, 2023
Merged via the queue into main with commit 876e23c Dec 15, 2023
3 checks passed
@dmpierre dmpierre deleted the feature/sumcheck branch December 15, 2023 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt SumCheck Transcript
4 participants