@zkpassport/sdk 0.10.0 → 0.11.0-beta.2
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/index.cjs +386 -854
- package/dist/cjs/public-input-checker.cjs +164 -84
- package/dist/cjs/public-input-checker.d.cts +1 -0
- package/dist/cjs/solidity-verifier.cjs +218 -767
- package/dist/cjs/types.d.cts +11 -2
- package/dist/esm/{chunk-O7ZONMCQ.js → chunk-6IK5VUOR.js} +168 -87
- package/dist/esm/chunk-CFGZMKF7.js +2019 -0
- package/dist/esm/index.js +6 -5
- package/dist/esm/public-input-checker.d.ts +1 -0
- package/dist/esm/public-input-checker.js +1 -1
- package/dist/esm/solidity-verifier.js +1 -1
- package/dist/esm/types.d.ts +11 -2
- package/package.json +3 -3
- package/dist/esm/chunk-I7PGO4XY.js +0 -2567
|
@@ -426,21 +426,6 @@ var PublicInputChecker = class {
|
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
-
const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
|
|
430
|
-
proof.committedInputs?.compare_age ?? proof.committedInputs?.compare_age_evm
|
|
431
|
-
);
|
|
432
|
-
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
433
|
-
console.warn("Current date in the proof is too old");
|
|
434
|
-
isCorrect = false;
|
|
435
|
-
queryResultErrors.age = {
|
|
436
|
-
...queryResultErrors.age,
|
|
437
|
-
disclose: {
|
|
438
|
-
expected: `${today.toISOString()}`,
|
|
439
|
-
received: `${currentDate.toISOString()}`,
|
|
440
|
-
message: "Current date in the proof is too old"
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
429
|
return { isCorrect, queryResultErrors };
|
|
445
430
|
}
|
|
446
431
|
static checkBirthdatePublicInputs(proof, queryResult) {
|
|
@@ -463,9 +448,6 @@ var PublicInputChecker = class {
|
|
|
463
448
|
proof.committedInputs?.compare_birthdate ?? proof.committedInputs?.compare_birthdate_evm,
|
|
464
449
|
-1 * import_utils.SECONDS_BETWEEN_1900_AND_1970
|
|
465
450
|
);
|
|
466
|
-
const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
|
|
467
|
-
proof.committedInputs?.compare_birthdate ?? proof.committedInputs?.compare_birthdate_evm
|
|
468
|
-
);
|
|
469
451
|
if (queryResult.birthdate) {
|
|
470
452
|
if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && !(0, import_utils.areDatesEqual)(minDate, queryResult.birthdate.gte.expected)) {
|
|
471
453
|
console.warn("Birthdate is not greater than or equal to the expected birthdate");
|
|
@@ -539,18 +521,6 @@ var PublicInputChecker = class {
|
|
|
539
521
|
}
|
|
540
522
|
};
|
|
541
523
|
}
|
|
542
|
-
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
543
|
-
console.warn("Current date in the proof is too old");
|
|
544
|
-
isCorrect = false;
|
|
545
|
-
queryResultErrors.birthdate = {
|
|
546
|
-
...queryResultErrors.birthdate,
|
|
547
|
-
disclose: {
|
|
548
|
-
expected: `${today.toISOString()}`,
|
|
549
|
-
received: `${currentDate.toISOString()}`,
|
|
550
|
-
message: "Current date in the proof is too old"
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
524
|
return { isCorrect, queryResultErrors };
|
|
555
525
|
}
|
|
556
526
|
static checkExpiryDatePublicInputs(proof, queryResult) {
|
|
@@ -571,9 +541,6 @@ var PublicInputChecker = class {
|
|
|
571
541
|
const maxDate = (0, import_utils.getMaxDateFromCommittedInputs)(
|
|
572
542
|
proof.committedInputs?.compare_expiry ?? proof.committedInputs?.compare_expiry_evm
|
|
573
543
|
);
|
|
574
|
-
const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
|
|
575
|
-
proof.committedInputs?.compare_expiry ?? proof.committedInputs?.compare_expiry_evm
|
|
576
|
-
);
|
|
577
544
|
if (queryResult.expiry_date) {
|
|
578
545
|
if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && !(0, import_utils.areDatesEqual)(minDate, queryResult.expiry_date.gte.expected)) {
|
|
579
546
|
console.warn("Expiry date is not greater than or equal to the expected expiry date");
|
|
@@ -647,18 +614,6 @@ var PublicInputChecker = class {
|
|
|
647
614
|
}
|
|
648
615
|
};
|
|
649
616
|
}
|
|
650
|
-
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
651
|
-
console.warn("Current date in the proof is too old");
|
|
652
|
-
isCorrect = false;
|
|
653
|
-
queryResultErrors.expiry_date = {
|
|
654
|
-
...queryResultErrors.expiry_date,
|
|
655
|
-
disclose: {
|
|
656
|
-
expected: `${today.toISOString()}`,
|
|
657
|
-
received: `${currentDate.toISOString()}`,
|
|
658
|
-
message: "Current date in the proof is too old"
|
|
659
|
-
}
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
617
|
return { isCorrect, queryResultErrors };
|
|
663
618
|
}
|
|
664
619
|
static checkNationalityExclusionPublicInputs(queryResult, countryList) {
|
|
@@ -803,7 +758,7 @@ var PublicInputChecker = class {
|
|
|
803
758
|
}
|
|
804
759
|
static checkScopeFromDisclosureProof(domain, proofData, queryResultErrors, key, scope) {
|
|
805
760
|
let isCorrect = true;
|
|
806
|
-
if (domain && (0, import_utils.getServiceScopeHash)(domain) !==
|
|
761
|
+
if (domain && (0, import_utils.getServiceScopeHash)(domain) !== (0, import_utils.getServiceScopeFromDisclosureProof)(proofData)) {
|
|
807
762
|
console.warn("The proof comes from a different domain than the one expected");
|
|
808
763
|
isCorrect = false;
|
|
809
764
|
if (!queryResultErrors[key]) {
|
|
@@ -815,7 +770,7 @@ var PublicInputChecker = class {
|
|
|
815
770
|
message: "The proof comes from a different domain than the one expected"
|
|
816
771
|
};
|
|
817
772
|
}
|
|
818
|
-
if (scope && (0, import_utils.getScopeHash)(scope) !==
|
|
773
|
+
if (scope && (0, import_utils.getScopeHash)(scope) !== (0, import_utils.getServiceSubScopeFromDisclosureProof)(proofData)) {
|
|
819
774
|
console.warn("The proof uses a different scope than the one expected");
|
|
820
775
|
isCorrect = false;
|
|
821
776
|
if (!queryResultErrors[key]) {
|
|
@@ -996,6 +951,36 @@ var PublicInputChecker = class {
|
|
|
996
951
|
}
|
|
997
952
|
return { isCorrect, queryResultErrors };
|
|
998
953
|
}
|
|
954
|
+
static async checkCurrentDate(circuitName, proofData, validity, queryResultErrors) {
|
|
955
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
956
|
+
const today = new Date(
|
|
957
|
+
currentTime.getFullYear(),
|
|
958
|
+
currentTime.getMonth(),
|
|
959
|
+
currentTime.getDate(),
|
|
960
|
+
0,
|
|
961
|
+
0,
|
|
962
|
+
0,
|
|
963
|
+
0
|
|
964
|
+
);
|
|
965
|
+
const currentDate = (0, import_utils.getCurrentDateFromDisclosureProof)(proofData);
|
|
966
|
+
const todayToCurrentDate = today.getTime() - currentDate.getTime();
|
|
967
|
+
const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
|
|
968
|
+
const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
|
|
969
|
+
let isCorrect = true;
|
|
970
|
+
if (todayToCurrentDate >= actualDifference) {
|
|
971
|
+
console.warn("The date used to check the validity of the ID falls out of the validity period");
|
|
972
|
+
isCorrect = false;
|
|
973
|
+
if (!queryResultErrors[circuitName]) {
|
|
974
|
+
queryResultErrors[circuitName] = {};
|
|
975
|
+
}
|
|
976
|
+
queryResultErrors[circuitName].date = {
|
|
977
|
+
expected: `Difference: ${validity} seconds`,
|
|
978
|
+
received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
|
|
979
|
+
message: "The date used to check the validity of the ID falls out of the validity period"
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
return { isCorrect, queryResultErrors };
|
|
983
|
+
}
|
|
999
984
|
static async checkPublicInputs(domain, proofs, queryResult, validity, scope) {
|
|
1000
985
|
let commitmentIn;
|
|
1001
986
|
let commitmentOut;
|
|
@@ -1124,14 +1109,9 @@ var PublicInputChecker = class {
|
|
|
1124
1109
|
if (!!committedInputs?.compare_age || !!committedInputs?.compare_age_evm) {
|
|
1125
1110
|
const ageCommittedInputs = committedInputs?.compare_age ?? committedInputs?.compare_age_evm;
|
|
1126
1111
|
const ageParameterCommitment = isForEVM ? await (0, import_utils.getAgeEVMParameterCommitment)(
|
|
1127
|
-
ageCommittedInputs.currentDateTimestamp,
|
|
1128
|
-
ageCommittedInputs.minAge,
|
|
1129
|
-
ageCommittedInputs.maxAge
|
|
1130
|
-
) : await (0, import_utils.getAgeParameterCommitment)(
|
|
1131
|
-
ageCommittedInputs.currentDateTimestamp,
|
|
1132
1112
|
ageCommittedInputs.minAge,
|
|
1133
1113
|
ageCommittedInputs.maxAge
|
|
1134
|
-
);
|
|
1114
|
+
) : await (0, import_utils.getAgeParameterCommitment)(ageCommittedInputs.minAge, ageCommittedInputs.maxAge);
|
|
1135
1115
|
if (!paramCommitments.includes(ageParameterCommitment)) {
|
|
1136
1116
|
console.warn("This proof does not verify the age");
|
|
1137
1117
|
isCorrect = false;
|
|
@@ -1155,16 +1135,12 @@ var PublicInputChecker = class {
|
|
|
1155
1135
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate ?? committedInputs?.compare_birthdate_evm;
|
|
1156
1136
|
const birthdateParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
1157
1137
|
import_utils.ProofType.BIRTHDATE,
|
|
1158
|
-
birthdateCommittedInputs.currentDateTimestamp,
|
|
1159
1138
|
birthdateCommittedInputs.minDateTimestamp,
|
|
1160
|
-
birthdateCommittedInputs.maxDateTimestamp
|
|
1161
|
-
0
|
|
1139
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
1162
1140
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
1163
1141
|
import_utils.ProofType.BIRTHDATE,
|
|
1164
|
-
birthdateCommittedInputs.currentDateTimestamp,
|
|
1165
1142
|
birthdateCommittedInputs.minDateTimestamp,
|
|
1166
|
-
birthdateCommittedInputs.maxDateTimestamp
|
|
1167
|
-
0
|
|
1143
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
1168
1144
|
);
|
|
1169
1145
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
1170
1146
|
console.warn("This proof does not verify the birthdate");
|
|
@@ -1189,12 +1165,10 @@ var PublicInputChecker = class {
|
|
|
1189
1165
|
const expiryCommittedInputs = committedInputs?.compare_expiry ?? committedInputs?.compare_expiry_evm;
|
|
1190
1166
|
const expiryParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
1191
1167
|
import_utils.ProofType.EXPIRY_DATE,
|
|
1192
|
-
expiryCommittedInputs.currentDateTimestamp,
|
|
1193
1168
|
expiryCommittedInputs.minDateTimestamp,
|
|
1194
1169
|
expiryCommittedInputs.maxDateTimestamp
|
|
1195
1170
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
1196
1171
|
import_utils.ProofType.EXPIRY_DATE,
|
|
1197
|
-
expiryCommittedInputs.currentDateTimestamp,
|
|
1198
1172
|
expiryCommittedInputs.minDateTimestamp,
|
|
1199
1173
|
expiryCommittedInputs.maxDateTimestamp
|
|
1200
1174
|
);
|
|
@@ -1398,7 +1372,11 @@ var PublicInputChecker = class {
|
|
|
1398
1372
|
if (!!committedInputs?.exclusion_check_sanctions || !!committedInputs?.exclusion_check_sanctions_evm) {
|
|
1399
1373
|
const sanctionsBuilder = await import_utils.SanctionsBuilder.create();
|
|
1400
1374
|
const exclusionCheckSanctionsCommittedInputs = committedInputs?.exclusion_check_sanctions ?? committedInputs?.exclusion_check_sanctions_evm;
|
|
1401
|
-
const exclusionCheckSanctionsParameterCommitment = isForEVM ? await sanctionsBuilder.getSanctionsEvmParameterCommitment(
|
|
1375
|
+
const exclusionCheckSanctionsParameterCommitment = isForEVM ? await sanctionsBuilder.getSanctionsEvmParameterCommitment(
|
|
1376
|
+
exclusionCheckSanctionsCommittedInputs.isStrict
|
|
1377
|
+
) : await sanctionsBuilder.getSanctionsParameterCommitment(
|
|
1378
|
+
exclusionCheckSanctionsCommittedInputs.isStrict
|
|
1379
|
+
);
|
|
1402
1380
|
if (!paramCommitments.includes(exclusionCheckSanctionsParameterCommitment)) {
|
|
1403
1381
|
console.warn("This proof does not verify the exclusion from the sanction lists");
|
|
1404
1382
|
isCorrect = false;
|
|
@@ -1507,24 +1485,6 @@ var PublicInputChecker = class {
|
|
|
1507
1485
|
};
|
|
1508
1486
|
}
|
|
1509
1487
|
commitmentOut = (0, import_utils.getCommitmentOutFromIntegrityProof)(proofData);
|
|
1510
|
-
const currentDate = (0, import_utils.getCurrentDateFromIntegrityProof)(proofData);
|
|
1511
|
-
const todayToCurrentDate = today.getTime() - currentDate.getTime();
|
|
1512
|
-
const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
|
|
1513
|
-
const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
|
|
1514
|
-
if (todayToCurrentDate >= actualDifference) {
|
|
1515
|
-
console.warn(
|
|
1516
|
-
`The date used to check the validity of the ID is older than the validity period`
|
|
1517
|
-
);
|
|
1518
|
-
isCorrect = false;
|
|
1519
|
-
queryResultErrors.data_check_integrity = {
|
|
1520
|
-
...queryResultErrors.data_check_integrity,
|
|
1521
|
-
date: {
|
|
1522
|
-
expected: `Difference: ${validity} seconds`,
|
|
1523
|
-
received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
|
|
1524
|
-
message: "The date used to check the validity of the ID is older than the validity period"
|
|
1525
|
-
}
|
|
1526
|
-
};
|
|
1527
|
-
}
|
|
1528
1488
|
} else if (proof.name === "disclose_bytes") {
|
|
1529
1489
|
commitmentIn = (0, import_utils.getCommitmentInFromDisclosureProof)(proofData);
|
|
1530
1490
|
if (commitmentIn !== commitmentOut) {
|
|
@@ -1577,6 +1537,17 @@ var PublicInputChecker = class {
|
|
|
1577
1537
|
...queryResultErrorsDisclose,
|
|
1578
1538
|
...queryResultErrorsScope
|
|
1579
1539
|
};
|
|
1540
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1541
|
+
"disclose",
|
|
1542
|
+
proofData,
|
|
1543
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1544
|
+
queryResultErrors
|
|
1545
|
+
);
|
|
1546
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1547
|
+
queryResultErrors = {
|
|
1548
|
+
...queryResultErrors,
|
|
1549
|
+
...queryResultErrorsCurrentDate
|
|
1550
|
+
};
|
|
1580
1551
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1581
1552
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1582
1553
|
} else if (proof.name === "compare_age") {
|
|
@@ -1598,7 +1569,6 @@ var PublicInputChecker = class {
|
|
|
1598
1569
|
const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
|
|
1599
1570
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
1600
1571
|
const calculatedParamCommitment = await (0, import_utils.getAgeParameterCommitment)(
|
|
1601
|
-
committedInputs.currentDateTimestamp,
|
|
1602
1572
|
committedInputs.minAge,
|
|
1603
1573
|
committedInputs.maxAge
|
|
1604
1574
|
);
|
|
@@ -1624,6 +1594,17 @@ var PublicInputChecker = class {
|
|
|
1624
1594
|
...queryResultErrorsAge,
|
|
1625
1595
|
...queryResultErrorsScope
|
|
1626
1596
|
};
|
|
1597
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1598
|
+
"age",
|
|
1599
|
+
proofData,
|
|
1600
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1601
|
+
queryResultErrors
|
|
1602
|
+
);
|
|
1603
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1604
|
+
queryResultErrors = {
|
|
1605
|
+
...queryResultErrors,
|
|
1606
|
+
...queryResultErrorsCurrentDate
|
|
1607
|
+
};
|
|
1627
1608
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1628
1609
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1629
1610
|
} else if (proof.name === "compare_birthdate") {
|
|
@@ -1646,7 +1627,6 @@ var PublicInputChecker = class {
|
|
|
1646
1627
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
1647
1628
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
1648
1629
|
import_utils.ProofType.BIRTHDATE,
|
|
1649
|
-
committedInputs.currentDateTimestamp,
|
|
1650
1630
|
committedInputs.minDateTimestamp,
|
|
1651
1631
|
committedInputs.maxDateTimestamp,
|
|
1652
1632
|
0
|
|
@@ -1679,6 +1659,17 @@ var PublicInputChecker = class {
|
|
|
1679
1659
|
...queryResultErrorsBirthdate,
|
|
1680
1660
|
...queryResultErrorsScope
|
|
1681
1661
|
};
|
|
1662
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1663
|
+
"birthdate",
|
|
1664
|
+
proofData,
|
|
1665
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1666
|
+
queryResultErrors
|
|
1667
|
+
);
|
|
1668
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1669
|
+
queryResultErrors = {
|
|
1670
|
+
...queryResultErrors,
|
|
1671
|
+
...queryResultErrorsCurrentDate
|
|
1672
|
+
};
|
|
1682
1673
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1683
1674
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1684
1675
|
} else if (proof.name === "compare_expiry") {
|
|
@@ -1701,7 +1692,6 @@ var PublicInputChecker = class {
|
|
|
1701
1692
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
1702
1693
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
1703
1694
|
import_utils.ProofType.EXPIRY_DATE,
|
|
1704
|
-
committedInputs.currentDateTimestamp,
|
|
1705
1695
|
committedInputs.minDateTimestamp,
|
|
1706
1696
|
committedInputs.maxDateTimestamp
|
|
1707
1697
|
);
|
|
@@ -1733,6 +1723,17 @@ var PublicInputChecker = class {
|
|
|
1733
1723
|
...queryResultErrorsExpiryDate,
|
|
1734
1724
|
...queryResultErrorsScope
|
|
1735
1725
|
};
|
|
1726
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1727
|
+
"expiry_date",
|
|
1728
|
+
proofData,
|
|
1729
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1730
|
+
queryResultErrors
|
|
1731
|
+
);
|
|
1732
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1733
|
+
queryResultErrors = {
|
|
1734
|
+
...queryResultErrors,
|
|
1735
|
+
...queryResultErrorsCurrentDate
|
|
1736
|
+
};
|
|
1736
1737
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1737
1738
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1738
1739
|
} else if (proof.name === "exclusion_check_nationality") {
|
|
@@ -1789,6 +1790,17 @@ var PublicInputChecker = class {
|
|
|
1789
1790
|
...queryResultErrorsNationalityExclusion,
|
|
1790
1791
|
...queryResultErrorsScope
|
|
1791
1792
|
};
|
|
1793
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1794
|
+
"nationality",
|
|
1795
|
+
proofData,
|
|
1796
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1797
|
+
queryResultErrors
|
|
1798
|
+
);
|
|
1799
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1800
|
+
queryResultErrors = {
|
|
1801
|
+
...queryResultErrors,
|
|
1802
|
+
...queryResultErrorsCurrentDate
|
|
1803
|
+
};
|
|
1792
1804
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1793
1805
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1794
1806
|
} else if (proof.name === "exclusion_check_issuing_country") {
|
|
@@ -1845,6 +1857,17 @@ var PublicInputChecker = class {
|
|
|
1845
1857
|
...queryResultErrorsIssuingCountryExclusion,
|
|
1846
1858
|
...queryResultErrorsScope
|
|
1847
1859
|
};
|
|
1860
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1861
|
+
"issuing_country",
|
|
1862
|
+
proofData,
|
|
1863
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1864
|
+
queryResultErrors
|
|
1865
|
+
);
|
|
1866
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1867
|
+
queryResultErrors = {
|
|
1868
|
+
...queryResultErrors,
|
|
1869
|
+
...queryResultErrorsCurrentDate
|
|
1870
|
+
};
|
|
1848
1871
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1849
1872
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1850
1873
|
} else if (proof.name === "inclusion_check_nationality") {
|
|
@@ -1901,6 +1924,17 @@ var PublicInputChecker = class {
|
|
|
1901
1924
|
...queryResultErrorsNationalityInclusion,
|
|
1902
1925
|
...queryResultErrorsScope
|
|
1903
1926
|
};
|
|
1927
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1928
|
+
"nationality",
|
|
1929
|
+
proofData,
|
|
1930
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1931
|
+
queryResultErrors
|
|
1932
|
+
);
|
|
1933
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
1934
|
+
queryResultErrors = {
|
|
1935
|
+
...queryResultErrors,
|
|
1936
|
+
...queryResultErrorsCurrentDate
|
|
1937
|
+
};
|
|
1904
1938
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1905
1939
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1906
1940
|
} else if (proof.name === "inclusion_check_issuing_country") {
|
|
@@ -1957,6 +1991,17 @@ var PublicInputChecker = class {
|
|
|
1957
1991
|
...queryResultErrorsIssuingCountryInclusion,
|
|
1958
1992
|
...queryResultErrorsScope
|
|
1959
1993
|
};
|
|
1994
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
1995
|
+
"issuing_country",
|
|
1996
|
+
proofData,
|
|
1997
|
+
validity ?? DEFAULT_VALIDITY,
|
|
1998
|
+
queryResultErrors
|
|
1999
|
+
);
|
|
2000
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
2001
|
+
queryResultErrors = {
|
|
2002
|
+
...queryResultErrors,
|
|
2003
|
+
...queryResultErrorsCurrentDate
|
|
2004
|
+
};
|
|
1960
2005
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1961
2006
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1962
2007
|
} else if (proof.name === "bind") {
|
|
@@ -1983,12 +2028,25 @@ var PublicInputChecker = class {
|
|
|
1983
2028
|
...queryResultErrors,
|
|
1984
2029
|
...queryResultErrorsBind
|
|
1985
2030
|
};
|
|
2031
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
2032
|
+
"bind",
|
|
2033
|
+
proofData,
|
|
2034
|
+
validity ?? DEFAULT_VALIDITY,
|
|
2035
|
+
queryResultErrors
|
|
2036
|
+
);
|
|
2037
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
2038
|
+
queryResultErrors = {
|
|
2039
|
+
...queryResultErrors,
|
|
2040
|
+
...queryResultErrorsCurrentDate
|
|
2041
|
+
};
|
|
1986
2042
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
1987
2043
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
1988
2044
|
} else if (proof.name === "exclusion_check_sanctions") {
|
|
1989
2045
|
const sanctionsBuilder = await import_utils.SanctionsBuilder.create();
|
|
1990
2046
|
const exclusionCheckSanctionsCommittedInputs = proof.committedInputs?.exclusion_check_sanctions;
|
|
1991
|
-
const calculatedParamCommitment = await sanctionsBuilder.getSanctionsParameterCommitment(
|
|
2047
|
+
const calculatedParamCommitment = await sanctionsBuilder.getSanctionsParameterCommitment(
|
|
2048
|
+
exclusionCheckSanctionsCommittedInputs.isStrict
|
|
2049
|
+
);
|
|
1992
2050
|
const paramCommittment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
|
|
1993
2051
|
if (paramCommittment !== calculatedParamCommitment) {
|
|
1994
2052
|
console.warn(
|
|
@@ -2017,6 +2075,17 @@ var PublicInputChecker = class {
|
|
|
2017
2075
|
...queryResultErrors,
|
|
2018
2076
|
...queryResultErrorsSanctionsExclusion
|
|
2019
2077
|
};
|
|
2078
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
2079
|
+
"sanctions",
|
|
2080
|
+
proofData,
|
|
2081
|
+
validity ?? DEFAULT_VALIDITY,
|
|
2082
|
+
queryResultErrors
|
|
2083
|
+
);
|
|
2084
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
2085
|
+
queryResultErrors = {
|
|
2086
|
+
...queryResultErrors,
|
|
2087
|
+
...queryResultErrorsCurrentDate
|
|
2088
|
+
};
|
|
2020
2089
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
2021
2090
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
2022
2091
|
} else if (proof.name?.startsWith("facematch") && !proof.name?.endsWith("_evm")) {
|
|
@@ -2046,6 +2115,17 @@ var PublicInputChecker = class {
|
|
|
2046
2115
|
...queryResultErrors,
|
|
2047
2116
|
...queryResultErrorsFacematch
|
|
2048
2117
|
};
|
|
2118
|
+
const { isCorrect: isCorrectCurrentDate, queryResultErrors: queryResultErrorsCurrentDate } = await this.checkCurrentDate(
|
|
2119
|
+
"facematch",
|
|
2120
|
+
proofData,
|
|
2121
|
+
validity ?? DEFAULT_VALIDITY,
|
|
2122
|
+
queryResultErrors
|
|
2123
|
+
);
|
|
2124
|
+
isCorrect = isCorrect && isCorrectCurrentDate;
|
|
2125
|
+
queryResultErrors = {
|
|
2126
|
+
...queryResultErrors,
|
|
2127
|
+
...queryResultErrorsCurrentDate
|
|
2128
|
+
};
|
|
2049
2129
|
uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
2050
2130
|
uniqueIdentifierType = (0, import_utils.getNullifierTypeFromDisclosureProof)(proofData);
|
|
2051
2131
|
}
|
|
@@ -58,6 +58,7 @@ declare class PublicInputChecker {
|
|
|
58
58
|
isCorrect: boolean;
|
|
59
59
|
queryResultErrors: Partial<QueryResultErrors>;
|
|
60
60
|
}>;
|
|
61
|
+
private static checkCurrentDate;
|
|
61
62
|
static checkPublicInputs(domain: string, proofs: Array<ProofResult>, queryResult: QueryResult, validity?: number, scope?: string): Promise<{
|
|
62
63
|
isCorrect: boolean;
|
|
63
64
|
uniqueIdentifier: string | undefined;
|