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

feat: New stdlib Transcript #1219

Merged
merged 11 commits into from
Aug 2, 2023
Merged

feat: New stdlib Transcript #1219

merged 11 commits into from
Aug 2, 2023

Conversation

ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented Jul 26, 2023

Description

Basic structure for a new stdlib Transcript corresponding to the new native transcript used by the Honk proving systems. Implements all functions required with the CAVEAT that no constraints are imposed for hashing in get_challenge. May be useful to do this properly at some point but avoiding it for now since it was non-trivial and the hash will change anyway.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for preeminent-bienenstitch-606ad0 canceled.

Name Link
🔨 Latest commit 66776da
🔍 Latest deploy log https://app.netlify.com/sites/preeminent-bienenstitch-606ad0/deploys/64c292f482682f00082a2a11

@ledwards2225 ledwards2225 changed the title New stdlib Transcript feat: New stdlib Transcript Jul 26, 2023
@ludamad
Copy link
Collaborator

ludamad commented Jul 26, 2023

FYI was looking into that l1-contracts issue, it's known at least, not sure what's causing it though
EDIT: was solved

@ledwards2225 ledwards2225 force-pushed the lde/stdlib_transcript branch from 66776da to c63dbe2 Compare July 28, 2023 19:34
@ledwards2225 ledwards2225 marked this pull request as ready for review July 28, 2023 22:24
@ledwards2225 ledwards2225 requested a review from codygunton July 28, 2023 23:05
@iAmMichaelConnor iAmMichaelConnor added the crypto cryptography label Jul 29, 2023
@ledwards2225 ledwards2225 force-pushed the lde/stdlib_transcript branch from 4fbd067 to 8b7e7b1 Compare July 31, 2023 11:42
Copy link
Contributor

@codygunton codygunton left a comment

Choose a reason for hiding this comment

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

Looks good, main things I ask: please break out TODOs into issues in aztec-packages and reference here; please move constructor-like functions into appropriate types as constructors or from_ functions as appropriate.

using VerifierTranscript = proof_system::honk::VerifierTranscript<FF>;
template <size_t LENGTH> using Univariate = proof_system::honk::sumcheck::Univariate<FF, LENGTH>;

static constexpr size_t HASH_OUTPUT_SIZE = 32; // WORKTODO: Duplicated from native transcript
Copy link
Contributor

Choose a reason for hiding this comment

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

Resolve TODO or remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved, thanks

native_challenges = native_transcript.get_challenges(labels...);

/*
* TODO(luke): Do stdlib hashing here. E.g., for the current pedersen/blake setup, we could write data into a
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make an issue int he aztec-packages repo and put in the appropriate slot in the project board and link here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, #1351

* @param element
* @return field_pt
*/
field_pt stdlib_type_from_witness(uint32_t native_element)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use existing functionality? for this and similar functions below? For instance, we have a function field_t<Builder>::from_witness. These things are generally useful and therefore should be constructors or member functions on the appropriate types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I follow. Do you just mean e.g. change this from witness_pt(builder, native_element); to field_pt::from_witness(builder, native_element)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean rather than defining these little utility functions in the class, you should use existing functions or put the utility functions in the appropriate classes -- if you're interested in having these constructor-like functions, then somebody else might be. If you're hesitant to put them there then maybe they shouldn't exist at all?

Copy link
Contributor Author

@ledwards2225 ledwards2225 Aug 1, 2023

Choose a reason for hiding this comment

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

I'm having a hard time finding a clean solution along the lines of what you're describing. I've taken a half-measure for now and moved the "from witness" functions into a utility class in the stdlib so at least they are separated from the Transcript.

It's possible I'm not understanding your suggestion well but an example of why it seems difficult: The template type for receive_from_prover() is currently the native type to be extracted and there are no existing methods that map native types to stdlib types, as far as I know. In theory I could add a function to_field_t() or something to field, but as far as I can tell the native types don't currently know anything about stdlib types so that feels like a major departure. Then there are types like uint32_t (which I cant add methods to unless I create a wrapper for the c++ std library type) and std::array<field> which is not a first class type to which I could add methods.

We do have from_witness methods implemented on the stdlib field/group types but I still need to connect the stdlib type to the native type that I'm trying to extract from the native transcript. So for example if I changed the template parameter in receive_from_prover() to a stdlib type, I'm not sure how I would distinguish between extracting a uint32_t or fr from the native transcript.

Anyway, I'm very open to making this better so if you have suggestions I'm happy to keep trying. Otherwise I'd request that we get this in as is and I can make a proper issue for it in case we want to improve it in the future. Either way I'd say it's a substantial improvement over what the existing recursive transcript does.

@codygunton
Copy link
Contributor

It's a small thing but also: do you mind not using the alians _pt? I think it was chosen for "plookup type" but it's not really an important distinction to call out, it's not used well, and it conflicts with the CTs of the circuits lib.

@ledwards2225 ledwards2225 force-pushed the lde/stdlib_transcript branch from 8b7e7b1 to 776a37a Compare August 1, 2023 19:02
@ledwards2225 ledwards2225 force-pushed the lde/stdlib_transcript branch from b185256 to 8cdcb5a Compare August 2, 2023 15:09
@ledwards2225 ledwards2225 merged commit 2f66de1 into master Aug 2, 2023
@ledwards2225 ledwards2225 deleted the lde/stdlib_transcript branch August 2, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto cryptography
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants