mirror of
https://github.com/selfxyz/self.git
synced 2026-01-10 07:08:10 -05:00
add variable first and lastname size
This commit is contained in:
@@ -14,13 +14,14 @@ let circuit: any;
|
||||
// Mock passport added in ofac list to test circuits
|
||||
const passportData = genMockPassportData('rsa_sha256', 'FRA', '040211', '300101');
|
||||
// Mock passport not added in ofac list to test circuits
|
||||
const passportData2 = genMockPassportData(
|
||||
const passportDataInOfac = genMockPassportData(
|
||||
'rsa_sha256',
|
||||
'FRA',
|
||||
'000102',
|
||||
'541007',
|
||||
'300101',
|
||||
'24HB81833',
|
||||
'CLAQUE'
|
||||
'98lh90556',
|
||||
'HENAO MONTOYA',
|
||||
'ARCANGEL DE JESUS'
|
||||
);
|
||||
|
||||
|
||||
@@ -52,13 +53,13 @@ describe('OFAC - Passport number match', function () {
|
||||
passno_smt.import(passportNojson);
|
||||
const proofLevel = 3;
|
||||
memSmtInputs = generateCircuitInputsOfac(
|
||||
passportData,
|
||||
passportDataInOfac,
|
||||
passno_smt,
|
||||
proofLevel
|
||||
);
|
||||
|
||||
nonMemSmtInputs = generateCircuitInputsOfac(
|
||||
passportData2,
|
||||
passportData,
|
||||
passno_smt,
|
||||
proofLevel
|
||||
);
|
||||
@@ -116,14 +117,14 @@ describe('OFAC - Name and DOB match', function () {
|
||||
const proofLevel = 2;
|
||||
memSmtInputs = generateCircuitInputsOfac(
|
||||
// proof of membership
|
||||
passportData,
|
||||
passportDataInOfac,
|
||||
namedob_smt,
|
||||
proofLevel
|
||||
);
|
||||
|
||||
nonMemSmtInputs = generateCircuitInputsOfac(
|
||||
// proof of non-membership
|
||||
passportData2,
|
||||
passportData,
|
||||
namedob_smt,
|
||||
proofLevel
|
||||
);
|
||||
@@ -181,14 +182,14 @@ describe('OFAC - Name match', function () {
|
||||
const proofLevel = 1;
|
||||
memSmtInputs = generateCircuitInputsOfac(
|
||||
// proof of membership
|
||||
passportData,
|
||||
passportDataInOfac,
|
||||
name_smt,
|
||||
proofLevel
|
||||
);
|
||||
|
||||
nonMemSmtInputs = generateCircuitInputsOfac(
|
||||
// proof of non-membership
|
||||
passportData2,
|
||||
passportData,
|
||||
name_smt,
|
||||
proofLevel
|
||||
);
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
[
|
||||
{
|
||||
"First_Name": "ALPHONSE HUGUES ALBERT",
|
||||
"Last_Name": "DUPONT",
|
||||
"day" : "11",
|
||||
"month" : "Feb",
|
||||
"year" : "2004"
|
||||
},
|
||||
{
|
||||
"First_Name": "ABU",
|
||||
"Last_Name": "ABBAS",
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
[
|
||||
{
|
||||
"Pass_No": "24HB81832",
|
||||
"Pass_Country": "france"
|
||||
},
|
||||
{
|
||||
"Pass_No": "1084010",
|
||||
"Pass_Country": "egypt"
|
||||
|
||||
@@ -33,14 +33,42 @@ export function genMockPassportData(
|
||||
nationality: keyof typeof countryCodes,
|
||||
birthDate: string,
|
||||
expiryDate: string,
|
||||
passportNumber: string = "24HB81832",
|
||||
lastName: string = "DUPONT"
|
||||
passportNumber: string = "15AA81234",
|
||||
lastName: string = "DUPONT",
|
||||
firstName: string = "ALPHONSE HUGHUES ALBERT"
|
||||
): PassportData {
|
||||
if (birthDate.length !== 6 || expiryDate.length !== 6) {
|
||||
throw new Error('birthdate and expiry date have to be in the "YYMMDD" format');
|
||||
}
|
||||
|
||||
const mrz = `P<${nationality}${lastName}<<ALPHONSE<HUGUES<ALBERT<<<<<<<<<${passportNumber}4${nationality}${birthDate}1M${expiryDate}5<<<<<<<<<<<<<<02`;
|
||||
// Prepare last name: Convert to uppercase, remove invalid characters, split by spaces, and join with '<'
|
||||
const lastNameParts = lastName.toUpperCase().replace(/[^A-Z< ]/g, '').split(' ');
|
||||
const formattedLastName = lastNameParts.join('<');
|
||||
|
||||
// Prepare first name: Convert to uppercase, remove invalid characters, split by spaces, and join with '<'
|
||||
const firstNameParts = firstName.toUpperCase().replace(/[^A-Z< ]/g, '').split(' ');
|
||||
const formattedFirstName = firstNameParts.join('<');
|
||||
|
||||
// Build the first line of MRZ
|
||||
let mrzLine1 = `P<${nationality}${formattedLastName}<<${formattedFirstName}`;
|
||||
|
||||
// Pad the first line with '<' to make it exactly 44 characters
|
||||
mrzLine1 = mrzLine1.padEnd(44, '<');
|
||||
|
||||
if (mrzLine1.length > 44) {
|
||||
throw new Error('First line of MRZ exceeds 44 characters');
|
||||
}
|
||||
|
||||
// Build the second line of MRZ
|
||||
const mrzLine2 = `${passportNumber}4${nationality}${birthDate}1M${expiryDate}5<<<<<<<<<<<<<<02`;
|
||||
|
||||
// Combine both lines to form the MRZ
|
||||
const mrz = mrzLine1 + mrzLine2;
|
||||
|
||||
// Validate the MRZ length
|
||||
if (mrz.length !== 88) {
|
||||
throw new Error(`MRZ must be 88 characters long, got ${mrz.length}`);
|
||||
}
|
||||
|
||||
let privateKeyPem: string;
|
||||
let dsc: string;
|
||||
|
||||
Reference in New Issue
Block a user