Skip to content

Commit

Permalink
delete repeated test
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenciak committed Jul 26, 2023
1 parent ad161de commit f6b5dbb
Showing 1 changed file with 0 additions and 264 deletions.
264 changes: 0 additions & 264 deletions test/sumcheck-tests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,270 +359,6 @@ contract SumcheckTest is Test {
assertEq(tau[13], 0x25ad865935043775d676da736cc400404b1060585df1386dd4f560de4c4680bc);
}

function loadCompressedPolysPrimary(uint256 num_rounds_x)
public
pure
returns (PallasPolyLib.CompressedUniPoly[] memory)
{
PallasPolyLib.CompressedUniPoly[] memory compressed_polys = new PallasPolyLib.CompressedUniPoly[](num_rounds_x);

uint256[] memory raw_poly;
PallasPolyLib.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);
compressed_polys[0] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x2a0cd6f39b97ed92a45886a8e80a5944ed373498922050a3745f29c2ec6667ae;
raw_poly[1] = 0x12fbd521f3fdb45f92e1bc9d045197000c74f40e67292ccac43f9b65f854b955;
raw_poly[2] = 0x0bf922cb074481cf22bfe02c62561af632503238b4198aeb5e2bb5cf8dd0fac3;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[1] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x1a7160ebd6e443d51da504fa28e5168868012deaacfc8188014cde90744297bc;
raw_poly[1] = 0x281222608e87d3d0d154e6621dbe68a181e5e646bbaab420859659a0e042dd4c;
raw_poly[2] = 0x2ae2df351788ef2c603da9501a93ea6ea1080a1742c923a56e0daa7e0599cd1e;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[2] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x2cadc3a75b23fdebbcef67f3b2d193348ea927786e761d43406e4358d324c4d1;
raw_poly[1] = 0x06d2d5a5f516f2734156ed7b78e9687e0a6a52c89456c09af0609fe5b27b1fca;
raw_poly[2] = 0x0a1a4cee698d0bea9725c189f39509b1e3fb54dcbf0cfeb0ead4a679e30b6b97;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[3] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x21d36d5eeab44b9e1dab9a1941353a9b259b0e37f8130c97ac45e7ee1ee46e5d;
raw_poly[1] = 0x09cd8f4b3cdb357a80b6d967f5c0f33335ba536e76092ed3ac9ce4b576777817;
raw_poly[2] = 0x047de779ead5aef11c60969244ec4bdcf2ef7e7081f734a4239cfe4607768d6c;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[4] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x25291aac7c299b973f93613a17c13191037cb2fd01e2eccdf4697deaf0c9a04a;
raw_poly[1] = 0x35f26c09cec10804a870e39ef1d192dd5609b1481229da10415680c367fce145;
raw_poly[2] = 0x2b37031e0daac3039e35efc738ca354614b0263e45658a0c90de1dccd6735711;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[5] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x02563c53bdabeb954ec43901c61cb5ad9e81c2cb7dd31b9f46f80440078fd7fd;
raw_poly[1] = 0x0807ce199363c83d6c6fbeb708cef45c4f96236b7e861812b879de1a205db161;
raw_poly[2] = 0x32fcb855b9dd89717b27154af419b9389ad459a36f94730efe771b0f5940f633;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[6] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x2087b996187c4be4d5eb576a9b6d00d315ad25cee961c8f424621a41c6b0c971;
raw_poly[1] = 0x1ef0832cd1a4ba98bf66682a990f9c56216fc31b39d2adecc94c5cc9b4031ab8;
raw_poly[2] = 0x0b652696a88affcc0ab69d52903bcd3965f262ddf222c3fe2da3af2fa6a0f27a;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[7] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x36a3f10a14df17c5dde2ec64df992874659af5e22e4db23ad1ea73d66807c8ef;
raw_poly[1] = 0x09c9b72ebe89f51aec378af41815f75964c4d8f993e5f9b1681e2b21a42385f9;
raw_poly[2] = 0x1b75c4dd2c3cb3a62b90b02ea20c4051ca98c9d9c1424a2421f947c12c7d3eb7;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[8] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x2828a18fa8618435b512a4292b9fcea3b150859f50a3e74bb2a3ee15ae88da9c;
raw_poly[1] = 0x1964a64964a1859af0d3d333762bbec3a22487ca091e6b89494ce72cef90130a;
raw_poly[2] = 0x10e43d7966039b6cc7b1ced16fd886fe1ca375a8485b820f48611b822781226c;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[9] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x3eb95a4f74af56e31c0b35fe7498c938009c9bea670a61a8383dab0c4c429bfe;
raw_poly[1] = 0x0dff761d89b94a2551136b0f4df357b400850910295952ad9ee5c2f85123e5e5;
raw_poly[2] = 0x13e46518e76c51be58f3748832326568b0c2cd2e683ae9bb4b1ece9b93c56376;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[10] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x26592d33bfd615e40cfe4c9a0b8e56e88a2c8aa00c84f49b783b4f0c1c359706;
raw_poly[1] = 0x29f1f0b13ba89df090f4d23bc74060929ca75281737b7200ec6ad66e94e3c1e2;
raw_poly[2] = 0x36ede69bcd3a25e759a2b798f83b569a4906b688623ac23529b8cdc12355abc3;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[11] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x05d85babbee109ab6d627a03a8e8ea0d372d96cfa1929cee86ae5af797cb9657;
raw_poly[1] = 0x2b9ce21b23851fcce3cc996e5c80da63f8818737d35957b31b0125bccfebe967;
raw_poly[2] = 0x15f5eb776094fbed243e952d5c3512ec31b123db1af788fa9686b8b18b7d7168;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[12] = poly;

