From ac1c261b2eeab9c8e8e0ca8359f92f798bd95301 Mon Sep 17 00:00:00 2001 From: Matej Penciak Date: Tue, 1 Aug 2023 21:21:38 -0400 Subject: [PATCH] finish the refactor --- src/Polynomial.sol | 110 +++++ src/verifier/step4/KeccakTranscript.sol | 10 +- src/verifier/step4/SumcheckData.sol | 197 ++++---- src/verifier/step4/SumcheckLogic.sol | 444 ++---------------- .../step4/sumcheck-data-contract-gen.py | 9 +- test/nova-verifier-tests.t.sol | 2 + test/sumcheck-tests.t.sol | 35 +- 7 files changed, 276 insertions(+), 531 deletions(-) create mode 100644 src/Polynomial.sol diff --git a/src/Polynomial.sol b/src/Polynomial.sol new file mode 100644 index 0000000..28b4b2b --- /dev/null +++ b/src/Polynomial.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +import "src/verifier/step4/EqPolynomial.sol"; + +library PolyLib { + struct UniPoly { + uint256[] coeffs; + } + + struct CompressedUniPoly { + uint256[] coeffs_except_linear_term; + } + + function degree(UniPoly memory poly) public pure returns (uint256) { + return poly.coeffs.length - 1; + } + + function evalAtZero(UniPoly memory poly) public pure returns (uint256) { + return poly.coeffs[0]; + } + + function evalAtOne(UniPoly memory poly, uint256 mod) public pure returns (uint256 result) { + for (uint256 i = 0; i < poly.coeffs.length; i++) { + // result += poly.coeffs[i]; + result = addmod(result, poly.coeffs[i], mod); + } + } + + function evaluate(UniPoly memory poly, uint256 r, uint256 mod) public pure returns (uint256) { + uint256 power = r; + uint256 result = poly.coeffs[0]; + for (uint256 i = 1; i < poly.coeffs.length; i++) { + // result += power * poly.coeffs[i]; + result = addmod(result, mulmod(power, poly.coeffs[i], mod), mod); + // power *= r; + power = mulmod(power, r, mod); + } + + return result; + } + + function negate(uint256 x, uint256 mod) internal pure returns (uint256) { + return mod - (x % mod); + } + + function decompress(CompressedUniPoly calldata poly, uint256 hint, uint256 mod) + public + pure + returns (UniPoly memory) + { + // uint256 linear_term = hint - poly.coeffs_except_linear_term[0] - poly.coeffs_except_linear_term[0]; + uint256 linear_term = addmod( + hint, + negate(addmod(poly.coeffs_except_linear_term[0], poly.coeffs_except_linear_term[0], mod), mod), + mod + ); + + for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { + // linear_term -= poly.coeffs_except_linear_term[i]; + linear_term = addmod(linear_term, negate(poly.coeffs_except_linear_term[i], mod), mod); + } + + uint256 coeff_index = 0; + uint256[] memory coeffs = new uint256[](poly.coeffs_except_linear_term.length + 1); + coeffs[coeff_index] = poly.coeffs_except_linear_term[0]; + coeff_index++; + coeffs[coeff_index] = linear_term; + coeff_index++; + + for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { + coeffs[coeff_index] = poly.coeffs_except_linear_term[i]; + coeff_index++; + } + + return UniPoly(coeffs); + } + + function toUInt8Array(uint256 input) private pure returns (uint8[] memory) { + uint8[] memory result = new uint8[](32); + + bytes32 input_bytes = bytes32(input); + + for (uint256 i = 0; i < 32; i++) { + result[i] = uint8(input_bytes[31 - i]); + } + return result; + } + + function toTranscriptBytes(UniPoly memory poly) public pure returns (uint8[] memory) { + uint8[] memory result = new uint8[](32 * (poly.coeffs.length - 1)); + + uint256 offset; + uint8[] memory coeff_bytes = toUInt8Array(poly.coeffs[0]); + for (uint256 i = 0; i < 32; i++) { + result[i] = coeff_bytes[i]; + } + offset += 32; + + for (uint256 i = 2; i < poly.coeffs.length; i++) { + coeff_bytes = toUInt8Array(poly.coeffs[i]); + for (uint256 j = 0; j < 32; j++) { + result[offset + j] = coeff_bytes[j]; + } + offset += 32; + } + + return result; + } +} diff --git a/src/verifier/step4/KeccakTranscript.sol b/src/verifier/step4/KeccakTranscript.sol index 09f7fcf..c437d03 100644 --- a/src/verifier/step4/KeccakTranscript.sol +++ b/src/verifier/step4/KeccakTranscript.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.0; import "src/pasta/Vesta.sol"; import "src/pasta/Pallas.sol"; +import "src/Polynomial.sol"; library ScalarFromUniformLib { uint256 private constant SCALAR_UNIFORM_BYTE_SIZE = 64; @@ -398,7 +399,6 @@ library KeccakTranscriptLib { pure returns (KeccakTranscript memory) { - // uint256 input will always take 32 bytes uint8[] memory transcript = new uint8[](keccak.transcript.length + label.length + input.length); uint256 index = 0; // TODO think how to make it more efficient (without copying current transcript) @@ -516,6 +516,14 @@ library KeccakTranscriptLib { return absorb(keccak, label, input); } + function absorb(KeccakTranscript memory keccak, uint8[] memory label, PolyLib.UniPoly memory poly) + public + pure + returns (KeccakTranscript memory) + { + return absorb(keccak, label, PolyLib.toTranscriptBytes(poly)); + } + function squeeze(KeccakTranscript memory keccak, ScalarFromUniformLib.Curve curve, uint8[] memory label) public pure diff --git a/src/verifier/step4/SumcheckData.sol b/src/verifier/step4/SumcheckData.sol index f19d592..a8e96e7 100644 --- a/src/verifier/step4/SumcheckData.sol +++ b/src/verifier/step4/SumcheckData.sol @@ -2,511 +2,512 @@ // Do not change manually. This contract has been auto-generated by src/verifier/step4/sumcheck-data-contract-gen.py pragma solidity ^0.8.0; +import "src/Polynomial.sol"; import "src/verifier/step4/SumcheckLogic.sol"; library SumcheckData { // This function returns a SumcheckProof for the relevant corresponding field function returnPrimaryOuterData() public pure returns (PrimarySumcheck.SumcheckProof memory) { - PallasPolyLib.CompressedUniPoly[] memory proof_array = new PallasPolyLib.CompressedUniPoly[](14); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](14); uint256[] memory poly_array; - PallasPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](3); poly_array[0] = 0x0000000000000000000000000000000000000000000000000000000000000000; poly_array[1] = 0x3156ab3e1bea772559548817e8d23e4d60a57bc280baf032420e3c6133dd7e2f; poly_array[2] = 0x1dff490409def9717737be07798dad2c3a6bc952eec88937c6076da01f9d9af0; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](3); poly_array[0] = 0x2a0cd6f39b97ed92a45886a8e80a5944ed373498922050a3745f29c2ec6667ae; poly_array[1] = 0x12fbd521f3fdb45f92e1bc9d045197000c74f40e67292ccac43f9b65f854b955; poly_array[2] = 0x0bf922cb074481cf22bfe02c62561af632503238b4198aeb5e2bb5cf8dd0fac3; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](3); poly_array[0] = 0x1a7160ebd6e443d51da504fa28e5168868012deaacfc8188014cde90744297bc; poly_array[1] = 0x281222608e87d3d0d154e6621dbe68a181e5e646bbaab420859659a0e042dd4c; poly_array[2] = 0x2ae2df351788ef2c603da9501a93ea6ea1080a1742c923a56e0daa7e0599cd1e; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](3); poly_array[0] = 0x2cadc3a75b23fdebbcef67f3b2d193348ea927786e761d43406e4358d324c4d1; poly_array[1] = 0x06d2d5a5f516f2734156ed7b78e9687e0a6a52c89456c09af0609fe5b27b1fca; poly_array[2] = 0x0a1a4cee698d0bea9725c189f39509b1e3fb54dcbf0cfeb0ead4a679e30b6b97; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](3); poly_array[0] = 0x21d36d5eeab44b9e1dab9a1941353a9b259b0e37f8130c97ac45e7ee1ee46e5d; poly_array[1] = 0x09cd8f4b3cdb357a80b6d967f5c0f33335ba536e76092ed3ac9ce4b576777817; poly_array[2] = 0x047de779ead5aef11c60969244ec4bdcf2ef7e7081f734a4239cfe4607768d6c; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](3); poly_array[0] = 0x25291aac7c299b973f93613a17c13191037cb2fd01e2eccdf4697deaf0c9a04a; poly_array[1] = 0x35f26c09cec10804a870e39ef1d192dd5609b1481229da10415680c367fce145; poly_array[2] = 0x2b37031e0daac3039e35efc738ca354614b0263e45658a0c90de1dccd6735711; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](3); poly_array[0] = 0x02563c53bdabeb954ec43901c61cb5ad9e81c2cb7dd31b9f46f80440078fd7fd; poly_array[1] = 0x0807ce199363c83d6c6fbeb708cef45c4f96236b7e861812b879de1a205db161; poly_array[2] = 0x32fcb855b9dd89717b27154af419b9389ad459a36f94730efe771b0f5940f633; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](3); poly_array[0] = 0x2087b996187c4be4d5eb576a9b6d00d315ad25cee961c8f424621a41c6b0c971; poly_array[1] = 0x1ef0832cd1a4ba98bf66682a990f9c56216fc31b39d2adecc94c5cc9b4031ab8; poly_array[2] = 0x0b652696a88affcc0ab69d52903bcd3965f262ddf222c3fe2da3af2fa6a0f27a; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](3); poly_array[0] = 0x36a3f10a14df17c5dde2ec64df992874659af5e22e4db23ad1ea73d66807c8ef; poly_array[1] = 0x09c9b72ebe89f51aec378af41815f75964c4d8f993e5f9b1681e2b21a42385f9; poly_array[2] = 0x1b75c4dd2c3cb3a62b90b02ea20c4051ca98c9d9c1424a2421f947c12c7d3eb7; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](3); poly_array[0] = 0x2828a18fa8618435b512a4292b9fcea3b150859f50a3e74bb2a3ee15ae88da9c; poly_array[1] = 0x1964a64964a1859af0d3d333762bbec3a22487ca091e6b89494ce72cef90130a; poly_array[2] = 0x10e43d7966039b6cc7b1ced16fd886fe1ca375a8485b820f48611b822781226c; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](3); poly_array[0] = 0x3eb95a4f74af56e31c0b35fe7498c938009c9bea670a61a8383dab0c4c429bfe; poly_array[1] = 0x0dff761d89b94a2551136b0f4df357b400850910295952ad9ee5c2f85123e5e5; poly_array[2] = 0x13e46518e76c51be58f3748832326568b0c2cd2e683ae9bb4b1ece9b93c56376; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](3); poly_array[0] = 0x26592d33bfd615e40cfe4c9a0b8e56e88a2c8aa00c84f49b783b4f0c1c359706; poly_array[1] = 0x29f1f0b13ba89df090f4d23bc74060929ca75281737b7200ec6ad66e94e3c1e2; poly_array[2] = 0x36ede69bcd3a25e759a2b798f83b569a4906b688623ac23529b8cdc12355abc3; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](3); poly_array[0] = 0x05d85babbee109ab6d627a03a8e8ea0d372d96cfa1929cee86ae5af797cb9657; poly_array[1] = 0x2b9ce21b23851fcce3cc996e5c80da63f8818737d35957b31b0125bccfebe967; poly_array[2] = 0x15f5eb776094fbed243e952d5c3512ec31b123db1af788fa9686b8b18b7d7168; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](3); poly_array[0] = 0x07e180612d7bd63a41bd64c2e6c1b0c5edbe6fa6f318cba353edb77eecd59bac; poly_array[1] = 0x1785c227874bcb2e816af7d0b1b39d6369dc3017b21cfdaccbbbdf3e9a63c9ca; poly_array[2] = 0x3001d35ebe98119d070a55ea1544bcb729493df381bf7c80ffb0203b2956d7c9; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; return PrimarySumcheck.SumcheckProof(proof_array); } // This function returns a SumcheckProof for the relevant corresponding field function returnPrimaryInnerData() public pure returns (PrimarySumcheck.SumcheckProof memory) { - PallasPolyLib.CompressedUniPoly[] memory proof_array = new PallasPolyLib.CompressedUniPoly[](15); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](15); uint256[] memory poly_array; - PallasPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](2); poly_array[0] = 0x1c4716f6500639b9ee9e0a493a76aa7c7aa8196dd10d4eeb40627f83ec901ab3; poly_array[1] = 0x12ddcbfdc897aea3ddd931a65341be5be2cd518c188a73256a71b0b5d742f87a; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](2); poly_array[0] = 0x1eacd6a8ccb244c64826baf09705d29d8ef995632ed1b70c7e7af712825d19e2; poly_array[1] = 0x03ef3e2a0f4b278e998da912353b35a0c40e76e67f4d8b8213f2393d8f742b8d; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3fec761f5f12b29c168cc1fe7b27254666e8fed9d0eefbc314e634e30ef07d92; poly_array[1] = 0x1d16b757b0e8d062872b6d3c5958e93ce78bf3e31be62d1b7ebf4c35c93c21fe; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](2); poly_array[0] = 0x069a0ee19958d15bfed6947ab0a689a0f6e4384f651407760e1045e363015b9b; poly_array[1] = 0x1e154ecac18821ead0126f8a850c4a9fc7c06e9078af0eb02a5362c2ab19ddba; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](2); poly_array[0] = 0x0960f1909773fd0cd0142c4f988a17be72b09d5542276c24b10ac96c9f964b88; poly_array[1] = 0x004fdcee2f0b851cd672ea49de9760f69e56fb6d7fec59445daba272d849dc06; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](2); poly_array[0] = 0x21b81234955853a2affe69496b2831035b90d5b31eefd3bda3fdad37974efeab; poly_array[1] = 0x22f8ec817975e9313c8ee3a49b477633ad32819965e0a6e6d821691a510eeb0b; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](2); poly_array[0] = 0x38a2603ead84692ace689ec57ebe7cec1a9453fd2919c650b048740c8a2c39e3; poly_array[1] = 0x254b089648bcfb1ac112cf795a7189a93555820e2e9489d0eeee4513a166e793; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](2); poly_array[0] = 0x178f3b3f5ff04fd87346830452d7b923df016a390bc502f6ffe557120744290e; poly_array[1] = 0x1b849c9bb28d386b2b3adad7183f80dea1242964ccb38188937129ba5fbc3a7a; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](2); poly_array[0] = 0x02d85bd61ed1849b2f3e7b9be14a86055723a97303f0df2b04a533bffa285c16; poly_array[1] = 0x3b4bbb46b769c1725e934257a561e01248e8876d9c8197c8b4a4f62ff53cbd65; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](2); poly_array[0] = 0x102abddb1ed3784b298cd43c10ffabfed2d649332fb82ab7027daef4c6e6f845; poly_array[1] = 0x3d57a9cf5588852f198f874e37ea5db4dc46a684c2d9a9b2186fdf60c497ce6a; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](2); poly_array[0] = 0x020391cbc46173b9e1908c9f90bfbbf44ccd3328112f1a42482099dd60eb822e; poly_array[1] = 0x1b2f8805ccd6bb1855294ac62537075a102441b5743caca629a0de56dc3d0bae; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](2); poly_array[0] = 0x1e1639b26e4bc45cacfe52d84ff1e5a9333ef770aa814dbe444ba16345b07b89; poly_array[1] = 0x2136cf7fba716952ec0dbb672c7d3e9e8200ac6ef547dc06f0e87317ec8acd30; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](2); poly_array[0] = 0x32ca14ba8af6c53fc1e8cd50dcd3d718fb444f16a3e4e832a26195285489a961; poly_array[1] = 0x2c8f9603d754035cc3efe1af4a55c24e498bd10e4d289a9cf4ebde41c78bb63f; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](2); poly_array[0] = 0x1fd16fb6bf71d9b5e27c81cc22ca308b6ecf227c279a540fb78435d9661a92d2; poly_array[1] = 0x0e7136096c545edbeaca24dad44083385fe147980df8b0d4149ac693d483a66e; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; poly_array = new uint256[](2); poly_array[0] = 0x0df4439409c23205c94fff01fab2978f40f8aee927a2a97ff3168af0a5d28fc8; poly_array[1] = 0x0144eebfcf46c4d529bd5875de0d23df56c65a2eb54d7000b68837f01eacd58e; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[14] = poly; return PrimarySumcheck.SumcheckProof(proof_array); } // This function returns a SumcheckProof for the relevant corresponding field function returnPrimaryBatchData() public pure returns (PrimarySumcheck.SumcheckProof memory) { - PallasPolyLib.CompressedUniPoly[] memory proof_array = new PallasPolyLib.CompressedUniPoly[](14); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](14); uint256[] memory poly_array; - PallasPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](2); poly_array[0] = 0x2155c5a20f5a1194e2ac3f9177909cef926c05e32fb7e9d22ef0d77d28688763; poly_array[1] = 0x27fad0f1b0d77c1f120661e1a815714a8dad8f5ff4a2310c450fa9ab2e742e54; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](2); poly_array[0] = 0x1eed419f37fe888cd7019a630b689deea4d7ed62a38ee9ec6d369f8034c85b09; poly_array[1] = 0x3b70d8d30df9e02f4f7adb9bf411f1011f0d92bb13be7e28fc751867a6fd033c; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](2); poly_array[0] = 0x02c9849afed1c30df760be1f226a08a7ce3590ea9c3b65d2dcf5894627c9d152; poly_array[1] = 0x2b6ea31acdb0372acf50cba700488af46ce8a93950a59c156fde310099e0322b; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](2); poly_array[0] = 0x39765fa514c503853592b2f72c557234c2efafba9815111959b6463678b15c5e; poly_array[1] = 0x33a7ff8c7d32efdfafdee39e62c74afa54d488dc72dfe1ca78d0744fdf308ee1; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](2); poly_array[0] = 0x2c391fa31a4e5650852011c5f16ada3f59db9ba0b4dafaef57099430348801d6; poly_array[1] = 0x197b3e0837694a8ebab6d966f4a920f05af65dd30833e7dc0e913bf85ad37225; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](2); poly_array[0] = 0x2d7be88f517910bc0fac0392ee91efe8d85a3a97d6a0d61afa3a0cb41712fe76; poly_array[1] = 0x32843e5549400578b03af5fe731709f0a21d1c415b45d5c4b14f9fd149e66c1e; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](2); poly_array[0] = 0x330b20e3b08c055a68e60d46f6b7b108fd953bbc7cde6ce77f0810887e2474f8; poly_array[1] = 0x3a2d7c73d3d387ec99c36e57269e60cdcb76e747db777519f0b428306656db34; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3b6cf05c93b2ddce857281ab92c00820662ea883470eae0687fe528623881b2e; poly_array[1] = 0x2bea6206030ca0310385056aab275eeb953faa84fe98143e6c450ca2bd914bfc; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3427a9cac1fadf65a0ee155dbce8116cc074c1e610f07b4f5f1488cbc4a3e0b8; poly_array[1] = 0x23a552df25fa8ac97bf3441e7b4db68043c76ed2525ff794a31bcde16fb3e40c; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](2); poly_array[0] = 0x0f83b9b92c770da002d1a2f26ff04acd3cbb2e5fa74e5b4751563f6e0d09ae57; poly_array[1] = 0x2d83e394e01194e288428b4c5dbc4c25239fe6ed91e24c5e72a8d6efd7fc390e; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3f58d15471a50cb03e5ef99c687bc24c904dc825c944c528e267a8e0ca821806; poly_array[1] = 0x0312eec0bd722003eaf7f6e00874f9770f2d3a988ec3f7fae804fab1d3269114; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](2); poly_array[0] = 0x00c1c1243543a2e54373171f76be13e5942593734afef8b5b3c1a5bfb0bf2dc9; poly_array[1] = 0x0bd82242c23980470f76eb13dfe88cf1ad2fc918f0cae76e63c9c34ff2dd58e2; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](2); poly_array[0] = 0x0bec8b247b7b9aaa0f47ef1fa6e525878bf760049f601a4adeabb8d02223d171; poly_array[1] = 0x1d4e02fdcd90b13c5b2bc528f50e11313a8e8b47f5177abd475c8bb23406510c; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3b314367a784bbad47b57679d0c57345027fea6e2e8d44c1ca6746971670fbe0; poly_array[1] = 0x10c1a4c0d36de5eb0b5e3f733eeb644f9d29f4069afa840606b7e0a33214dbec; - poly = PallasPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; return PrimarySumcheck.SumcheckProof(proof_array); } // This function returns a SumcheckProof for the relevant corresponding field function returnSecondaryOuterData() public pure returns (SecondarySumcheck.SumcheckProof memory) { - VestaPolyLib.CompressedUniPoly[] memory proof_array = new VestaPolyLib.CompressedUniPoly[](14); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](14); uint256[] memory poly_array; - VestaPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](3); poly_array[0] = 0x0000000000000000000000000000000000000000000000000000000000000000; poly_array[1] = 0x090796c2a029b81e4b30b65a449b8f943a1cd5a119a5d6ea1865efebcc515975; poly_array[2] = 0x067c67d9f00d27334795d0b6587f7de9e8bbb3ae85a2aa0730e87eb038750fd3; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](3); poly_array[0] = 0x35ab7e62b24329fc2784fd4ddf143a4919e7b06b7f101b94c23325707d972598; poly_array[1] = 0x0368440836408ed96cdeeda474fa6d50ca5304bcd994a59b04a35ad5cb82988c; poly_array[2] = 0x0cd794be4f0dcd1962d1c3b94abf4869362315cde53e76c54ca6e69ffbb54fd1; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](3); poly_array[0] = 0x1ac92b883ac9222ed2f099dc01a9a8698fdd2a981dc515a2908c73ee0779d4ed; poly_array[1] = 0x05fa19839ccd1d979f724185a504eadf564e8cb13a35c789dc4c97862a1ab43f; poly_array[2] = 0x3161fbce7771ce913d815456b42b3c129a9c3c120d8694ad5ddc53135bd7957c; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](3); poly_array[0] = 0x3f8bfb004ecbb634983b60395e025445d813d52e2038661f2c2611e0efe87bb9; poly_array[1] = 0x02e1a31742c3893a5022e217bd46588e69f284a88a1aab7fa821e9ae309e35f1; poly_array[2] = 0x3f5038f7aada98ba046b1677110fc20c2308af4a7d4248a0fc20abac09fad80e; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](3); poly_array[0] = 0x31411873831a3d0f76b6e21c1f0d638332453d84f73e6e62f597ea16d318f98a; poly_array[1] = 0x181254eb869f39f12708a854068abfcf4fed2aedd2ffc2e28dcd00477b3b408a; poly_array[2] = 0x2a38ce34a893f57f46230dc86c278af06f38201d09a5aac25fff21a362c19503; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](3); poly_array[0] = 0x3b390cebb5321a5d374cfdc02f36e268e57436648adeb4a6f374d687e3b83f80; poly_array[1] = 0x372ef3614d501411ece142d48fd34cb9cb092066f1257d38601b69788ad2eb7c; poly_array[2] = 0x00c12c5100c9064d735aed7b10cc0ab283747058decbbb18a5b741acb8124bcd; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](3); poly_array[0] = 0x1a904ae3fa645c6a5085fdd7e6a32aa13156989ceb38b27bcb6d50b93b9f5e50; poly_array[1] = 0x2040c55e383b83f0aee66f0507d8b8dbad9712d946f0af4bf8b44927cef92620; poly_array[2] = 0x0821176e32ab95c32676b38d8b9ab811c957f1831c9b27ab1f370ece48b671c6; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](3); poly_array[0] = 0x17290df24a694e928dd665c9d347d71c787503678da8b85d0e68459512116b9e; poly_array[1] = 0x1f2fb1f39a8e22a3837735fb2f050de5fe9db26f7c75abf1381dea16a557dec1; poly_array[2] = 0x36a1cbeb839a6959595764789ff67be0e8a74f007ca7e7805794fbd6bad88b68; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](3); poly_array[0] = 0x265113405d948ad03ae371265f568532c6ad37c400c92d667aa0140cd32969ac; poly_array[1] = 0x22641d41c810605b33f7c87487722d6f41dabf9b1ceb8c99e8269a1f5a8c8037; poly_array[2] = 0x0ced61caaabe14bf7895a0bdf4b841441aee4d43b5a7c4733b3472574f0a983d; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](3); poly_array[0] = 0x1efdf83fe07484106737f606fbd1e3c29417a4d88fcd0969f6bc8cdfde0eec46; poly_array[1] = 0x1b17694bef0a2f6d89acf07e0a830eb8088f07b6c2cb24d1108a6d3d83657a54; poly_array[2] = 0x219f36cf1c636cb8e8f23931d44a1af19b5422d992773a1276c4c4ad7aeb81e6; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](3); poly_array[0] = 0x3b1eb16f9af3e92be52401f4bc1a72e8819c7dada4bcb7085a1e660c6cd3b32c; poly_array[1] = 0x0776b65ef71b553ccc400eb387c8eb1a5ee7205ad30c0fe2438373fd6a1bb7da; poly_array[2] = 0x2151dbbf153f7aab0338111f1dad8709dae12680167d12fc3fa48aa5729ce042; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](3); poly_array[0] = 0x008cd96ec564a9908459113718ebe2061337339f37d3c008e57ef3e0ce4c06f2; poly_array[1] = 0x094407f4448f79930c8326c88624b016b7f6439a61664d2a7796d190a74d30c6; poly_array[2] = 0x1bbbbb0e733aa832acf78c89ecfae9da618df4ad0addb0096d79d8feeb74df89; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](3); poly_array[0] = 0x2589f6fbbb4b1b0fb0b2470bbc28d6cbf47536bd8c26c8e31e2acc3a10a761f6; poly_array[1] = 0x34af65ce9841e688d2bfdeca1c90fa613bd53ccdd6027ccdbeb4749b41637824; poly_array[2] = 0x109e02018ce3cfff0b3cbab192ee2848ab1653edfe520a57966a37827bff815b; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](3); poly_array[0] = 0x3914ef9f52080f298240bedac07f6a3fbfe78a4b78b2012a43af5b9fed3eb2ab; poly_array[1] = 0x03150bd2bc4fc7a377d012ace84edf8f266494b2a45e9e658df389a7970598f9; poly_array[2] = 0x0e1d558f115e7184052f3a1a689989506165b26e4bfbcdde9245d38dd4b47149; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; return SecondarySumcheck.SumcheckProof(proof_array); } // This function returns a SumcheckProof for the relevant corresponding field function returnSecondaryInnerData() public pure returns (SecondarySumcheck.SumcheckProof memory) { - VestaPolyLib.CompressedUniPoly[] memory proof_array = new VestaPolyLib.CompressedUniPoly[](15); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](15); uint256[] memory poly_array; - VestaPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](2); poly_array[0] = 0x2c5ad28caf2a30723db06b0c5f2daf1bd489089b295bea581a34b87ac4c992c5; poly_array[1] = 0x11c867d92fbfd8321e07fa9f7bade6ca1e6485378644fb3c81ec92f75cd0f138; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](2); poly_array[0] = 0x38db06de76eda60bb2ba837d498b852235666824b6a4a34fd4f0542a07eaf83c; poly_array[1] = 0x0bc76064c182c83bf55acd1ef18e78b3edc84ccf6fbdc7cc13ab541423f1d777; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](2); poly_array[0] = 0x107dc161b518391d870ad4776828cdbd7c2aa856ca05db4bca3ccebeb40b3e79; poly_array[1] = 0x02cdd0b15810133f2614e9c3db70cce5703ebfe1942dedea4f8e814cdee6e9b9; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3acc1c97598f737e4f0a33c2a31448185bea391c46ca3c9a2d2f32b01cc00cfe; poly_array[1] = 0x19159c6766b74f0cf6a164c5702700140c556041e42a9cd55f0395aaa3751d62; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3ddcb7ecc9a8a9746f03ddab3e84d35f5c5687db7777d1024f99715a2a0cf5e9; poly_array[1] = 0x0f386d55fa899a2f680448f082f4044e94b16c619c0e00dc161abb316f5f055c; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](2); poly_array[0] = 0x02bb0cd20cd33767bb2ced0bd20cf59964347983eb7d627679a10fec348dd93c; poly_array[1] = 0x308611d1239b841723ea46beedd4ad6c18256cd7abace7ade92daffb85d432f1; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](2); poly_array[0] = 0x091533e2c27b3de8b92b136f00258e310c4be08bf4deee63f6c2106d17226535; poly_array[1] = 0x394e426b7ce6acc45aadb1149582754723398a47af7a048cad8c965a4a23edac; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](2); poly_array[0] = 0x27f986cec5aa415f5c4f55605025a76fd3a3680513eb8cf846c2b807a1133a88; poly_array[1] = 0x21073e2efb597f693306bfa1e7a9d69dc5017a496ceb6c60d4e24597de7bf386; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](2); poly_array[0] = 0x089c618c7dd2d0d4cd214509ee66c061400af394292d26ab986a6d245396e726; poly_array[1] = 0x3fc835443a5dcfcd52e21e2267cc07bd422c66cfe6c689d058da4f489361bdaf; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](2); poly_array[0] = 0x02cc3866a95d1134d02f44744d2b9b07b7986ec7b0b9a86310e613973756329d; poly_array[1] = 0x2ecadda0e35901a6d5d4619df0d1704f5b471c7e7ad17ce073628bd2688cea7a; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](2); poly_array[0] = 0x187f6facad361cd0cb88c8b74b75d47b9d861d7822bbf19fe53106388af01b59; poly_array[1] = 0x11bdfe5683e46f19bb9fd7052534090aff4c107f43ab0d972596ea4790a5b6c4; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](2); poly_array[0] = 0x1cb6de6208c78deb1857e9c6e17561ca0f1b89430f6e03b4a9ca5963a14f62c1; poly_array[1] = 0x2ffddcf67dd8dc7425ab39f6c9846052dd12e60627d1d434cc1d4febc6f096f1; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](2); poly_array[0] = 0x2c6f01df34d61c82e0240a814a361eabf531e35c4e92df971e2b6ee6f933e490; poly_array[1] = 0x195499856700d4f79a24519ecde2beee9d62249d638380691cb11a15a3d51b0f; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](2); poly_array[0] = 0x08360997dd7d4470e3caefefc6189a980515f68cbe583138e24ea7225d7d463f; poly_array[1] = 0x0ab471e96ccc91e240ee9c324d755cbc5df9ae23b784cd1958178d8b79c9360f; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; poly_array = new uint256[](2); poly_array[0] = 0x20350438adcd696b8d02f7fc56c0b61ec52a701e50a20f6d11fe7ff80bb3600b; poly_array[1] = 0x196579d55c1006d34fe99b580bf70f1ca34cd057d73726f018de41e3004aa5e7; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[14] = poly; return SecondarySumcheck.SumcheckProof(proof_array); } // This function returns a SumcheckProof for the relevant corresponding field function returnSecondaryBatchData() public pure returns (SecondarySumcheck.SumcheckProof memory) { - VestaPolyLib.CompressedUniPoly[] memory proof_array = new VestaPolyLib.CompressedUniPoly[](14); + PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[](14); uint256[] memory poly_array; - VestaPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; poly_array = new uint256[](2); poly_array[0] = 0x3778dd47bff37eaa5f46f8cf0b8a83df26ab59e81d834880a62c98628dab18cb; poly_array[1] = 0x36430699e436e3fd6d3a9d5c41285d72b43cbe9e7c0def5b430630beb883322e; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[0] = poly; poly_array = new uint256[](2); poly_array[0] = 0x23b2f8541fd8cca0087e7e772432296e6d5637b38694a0d3959dafec886a581d; poly_array[1] = 0x380153e856d13c73bf6df99c746256f44790832f1b920537cb236e0700c41076; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[1] = poly; poly_array = new uint256[](2); poly_array[0] = 0x25264d4ca84b5fab52ed410c0b1edf4b73c283d36915442cdbf774b534d35b07; poly_array[1] = 0x3bc4d96b1ff53b954914bf9695d6cae5dd7bd3857ff08cc9b44c525525d65e28; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[2] = poly; poly_array = new uint256[](2); poly_array[0] = 0x045c77586032794edc94fa6ef6baa4a1de0cae38cb0e50f292837e91a6c8da0f; poly_array[1] = 0x3012c9f83f5d5897e253963d60f9e7764e5faefc3acdd2da0bc3357b77f56723; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[3] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3552e33e401d19eb6efd85b828f4da62edb71c482ecb551e2731611f116b6b37; poly_array[1] = 0x1d77f649e9c08c2b722b7ea57e2b862f9a92c923e0d4e0bc29bb0c21d4a514f3; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[4] = poly; poly_array = new uint256[](2); poly_array[0] = 0x228c5e1529107612f903bf0006d376d2183fc2abfbed7097f53945c2fb99a2b1; poly_array[1] = 0x263b63e884d49ce6ef5693aa4f4cd64efcee6b7c5c149585048aa2036609c209; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[5] = poly; poly_array = new uint256[](2); poly_array[0] = 0x31baa5e08c957f55acf5392f4e98c8b02ec7dc9142b6d2442cad8875c8ad1ac1; poly_array[1] = 0x2d526b31084c79c9ba271b4f9dec0641b18fa4aded4fe24fb58f9e2262c7836f; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[6] = poly; poly_array = new uint256[](2); poly_array[0] = 0x15260793e8c1ebcdd6c40e7da3c223b56d99dddbc7835a708915f5da392065bf; poly_array[1] = 0x33e63541161ad8a8f215e76fa48516d1736caefe88b8398e273444a1e3e5335c; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[7] = poly; poly_array = new uint256[](2); poly_array[0] = 0x3499aef515afcad923dd687caac79e2d8759ac186fa6353cc9af2e53078b4450; poly_array[1] = 0x2070daf5b2e65015ee0a1adbe3037a2ee5f52d7b0c1da1e04bac11fadfb9d2e4; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[8] = poly; poly_array = new uint256[](2); poly_array[0] = 0x0b89d997302a0eb3e2d636852d43df2b478413a640c845dccbc4a71b9a1930be; poly_array[1] = 0x088218b57f51763066db38c08963d7dff1dc61b08442f85d8b1cffd4a67de019; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[9] = poly; poly_array = new uint256[](2); poly_array[0] = 0x24beaaa573677f834b463dbdcd3877069039cba9c4480c0af736addb9ec539d8; poly_array[1] = 0x1b77b1f53662c3bae203b71fde3886eccfc6a542cee8fa4e4584c21f524891d2; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[10] = poly; poly_array = new uint256[](2); poly_array[0] = 0x22c71df97cecf7de4475f48b77ddab8b514a000d732485eb0001ce5addb5f83d; poly_array[1] = 0x1d9d3928f0d029539b68648d9ab43fbbe53f9abcda7bfe8b7e3e66a0ea9c08c9; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[11] = poly; poly_array = new uint256[](2); poly_array[0] = 0x31978a8cb06be3b5eacaf8f6cb648285b08e0440691a7f7e6108724cc74c2d35; poly_array[1] = 0x1964ce18e81e22fcff8c793b878295a37d8960d07d878682ce5b1ac12686c41a; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[12] = poly; poly_array = new uint256[](2); poly_array[0] = 0x15c712d36849a0762b953a465e8c044fd7ca946dcf04265c68cd652859f5f9b1; poly_array[1] = 0x04d0d2dfc250cd724074c023f2f099ffa61313893e0e4f84b4d99964e2186c29; - poly = VestaPolyLib.CompressedUniPoly(poly_array); + poly = PolyLib.CompressedUniPoly(poly_array); proof_array[13] = poly; return SecondarySumcheck.SumcheckProof(proof_array); } diff --git a/src/verifier/step4/SumcheckLogic.sol b/src/verifier/step4/SumcheckLogic.sol index 16556e3..42e5fb2 100644 --- a/src/verifier/step4/SumcheckLogic.sol +++ b/src/verifier/step4/SumcheckLogic.sol @@ -5,395 +5,11 @@ import "src/pasta/Pallas.sol"; import "src/pasta/Vesta.sol"; import "src/verifier/step4/KeccakTranscript.sol"; import "src/verifier/step4/EqPolynomial.sol"; - -library PallasPolyLib { - struct MLPoly { - uint64 numvars; - uint256[] Z; - } - - struct SparseEntry { - uint256 idx; - uint256 entry; - } - - struct SparsePoly { - uint64 numvars; - SparseEntry[] Z; - } - - struct UniPoly { - uint256[] coeffs; - } - - struct CompressedUniPoly { - uint256[] coeffs_except_linear_term; - } - - function newML(uint256[] memory Z, uint64 numvars) public pure returns (MLPoly memory) { - require(Z.length == 2 ^ numvars); - return MLPoly(numvars, Z); - } - - function boundPolyVarTop(MLPoly calldata P, uint256 r) public pure returns (MLPoly memory) { - uint256 mid = P.Z.length / 2; - - uint256[] memory new_Z; - - for (uint256 i = 0; i < mid; i++) { - uint256 a = P.Z[i]; - uint256 b = P.Z[mid + i]; - // new_Z[i] = a + r * (b - a); - new_Z[i] = addmod(a, mulmod(r, addmod(b, Pallas.negateBase(a), Pallas.P_MOD), Pallas.P_MOD), Pallas.P_MOD); - } - - return MLPoly(P.numvars - 1, new_Z); - } - - function evaluate(MLPoly calldata P, uint256[] calldata r) public pure returns (uint256 result) { - require(P.Z.length == r.length); - - uint256[] memory chis = EqPolinomialLib.evalsPallas(r); - - for (uint256 i = 0; i < r.length; i++) { - // result += chis[i] * P.Z[i]; - result = addmod(result, mulmod(chis[i], P.Z[i], Pallas.P_MOD), Pallas.P_MOD); - } - } - - function computeChi(bool[] memory a, uint256[] calldata r) public pure returns (uint256) { - require(a.length == r.length); - - uint256 result; - - for (uint256 j = 0; j < r.length; j++) { - if (a[j]) { - // result *= r[j]; - result = mulmod(result, r[j], Pallas.P_MOD); - } else { - // result *= (1 - r[j]); - result = mulmod(result, addmod(1, Pallas.negateBase(r[j]), Pallas.P_MOD), Pallas.P_MOD); - } - } - - return result; - } - - function getBits(uint256 num, uint256 numbits) private pure returns (bool[] memory) { - bool[] memory result; - - for (uint256 shift_amount = 0; shift_amount < numbits; shift_amount++) { - result[shift_amount] = (num & (1 << (numbits - shift_amount - 1)) > 0); - } - - return result; - } - - function evaluate(SparsePoly calldata P, uint256[] calldata r) public pure returns (uint256) { - require(P.numvars == r.length); - - uint256 result; - - for (uint256 i = 0; i < r.length; i++) { - bool[] memory bits = getBits(P.Z[i].entry, r.length); - // result += computeChi(bits, r) * P.Z[i].idx; - result = addmod(result, mulmod(computeChi(bits, r), P.Z[i].idx, Pallas.P_MOD), Pallas.P_MOD); - } - - return result; - } - - function degree(UniPoly memory poly) public pure returns (uint256) { - return poly.coeffs.length - 1; - } - - function evalAtZero(UniPoly memory poly) public pure returns (uint256) { - return poly.coeffs[0]; - } - - function evalAtOne(UniPoly memory poly) public pure returns (uint256 result) { - for (uint256 i = 0; i < poly.coeffs.length; i++) { - // result += poly.coeffs[i]; - result = addmod(result, poly.coeffs[i], Pallas.R_MOD); - } - } - - function evaluate(UniPoly memory poly, uint256 r) public pure returns (uint256) { - uint256 power = r; - uint256 result = poly.coeffs[0]; - for (uint256 i = 1; i < poly.coeffs.length; i++) { - // result += power * poly.coeffs[i]; - result = addmod(result, mulmod(power, poly.coeffs[i], Pallas.R_MOD), Pallas.R_MOD); - // power *= r; - power = mulmod(power, r, Pallas.R_MOD); - } - - return result; - } - - function compress(UniPoly memory poly) public pure returns (CompressedUniPoly memory result) { - result.coeffs_except_linear_term[0] = poly.coeffs[0]; - for (uint256 i = 1; i < poly.coeffs.length; i++) { - result.coeffs_except_linear_term[i - 1] = poly.coeffs[i]; - } - } - - function decompress(CompressedUniPoly calldata poly, uint256 hint) public pure returns (UniPoly memory) { - // uint256 linear_term = hint - poly.coeffs_except_linear_term[0] - poly.coeffs_except_linear_term[0]; - uint256 linear_term = addmod( - hint, - Pallas.negateScalar( - addmod(poly.coeffs_except_linear_term[0], poly.coeffs_except_linear_term[0], Pallas.R_MOD) - ), - Pallas.R_MOD - ); - - for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { - // linear_term -= poly.coeffs_except_linear_term[i]; - linear_term = addmod(linear_term, Pallas.negateScalar(poly.coeffs_except_linear_term[i]), Pallas.R_MOD); - } - - uint256 coeff_index = 0; - uint256[] memory coeffs = new uint256[](poly.coeffs_except_linear_term.length + 1); - coeffs[coeff_index] = poly.coeffs_except_linear_term[0]; - coeff_index++; - coeffs[coeff_index] = linear_term; - coeff_index++; - - for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { - coeffs[coeff_index] = poly.coeffs_except_linear_term[i]; - coeff_index++; - } - - return UniPoly(coeffs); - } - - function toUInt8Array(uint256 input) private pure returns (uint8[] memory) { - uint8[] memory result = new uint8[](32); - - bytes32 input_bytes = bytes32(input); - - for (uint256 i = 0; i < 32; i++) { - result[i] = uint8(input_bytes[31 - i]); - } - return result; - } - - function toTranscriptBytes(UniPoly memory poly) public pure returns (uint8[] memory) { - uint8[] memory result = new uint8[](32 * (poly.coeffs.length - 1)); - - uint256 offset; - uint8[] memory coeff_bytes = toUInt8Array(poly.coeffs[0]); - for (uint256 i = 0; i < 32; i++) { - result[i] = coeff_bytes[i]; - } - offset += 32; - - for (uint256 i = 2; i < poly.coeffs.length; i++) { - coeff_bytes = toUInt8Array(poly.coeffs[i]); - for (uint256 j = 0; j < 32; j++) { - result[offset + j] = coeff_bytes[j]; - } - offset += 32; - } - - return result; - } -} - -library VestaPolyLib { - struct MLPoly { - uint64 numvars; - uint256[] Z; - } - - struct SparseEntry { - uint256 idx; - uint256 entry; - } - - struct SparsePoly { - uint64 numvars; - SparseEntry[] Z; - } - - struct UniPoly { - uint256[] coeffs; - } - - struct CompressedUniPoly { - uint256[] coeffs_except_linear_term; - } - - function newML(uint256[] memory Z, uint64 numvars) public pure returns (MLPoly memory) { - require(Z.length == 2 ^ numvars); - return MLPoly(numvars, Z); - } - - function boundPolyVarTop(MLPoly calldata P, uint256 r) public pure returns (MLPoly memory) { - uint256 mid = P.Z.length / 2; - - uint256[] memory new_Z; - - for (uint256 i = 0; i < mid; i++) { - uint256 a = P.Z[i]; - uint256 b = P.Z[mid + i]; - // new_Z[i] = a + r * (b - a); - new_Z[i] = addmod(a, mulmod(r, addmod(b, Vesta.negateBase(a), Vesta.P_MOD), Vesta.P_MOD), Vesta.P_MOD); - } - - return MLPoly(P.numvars - 1, new_Z); - } - - function evaluate(MLPoly calldata P, uint256[] calldata r) public pure returns (uint256 result) { - require(P.Z.length == r.length); - - uint256[] memory chis = EqPolinomialLib.evalsVesta(r); - - for (uint256 i = 0; i < r.length; i++) { - // result += chis[i] * P.Z[i]; - result = addmod(result, mulmod(chis[i], P.Z[i], Vesta.P_MOD), Vesta.P_MOD); - } - } - - function computeChi(bool[] memory a, uint256[] calldata r) public pure returns (uint256) { - require(a.length == r.length); - - uint256 result; - - for (uint256 j = 0; j < r.length; j++) { - if (a[j]) { - // result *= r[j]; - result = mulmod(result, r[j], Vesta.P_MOD); - } else { - // result *= (1 - r[j]); - result = mulmod(result, addmod(1, Vesta.negateBase(r[j]), Vesta.P_MOD), Vesta.P_MOD); - } - } - - return result; - } - - function getBits(uint256 num, uint256 numbits) private pure returns (bool[] memory) { - bool[] memory result; - - for (uint256 shift_amount = 0; shift_amount < numbits; shift_amount++) { - result[shift_amount] = (num & (1 << (numbits - shift_amount - 1)) > 0); - } - - return result; - } - - function evaluate(SparsePoly calldata P, uint256[] calldata r) public pure returns (uint256) { - require(P.numvars == r.length); - - uint256 result; - - for (uint256 i = 0; i < r.length; i++) { - bool[] memory bits = getBits(P.Z[i].entry, r.length); - // result += computeChi(bits, r) * P.Z[i].idx; - result = addmod(result, mulmod(computeChi(bits, r), P.Z[i].idx, Vesta.R_MOD), Vesta.R_MOD); - } - - return result; - } - - function degree(UniPoly memory poly) public pure returns (uint256) { - return poly.coeffs.length - 1; - } - - function evalAtZero(UniPoly memory poly) public pure returns (uint256) { - return poly.coeffs[0]; - } - - function evalAtOne(UniPoly memory poly) public pure returns (uint256 result) { - for (uint256 i = 0; i < poly.coeffs.length; i++) { - // result += poly.coeffs[i]; - result = addmod(result, poly.coeffs[i], Vesta.R_MOD); - } - } - - function evaluate(UniPoly memory poly, uint256 r) public pure returns (uint256) { - uint256 power = r; - uint256 result = poly.coeffs[0]; - for (uint256 i = 1; i < poly.coeffs.length; i++) { - // result += power * poly.coeffs[i]; - result = addmod(result, mulmod(power, poly.coeffs[i], Vesta.R_MOD), Vesta.R_MOD); - // power *= r; - power = mulmod(power, r, Vesta.R_MOD); - } - - return result; - } - - function compress(UniPoly memory poly) public pure returns (CompressedUniPoly memory result) { - result.coeffs_except_linear_term[0] = poly.coeffs[0]; - for (uint256 i = 0; i < poly.coeffs.length; i++) { - result.coeffs_except_linear_term[i - 1] = poly.coeffs[i]; - } - } - - function decompress(CompressedUniPoly calldata poly, uint256 hint) public pure returns (UniPoly memory) { - // uint256 linear_term = hint - poly.coeffs_except_linear_term[0] - poly.coeffs_except_linear_term[0]; - uint256 linear_term = addmod( - hint, - Vesta.negateScalar( - addmod(poly.coeffs_except_linear_term[0], poly.coeffs_except_linear_term[0], Vesta.R_MOD) - ), - Vesta.R_MOD - ); - for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { - // linear_term -= poly.coeffs_except_linear_term[i]; - linear_term = addmod(linear_term, Vesta.negateScalar(poly.coeffs_except_linear_term[i]), Vesta.R_MOD); - } - - uint256[] memory coeffs = new uint256[](poly.coeffs_except_linear_term.length + 1); - coeffs[0] = poly.coeffs_except_linear_term[0]; - coeffs[1] = linear_term; - - for (uint256 i = 1; i < poly.coeffs_except_linear_term.length; i++) { - coeffs[i + 1] = poly.coeffs_except_linear_term[i]; - } - - return UniPoly(coeffs); - } - - function toUInt8Array(uint256 input) private pure returns (uint8[] memory) { - uint8[] memory result = new uint8[](32); - - bytes32 input_bytes = bytes32(input); - - for (uint256 i = 0; i < 32; i++) { - result[i] = uint8(input_bytes[31 - i]); - } - return result; - } - - function toTranscriptBytes(UniPoly memory poly) public pure returns (uint8[] memory) { - uint8[] memory result = new uint8[](32 * (poly.coeffs.length - 1)); - - uint256 offset; - uint8[] memory coeff_bytes = toUInt8Array(poly.coeffs[0]); - for (uint256 i = 0; i < 32; i++) { - result[i] = coeff_bytes[i]; - } - offset += 32; - - for (uint256 i = 2; i < poly.coeffs.length; i++) { - coeff_bytes = toUInt8Array(poly.coeffs[i]); - for (uint256 j = 0; j < 32; j++) { - result[offset + j] = coeff_bytes[j]; - } - offset += 32; - } - - return result; - } -} +import "src/Polynomial.sol"; library PrimarySumcheck { struct SumcheckProof { - PallasPolyLib.CompressedUniPoly[] compressed_polys; + PolyLib.CompressedUniPoly[] compressed_polys; } function verify( @@ -406,33 +22,32 @@ library PrimarySumcheck { uint256 e = claim; uint256[] memory r = new uint256[](num_rounds); - uint8[] memory p_label = new uint8[](1); - uint8[] memory c_label = new uint8[](1); + uint8[] memory label = new uint8[](1); - p_label[0] = 112; - c_label[0] = 99; + require(proof.compressed_polys.length == num_rounds, "[PrimarySumcheck::verify] Wrong number of polynomials"); - require(proof.compressed_polys.length == num_rounds, "Wrong number of polynomials"); - - PallasPolyLib.UniPoly memory poly; + PolyLib.UniPoly memory poly; for (uint256 i = 0; i < num_rounds; i++) { - poly = PallasPolyLib.decompress(proof.compressed_polys[i], e); + poly = PolyLib.decompress(proof.compressed_polys[i], e, Pallas.R_MOD); - require(PallasPolyLib.degree(poly) == degree_bound, "Polynomial has wrong degree"); + require(PolyLib.degree(poly) == degree_bound, "[PrimarySumcheck::verify] Polynomial has wrong degree"); require( - addmod(PallasPolyLib.evalAtZero(poly), PallasPolyLib.evalAtOne(poly), Pallas.R_MOD) == e, - "Polynomial decompression yields incorrect result" + addmod(PolyLib.evalAtZero(poly), PolyLib.evalAtOne(poly, Pallas.R_MOD), Pallas.R_MOD) == e, + "[PrimarySumcheck::verify] Polynomial decompression yields incorrect result" ); - transcript = KeccakTranscriptLib.absorb(transcript, p_label, PallasPolyLib.toTranscriptBytes(poly)); + label[0] = 112; // p_label[0] = 112; + + transcript = KeccakTranscriptLib.absorb(transcript, label, poly); uint256 r_i; - (transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curveVesta(), c_label); + label[0] = 99; // c_label[0] = 99; + (transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curveVesta(), label); r[i] = r_i; - e = PallasPolyLib.evaluate(poly, r_i); + e = PolyLib.evaluate(poly, r_i, Pallas.R_MOD); } return (e, r, transcript); @@ -441,7 +56,7 @@ library PrimarySumcheck { library SecondarySumcheck { struct SumcheckProof { - VestaPolyLib.CompressedUniPoly[] compressed_polys; + PolyLib.CompressedUniPoly[] compressed_polys; } function verify( @@ -454,33 +69,32 @@ library SecondarySumcheck { uint256 e = claim; uint256[] memory r = new uint256[](num_rounds); - uint8[] memory p_label = new uint8[](1); - uint8[] memory c_label = new uint8[](1); + uint8[] memory label = new uint8[](1); - p_label[0] = 112; - c_label[0] = 99; + require(proof.compressed_polys.length == num_rounds, "[SecondarySumcheck::verify] Wrong number of polynomials"); - require(proof.compressed_polys.length == num_rounds, "Wrong number of polynomials"); - - VestaPolyLib.UniPoly memory poly; + PolyLib.UniPoly memory poly; for (uint256 i = 0; i < num_rounds; i++) { - poly = VestaPolyLib.decompress(proof.compressed_polys[i], e); + poly = PolyLib.decompress(proof.compressed_polys[i], e, Vesta.R_MOD); - require(VestaPolyLib.degree(poly) == degree_bound, "Polynomial has wrong degree"); + require(PolyLib.degree(poly) == degree_bound, "[SecondarySumcheck::verify] Polynomial has wrong degree"); require( - addmod(VestaPolyLib.evalAtZero(poly), VestaPolyLib.evalAtOne(poly), Vesta.R_MOD) == e, - "Polynomial decompression yields incorrect result" + addmod(PolyLib.evalAtZero(poly), PolyLib.evalAtOne(poly, Vesta.R_MOD), Vesta.R_MOD) == e, + "[SecondarySumcheck::verify] Polynomial decompression yields incorrect result" ); - transcript = KeccakTranscriptLib.absorb(transcript, p_label, VestaPolyLib.toTranscriptBytes(poly)); + label[0] = 112; // p_label[0] = 112; + + transcript = KeccakTranscriptLib.absorb(transcript, label, poly); uint256 r_i; - (transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curvePallas(), c_label); + label[0] = 99; // c_label[0] = 99; + (transcript, r_i) = KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curvePallas(), label); r[i] = r_i; - e = VestaPolyLib.evaluate(poly, r_i); + e = PolyLib.evaluate(poly, r_i, Vesta.R_MOD); } return (e, r, transcript); diff --git a/src/verifier/step4/sumcheck-data-contract-gen.py b/src/verifier/step4/sumcheck-data-contract-gen.py index 43b1057..6846f63 100644 --- a/src/verifier/step4/sumcheck-data-contract-gen.py +++ b/src/verifier/step4/sumcheck-data-contract-gen.py @@ -30,17 +30,17 @@ def reverse_bytes(val): def sumcheck_data_contract_gen(data, ver: Version): compressed_polynomials = data["compressed_polys"] - output = f"{ver.get_curve()}PolyLib.CompressedUniPoly[] memory proof_array = new {ver.get_curve()}PolyLib.CompressedUniPoly[]({len(compressed_polynomials)});\n" + output = f"PolyLib.CompressedUniPoly[] memory proof_array = new PolyLib.CompressedUniPoly[]({len(compressed_polynomials)});\n" output += "uint256[] memory poly_array;\n" degree = len(compressed_polynomials[0]["coeffs_except_linear_term"]) - output += f"{ver.get_curve()}PolyLib.CompressedUniPoly memory poly;\n" + output += f"PolyLib.CompressedUniPoly memory poly;\n" for poly_idx, poly in enumerate(compressed_polynomials): coeffs = poly["coeffs_except_linear_term"] output += f"poly_array = new uint256[]({degree});\n" for coeff_idx, coeff in enumerate(coeffs): output += f"poly_array[{coeff_idx}] = {h(reverse_bytes(coeff))};\n" - output += f"poly = {ver.get_curve()}PolyLib.CompressedUniPoly(poly_array);\n" + output += f"poly = PolyLib.CompressedUniPoly(poly_array);\n" output += f"proof_array[{poly_idx}] = poly;\n" output += f"return {ver.value}Sumcheck.SumcheckProof(proof_array);\n" @@ -81,6 +81,7 @@ def sumcheck_function_return(ver: Version) -> str: header = "// SPDX-License-Identifier: Apache-2.0\n" header += f"// Do not change manually. This contract has been auto-generated by {sys.argv[0]}\n" header += "pragma solidity ^0.8.0;\n" +header += 'import "src/Polynomial.sol";\n' header += 'import "src/verifier/step4/SumcheckLogic.sol";\n' sumcheck_function_doc = "// This function returns a SumcheckProof for the relevant corresponding field\n" @@ -156,4 +157,4 @@ def sumcheck_function_return(ver: Version) -> str: data_contract_body += "}\n" print(header) -print(data_contract_body) \ No newline at end of file +print(data_contract_body) diff --git a/test/nova-verifier-tests.t.sol b/test/nova-verifier-tests.t.sol index 2bc2047..ed14a9a 100644 --- a/test/nova-verifier-tests.t.sol +++ b/test/nova-verifier-tests.t.sol @@ -12,6 +12,8 @@ import "src/poseidon/Sponge.sol"; import "src/verifier/step4/SubStep2.sol"; import "src/verifier/step4/SumcheckLogic.sol"; import "src/verifier/step4/SumcheckData.sol"; +import "src/pasta/Pallas.sol"; +import "src/pasta/Vesta.sol"; contract NovaVerifierContractTest is Test { function testVerificationStep1() public pure { diff --git a/test/sumcheck-tests.t.sol b/test/sumcheck-tests.t.sol index a7e908e..0b15563 100644 --- a/test/sumcheck-tests.t.sol +++ b/test/sumcheck-tests.t.sol @@ -363,16 +363,16 @@ contract SumcheckTest is Test { uint256 e = 0; uint256[] memory raw_poly; - PallasPolyLib.CompressedUniPoly memory poly; + PolyLib.CompressedUniPoly memory poly; raw_poly = new uint256[](3); raw_poly[0] = 0x0000000000000000000000000000000000000000000000000000000000000000; raw_poly[1] = 0x3156ab3e1bea772559548817e8d23e4d60a57bc280baf032420e3c6133dd7e2f; raw_poly[2] = 0x1dff490409def9717737be07798dad2c3a6bc952eec88937c6076da01f9d9af0; - poly = PallasPolyLib.CompressedUniPoly(raw_poly); + poly = PolyLib.CompressedUniPoly(raw_poly); - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.decompress(poly, e); + PolyLib.UniPoly memory uni_poly = PolyLib.decompress(poly, e, Pallas.R_MOD); assertEq(uni_poly.coeffs[0], 0x0000000000000000000000000000000000000000000000000000000000000000); assertEq(uni_poly.coeffs[1], 0x30aa0bbdda368f692f73b9e09da01486a97bece2a3a5d85110782c40ac84e6e3); @@ -387,9 +387,9 @@ contract SumcheckTest is Test { coeffs[2] = 0x12fbd521f3fdb45f92e1bc9d045197000c74f40e67292ccac43f9b65f854b955; coeffs[3] = 0x0bf922cb074481cf22bfe02c62561af632503238b4198aeb5e2bb5cf8dd0fac3; - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.UniPoly(coeffs); + PolyLib.UniPoly memory uni_poly = PolyLib.UniPoly(coeffs); - assertEq(PallasPolyLib.evalAtZero(uni_poly), 0x2a0cd6f39b97ed92a45886a8e80a5944ed373498922050a3745f29c2ec6667ae); + assertEq(PolyLib.evalAtZero(uni_poly), 0x2a0cd6f39b97ed92a45886a8e80a5944ed373498922050a3745f29c2ec6667ae); } function testPolyEvalAtOne1() public { @@ -399,9 +399,12 @@ contract SumcheckTest is Test { coeffs[2] = 0x3156ab3e1bea772559548817e8d23e4d60a57bc280baf032420e3c6133dd7e2f; coeffs[3] = 0x1dff490409def9717737be07798dad2c3a6bc952eec88937c6076da01f9d9af0; - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.UniPoly(coeffs); + PolyLib.UniPoly memory uni_poly = PolyLib.UniPoly(coeffs); - assertEq(PallasPolyLib.evalAtOne(uni_poly), 0x0000000000000000000000000000000000000000000000000000000000000000); + assertEq( + PolyLib.evalAtOne(uni_poly, Pallas.R_MOD), + 0x0000000000000000000000000000000000000000000000000000000000000000 + ); } function testPolyEvalAtOne2() public { @@ -411,9 +414,12 @@ contract SumcheckTest is Test { coeffs[2] = 0x12fbd521f3fdb45f92e1bc9d045197000c74f40e67292ccac43f9b65f854b955; coeffs[3] = 0x0bf922cb074481cf22bfe02c62561af632503238b4198aeb5e2bb5cf8dd0fac3; - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.UniPoly(coeffs); + PolyLib.UniPoly memory uni_poly = PolyLib.UniPoly(coeffs); - assertEq(PallasPolyLib.evalAtOne(uni_poly), 0x1ed3a7699f3da343ac93395658773a5fe992d0ec2c26027ba1a4d0342d555a07); + assertEq( + PolyLib.evalAtOne(uni_poly, Pallas.R_MOD), + 0x1ed3a7699f3da343ac93395658773a5fe992d0ec2c26027ba1a4d0342d555a07 + ); } function testPolyEvalAtOne3() public { @@ -423,9 +429,12 @@ contract SumcheckTest is Test { coeffs[2] = 0x281222608e87d3d0d154e6621dbe68a181e5e646bbaab420859659a0e042dd4c; coeffs[3] = 0x2ae2df351788ef2c603da9501a93ea6ea1080a1742c923a56e0daa7e0599cd1e; - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.UniPoly(coeffs); + PolyLib.UniPoly memory uni_poly = PolyLib.UniPoly(coeffs); - assertEq(PallasPolyLib.evalAtOne(uni_poly), 0x2e5da7083e43a9fd5b62b5c356f420d1b97daa663fb77ab9c3815fecf111719b); + assertEq( + PolyLib.evalAtOne(uni_poly, Pallas.R_MOD), + 0x2e5da7083e43a9fd5b62b5c356f420d1b97daa663fb77ab9c3815fecf111719b + ); } function testPolyToTranscriptBytes() public { @@ -435,9 +444,9 @@ contract SumcheckTest is Test { coeffs[2] = 0x1785c227874bcb2e816af7d0b1b39d6369dc3017b21cfdaccbbbdf3e9a63c9ca; coeffs[3] = 0x3001d35ebe98119d070a55ea1544bcb729493df381bf7c80ffb0203b2956d7c9; - PallasPolyLib.UniPoly memory uni_poly = PallasPolyLib.UniPoly(coeffs); + PolyLib.UniPoly memory uni_poly = PolyLib.UniPoly(coeffs); - uint8[] memory polyBytes = PallasPolyLib.toTranscriptBytes(uni_poly); + uint8[] memory polyBytes = PolyLib.toTranscriptBytes(uni_poly); uint8[] memory expected = new uint8[](96); expected[0] = 0xac;