mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 14:48:06 -05:00
update vc_and_disclose_id test (dev branch) (#641)
* fix: vc_and_disclose_id test * chore: yarn prettier
This commit is contained in:
@@ -42,9 +42,9 @@ template DISCLOSE_ID(
|
||||
signal input ofac_nameyob_smt_leaf_key;
|
||||
signal input ofac_nameyob_smt_root;
|
||||
signal input ofac_nameyob_smt_siblings[nameyobTreeLevels];
|
||||
|
||||
|
||||
signal input selector_ofac;
|
||||
|
||||
|
||||
// assert selectors are 0 or 1
|
||||
for (var i = 0; i < 90; i++) {
|
||||
selector_dg1[i] * (selector_dg1[i] - 1) === 0;
|
||||
@@ -64,11 +64,11 @@ template DISCLOSE_ID(
|
||||
older_than_verified[0] <== isOlderThan.out * majority[0];
|
||||
older_than_verified[1] <== isOlderThan.out * majority[1];
|
||||
|
||||
signal revealedData[94]; // mrz: 88 bytes | older_than: 2 bytes | ofac: 3 byte
|
||||
signal revealedData[94]; // mrz: 90 bytes | older_than: 2 bytes | ofac: 2 byte
|
||||
for (var i = 0; i < 90; i++) {
|
||||
revealedData[i] <== dg1[5+i] * selector_dg1[i];
|
||||
}
|
||||
|
||||
|
||||
revealedData[90] <== older_than_verified[0] * selector_older_than;
|
||||
revealedData[91] <== older_than_verified[1] * selector_older_than;
|
||||
|
||||
@@ -91,4 +91,4 @@ template DISCLOSE_ID(
|
||||
|
||||
var chunkLength = computeIntChunkLength(MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH * 3);
|
||||
signal output forbidden_countries_list_packed[chunkLength] <== ProveCountryIsNotInList_ID(MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH)(dg1, forbidden_countries_list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import crypto from 'crypto';
|
||||
import { SMT } from '@openpassport/zk-kit-smt';
|
||||
import nameAndDobjson from '@selfxyz/common/ofacdata/outputs/nameAndDobSMT_ID.json' with { type: 'json' };
|
||||
import nameAndYobjson from '@selfxyz/common/ofacdata/outputs/nameAndYobSMT_ID.json' with { type: 'json' };
|
||||
import passportNojson from '@selfxyz/common/ofacdata/outputs/passportNoAndNationalitySMT.json' with { type: 'json' };
|
||||
import {
|
||||
formatAndUnpackForbiddenCountriesList,
|
||||
formatAndUnpackReveal,
|
||||
@@ -53,9 +52,6 @@ describe('Disclose', function () {
|
||||
const tree: any = new LeanIMT((a, b) => poseidon2([a, b]), []);
|
||||
tree.insert(BigInt(commitment));
|
||||
|
||||
const passportNo_smt = new SMT(poseidon2, true);
|
||||
passportNo_smt.import(passportNojson);
|
||||
|
||||
const nameAndDob_smt = new SMT(poseidon2, true);
|
||||
nameAndDob_smt.import(nameAndDobjson);
|
||||
|
||||
@@ -85,7 +81,7 @@ describe('Disclose', function () {
|
||||
selector_older_than,
|
||||
tree,
|
||||
majority,
|
||||
passportNo_smt,
|
||||
null,
|
||||
nameAndDob_smt,
|
||||
nameAndYob_smt,
|
||||
selector_ofac,
|
||||
@@ -141,7 +137,7 @@ describe('Disclose', function () {
|
||||
const revealedData_packed = await circuit.getOutput(w, ['revealedData_packed[4]']);
|
||||
const reveal_unpacked = formatAndUnpackReveal(revealedData_packed, 'id');
|
||||
|
||||
for (let i = 0; i < 88; i++) {
|
||||
for (let i = 0; i < 90; i++) {
|
||||
if (selector_dg1[i] == '1') {
|
||||
const char = String.fromCharCode(Number(inputs.dg1[i + 5]));
|
||||
assert(reveal_unpacked[i] == char, 'Should reveal the right character');
|
||||
@@ -187,8 +183,8 @@ describe('Disclose', function () {
|
||||
const revealedData_packed = await circuit.getOutput(w, ['revealedData_packed[4]']);
|
||||
|
||||
const reveal_unpacked = formatAndUnpackReveal(revealedData_packed, 'id');
|
||||
expect(reveal_unpacked[88]).to.equal('\x00');
|
||||
expect(reveal_unpacked[89]).to.equal('\x00');
|
||||
expect(reveal_unpacked[90]).to.equal('\x00');
|
||||
expect(reveal_unpacked[91]).to.equal('\x00');
|
||||
});
|
||||
|
||||
describe('OFAC disclosure', function () {
|
||||
@@ -269,7 +265,7 @@ describe('Disclose', function () {
|
||||
selector_older_than,
|
||||
tree,
|
||||
majority,
|
||||
passportNo_smt,
|
||||
null,
|
||||
nameAndDob_smt,
|
||||
nameAndYob_smt,
|
||||
'1', // selector_ofac
|
||||
|
||||
Reference in New Issue
Block a user