Skip to content

Commit

Permalink
Update compile_prove_verify.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Sep 26, 2023
1 parent f1d3602 commit 61f3f14
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async function getFile(url: URL): Promise<string> {
}

const CIRCUIT_SIZE = 2 ** 19;
const FIELD_ELEMENT_BYTES = 32;

const test_cases = [
{
Expand All @@ -50,7 +51,7 @@ const test_cases = [
case: "compiler/integration-tests/test/circuits/main",
compiled: "foundry-project/out/main.sol/UltraVerifier.json",
deployInformation: "foundry-project/main_output.json",
publicInputsLength: 32,
numPublicInputs: 1,
},
];

Expand Down Expand Up @@ -186,13 +187,14 @@ test_cases.forEach((testInfo) => {

try {
let result;
if (testInfo.publicInputsLength === 0) {
if (testInfo.numPublicInputs === 0) {
result = await contract.verify(proof, []);
} else {
const publicInputs = Array.from({ length: testInfo.publicInputsLength / 32 }, (_, i) =>
proof.slice(i, i + 1)
);
const slicedProof = proof.slice(testInfo.publicInputsLength);
const publicInputs = Array.from({ length: testInfo.numPublicInputs }, (_, i) => {
const offset = i * FIELD_ELEMENT_BYTES;
return proof.slice(offset, offset + FIELD_ELEMENT_BYTES)
});
const slicedProof = proof.slice(testInfo.numPublicInputs * FIELD_ELEMENT_BYTES);
result = await contract.verify(slicedProof, publicInputs);
}

Expand Down

0 comments on commit 61f3f14

Please sign in to comment.