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

End-to-end "pp-spartan" verification contract (Step 3) #27

Merged
merged 7 commits into from
Sep 21, 2023

Conversation

storojs72
Copy link
Collaborator

@storojs72 storojs72 commented Aug 29, 2023

This PR follows #25 by adding next subsequent part of e2e verification to the main contract. Step 3 actually involves computations of "inner", "outer", "set" and "mem" claims required for comparison. This PR merges Sumcheck block implementation written by @mpenciak , adds PolyEvalInstance block, updates KeccakTranscript block according to recent changes (microsoft/Nova#191) by @huitseeker and carefully integrates all these to the codebase in main branch

@@ -5,53 +5,14 @@ import "src/blocks/pasta/Vesta.sol";
import "src/blocks/pasta/Pallas.sol";

library EqPolinomialLib {
function evaluateVesta(uint256[] memory r, uint256[] memory rx) public pure returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth doing a similar refactor for evalsPallas and evalsVesta?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. One thing to note: this kind of evaluation is not used in e2e verification "pp-spartan" flow which is default - as far as I remember it was used in "regular" spartan. I guess it is a normal situation when we have building block which is not used currently but either used previously or may be can be used in future.

@@ -40,7 +40,7 @@ library PrimarySumcheck {
uint256 r_i;
label[0] = 99; // c_label[0] = 99;
(transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curveVesta(), label);

r_i = Field.reverse256(r_i);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like in the definition of squeeze you call Field.reverse256 before outputting r_i Unless I'm misunderstanding, could you delete both instances of Field.reverse256 and arrive at the same result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice catch! Thanks

@@ -87,7 +87,7 @@ library SecondarySumcheck {
uint256 r_i;
label[0] = 99; // c_label[0] = 99;
(transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curvePallas(), label);

r_i = Field.reverse256(r_i);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -81,7 +81,9 @@ contract KeccakTranscriptContractTest is Test {
assertEq(scalarVesta, expectedVesta);
}

function testKeccakTranscriptPallas() public {
// Following test has been ported: https://github.com/lurk-lab/Nova/blob/solidity-verifier-pp-spartan/src/provider/keccak.rs#L138
// TODO: For some reason, test vector passes if using Vesta curve parameters, but in reference implementation type of point is Pallas
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the TODO still necessary, or did we figure out the Pallas <-> Vesta mixup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it is still not 100% clear. I mean following test in reference is parameterised by Pallas point. But given test vector outcome is obtained when we use different curve (Vesta) parameterisation at Solidity side. May be my understanding of reference is not 100% correct... @huitseeker, any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the situation is a bit confusing for the following reason:

  • when Rust tests are parametrized by a point, it can mean that we are using the G parameter because a/ we're indeed digesting a point OR b/ we're using that parameter to link to its associated types, such as G::Scalar,
  • when we digest a point in the Nova protocol we are in general calling the function to_coordinates from the trait Group, which returns the components of the affine representation of the point. As specified, those coordinates are members of the base field of the point:
    https://github.com/microsoft/Nova/blob/200b47edab190c06a44cbd87a63d34a444184a41/src/traits/mod.rs#L79
    In the case of a Pallas Point, this will be two coordinates in the Vesta scalar field.
  • often in tests, we also absorb points from G::Scalar, which means field elements in the point's own associated scalar field. In the case of a Pallas Point, that's a field element from the Pallas scalar field.

@storojs72 storojs72 merged commit bbab071 into main Sep 21, 2023
@storojs72 storojs72 deleted the pp-spartan-merge branch September 21, 2023 11:11
storojs72 added a commit that referenced this pull request Oct 15, 2023
* End-to-end "pp-spartan" verification contract (#25)

* Add JSONs generated by pp-spartan

* Separate path (src/blocks/) for low-level crypto building blocks

* Add e2e verification contract skeleton

* Move FieldLib and PolyLib code to Utilities.sol file

* Step 1

* Step 2

* CI adjustments

* Update README

* Update integration testing infrastructure

* End-to-end "pp-spartan" verification contract (Step 3) (#27)

* Add PolyEvalInstance building block

* Refactor building blocks

* Add step 3 of verification to the e2e contract

* Remove data contracts for step 2 and step 3

* Adjust CI

* KeccakTranscript and Sumcheck blocks adjustments

* Requested changes

* Update Utilities.sol

---------

Co-authored-by: Artem Storozhuk <[email protected]>
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.

3 participants