From e278c6e828fc30be7cbdcb3693696b7c83aabcdc Mon Sep 17 00:00:00 2001 From: erdoganishe <59971786+erdoganishe@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:19:58 +0200 Subject: [PATCH] Add easm test multiple pasport processing (#53) * Add LTU and KNA support * Refactor new cases * Refactor hasher * Refactor hasher * Update registerIdentityBuilder.circom * Add wasm test multiple passport processing * Minor fix --------- Co-authored-by: Denis Riabtsev <68712122+1KitCat1@users.noreply.github.com> --- .../passportVerificationBuilder.circom | 2 +- tests/tests/automatisationTest.js | 21 ++++++++++++++++--- tests/tests/write_to_files.py | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/circuits/passportVerification/passportVerificationBuilder.circom b/circuits/passportVerification/passportVerificationBuilder.circom index 146993f..2c4ccbb 100644 --- a/circuits/passportVerification/passportVerificationBuilder.circom +++ b/circuits/passportVerification/passportVerificationBuilder.circom @@ -187,7 +187,7 @@ template PassportVerificationBuilder(SIGNATURE_TYPE,DG_HASH_TYPE,EC_BLOCK_NUMBER var EC_FIELD_SIZE = CHUNK_NUMBER * CHUNK_SIZE; var DIFF = 0; if (EC_FIELD_SIZE > 248){ - DIFF = 248 - EC_FIELD_SIZE; + DIFF = EC_FIELD_SIZE - 248; } component xToNum = Bits2Num(EC_FIELD_SIZE - DIFF); component yToNum = Bits2Num(EC_FIELD_SIZE - DIFF); diff --git a/tests/tests/automatisationTest.js b/tests/tests/automatisationTest.js index 52bf2b9..daca22a 100644 --- a/tests/tests/automatisationTest.js +++ b/tests/tests/automatisationTest.js @@ -12,9 +12,19 @@ const Fr = new F1Field(exports.p); const assert = chai.assert; +let files = []; function generateFilesForAll(filenames, done) { let index = 0; + const tmpfilePath = path.join(__dirname, `./inputs/tmp.txt`); + fs.writeFile(tmpfilePath, '', (err) => { + if (err) { + console.error('Error emptying file:', err); + } else { + console.log('File emptied successfully'); + } + }); + function executeNext() { if (index >= filenames.length) { return done(); // All files have been processed @@ -32,7 +42,9 @@ function generateFilesForAll(filenames, done) { console.error(`Script stderr: ${stderr}`); return done(new Error(stderr)); } - + const tmp_txt = path.join(__dirname, `./inputs/tmp.txt`); + const short_fileneme = fs.promises.readFile(tmp_txt, 'utf8'); + files.push(short_fileneme); index++; setTimeout(executeNext, 2000); // 2-second delay before processing the next file }); @@ -53,6 +65,7 @@ describe("File generation test", function () { generateFilesForAll(filenames.map(file => path.join(passportDir, file)), done); }); + let counter = 0; filenames.forEach(filename => { // it("Verification passport test", async function () { @@ -89,9 +102,10 @@ describe("File generation test", function () { it("Register identity test", async function () { const tmp_txt = path.join(__dirname, `./inputs/tmp.txt`); - const short_fileneme = await fs.promises.readFile(tmp_txt, 'utf8'); - + const short_filenemes = await fs.promises.readFile(tmp_txt, 'utf8'); + let short_fileneme = short_filenemes.split("\n")[counter]; + console.log("Executing " + short_fileneme + ".circom"); const testJson = path.join(__dirname, `./inputs/generated/input_${short_fileneme}_2.dev.json`); try { @@ -118,6 +132,7 @@ describe("File generation test", function () { console.error('Error:', err); throw err; } + counter+=1; }); }); diff --git a/tests/tests/write_to_files.py b/tests/tests/write_to_files.py index 9e6035d..1d0cf6c 100644 --- a/tests/tests/write_to_files.py +++ b/tests/tests/write_to_files.py @@ -73,5 +73,5 @@ def write_to_json(dg1_res, dg15_res, sa_res, ec_res, pubkey_arr, signature_arr, }, f_out, indent=4) def write_tmp_to_file(real_name): - with open('./tests/tests/inputs/tmp.txt', 'w') as file: - file.write(real_name) \ No newline at end of file + with open('./tests/tests/inputs/tmp.txt', 'a') as file: + file.write(real_name+"\n") \ No newline at end of file