Skip to content

Commit

Permalink
Add easm test multiple pasport processing (#53)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
erdoganishe and 1KitCat1 authored Nov 7, 2024
1 parent 617b408 commit e278c6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 18 additions & 3 deletions tests/tests/automatisationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
});
Expand All @@ -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 () {

Expand Down Expand Up @@ -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 {
Expand All @@ -118,6 +132,7 @@ describe("File generation test", function () {
console.error('Error:', err);
throw err;
}
counter+=1;
});
});

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/write_to_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
with open('./tests/tests/inputs/tmp.txt', 'a') as file:
file.write(real_name+"\n")

0 comments on commit e278c6e

Please sign in to comment.