Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions circuits/circuits/utils/passport/disclose/disclose_id.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
}
}
14 changes: 5 additions & 9 deletions circuits/tests/disclose/vc_and_disclose_id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -85,7 +81,7 @@ describe('Disclose', function () {
selector_older_than,
tree,
majority,
passportNo_smt,
null,
nameAndDob_smt,
nameAndYob_smt,
selector_ofac,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -269,7 +265,7 @@ describe('Disclose', function () {
selector_older_than,
tree,
majority,
passportNo_smt,
null,
nameAndDob_smt,
nameAndYob_smt,
'1', // selector_ofac
Expand Down