@zkpassport/sdk 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.cjs +10 -4
- package/dist/cjs/constants.d.cts +5 -3
- package/dist/cjs/index.cjs +765 -737
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/public-input-checker.cjs +59 -58
- package/dist/cjs/solidity-verifier.cjs +692 -667
- package/dist/cjs/types.d.cts +11 -2
- package/dist/esm/chunk-I7PGO4XY.js +2567 -0
- package/dist/esm/chunk-JG37KYXW.js +18 -0
- package/dist/esm/{chunk-BUYJZSHP.js → chunk-O7ZONMCQ.js} +60 -59
- package/dist/esm/constants.d.ts +5 -3
- package/dist/esm/constants.js +7 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +16 -14
- package/dist/esm/public-input-checker.js +2 -2
- package/dist/esm/solidity-verifier.js +2 -2
- package/dist/esm/types.d.ts +11 -2
- package/package.json +4 -4
- package/dist/esm/chunk-JITNXEQS.js +0 -2542
- package/dist/esm/chunk-XOQW7AOQ.js +0 -14
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var VERSION = "0.10.0";
|
|
3
|
+
var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
|
|
4
|
+
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
5
|
+
var ZKPASSPORT_IOS_APP_ID_HASH = "0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b";
|
|
6
|
+
var ZKPASSPORT_ANDROID_APP_ID_HASH = "0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d";
|
|
7
|
+
var APPLE_APP_ATTEST_ROOT_KEY_HASH = "0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b";
|
|
8
|
+
var GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH = "0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
VERSION,
|
|
12
|
+
DEFAULT_VALIDITY,
|
|
13
|
+
DEFAULT_DATE_VALUE,
|
|
14
|
+
ZKPASSPORT_IOS_APP_ID_HASH,
|
|
15
|
+
ZKPASSPORT_ANDROID_APP_ID_HASH,
|
|
16
|
+
APPLE_APP_ATTEST_ROOT_KEY_HASH,
|
|
17
|
+
GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH
|
|
18
|
+
};
|
|
@@ -2,8 +2,10 @@ import {
|
|
|
2
2
|
APPLE_APP_ATTEST_ROOT_KEY_HASH,
|
|
3
3
|
DEFAULT_DATE_VALUE,
|
|
4
4
|
DEFAULT_VALIDITY,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH,
|
|
6
|
+
ZKPASSPORT_ANDROID_APP_ID_HASH,
|
|
7
|
+
ZKPASSPORT_IOS_APP_ID_HASH
|
|
8
|
+
} from "./chunk-JG37KYXW.js";
|
|
7
9
|
|
|
8
10
|
// src/public-input-checker.ts
|
|
9
11
|
import {
|
|
@@ -62,14 +64,9 @@ var PublicInputChecker = class {
|
|
|
62
64
|
static checkDiscloseBytesPublicInputs(proof, queryResult) {
|
|
63
65
|
const queryResultErrors = {};
|
|
64
66
|
let isCorrect = true;
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
69
|
-
const disclosedDataIDCard = DisclosedData.fromDisclosedBytes(
|
|
70
|
-
(proof.committedInputs?.disclose_bytes).disclosedBytes,
|
|
71
|
-
"id_card"
|
|
72
|
-
);
|
|
67
|
+
const disclosedBytes = (proof.committedInputs?.disclose_bytes).disclosedBytes ?? (proof.committedInputs?.disclose_bytes_evm).disclosedBytes;
|
|
68
|
+
const disclosedDataPassport = DisclosedData.fromDisclosedBytes(disclosedBytes, "passport");
|
|
69
|
+
const disclosedDataIDCard = DisclosedData.fromDisclosedBytes(disclosedBytes, "id_card");
|
|
73
70
|
if (queryResult.document_type) {
|
|
74
71
|
if (queryResult.document_type.eq && queryResult.document_type.eq.result && queryResult.document_type.eq.expected !== disclosedDataPassport.documentType) {
|
|
75
72
|
console.warn("Document type does not match the expected document type");
|
|
@@ -364,10 +361,10 @@ var PublicInputChecker = class {
|
|
|
364
361
|
0
|
|
365
362
|
);
|
|
366
363
|
const minAge = getMinAgeFromCommittedInputs(
|
|
367
|
-
proof.committedInputs?.compare_age
|
|
364
|
+
proof.committedInputs?.compare_age ?? proof.committedInputs?.compare_age_evm
|
|
368
365
|
);
|
|
369
366
|
const maxAge = getMaxAgeFromCommittedInputs(
|
|
370
|
-
proof.committedInputs?.compare_age
|
|
367
|
+
proof.committedInputs?.compare_age ?? proof.committedInputs?.compare_age_evm
|
|
371
368
|
);
|
|
372
369
|
if (queryResult.age) {
|
|
373
370
|
if (queryResult.age.gte && queryResult.age.gte.result && minAge !== queryResult.age.gte.expected) {
|
|
@@ -455,7 +452,7 @@ var PublicInputChecker = class {
|
|
|
455
452
|
};
|
|
456
453
|
}
|
|
457
454
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
458
|
-
proof.committedInputs?.compare_age
|
|
455
|
+
proof.committedInputs?.compare_age ?? proof.committedInputs?.compare_age_evm
|
|
459
456
|
);
|
|
460
457
|
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
461
458
|
console.warn("Current date in the proof is too old");
|
|
@@ -484,15 +481,15 @@ var PublicInputChecker = class {
|
|
|
484
481
|
0
|
|
485
482
|
);
|
|
486
483
|
const minDate = getBirthdateMinDateTimestamp(
|
|
487
|
-
proof.committedInputs?.compare_birthdate,
|
|
484
|
+
proof.committedInputs?.compare_birthdate ?? proof.committedInputs?.compare_birthdate_evm,
|
|
488
485
|
-1 * SECONDS_BETWEEN_1900_AND_1970
|
|
489
486
|
);
|
|
490
487
|
const maxDate = getBirthdateMaxDateTimestamp(
|
|
491
|
-
proof.committedInputs?.compare_birthdate,
|
|
488
|
+
proof.committedInputs?.compare_birthdate ?? proof.committedInputs?.compare_birthdate_evm,
|
|
492
489
|
-1 * SECONDS_BETWEEN_1900_AND_1970
|
|
493
490
|
);
|
|
494
491
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
495
|
-
proof.committedInputs?.compare_birthdate
|
|
492
|
+
proof.committedInputs?.compare_birthdate ?? proof.committedInputs?.compare_birthdate_evm
|
|
496
493
|
);
|
|
497
494
|
if (queryResult.birthdate) {
|
|
498
495
|
if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && !areDatesEqual(minDate, queryResult.birthdate.gte.expected)) {
|
|
@@ -594,13 +591,13 @@ var PublicInputChecker = class {
|
|
|
594
591
|
0
|
|
595
592
|
);
|
|
596
593
|
const minDate = getMinDateFromCommittedInputs(
|
|
597
|
-
proof.committedInputs?.compare_expiry
|
|
594
|
+
proof.committedInputs?.compare_expiry ?? proof.committedInputs?.compare_expiry_evm
|
|
598
595
|
);
|
|
599
596
|
const maxDate = getMaxDateFromCommittedInputs(
|
|
600
|
-
proof.committedInputs?.compare_expiry
|
|
597
|
+
proof.committedInputs?.compare_expiry ?? proof.committedInputs?.compare_expiry_evm
|
|
601
598
|
);
|
|
602
599
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
603
|
-
proof.committedInputs?.compare_expiry
|
|
600
|
+
proof.committedInputs?.compare_expiry ?? proof.committedInputs?.compare_expiry_evm
|
|
604
601
|
);
|
|
605
602
|
if (queryResult.expiry_date) {
|
|
606
603
|
if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && !areDatesEqual(minDate, queryResult.expiry_date.gte.expected)) {
|
|
@@ -982,13 +979,13 @@ var PublicInputChecker = class {
|
|
|
982
979
|
let isCorrect = true;
|
|
983
980
|
let queryResultErrors = {};
|
|
984
981
|
if (queryResult.facematch && queryResult.facematch.passed) {
|
|
985
|
-
if (facematchCommittedInputs.rootKeyLeaf !== APPLE_APP_ATTEST_ROOT_KEY_HASH) {
|
|
982
|
+
if (facematchCommittedInputs.rootKeyLeaf !== APPLE_APP_ATTEST_ROOT_KEY_HASH && facematchCommittedInputs.rootKeyLeaf !== GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH) {
|
|
986
983
|
console.warn("Invalid facematch root key hash");
|
|
987
984
|
isCorrect = false;
|
|
988
985
|
queryResultErrors.facematch = {
|
|
989
986
|
...queryResultErrors.facematch,
|
|
990
987
|
eq: {
|
|
991
|
-
expected: APPLE_APP_ATTEST_ROOT_KEY_HASH
|
|
988
|
+
expected: `${APPLE_APP_ATTEST_ROOT_KEY_HASH} (iOS) or ${GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH} (Android)`,
|
|
992
989
|
received: facematchCommittedInputs.rootKeyLeaf,
|
|
993
990
|
message: "Invalid facematch root key hash"
|
|
994
991
|
}
|
|
@@ -1007,7 +1004,7 @@ var PublicInputChecker = class {
|
|
|
1007
1004
|
}
|
|
1008
1005
|
};
|
|
1009
1006
|
}
|
|
1010
|
-
if (facematchCommittedInputs.
|
|
1007
|
+
if (facematchCommittedInputs.appIdHash !== ZKPASSPORT_IOS_APP_ID_HASH && facematchCommittedInputs.appIdHash !== ZKPASSPORT_ANDROID_APP_ID_HASH) {
|
|
1011
1008
|
console.warn(
|
|
1012
1009
|
"Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"
|
|
1013
1010
|
);
|
|
@@ -1015,8 +1012,8 @@ var PublicInputChecker = class {
|
|
|
1015
1012
|
queryResultErrors.facematch = {
|
|
1016
1013
|
...queryResultErrors.facematch,
|
|
1017
1014
|
eq: {
|
|
1018
|
-
expected:
|
|
1019
|
-
received: facematchCommittedInputs.
|
|
1015
|
+
expected: `${ZKPASSPORT_IOS_APP_ID_HASH} (iOS) or ${ZKPASSPORT_ANDROID_APP_ID_HASH} (Android)`,
|
|
1016
|
+
received: facematchCommittedInputs.appIdHash,
|
|
1020
1017
|
message: "Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"
|
|
1021
1018
|
}
|
|
1022
1019
|
};
|
|
@@ -1149,8 +1146,8 @@ var PublicInputChecker = class {
|
|
|
1149
1146
|
}
|
|
1150
1147
|
};
|
|
1151
1148
|
}
|
|
1152
|
-
if (!!committedInputs?.compare_age) {
|
|
1153
|
-
const ageCommittedInputs = committedInputs?.compare_age;
|
|
1149
|
+
if (!!committedInputs?.compare_age || !!committedInputs?.compare_age_evm) {
|
|
1150
|
+
const ageCommittedInputs = committedInputs?.compare_age ?? committedInputs?.compare_age_evm;
|
|
1154
1151
|
const ageParameterCommitment = isForEVM ? await getAgeEVMParameterCommitment(
|
|
1155
1152
|
ageCommittedInputs.currentDateTimestamp,
|
|
1156
1153
|
ageCommittedInputs.minAge,
|
|
@@ -1178,8 +1175,9 @@ var PublicInputChecker = class {
|
|
|
1178
1175
|
...queryResultErrors,
|
|
1179
1176
|
...queryResultErrorsAge
|
|
1180
1177
|
};
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1178
|
+
}
|
|
1179
|
+
if (!!committedInputs?.compare_birthdate || !!committedInputs?.compare_birthdate_evm) {
|
|
1180
|
+
const birthdateCommittedInputs = committedInputs?.compare_birthdate ?? committedInputs?.compare_birthdate_evm;
|
|
1183
1181
|
const birthdateParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
1184
1182
|
ProofType.BIRTHDATE,
|
|
1185
1183
|
birthdateCommittedInputs.currentDateTimestamp,
|
|
@@ -1211,8 +1209,9 @@ var PublicInputChecker = class {
|
|
|
1211
1209
|
...queryResultErrors,
|
|
1212
1210
|
...queryResultErrorsBirthdate
|
|
1213
1211
|
};
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1212
|
+
}
|
|
1213
|
+
if (!!committedInputs?.compare_expiry || !!committedInputs?.compare_expiry_evm) {
|
|
1214
|
+
const expiryCommittedInputs = committedInputs?.compare_expiry ?? committedInputs?.compare_expiry_evm;
|
|
1216
1215
|
const expiryParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
1217
1216
|
ProofType.EXPIRY_DATE,
|
|
1218
1217
|
expiryCommittedInputs.currentDateTimestamp,
|
|
@@ -1242,8 +1241,9 @@ var PublicInputChecker = class {
|
|
|
1242
1241
|
...queryResultErrors,
|
|
1243
1242
|
...queryResultErrorsExpiryDate
|
|
1244
1243
|
};
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1244
|
+
}
|
|
1245
|
+
if (!!committedInputs?.disclose_bytes || !!committedInputs?.disclose_bytes_evm) {
|
|
1246
|
+
const discloseCommittedInputs = committedInputs?.disclose_bytes ?? committedInputs?.disclose_bytes_evm;
|
|
1247
1247
|
const discloseParameterCommitment = isForEVM ? await getDiscloseEVMParameterCommitment(
|
|
1248
1248
|
discloseCommittedInputs.discloseMask,
|
|
1249
1249
|
discloseCommittedInputs.disclosedBytes
|
|
@@ -1269,8 +1269,9 @@ var PublicInputChecker = class {
|
|
|
1269
1269
|
...queryResultErrors,
|
|
1270
1270
|
...queryResultErrorsDisclose
|
|
1271
1271
|
};
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1272
|
+
}
|
|
1273
|
+
if (!!committedInputs?.inclusion_check_nationality || !!committedInputs?.inclusion_check_nationality_evm) {
|
|
1274
|
+
const inclusionCheckNationalityCommittedInputs = committedInputs?.inclusion_check_nationality ?? committedInputs?.inclusion_check_nationality_evm;
|
|
1274
1275
|
const inclusionCheckNationalityParameterCommitment = isForEVM ? await getCountryEVMParameterCommitment(
|
|
1275
1276
|
ProofType.NATIONALITY_INCLUSION,
|
|
1276
1277
|
inclusionCheckNationalityCommittedInputs.countries
|
|
@@ -1300,8 +1301,9 @@ var PublicInputChecker = class {
|
|
|
1300
1301
|
...queryResultErrors,
|
|
1301
1302
|
...queryResultErrorsNationalityInclusion
|
|
1302
1303
|
};
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1304
|
+
}
|
|
1305
|
+
if (!!committedInputs?.inclusion_check_issuing_country || !!committedInputs?.inclusion_check_issuing_country_evm) {
|
|
1306
|
+
const inclusionCheckIssuingCountryCommittedInputs = committedInputs?.inclusion_check_issuing_country ?? committedInputs?.inclusion_check_issuing_country_evm;
|
|
1305
1307
|
const inclusionCheckIssuingCountryParameterCommitment = isForEVM ? await getCountryEVMParameterCommitment(
|
|
1306
1308
|
ProofType.ISSUING_COUNTRY_INCLUSION,
|
|
1307
1309
|
inclusionCheckIssuingCountryCommittedInputs.countries
|
|
@@ -1331,8 +1333,9 @@ var PublicInputChecker = class {
|
|
|
1331
1333
|
...queryResultErrors,
|
|
1332
1334
|
...queryResultErrorsIssuingCountryInclusion
|
|
1333
1335
|
};
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
+
}
|
|
1337
|
+
if (!!committedInputs?.exclusion_check_nationality || !!committedInputs?.exclusion_check_nationality_evm) {
|
|
1338
|
+
const exclusionCheckNationalityCommittedInputs = committedInputs?.exclusion_check_nationality ?? committedInputs?.exclusion_check_nationality_evm;
|
|
1336
1339
|
const exclusionCheckNationalityParameterCommitment = isForEVM ? await getCountryEVMParameterCommitment(
|
|
1337
1340
|
ProofType.NATIONALITY_EXCLUSION,
|
|
1338
1341
|
exclusionCheckNationalityCommittedInputs.countries
|
|
@@ -1362,8 +1365,9 @@ var PublicInputChecker = class {
|
|
|
1362
1365
|
...queryResultErrors,
|
|
1363
1366
|
...queryResultErrorsNationalityExclusion
|
|
1364
1367
|
};
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1368
|
+
}
|
|
1369
|
+
if (!!committedInputs?.exclusion_check_issuing_country || !!committedInputs?.exclusion_check_issuing_country_evm) {
|
|
1370
|
+
const exclusionCheckIssuingCountryCommittedInputs = committedInputs?.exclusion_check_issuing_country ?? committedInputs?.exclusion_check_issuing_country_evm;
|
|
1367
1371
|
const exclusionCheckIssuingCountryParameterCommitment = isForEVM ? await getCountryEVMParameterCommitment(
|
|
1368
1372
|
ProofType.ISSUING_COUNTRY_EXCLUSION,
|
|
1369
1373
|
exclusionCheckIssuingCountryCommittedInputs.countries
|
|
@@ -1393,8 +1397,9 @@ var PublicInputChecker = class {
|
|
|
1393
1397
|
...queryResultErrors,
|
|
1394
1398
|
...queryResultErrorsIssuingCountryExclusion
|
|
1395
1399
|
};
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1400
|
+
}
|
|
1401
|
+
if (!!committedInputs?.bind || !!committedInputs?.bind_evm) {
|
|
1402
|
+
const bindCommittedInputs = committedInputs?.bind ?? committedInputs?.bind_evm;
|
|
1398
1403
|
const bindParameterCommitment = isForEVM ? await getBindEVMParameterCommitment(formatBoundData(bindCommittedInputs.data)) : await getBindParameterCommitment(formatBoundData(bindCommittedInputs.data));
|
|
1399
1404
|
if (!paramCommitments.includes(bindParameterCommitment)) {
|
|
1400
1405
|
console.warn("This proof does not verify the bound data");
|
|
@@ -1414,9 +1419,10 @@ var PublicInputChecker = class {
|
|
|
1414
1419
|
...queryResultErrors,
|
|
1415
1420
|
...queryResultErrorsBind
|
|
1416
1421
|
};
|
|
1417
|
-
}
|
|
1422
|
+
}
|
|
1423
|
+
if (!!committedInputs?.exclusion_check_sanctions || !!committedInputs?.exclusion_check_sanctions_evm) {
|
|
1418
1424
|
const sanctionsBuilder = await SanctionsBuilder.create();
|
|
1419
|
-
const exclusionCheckSanctionsCommittedInputs = committedInputs?.exclusion_check_sanctions;
|
|
1425
|
+
const exclusionCheckSanctionsCommittedInputs = committedInputs?.exclusion_check_sanctions ?? committedInputs?.exclusion_check_sanctions_evm;
|
|
1420
1426
|
const exclusionCheckSanctionsParameterCommitment = isForEVM ? await sanctionsBuilder.getSanctionsEvmParameterCommitment() : await sanctionsBuilder.getSanctionsParameterCommitment();
|
|
1421
1427
|
if (!paramCommitments.includes(exclusionCheckSanctionsParameterCommitment)) {
|
|
1422
1428
|
console.warn("This proof does not verify the exclusion from the sanction lists");
|
|
@@ -1443,22 +1449,19 @@ var PublicInputChecker = class {
|
|
|
1443
1449
|
...queryResultErrors,
|
|
1444
1450
|
...queryResultErrorsSanctionsExclusion
|
|
1445
1451
|
};
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1452
|
+
}
|
|
1453
|
+
if (!!committedInputs?.facematch || !!committedInputs?.facematch_evm) {
|
|
1454
|
+
const facematchCommittedInputs = committedInputs?.facematch ?? committedInputs?.facematch_evm;
|
|
1448
1455
|
const facematchParameterCommitment = isForEVM ? await getFacematchEvmParameterCommitment(
|
|
1449
1456
|
BigInt(facematchCommittedInputs.rootKeyLeaf),
|
|
1450
1457
|
facematchCommittedInputs.environment === "development" ? 0n : 1n,
|
|
1451
|
-
BigInt(facematchCommittedInputs.
|
|
1452
|
-
|
|
1453
|
-
// facematchCommittedInputs.mode === "regular" ? 1n : 2n,
|
|
1454
|
-
1n
|
|
1458
|
+
BigInt(facematchCommittedInputs.appIdHash),
|
|
1459
|
+
facematchCommittedInputs.mode === "regular" ? 1n : 2n
|
|
1455
1460
|
) : await getFacematchParameterCommitment(
|
|
1456
1461
|
BigInt(facematchCommittedInputs.rootKeyLeaf),
|
|
1457
1462
|
facematchCommittedInputs.environment === "development" ? 0n : 1n,
|
|
1458
|
-
BigInt(facematchCommittedInputs.
|
|
1459
|
-
|
|
1460
|
-
// facematchCommittedInputs.mode === "regular" ? 1n : 2n,
|
|
1461
|
-
1n
|
|
1463
|
+
BigInt(facematchCommittedInputs.appIdHash),
|
|
1464
|
+
facematchCommittedInputs.mode === "regular" ? 1n : 2n
|
|
1462
1465
|
);
|
|
1463
1466
|
if (!paramCommitments.includes(facematchParameterCommitment)) {
|
|
1464
1467
|
console.warn("This proof does not verify FaceMatch");
|
|
@@ -2041,16 +2044,14 @@ var PublicInputChecker = class {
|
|
|
2041
2044
|
};
|
|
2042
2045
|
uniqueIdentifier = getNullifierFromDisclosureProof(proofData).toString(10);
|
|
2043
2046
|
uniqueIdentifierType = getNullifierTypeFromDisclosureProof(proofData);
|
|
2044
|
-
} else if (proof.name
|
|
2047
|
+
} else if (proof.name?.startsWith("facematch") && !proof.name?.endsWith("_evm")) {
|
|
2045
2048
|
const facematchCommittedInputs = proof.committedInputs?.facematch;
|
|
2046
2049
|
const paramCommittment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2047
2050
|
const calculatedParamCommitment = await getFacematchParameterCommitment(
|
|
2048
2051
|
BigInt(facematchCommittedInputs.rootKeyLeaf),
|
|
2049
2052
|
facematchCommittedInputs.environment === "development" ? 0n : 1n,
|
|
2050
|
-
BigInt(facematchCommittedInputs.
|
|
2051
|
-
|
|
2052
|
-
// facematchCommittedInputs.mode === "regular" ? 1n : 2n,
|
|
2053
|
-
1n
|
|
2053
|
+
BigInt(facematchCommittedInputs.appIdHash),
|
|
2054
|
+
facematchCommittedInputs.mode === "regular" ? 1n : 2n
|
|
2054
2055
|
);
|
|
2055
2056
|
if (paramCommittment !== calculatedParamCommitment) {
|
|
2056
2057
|
console.warn("The FaceMatch verification does not match the ones from the proof");
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
declare const VERSION = "0.
|
|
1
|
+
declare const VERSION = "0.10.0";
|
|
2
2
|
declare const DEFAULT_VALIDITY: number;
|
|
3
3
|
declare const DEFAULT_DATE_VALUE: Date;
|
|
4
|
-
declare const
|
|
4
|
+
declare const ZKPASSPORT_IOS_APP_ID_HASH = "0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b";
|
|
5
|
+
declare const ZKPASSPORT_ANDROID_APP_ID_HASH = "0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d";
|
|
5
6
|
declare const APPLE_APP_ATTEST_ROOT_KEY_HASH = "0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b";
|
|
7
|
+
declare const GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH = "0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211";
|
|
6
8
|
|
|
7
|
-
export { APPLE_APP_ATTEST_ROOT_KEY_HASH, DEFAULT_DATE_VALUE, DEFAULT_VALIDITY, VERSION,
|
|
9
|
+
export { APPLE_APP_ATTEST_ROOT_KEY_HASH, DEFAULT_DATE_VALUE, DEFAULT_VALIDITY, GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH, VERSION, ZKPASSPORT_ANDROID_APP_ID_HASH, ZKPASSPORT_IOS_APP_ID_HASH };
|
package/dist/esm/constants.js
CHANGED
|
@@ -2,13 +2,17 @@ import {
|
|
|
2
2
|
APPLE_APP_ATTEST_ROOT_KEY_HASH,
|
|
3
3
|
DEFAULT_DATE_VALUE,
|
|
4
4
|
DEFAULT_VALIDITY,
|
|
5
|
+
GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH,
|
|
5
6
|
VERSION,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
ZKPASSPORT_ANDROID_APP_ID_HASH,
|
|
8
|
+
ZKPASSPORT_IOS_APP_ID_HASH
|
|
9
|
+
} from "./chunk-JG37KYXW.js";
|
|
8
10
|
export {
|
|
9
11
|
APPLE_APP_ATTEST_ROOT_KEY_HASH,
|
|
10
12
|
DEFAULT_DATE_VALUE,
|
|
11
13
|
DEFAULT_VALIDITY,
|
|
14
|
+
GOOGLE_APP_ATTEST_RSA_ROOT_KEY_HASH,
|
|
12
15
|
VERSION,
|
|
13
|
-
|
|
16
|
+
ZKPASSPORT_ANDROID_APP_ID_HASH,
|
|
17
|
+
ZKPASSPORT_IOS_APP_ID_HASH
|
|
14
18
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryBuilder, QueryResultErrors, SolidityVerifierParameters } from './types.js';
|
|
2
|
-
export { QueryBuilderResult, QueryResultError } from './types.js';
|
|
2
|
+
export { QueryBuilderResult, QueryResultError, SolidityCommitments, SolidityProofVerificationData, SolidityServiceConfig } from './types.js';
|
|
3
3
|
import { ProofMode, ProofResult, QueryResult, NullifierType, SupportedChain } from '@zkpassport/utils';
|
|
4
4
|
export * from '@zkpassport/utils';
|
|
5
5
|
export { ASEAN_COUNTRIES, EEA_COUNTRIES, EU_COUNTRIES, MERCOSUR_COUNTRIES, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES } from '@zkpassport/utils';
|
package/dist/esm/index.js
CHANGED
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-AFLQN3AC.js";
|
|
4
4
|
import {
|
|
5
5
|
PublicInputChecker
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-O7ZONMCQ.js";
|
|
7
7
|
import {
|
|
8
8
|
SolidityVerifier
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-I7PGO4XY.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_VALIDITY,
|
|
12
12
|
VERSION
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JG37KYXW.js";
|
|
14
14
|
import "./chunk-6F4PWJZI.js";
|
|
15
15
|
|
|
16
16
|
// src/index.ts
|
|
@@ -448,11 +448,11 @@ var ZKPassport = class {
|
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
450
|
const formattedResult = formatQueryResultDates(queryResult);
|
|
451
|
-
const {
|
|
451
|
+
const { UltraHonkVerifierBackend } = await import("@aztec/bb.js");
|
|
452
452
|
if (typeof window === "undefined" && !writingDirectory) {
|
|
453
453
|
writingDirectory = "/tmp";
|
|
454
454
|
}
|
|
455
|
-
const verifier = new
|
|
455
|
+
const verifier = new UltraHonkVerifierBackend({
|
|
456
456
|
crsPath: writingDirectory ? writingDirectory + "/.bb-crs" : void 0
|
|
457
457
|
});
|
|
458
458
|
let verified = true;
|
|
@@ -489,11 +489,15 @@ var ZKPassport = class {
|
|
|
489
489
|
});
|
|
490
490
|
for (const proof of proofs) {
|
|
491
491
|
const isOuterEVM = proof.name?.startsWith("outer_evm_");
|
|
492
|
-
const proofName =
|
|
492
|
+
const proofName = proof.name;
|
|
493
493
|
const proofData = getProofData(proof.proof, getNumberOfPublicInputs(proofName));
|
|
494
494
|
const hostedPackagedCircuit = await registryClient.getPackagedCircuit(
|
|
495
495
|
proofName,
|
|
496
|
-
circuitManifest
|
|
496
|
+
circuitManifest,
|
|
497
|
+
// TODO: set to always validate when the issue is vkey hash calculation is fixed
|
|
498
|
+
// Not as important anyway, as the solidity verifier is the ultimate anchor for
|
|
499
|
+
// EVM outer proofs verification
|
|
500
|
+
{ validate: !isOuterEVM }
|
|
497
501
|
);
|
|
498
502
|
if (isOuterEVM) {
|
|
499
503
|
try {
|
|
@@ -525,13 +529,11 @@ var ZKPassport = class {
|
|
|
525
529
|
} else {
|
|
526
530
|
const vkeyBytes = Buffer.from(hostedPackagedCircuit.vkey, "base64");
|
|
527
531
|
try {
|
|
528
|
-
verified = await verifier.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
new Uint8Array(vkeyBytes)
|
|
534
|
-
);
|
|
532
|
+
verified = await verifier.verifyProof({
|
|
533
|
+
proof: Buffer.from(proofData.proof.join(""), "hex"),
|
|
534
|
+
publicInputs: proofData.publicInputs,
|
|
535
|
+
verificationKey: new Uint8Array(vkeyBytes)
|
|
536
|
+
});
|
|
535
537
|
} catch (e) {
|
|
536
538
|
console.warn("Error verifying proof", e);
|
|
537
539
|
verified = false;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,17 +21,26 @@ type QueryResultErrors = {
|
|
|
21
21
|
scope?: QueryResultError<string>;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
type
|
|
24
|
+
type SolidityProofVerificationData = {
|
|
25
25
|
vkeyHash: string;
|
|
26
26
|
proof: string;
|
|
27
27
|
publicInputs: string[];
|
|
28
|
+
};
|
|
29
|
+
type SolidityCommitments = {
|
|
28
30
|
committedInputs: string;
|
|
29
31
|
committedInputCounts: number[];
|
|
32
|
+
};
|
|
33
|
+
type SolidityServiceConfig = {
|
|
30
34
|
validityPeriodInSeconds: number;
|
|
31
35
|
domain: string;
|
|
32
36
|
scope: string;
|
|
33
37
|
devMode: boolean;
|
|
34
38
|
};
|
|
39
|
+
type SolidityVerifierParameters = {
|
|
40
|
+
proofVerificationData: SolidityProofVerificationData;
|
|
41
|
+
commitments: SolidityCommitments;
|
|
42
|
+
serviceConfig: SolidityServiceConfig;
|
|
43
|
+
};
|
|
35
44
|
type QueryBuilderResult = {
|
|
36
45
|
/**
|
|
37
46
|
* The URL of the request.
|
|
@@ -188,4 +197,4 @@ type QueryBuilder = {
|
|
|
188
197
|
done: () => QueryBuilderResult;
|
|
189
198
|
};
|
|
190
199
|
|
|
191
|
-
export type { QueryBuilder, QueryBuilderResult, QueryResultError, QueryResultErrors, SolidityVerifierParameters };
|
|
200
|
+
export type { QueryBuilder, QueryBuilderResult, QueryResultError, QueryResultErrors, SolidityCommitments, SolidityProofVerificationData, SolidityServiceConfig, SolidityVerifierParameters };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Privacy-preserving identity verification using passports and ID cards",
|
|
5
5
|
"author": "ZKPassport",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"sdk"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aztec/bb.js": "
|
|
34
|
+
"@aztec/bb.js": "2.0.3",
|
|
35
35
|
"@noble/ciphers": "^1.2.1",
|
|
36
36
|
"@noble/hashes": "^1.7.2",
|
|
37
37
|
"@noble/secp256k1": "^2.2.3",
|
|
38
38
|
"@obsidion/bridge": "^0.10.4",
|
|
39
|
-
"@zkpassport/registry": "0.
|
|
40
|
-
"@zkpassport/utils": "0.
|
|
39
|
+
"@zkpassport/registry": "0.11.1",
|
|
40
|
+
"@zkpassport/utils": "0.25.2",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"i18n-iso-countries": "^7.12.0",
|
|
43
43
|
"pako": "^2.1.0",
|