raw_poly = new uint256[](3);
raw_poly[0] = 0x07e180612d7bd63a41bd64c2e6c1b0c5edbe6fa6f318cba353edb77eecd59bac;
raw_poly[1] = 0x1785c227874bcb2e816af7d0b1b39d6369dc3017b21cfdaccbbbdf3e9a63c9ca;
raw_poly[2] = 0x3001d35ebe98119d070a55ea1544bcb729493df381bf7c80ffb0203b2956d7c9;

poly = PallasPolyLib.CompressedUniPoly(raw_poly);
compressed_polys[13] = poly;

return compressed_polys;
}

function testSumcheckPrimary() public {
uint256 e = 0;
uint256 num_rounds_x = 14;
uint256 degreeBound = 3;

uint16 rounds = 14;
uint8[] memory state = new uint8[](KeccakTranscriptLib.KECCAK_TRANSCRIPT_STATE_BYTE_LEN);
state[0] = 0x6e;
state[1] = 0x4d;
state[2] = 0x2b;
state[3] = 0x8b;
state[4] = 0x6c;
state[5] = 0x32;
state[6] = 0xc7;
state[7] = 0xce;
state[8] = 0xda;
state[9] = 0x36;
state[10] = 0x09;
state[11] = 0xca;
state[12] = 0x86;
state[13] = 0xe9;
state[14] = 0x7b;
state[15] = 0x40;
state[16] = 0xc7;
state[17] = 0x5c;
state[18] = 0x3f;
state[19] = 0xf4;
state[20] = 0xc0;
state[21] = 0xc8;
state[22] = 0xde;
state[23] = 0x11;
state[24] = 0x18;
state[25] = 0x3c;
state[26] = 0xe5;
state[27] = 0x6f;
state[28] = 0x51;
state[29] = 0x65;
state[30] = 0xb3;
state[31] = 0x00;
state[32] = 0x97;
state[33] = 0x32;
state[34] = 0x29;
state[35] = 0xfc;
state[36] = 0xbe;
state[37] = 0x23;
state[38] = 0x81;
state[39] = 0x62;
state[40] = 0x89;
state[41] = 0xaf;
state[42] = 0xab;
state[43] = 0x47;
state[44] = 0xe3;
state[45] = 0xd6;
state[46] = 0x54;
state[47] = 0xe0;
state[48] = 0x3a;
state[49] = 0xaa;
state[50] = 0x9d;
state[51] = 0xd4;
state[52] = 0x51;
state[53] = 0x7d;
state[54] = 0x37;
state[55] = 0x72;
state[56] = 0x53;
state[57] = 0xd0;
state[58] = 0x3e;
state[59] = 0x03;
state[60] = 0xe7;
state[61] = 0xf8;
state[62] = 0xd7;
state[63] = 0x50;

uint8[] memory transcriptField = new uint8[](0);

KeccakTranscriptLib.KeccakTranscript memory transcript =
KeccakTranscriptLib.KeccakTranscript(rounds, state, transcriptField);

//uint256 claim_outer_final_expected = 0x346b738474d5b2cda8c002566f1a7004d06cab6b467303a2b7c4b04eaa6df733;
uint256[] memory r_x_expected = new uint256[](14 + 1);
r_x_expected[0] = 0x265e1d73ee4ce9a23d98bf74a9807abd1c0bedf6368e8db884c05bd9336549bd;
r_x_expected[1] = 0x3a009bec1c4dc776ba75c643de9e61b3070a4a6b3865b5751a3d6f517e483a4a;
r_x_expected[2] = 0x3932891c1f17ba15d07baba47d6599058812a73225d11a554ced25ad00fd78dd;
r_x_expected[3] = 0x140622b73b006b8470ed724172721f7d25f3efb2208f42c73e0658fbc493579b;
r_x_expected[4] = 0x2516f6f6ccf854843d9319fad46a0dff2729c608af31c143590c347d0f0805c6;
r_x_expected[5] = 0x28942f6ecc7b89c49bfaa569687a9b6902ace63343300e808e86d608eca3f9dc;
r_x_expected[6] = 0x1ae6542e6085a0c42ae6e947813a6f701329263a1a59f823cb544e83dce0b9cf;
r_x_expected[7] = 0x39979cf05d7d96da05aba4dd24e9f072d52e8efbf4740f1a857680a096193f8b;
r_x_expected[8] = 0x2d887fae3954bcb89f20051c96f6812eb841ccc29c8b56e2879e445f74cb4331;
r_x_expected[9] = 0x29fb4b14d5d53616b881719c4986e5aad92f7320fc1e6c89f301b8a81ab72896;
r_x_expected[10] = 0x2d69fc2f360b3328cb723687589b065ff4250c414c817bd4f6b187583e103270;
r_x_expected[11] = 0x06dc812740949078bc2487f020274042e7400e44f7a95d26c2cf6de8b7ba5099;
r_x_expected[12] = 0x39ade5abede093bbb12d81f27c28cbc7149d1b1ad6e43c49424687fb4c29ae31;
r_x_expected[13] = 0x3d764ae71118a8a3c653b58c534db9fae607dd9c316cdd3675de0d62e0882bf1;
r_x_expected[14] = 0x346b738474d5b2cda8c002566f1a7004d06cab6b467303a2b7c4b04eaa6df733; // <-- include claim_outer_final_expected due to avoiding StackTooDeep

PallasPolyLib.CompressedUniPoly[] memory compressed_polys = loadCompressedPolysPrimary(num_rounds_x);

if (compressed_polys.length != num_rounds_x) {
console.log("[NovaError::InvalidSumcheckProof], compressed_polys.length != num_rounds_x");
revert();
}

PallasPolyLib.UniPoly memory uni_poly;
uint8[] memory transcriptBytes;

// use transcriptField as label
transcriptField = new uint8[](1);

uint256 r_i;
for (uint256 index = 0; index < compressed_polys.length; index++) {
uni_poly = PallasPolyLib.decompress(compressed_polys[index], e);

if (PallasPolyLib.degree(uni_poly) != degreeBound) {
console.log("[NovaError::InvalidSumcheckProof], PallasPolyLib.degree(uni_poly) != degreeBound");
revert();
}

require(
addmod(PallasPolyLib.evalAtZero(uni_poly), PallasPolyLib.evalAtOne(uni_poly), Pallas.R_MOD) == e,
"evalAtZero + evalAtOne != e"
);

transcriptBytes = PallasPolyLib.toTranscriptBytes(uni_poly);

transcriptField[0] = 0x70; // b"p" in Rust
transcript = KeccakTranscriptLib.absorb(transcript, transcriptField, transcriptBytes);

transcriptField[0] = 0x63; // b"c" in Rust
(transcript, r_i) =
KeccakTranscriptLib.squeeze(transcript, ScalarFromUniformLib.curveVesta(), transcriptField); // Vesta

e = PallasPolyLib.evaluate(uni_poly, r_i);

assertEq(r_i, r_x_expected[index]);
}

assertEq(e, r_x_expected[r_x_expected.length - 1]);
}

function testPolyUncompress() public {
uint256 e = 0;

Expand Down

0 comments on commit f6b5dbb

Please sign in to comment.