-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.0; | ||
|
||
import "@std/Test.sol"; | ||
import "src/blocks/pasta/Pallas.sol"; | ||
import "src/blocks/pasta/Vesta.sol"; | ||
import "src/NovaVerifierAbstractions.sol"; | ||
|
||
library Step4Lib { | ||
function verify(Abstractions.CompressedSnark calldata proof) public view returns (bool) { | ||
if (!verifyInner(proof.r_W_snark_primary, Vesta.P_MOD)) { | ||
return false; | ||
} else if (!verifyInner(proof.f_W_snark_secondary, Pallas.P_MOD)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
function verifyInner(Abstractions.RelaxedR1CSSNARK calldata proof, uint256 modulus) private view returns (bool) { | ||
// row | ||
uint256 left = mulmod(proof.claims_product_arr[0], proof.claims_product_arr[2], modulus); | ||
uint256 right = mulmod(proof.claims_product_arr[1], proof.claims_product_arr[3], modulus); | ||
if (left != right) { | ||
return false; | ||
} | ||
|
||
// col | ||
left = mulmod(proof.claims_product_arr[4], proof.claims_product_arr[6], modulus); | ||
right = mulmod(proof.claims_product_arr[5], proof.claims_product_arr[7], modulus); | ||
if (left != right) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |