@zkpassport/sdk 0.7.1 → 0.8.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 +782 -573
- package/dist/cjs/index.d.cts +27 -9
- package/dist/esm/index.d.ts +27 -9
- package/dist/esm/index.js +787 -575
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -48,9 +48,12 @@ import {
|
|
|
48
48
|
formatBoundData,
|
|
49
49
|
getCircuitRegistryRootFromOuterProof,
|
|
50
50
|
areDatesEqual,
|
|
51
|
-
formatQueryResultDates
|
|
51
|
+
formatQueryResultDates,
|
|
52
|
+
getBirthdateMinDateTimestamp,
|
|
53
|
+
getBirthdateMaxDateTimestamp,
|
|
54
|
+
SanctionsBuilder
|
|
52
55
|
} from "@zkpassport/utils";
|
|
53
|
-
import { bytesToHex } from "@noble/ciphers/utils";
|
|
56
|
+
import { bytesToHex, numberToBytesBE } from "@noble/ciphers/utils";
|
|
54
57
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
55
58
|
import { Buffer } from "buffer/";
|
|
56
59
|
import { sha256 } from "@noble/hashes/sha2";
|
|
@@ -815,8 +818,9 @@ import {
|
|
|
815
818
|
ASEAN_COUNTRIES,
|
|
816
819
|
MERCOSUR_COUNTRIES
|
|
817
820
|
} from "@zkpassport/utils";
|
|
818
|
-
var VERSION = "0.
|
|
819
|
-
var DEFAULT_DATE_VALUE = new Date(
|
|
821
|
+
var VERSION = "0.8.0";
|
|
822
|
+
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
823
|
+
var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
|
|
820
824
|
if (typeof globalThis.Buffer === "undefined") {
|
|
821
825
|
globalThis.Buffer = Buffer;
|
|
822
826
|
if (typeof window !== "undefined") {
|
|
@@ -865,7 +869,6 @@ function generalCompare(fnName, key, value, requestId, requestIdToConfig) {
|
|
|
865
869
|
};
|
|
866
870
|
}
|
|
867
871
|
var ZKPassport = class {
|
|
868
|
-
//private wasmVerifierInit: boolean = false
|
|
869
872
|
constructor(_domain) {
|
|
870
873
|
this.topicToConfig = {};
|
|
871
874
|
this.topicToLocalConfig = {};
|
|
@@ -887,7 +890,11 @@ var ZKPassport = class {
|
|
|
887
890
|
if (!_domain && typeof window === "undefined") {
|
|
888
891
|
throw new Error("Domain argument is required in Node.js environment");
|
|
889
892
|
}
|
|
890
|
-
this.domain = _domain || window.location.hostname;
|
|
893
|
+
this.domain = this.normalizeDomain(_domain || window.location.hostname);
|
|
894
|
+
}
|
|
895
|
+
//private wasmVerifierInit: boolean = false
|
|
896
|
+
normalizeDomain(domain) {
|
|
897
|
+
return domain.trim().replace(/^https?:\/\//, "").replace(/^.*\.([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+)/, "$1").replace(/\/[^/]*$/, "").replace(/:[0-9]+/, "").replace(/\?.*$/, "").replace(/#.*$/, "").toLowerCase();
|
|
891
898
|
}
|
|
892
899
|
async handleResult(topic) {
|
|
893
900
|
const result = this.topicToResults[topic];
|
|
@@ -969,6 +976,12 @@ var ZKPassport = class {
|
|
|
969
976
|
if (this.topicToConfig[topic].bind) {
|
|
970
977
|
neededCircuits.push("bind");
|
|
971
978
|
}
|
|
979
|
+
if (this.topicToConfig[topic].sanctions) {
|
|
980
|
+
neededCircuits.push("exclusion_check_sanctions");
|
|
981
|
+
}
|
|
982
|
+
if (this.topicToConfig[topic].facematch) {
|
|
983
|
+
neededCircuits.push("facematch");
|
|
984
|
+
}
|
|
972
985
|
this.topicToExpectedProofCount[topic] = neededCircuits.length === 0 ? 4 : 3 + neededCircuits.length;
|
|
973
986
|
this.topicToFailedProofCount[topic] = 0;
|
|
974
987
|
}
|
|
@@ -1074,6 +1087,27 @@ var ZKPassport = class {
|
|
|
1074
1087
|
};
|
|
1075
1088
|
return this.getZkPassportRequest(topic);
|
|
1076
1089
|
},
|
|
1090
|
+
sanctions: (countries = "all", lists = "all") => {
|
|
1091
|
+
this.topicToConfig[topic].sanctions = {
|
|
1092
|
+
...this.topicToConfig[topic].sanctions,
|
|
1093
|
+
countries: countries === "all" ? "all" : Array.isArray(countries) ? [
|
|
1094
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1095
|
+
...countries
|
|
1096
|
+
] : [
|
|
1097
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1098
|
+
countries
|
|
1099
|
+
],
|
|
1100
|
+
lists: lists === "all" ? "all" : Array.isArray(lists) ? [...this.topicToConfig[topic].sanctions?.lists ?? [], ...lists] : [...this.topicToConfig[topic].sanctions?.lists ?? [], lists]
|
|
1101
|
+
};
|
|
1102
|
+
return this.getZkPassportRequest(topic);
|
|
1103
|
+
},
|
|
1104
|
+
// TODO: Uncomment this when the facematch is ready
|
|
1105
|
+
/*facematch: (mode: FacematchMode = "regular") => {
|
|
1106
|
+
this.topicToConfig[topic].facematch = {
|
|
1107
|
+
mode,
|
|
1108
|
+
}
|
|
1109
|
+
return this.getZkPassportRequest(topic)
|
|
1110
|
+
},*/
|
|
1077
1111
|
done: () => {
|
|
1078
1112
|
this.setExpectedProofCount(topic);
|
|
1079
1113
|
return {
|
|
@@ -1098,7 +1132,7 @@ var ZKPassport = class {
|
|
|
1098
1132
|
* @param logo The logo of your service
|
|
1099
1133
|
* @param purpose To explain what you want to do with the user's data
|
|
1100
1134
|
* @param scope Scope this request to a specific use case
|
|
1101
|
-
* @param validity How many
|
|
1135
|
+
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
1102
1136
|
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
1103
1137
|
* @returns The query builder object.
|
|
1104
1138
|
*/
|
|
@@ -1133,8 +1167,8 @@ var ZKPassport = class {
|
|
|
1133
1167
|
this.topicToProofs[topic] = [];
|
|
1134
1168
|
this.topicToExpectedProofCount[topic] = 0;
|
|
1135
1169
|
this.topicToLocalConfig[topic] = {
|
|
1136
|
-
// Default to
|
|
1137
|
-
validity: validity ||
|
|
1170
|
+
// Default to 7 days
|
|
1171
|
+
validity: validity || DEFAULT_VALIDITY,
|
|
1138
1172
|
mode: mode || "fast",
|
|
1139
1173
|
devMode: devMode || false
|
|
1140
1174
|
};
|
|
@@ -1163,25 +1197,7 @@ var ZKPassport = class {
|
|
|
1163
1197
|
return this.getZkPassportRequest(topic);
|
|
1164
1198
|
}
|
|
1165
1199
|
checkDiscloseBytesPublicInputs(proof, queryResult) {
|
|
1166
|
-
const queryResultErrors = {
|
|
1167
|
-
sig_check_dsc: {},
|
|
1168
|
-
sig_check_id_data: {},
|
|
1169
|
-
data_check_integrity: {},
|
|
1170
|
-
disclose: {},
|
|
1171
|
-
age: {},
|
|
1172
|
-
birthdate: {},
|
|
1173
|
-
expiry_date: {},
|
|
1174
|
-
document_type: {},
|
|
1175
|
-
issuing_country: {},
|
|
1176
|
-
gender: {},
|
|
1177
|
-
nationality: {},
|
|
1178
|
-
firstname: {},
|
|
1179
|
-
lastname: {},
|
|
1180
|
-
fullname: {},
|
|
1181
|
-
document_number: {},
|
|
1182
|
-
outer: {},
|
|
1183
|
-
bind: {}
|
|
1184
|
-
};
|
|
1200
|
+
const queryResultErrors = {};
|
|
1185
1201
|
let isCorrect = true;
|
|
1186
1202
|
const disclosedDataPassport = DisclosedData.fromDisclosedBytes(
|
|
1187
1203
|
(proof.committedInputs?.disclose_bytes).disclosedBytes,
|
|
@@ -1195,19 +1211,25 @@ var ZKPassport = class {
|
|
|
1195
1211
|
if (queryResult.document_type.eq && queryResult.document_type.eq.result && queryResult.document_type.eq.expected !== disclosedDataPassport.documentType) {
|
|
1196
1212
|
console.warn("Document type does not match the expected document type");
|
|
1197
1213
|
isCorrect = false;
|
|
1198
|
-
queryResultErrors.document_type
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1214
|
+
queryResultErrors.document_type = {
|
|
1215
|
+
...queryResultErrors.document_type,
|
|
1216
|
+
eq: {
|
|
1217
|
+
expected: `${queryResult.document_type.eq.expected}`,
|
|
1218
|
+
received: `${disclosedDataPassport.documentType ?? disclosedDataIDCard.documentType}`,
|
|
1219
|
+
message: "Document type does not match the expected document type"
|
|
1220
|
+
}
|
|
1202
1221
|
};
|
|
1203
1222
|
}
|
|
1204
1223
|
if (queryResult.document_type.disclose?.result !== disclosedDataIDCard.documentType) {
|
|
1205
1224
|
console.warn("Document type does not match the disclosed document type in query result");
|
|
1206
1225
|
isCorrect = false;
|
|
1207
|
-
queryResultErrors.document_type
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1226
|
+
queryResultErrors.document_type = {
|
|
1227
|
+
...queryResultErrors.document_type,
|
|
1228
|
+
disclose: {
|
|
1229
|
+
expected: `${queryResult.document_type.disclose?.result}`,
|
|
1230
|
+
received: `${disclosedDataIDCard.documentType ?? disclosedDataPassport.documentType}`,
|
|
1231
|
+
message: "Document type does not match the disclosed document type in query result"
|
|
1232
|
+
}
|
|
1211
1233
|
};
|
|
1212
1234
|
}
|
|
1213
1235
|
}
|
|
@@ -1217,19 +1239,25 @@ var ZKPassport = class {
|
|
|
1217
1239
|
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && !areDatesEqual(queryResult.birthdate.eq.expected, birthdatePassport) && !areDatesEqual(queryResult.birthdate.eq.expected, birthdateIDCard)) {
|
|
1218
1240
|
console.warn("Birthdate does not match the expected birthdate");
|
|
1219
1241
|
isCorrect = false;
|
|
1220
|
-
queryResultErrors.birthdate
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1242
|
+
queryResultErrors.birthdate = {
|
|
1243
|
+
...queryResultErrors.birthdate,
|
|
1244
|
+
eq: {
|
|
1245
|
+
expected: `${queryResult.birthdate.eq.expected.toISOString()}`,
|
|
1246
|
+
received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
|
|
1247
|
+
message: "Birthdate does not match the expected birthdate"
|
|
1248
|
+
}
|
|
1224
1249
|
};
|
|
1225
1250
|
}
|
|
1226
1251
|
if (queryResult.birthdate.disclose && !areDatesEqual(queryResult.birthdate.disclose.result, birthdatePassport) && !areDatesEqual(queryResult.birthdate.disclose.result, birthdateIDCard)) {
|
|
1227
1252
|
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
1228
1253
|
isCorrect = false;
|
|
1229
|
-
queryResultErrors.birthdate
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1254
|
+
queryResultErrors.birthdate = {
|
|
1255
|
+
...queryResultErrors.birthdate,
|
|
1256
|
+
disclose: {
|
|
1257
|
+
expected: `${queryResult.birthdate.disclose.result.toISOString()}`,
|
|
1258
|
+
received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
|
|
1259
|
+
message: "Birthdate does not match the disclosed birthdate in query result"
|
|
1260
|
+
}
|
|
1233
1261
|
};
|
|
1234
1262
|
}
|
|
1235
1263
|
}
|
|
@@ -1239,19 +1267,25 @@ var ZKPassport = class {
|
|
|
1239
1267
|
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && !areDatesEqual(queryResult.expiry_date.eq.expected, expiryDatePassport) && !areDatesEqual(queryResult.expiry_date.eq.expected, expiryDateIDCard)) {
|
|
1240
1268
|
console.warn("Expiry date does not match the expected expiry date");
|
|
1241
1269
|
isCorrect = false;
|
|
1242
|
-
queryResultErrors.expiry_date
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1270
|
+
queryResultErrors.expiry_date = {
|
|
1271
|
+
...queryResultErrors.expiry_date,
|
|
1272
|
+
eq: {
|
|
1273
|
+
expected: `${queryResult.expiry_date.eq.expected.toISOString()}`,
|
|
1274
|
+
received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
|
|
1275
|
+
message: "Expiry date does not match the expected expiry date"
|
|
1276
|
+
}
|
|
1246
1277
|
};
|
|
1247
1278
|
}
|
|
1248
1279
|
if (queryResult.expiry_date.disclose && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDatePassport) && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDateIDCard)) {
|
|
1249
1280
|
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
1250
1281
|
isCorrect = false;
|
|
1251
|
-
queryResultErrors.expiry_date
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1282
|
+
queryResultErrors.expiry_date = {
|
|
1283
|
+
...queryResultErrors.expiry_date,
|
|
1284
|
+
disclose: {
|
|
1285
|
+
expected: `${queryResult.expiry_date.disclose.result.toISOString()}`,
|
|
1286
|
+
received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
|
|
1287
|
+
message: "Expiry date does not match the disclosed expiry date in query result"
|
|
1288
|
+
}
|
|
1255
1289
|
};
|
|
1256
1290
|
}
|
|
1257
1291
|
}
|
|
@@ -1261,19 +1295,25 @@ var ZKPassport = class {
|
|
|
1261
1295
|
if (queryResult.nationality.eq && queryResult.nationality.eq.result && queryResult.nationality.eq.expected !== nationalityPassport && queryResult.nationality.eq.expected !== nationalityIDCard) {
|
|
1262
1296
|
console.warn("Nationality does not match the expected nationality");
|
|
1263
1297
|
isCorrect = false;
|
|
1264
|
-
queryResultErrors.nationality
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1298
|
+
queryResultErrors.nationality = {
|
|
1299
|
+
...queryResultErrors.nationality,
|
|
1300
|
+
eq: {
|
|
1301
|
+
expected: `${queryResult.nationality.eq.expected}`,
|
|
1302
|
+
received: `${nationalityPassport ?? nationalityIDCard}`,
|
|
1303
|
+
message: "Nationality does not match the expected nationality"
|
|
1304
|
+
}
|
|
1268
1305
|
};
|
|
1269
1306
|
}
|
|
1270
1307
|
if (queryResult.nationality.disclose && queryResult.nationality.disclose.result !== nationalityPassport && queryResult.nationality.disclose.result !== nationalityIDCard) {
|
|
1271
1308
|
console.warn("Nationality does not match the disclosed nationality in query result");
|
|
1272
1309
|
isCorrect = false;
|
|
1273
|
-
queryResultErrors.nationality
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1310
|
+
queryResultErrors.nationality = {
|
|
1311
|
+
...queryResultErrors.nationality,
|
|
1312
|
+
disclose: {
|
|
1313
|
+
expected: `${queryResult.nationality.disclose.result}`,
|
|
1314
|
+
received: `${nationalityPassport ?? nationalityIDCard}`,
|
|
1315
|
+
message: "Nationality does not match the disclosed nationality in query result"
|
|
1316
|
+
}
|
|
1277
1317
|
};
|
|
1278
1318
|
}
|
|
1279
1319
|
}
|
|
@@ -1283,19 +1323,25 @@ var ZKPassport = class {
|
|
|
1283
1323
|
if (queryResult.document_number.eq && queryResult.document_number.eq.result && queryResult.document_number.eq.expected !== documentNumberPassport && queryResult.document_number.eq.expected !== documentNumberIDCard) {
|
|
1284
1324
|
console.warn("Document number does not match the expected document number");
|
|
1285
1325
|
isCorrect = false;
|
|
1286
|
-
queryResultErrors.document_number
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1326
|
+
queryResultErrors.document_number = {
|
|
1327
|
+
...queryResultErrors.document_number,
|
|
1328
|
+
eq: {
|
|
1329
|
+
expected: `${queryResult.document_number.eq.expected}`,
|
|
1330
|
+
received: `${documentNumberPassport ?? documentNumberIDCard}`,
|
|
1331
|
+
message: "Document number does not match the expected document number"
|
|
1332
|
+
}
|
|
1290
1333
|
};
|
|
1291
1334
|
}
|
|
1292
1335
|
if (queryResult.document_number.disclose && queryResult.document_number.disclose.result !== documentNumberPassport && queryResult.document_number.disclose.result !== documentNumberIDCard) {
|
|
1293
1336
|
console.warn("Document number does not match the disclosed document number in query result");
|
|
1294
1337
|
isCorrect = false;
|
|
1295
|
-
queryResultErrors.document_number
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1338
|
+
queryResultErrors.document_number = {
|
|
1339
|
+
...queryResultErrors.document_number,
|
|
1340
|
+
disclose: {
|
|
1341
|
+
expected: `${queryResult.document_number.disclose.result}`,
|
|
1342
|
+
received: `${documentNumberPassport ?? documentNumberIDCard}`,
|
|
1343
|
+
message: "Document number does not match the disclosed document number in query result"
|
|
1344
|
+
}
|
|
1299
1345
|
};
|
|
1300
1346
|
}
|
|
1301
1347
|
}
|
|
@@ -1305,19 +1351,25 @@ var ZKPassport = class {
|
|
|
1305
1351
|
if (queryResult.gender.eq && queryResult.gender.eq.result && queryResult.gender.eq.expected !== genderPassport && queryResult.gender.eq.expected !== genderIDCard) {
|
|
1306
1352
|
console.warn("Gender does not match the expected gender");
|
|
1307
1353
|
isCorrect = false;
|
|
1308
|
-
queryResultErrors.gender
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1354
|
+
queryResultErrors.gender = {
|
|
1355
|
+
...queryResultErrors.gender,
|
|
1356
|
+
eq: {
|
|
1357
|
+
expected: `${queryResult.gender.eq.expected}`,
|
|
1358
|
+
received: `${genderPassport ?? genderIDCard}`,
|
|
1359
|
+
message: "Gender does not match the expected gender"
|
|
1360
|
+
}
|
|
1312
1361
|
};
|
|
1313
1362
|
}
|
|
1314
1363
|
if (queryResult.gender.disclose && queryResult.gender.disclose.result !== genderPassport && queryResult.gender.disclose.result !== genderIDCard) {
|
|
1315
1364
|
console.warn("Gender does not match the disclosed gender in query result");
|
|
1316
1365
|
isCorrect = false;
|
|
1317
|
-
queryResultErrors.gender
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1366
|
+
queryResultErrors.gender = {
|
|
1367
|
+
...queryResultErrors.gender,
|
|
1368
|
+
disclose: {
|
|
1369
|
+
expected: `${queryResult.gender.disclose.result}`,
|
|
1370
|
+
received: `${genderPassport ?? genderIDCard}`,
|
|
1371
|
+
message: "Gender does not match the disclosed gender in query result"
|
|
1372
|
+
}
|
|
1321
1373
|
};
|
|
1322
1374
|
}
|
|
1323
1375
|
}
|
|
@@ -1327,19 +1379,25 @@ var ZKPassport = class {
|
|
|
1327
1379
|
if (queryResult.issuing_country.eq && queryResult.issuing_country.eq.result && queryResult.issuing_country.eq.expected !== issuingCountryPassport && queryResult.issuing_country.eq.expected !== issuingCountryIDCard) {
|
|
1328
1380
|
console.warn("Issuing country does not match the expected issuing country");
|
|
1329
1381
|
isCorrect = false;
|
|
1330
|
-
queryResultErrors.issuing_country
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1382
|
+
queryResultErrors.issuing_country = {
|
|
1383
|
+
...queryResultErrors.issuing_country,
|
|
1384
|
+
eq: {
|
|
1385
|
+
expected: `${queryResult.issuing_country.eq.expected}`,
|
|
1386
|
+
received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
|
|
1387
|
+
message: "Issuing country does not match the expected issuing country"
|
|
1388
|
+
}
|
|
1334
1389
|
};
|
|
1335
1390
|
}
|
|
1336
1391
|
if (queryResult.issuing_country.disclose && queryResult.issuing_country.disclose.result !== issuingCountryPassport && queryResult.issuing_country.disclose.result !== issuingCountryIDCard) {
|
|
1337
1392
|
console.warn("Issuing country does not match the disclosed issuing country in query result");
|
|
1338
1393
|
isCorrect = false;
|
|
1339
|
-
queryResultErrors.issuing_country
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1394
|
+
queryResultErrors.issuing_country = {
|
|
1395
|
+
...queryResultErrors.issuing_country,
|
|
1396
|
+
disclose: {
|
|
1397
|
+
expected: `${queryResult.issuing_country.disclose.result}`,
|
|
1398
|
+
received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
|
|
1399
|
+
message: "Issuing country does not match the disclosed issuing country in query result"
|
|
1400
|
+
}
|
|
1343
1401
|
};
|
|
1344
1402
|
}
|
|
1345
1403
|
}
|
|
@@ -1349,19 +1407,25 @@ var ZKPassport = class {
|
|
|
1349
1407
|
if (queryResult.fullname.eq && queryResult.fullname.eq.result && formatName(queryResult.fullname.eq.expected).toLowerCase() !== fullnamePassport.toLowerCase() && formatName(queryResult.fullname.eq.expected).toLowerCase() !== fullnameIDCard.toLowerCase()) {
|
|
1350
1408
|
console.warn("Fullname does not match the expected fullname");
|
|
1351
1409
|
isCorrect = false;
|
|
1352
|
-
queryResultErrors.fullname
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1410
|
+
queryResultErrors.fullname = {
|
|
1411
|
+
...queryResultErrors.fullname,
|
|
1412
|
+
eq: {
|
|
1413
|
+
expected: `${queryResult.fullname.eq.expected}`,
|
|
1414
|
+
received: `${fullnamePassport ?? fullnameIDCard}`,
|
|
1415
|
+
message: "Fullname does not match the expected fullname"
|
|
1416
|
+
}
|
|
1356
1417
|
};
|
|
1357
1418
|
}
|
|
1358
1419
|
if (queryResult.fullname.disclose && formatName(queryResult.fullname.disclose.result).toLowerCase() !== fullnamePassport.toLowerCase() && formatName(queryResult.fullname.disclose.result).toLowerCase() !== fullnameIDCard.toLowerCase()) {
|
|
1359
1420
|
console.warn("Fullname does not match the disclosed fullname in query result");
|
|
1360
1421
|
isCorrect = false;
|
|
1361
|
-
queryResultErrors.fullname
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1422
|
+
queryResultErrors.fullname = {
|
|
1423
|
+
...queryResultErrors.fullname,
|
|
1424
|
+
disclose: {
|
|
1425
|
+
expected: `${queryResult.fullname.disclose.result}`,
|
|
1426
|
+
received: `${fullnamePassport ?? fullnameIDCard}`,
|
|
1427
|
+
message: "Fullname does not match the disclosed fullname in query result"
|
|
1428
|
+
}
|
|
1365
1429
|
};
|
|
1366
1430
|
}
|
|
1367
1431
|
}
|
|
@@ -1371,19 +1435,25 @@ var ZKPassport = class {
|
|
|
1371
1435
|
if (queryResult.firstname.eq && queryResult.firstname.eq.result && formatName(queryResult.firstname.eq.expected).toLowerCase() !== firstnamePassport.toLowerCase() && formatName(queryResult.firstname.eq.expected).toLowerCase() !== firstnameIDCard.toLowerCase()) {
|
|
1372
1436
|
console.warn("Firstname does not match the expected firstname");
|
|
1373
1437
|
isCorrect = false;
|
|
1374
|
-
queryResultErrors.firstname
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1438
|
+
queryResultErrors.firstname = {
|
|
1439
|
+
...queryResultErrors.firstname,
|
|
1440
|
+
eq: {
|
|
1441
|
+
expected: `${queryResult.firstname.eq.expected}`,
|
|
1442
|
+
received: `${firstnamePassport ?? firstnameIDCard}`,
|
|
1443
|
+
message: "Firstname does not match the expected firstname"
|
|
1444
|
+
}
|
|
1378
1445
|
};
|
|
1379
1446
|
}
|
|
1380
1447
|
if (queryResult.firstname.disclose && formatName(queryResult.firstname.disclose.result).toLowerCase() !== firstnamePassport.toLowerCase() && formatName(queryResult.firstname.disclose.result).toLowerCase() !== firstnameIDCard.toLowerCase()) {
|
|
1381
1448
|
console.warn("Firstname does not match the disclosed firstname in query result");
|
|
1382
1449
|
isCorrect = false;
|
|
1383
|
-
queryResultErrors.firstname
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1450
|
+
queryResultErrors.firstname = {
|
|
1451
|
+
...queryResultErrors.firstname,
|
|
1452
|
+
disclose: {
|
|
1453
|
+
expected: `${queryResult.firstname.disclose.result}`,
|
|
1454
|
+
received: `${firstnamePassport ?? firstnameIDCard}`,
|
|
1455
|
+
message: "Firstname does not match the disclosed firstname in query result"
|
|
1456
|
+
}
|
|
1387
1457
|
};
|
|
1388
1458
|
}
|
|
1389
1459
|
}
|
|
@@ -1393,44 +1463,32 @@ var ZKPassport = class {
|
|
|
1393
1463
|
if (queryResult.lastname.eq && queryResult.lastname.eq.result && formatName(queryResult.lastname.eq.expected).toLowerCase() !== lastnamePassport.toLowerCase() && formatName(queryResult.lastname.eq.expected).toLowerCase() !== lastnameIDCard.toLowerCase()) {
|
|
1394
1464
|
console.warn("Lastname does not match the expected lastname");
|
|
1395
1465
|
isCorrect = false;
|
|
1396
|
-
queryResultErrors.lastname
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1466
|
+
queryResultErrors.lastname = {
|
|
1467
|
+
...queryResultErrors.lastname,
|
|
1468
|
+
eq: {
|
|
1469
|
+
expected: `${queryResult.lastname.eq.expected}`,
|
|
1470
|
+
received: `${lastnamePassport ?? lastnameIDCard}`,
|
|
1471
|
+
message: "Lastname does not match the expected lastname"
|
|
1472
|
+
}
|
|
1400
1473
|
};
|
|
1401
1474
|
}
|
|
1402
1475
|
if (queryResult.lastname.disclose && formatName(queryResult.lastname.disclose.result).toLowerCase() !== lastnamePassport.toLowerCase() && formatName(queryResult.lastname.disclose.result).toLowerCase() !== lastnameIDCard.toLowerCase()) {
|
|
1403
1476
|
console.warn("Lastname does not match the disclosed lastname in query result");
|
|
1404
1477
|
isCorrect = false;
|
|
1405
|
-
queryResultErrors.lastname
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1478
|
+
queryResultErrors.lastname = {
|
|
1479
|
+
...queryResultErrors.lastname,
|
|
1480
|
+
disclose: {
|
|
1481
|
+
expected: `${queryResult.lastname.disclose.result}`,
|
|
1482
|
+
received: `${lastnamePassport ?? lastnameIDCard}`,
|
|
1483
|
+
message: "Lastname does not match the disclosed lastname in query result"
|
|
1484
|
+
}
|
|
1409
1485
|
};
|
|
1410
1486
|
}
|
|
1411
1487
|
}
|
|
1412
1488
|
return { isCorrect, queryResultErrors };
|
|
1413
1489
|
}
|
|
1414
1490
|
checkAgePublicInputs(proof, queryResult) {
|
|
1415
|
-
const queryResultErrors = {
|
|
1416
|
-
sig_check_dsc: {},
|
|
1417
|
-
sig_check_id_data: {},
|
|
1418
|
-
data_check_integrity: {},
|
|
1419
|
-
disclose: {},
|
|
1420
|
-
age: {},
|
|
1421
|
-
birthdate: {},
|
|
1422
|
-
expiry_date: {},
|
|
1423
|
-
document_type: {},
|
|
1424
|
-
issuing_country: {},
|
|
1425
|
-
gender: {},
|
|
1426
|
-
nationality: {},
|
|
1427
|
-
firstname: {},
|
|
1428
|
-
lastname: {},
|
|
1429
|
-
fullname: {},
|
|
1430
|
-
document_number: {},
|
|
1431
|
-
outer: {},
|
|
1432
|
-
bind: {}
|
|
1433
|
-
};
|
|
1491
|
+
const queryResultErrors = {};
|
|
1434
1492
|
let isCorrect = true;
|
|
1435
1493
|
const currentTime = /* @__PURE__ */ new Date();
|
|
1436
1494
|
const today = new Date(
|
|
@@ -1452,64 +1510,85 @@ var ZKPassport = class {
|
|
|
1452
1510
|
if (queryResult.age.gte && queryResult.age.gte.result && minAge !== queryResult.age.gte.expected) {
|
|
1453
1511
|
console.warn("Age is not greater than or equal to the expected age");
|
|
1454
1512
|
isCorrect = false;
|
|
1455
|
-
queryResultErrors.age
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1513
|
+
queryResultErrors.age = {
|
|
1514
|
+
...queryResultErrors.age,
|
|
1515
|
+
gte: {
|
|
1516
|
+
expected: queryResult.age.gte.expected,
|
|
1517
|
+
received: minAge,
|
|
1518
|
+
message: "Age is not greater than or equal to the expected age"
|
|
1519
|
+
}
|
|
1459
1520
|
};
|
|
1460
1521
|
}
|
|
1461
1522
|
if (queryResult.age.lt && queryResult.age.lt.result && maxAge !== queryResult.age.lt.expected) {
|
|
1462
1523
|
console.warn("Age is not less than the expected age");
|
|
1463
1524
|
isCorrect = false;
|
|
1464
|
-
queryResultErrors.age
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1525
|
+
queryResultErrors.age = {
|
|
1526
|
+
...queryResultErrors.age,
|
|
1527
|
+
lt: {
|
|
1528
|
+
expected: queryResult.age.lt.expected,
|
|
1529
|
+
received: maxAge,
|
|
1530
|
+
message: "Age is not less than the expected age"
|
|
1531
|
+
}
|
|
1468
1532
|
};
|
|
1469
1533
|
}
|
|
1470
1534
|
if (queryResult.age.range) {
|
|
1471
1535
|
if (queryResult.age.range.result && (minAge !== queryResult.age.range.expected[0] || maxAge !== queryResult.age.range.expected[1])) {
|
|
1472
1536
|
console.warn("Age is not in the expected range");
|
|
1473
1537
|
isCorrect = false;
|
|
1474
|
-
queryResultErrors.age
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1538
|
+
queryResultErrors.age = {
|
|
1539
|
+
...queryResultErrors.age,
|
|
1540
|
+
range: {
|
|
1541
|
+
expected: queryResult.age.range.expected,
|
|
1542
|
+
received: [minAge, maxAge],
|
|
1543
|
+
message: "Age is not in the expected range"
|
|
1544
|
+
}
|
|
1478
1545
|
};
|
|
1479
1546
|
}
|
|
1480
1547
|
}
|
|
1481
1548
|
if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
|
|
1482
1549
|
console.warn("Maximum age should be equal to 0");
|
|
1483
1550
|
isCorrect = false;
|
|
1484
|
-
queryResultErrors.age
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1551
|
+
queryResultErrors.age = {
|
|
1552
|
+
...queryResultErrors.age,
|
|
1553
|
+
disclose: {
|
|
1554
|
+
expected: 0,
|
|
1555
|
+
received: maxAge,
|
|
1556
|
+
message: "Maximum age should be equal to 0"
|
|
1557
|
+
}
|
|
1488
1558
|
};
|
|
1489
1559
|
}
|
|
1490
1560
|
if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
|
|
1491
1561
|
console.warn("Minimum age should be equal to 0");
|
|
1492
1562
|
isCorrect = false;
|
|
1493
|
-
queryResultErrors.age
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1563
|
+
queryResultErrors.age = {
|
|
1564
|
+
...queryResultErrors.age,
|
|
1565
|
+
disclose: {
|
|
1566
|
+
expected: 0,
|
|
1567
|
+
received: minAge,
|
|
1568
|
+
message: "Minimum age should be equal to 0"
|
|
1569
|
+
}
|
|
1497
1570
|
};
|
|
1498
1571
|
}
|
|
1499
1572
|
if (queryResult.age.disclose && (queryResult.age.disclose.result !== minAge || queryResult.age.disclose.result !== maxAge)) {
|
|
1500
1573
|
console.warn("Age does not match the disclosed age in query result");
|
|
1501
1574
|
isCorrect = false;
|
|
1502
|
-
queryResultErrors.age
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1575
|
+
queryResultErrors.age = {
|
|
1576
|
+
...queryResultErrors.age,
|
|
1577
|
+
disclose: {
|
|
1578
|
+
expected: `${minAge}`,
|
|
1579
|
+
received: `${queryResult.age.disclose.result}`,
|
|
1580
|
+
message: "Age does not match the disclosed age in query result"
|
|
1581
|
+
}
|
|
1506
1582
|
};
|
|
1507
1583
|
}
|
|
1508
1584
|
} else {
|
|
1509
1585
|
console.warn("Age is not set in the query result");
|
|
1510
1586
|
isCorrect = false;
|
|
1511
|
-
queryResultErrors.age
|
|
1512
|
-
|
|
1587
|
+
queryResultErrors.age = {
|
|
1588
|
+
...queryResultErrors.age,
|
|
1589
|
+
disclose: {
|
|
1590
|
+
message: "Age is not set in the query result"
|
|
1591
|
+
}
|
|
1513
1592
|
};
|
|
1514
1593
|
}
|
|
1515
1594
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
@@ -1518,34 +1597,19 @@ var ZKPassport = class {
|
|
|
1518
1597
|
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1519
1598
|
console.warn("Current date in the proof is too old");
|
|
1520
1599
|
isCorrect = false;
|
|
1521
|
-
queryResultErrors.age
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1600
|
+
queryResultErrors.age = {
|
|
1601
|
+
...queryResultErrors.age,
|
|
1602
|
+
disclose: {
|
|
1603
|
+
expected: `${today.toISOString()}`,
|
|
1604
|
+
received: `${currentDate.toISOString()}`,
|
|
1605
|
+
message: "Current date in the proof is too old"
|
|
1606
|
+
}
|
|
1525
1607
|
};
|
|
1526
1608
|
}
|
|
1527
1609
|
return { isCorrect, queryResultErrors };
|
|
1528
1610
|
}
|
|
1529
1611
|
checkBirthdatePublicInputs(proof, queryResult) {
|
|
1530
|
-
const queryResultErrors = {
|
|
1531
|
-
sig_check_dsc: {},
|
|
1532
|
-
sig_check_id_data: {},
|
|
1533
|
-
data_check_integrity: {},
|
|
1534
|
-
disclose: {},
|
|
1535
|
-
age: {},
|
|
1536
|
-
birthdate: {},
|
|
1537
|
-
expiry_date: {},
|
|
1538
|
-
document_type: {},
|
|
1539
|
-
issuing_country: {},
|
|
1540
|
-
gender: {},
|
|
1541
|
-
nationality: {},
|
|
1542
|
-
firstname: {},
|
|
1543
|
-
lastname: {},
|
|
1544
|
-
fullname: {},
|
|
1545
|
-
document_number: {},
|
|
1546
|
-
outer: {},
|
|
1547
|
-
bind: {}
|
|
1548
|
-
};
|
|
1612
|
+
const queryResultErrors = {};
|
|
1549
1613
|
let isCorrect = true;
|
|
1550
1614
|
const currentTime = /* @__PURE__ */ new Date();
|
|
1551
1615
|
const today = new Date(
|
|
@@ -1556,10 +1620,10 @@ var ZKPassport = class {
|
|
|
1556
1620
|
0,
|
|
1557
1621
|
0
|
|
1558
1622
|
);
|
|
1559
|
-
const minDate =
|
|
1623
|
+
const minDate = getBirthdateMinDateTimestamp(
|
|
1560
1624
|
proof.committedInputs?.compare_birthdate
|
|
1561
1625
|
);
|
|
1562
|
-
const maxDate =
|
|
1626
|
+
const maxDate = getBirthdateMaxDateTimestamp(
|
|
1563
1627
|
proof.committedInputs?.compare_birthdate
|
|
1564
1628
|
);
|
|
1565
1629
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
@@ -1569,88 +1633,91 @@ var ZKPassport = class {
|
|
|
1569
1633
|
if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && minDate !== queryResult.birthdate.gte.expected) {
|
|
1570
1634
|
console.warn("Birthdate is not greater than or equal to the expected birthdate");
|
|
1571
1635
|
isCorrect = false;
|
|
1572
|
-
queryResultErrors.birthdate
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1636
|
+
queryResultErrors.birthdate = {
|
|
1637
|
+
...queryResultErrors.birthdate,
|
|
1638
|
+
gte: {
|
|
1639
|
+
expected: queryResult.birthdate.gte.expected,
|
|
1640
|
+
received: minDate,
|
|
1641
|
+
message: "Birthdate is not greater than or equal to the expected birthdate"
|
|
1642
|
+
}
|
|
1576
1643
|
};
|
|
1577
1644
|
}
|
|
1578
1645
|
if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && maxDate !== queryResult.birthdate.lte.expected) {
|
|
1579
1646
|
console.warn("Birthdate is not less than the expected birthdate");
|
|
1580
1647
|
isCorrect = false;
|
|
1581
|
-
queryResultErrors.birthdate
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1648
|
+
queryResultErrors.birthdate = {
|
|
1649
|
+
...queryResultErrors.birthdate,
|
|
1650
|
+
lte: {
|
|
1651
|
+
expected: queryResult.birthdate.lte.expected,
|
|
1652
|
+
received: maxDate,
|
|
1653
|
+
message: "Birthdate is not less than the expected birthdate"
|
|
1654
|
+
}
|
|
1585
1655
|
};
|
|
1586
1656
|
}
|
|
1587
1657
|
if (queryResult.birthdate.range) {
|
|
1588
1658
|
if (queryResult.birthdate.range.result && (minDate !== queryResult.birthdate.range.expected[0] || maxDate !== queryResult.birthdate.range.expected[1])) {
|
|
1589
1659
|
console.warn("Birthdate is not in the expected range");
|
|
1590
1660
|
isCorrect = false;
|
|
1591
|
-
queryResultErrors.birthdate
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1661
|
+
queryResultErrors.birthdate = {
|
|
1662
|
+
...queryResultErrors.birthdate,
|
|
1663
|
+
range: {
|
|
1664
|
+
expected: queryResult.birthdate.range.expected,
|
|
1665
|
+
received: [minDate, maxDate],
|
|
1666
|
+
message: "Birthdate is not in the expected range"
|
|
1667
|
+
}
|
|
1595
1668
|
};
|
|
1596
1669
|
}
|
|
1597
1670
|
}
|
|
1598
1671
|
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1599
1672
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1600
1673
|
isCorrect = false;
|
|
1601
|
-
queryResultErrors.birthdate
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1674
|
+
queryResultErrors.birthdate = {
|
|
1675
|
+
...queryResultErrors.birthdate,
|
|
1676
|
+
disclose: {
|
|
1677
|
+
expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
|
|
1678
|
+
received: `${maxDate.toISOString()}`,
|
|
1679
|
+
message: "Maximum birthdate should be equal to default date value"
|
|
1680
|
+
}
|
|
1605
1681
|
};
|
|
1606
1682
|
}
|
|
1607
1683
|
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1608
1684
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1609
1685
|
isCorrect = false;
|
|
1610
|
-
queryResultErrors.birthdate
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1686
|
+
queryResultErrors.birthdate = {
|
|
1687
|
+
...queryResultErrors.birthdate,
|
|
1688
|
+
disclose: {
|
|
1689
|
+
expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
|
|
1690
|
+
received: `${minDate.toISOString()}`,
|
|
1691
|
+
message: "Minimum birthdate should be equal to default date value"
|
|
1692
|
+
}
|
|
1614
1693
|
};
|
|
1615
1694
|
}
|
|
1616
1695
|
} else {
|
|
1617
1696
|
console.warn("Birthdate is not set in the query result");
|
|
1618
1697
|
isCorrect = false;
|
|
1619
|
-
queryResultErrors.birthdate
|
|
1620
|
-
|
|
1698
|
+
queryResultErrors.birthdate = {
|
|
1699
|
+
...queryResultErrors.birthdate,
|
|
1700
|
+
disclose: {
|
|
1701
|
+
message: "Birthdate is not set in the query result"
|
|
1702
|
+
}
|
|
1621
1703
|
};
|
|
1622
1704
|
}
|
|
1623
1705
|
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1624
1706
|
console.warn("Current date in the proof is too old");
|
|
1625
1707
|
isCorrect = false;
|
|
1626
|
-
queryResultErrors.
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1708
|
+
queryResultErrors.birthdate = {
|
|
1709
|
+
...queryResultErrors.birthdate,
|
|
1710
|
+
disclose: {
|
|
1711
|
+
expected: `${today.toISOString()}`,
|
|
1712
|
+
received: `${currentDate.toISOString()}`,
|
|
1713
|
+
message: "Current date in the proof is too old"
|
|
1714
|
+
}
|
|
1630
1715
|
};
|
|
1631
1716
|
}
|
|
1632
1717
|
return { isCorrect, queryResultErrors };
|
|
1633
1718
|
}
|
|
1634
1719
|
checkExpiryDatePublicInputs(proof, queryResult) {
|
|
1635
|
-
const queryResultErrors = {
|
|
1636
|
-
sig_check_dsc: {},
|
|
1637
|
-
sig_check_id_data: {},
|
|
1638
|
-
data_check_integrity: {},
|
|
1639
|
-
disclose: {},
|
|
1640
|
-
age: {},
|
|
1641
|
-
birthdate: {},
|
|
1642
|
-
expiry_date: {},
|
|
1643
|
-
document_type: {},
|
|
1644
|
-
issuing_country: {},
|
|
1645
|
-
gender: {},
|
|
1646
|
-
nationality: {},
|
|
1647
|
-
firstname: {},
|
|
1648
|
-
lastname: {},
|
|
1649
|
-
fullname: {},
|
|
1650
|
-
document_number: {},
|
|
1651
|
-
outer: {},
|
|
1652
|
-
bind: {}
|
|
1653
|
-
};
|
|
1720
|
+
const queryResultErrors = {};
|
|
1654
1721
|
let isCorrect = true;
|
|
1655
1722
|
const currentTime = /* @__PURE__ */ new Date();
|
|
1656
1723
|
const today = new Date(
|
|
@@ -1674,104 +1741,113 @@ var ZKPassport = class {
|
|
|
1674
1741
|
if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && minDate !== queryResult.expiry_date.gte.expected) {
|
|
1675
1742
|
console.warn("Expiry date is not greater than or equal to the expected expiry date");
|
|
1676
1743
|
isCorrect = false;
|
|
1677
|
-
queryResultErrors.expiry_date
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1744
|
+
queryResultErrors.expiry_date = {
|
|
1745
|
+
...queryResultErrors.expiry_date,
|
|
1746
|
+
gte: {
|
|
1747
|
+
expected: queryResult.expiry_date.gte.expected,
|
|
1748
|
+
received: minDate,
|
|
1749
|
+
message: "Expiry date is not greater than or equal to the expected expiry date"
|
|
1750
|
+
}
|
|
1681
1751
|
};
|
|
1682
1752
|
}
|
|
1683
1753
|
if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && maxDate !== queryResult.expiry_date.lte.expected) {
|
|
1684
1754
|
console.warn("Expiry date is not less than the expected expiry date");
|
|
1685
1755
|
isCorrect = false;
|
|
1686
|
-
queryResultErrors.expiry_date
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1756
|
+
queryResultErrors.expiry_date = {
|
|
1757
|
+
...queryResultErrors.expiry_date,
|
|
1758
|
+
lte: {
|
|
1759
|
+
expected: queryResult.expiry_date.lte.expected,
|
|
1760
|
+
received: maxDate,
|
|
1761
|
+
message: "Expiry date is not less than the expected expiry date"
|
|
1762
|
+
}
|
|
1690
1763
|
};
|
|
1691
1764
|
}
|
|
1692
1765
|
if (queryResult.expiry_date.range) {
|
|
1693
1766
|
if (queryResult.expiry_date.range.result && (minDate !== queryResult.expiry_date.range.expected[0] || maxDate !== queryResult.expiry_date.range.expected[1])) {
|
|
1694
1767
|
console.warn("Expiry date is not in the expected range");
|
|
1695
1768
|
isCorrect = false;
|
|
1696
|
-
queryResultErrors.expiry_date
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1769
|
+
queryResultErrors.expiry_date = {
|
|
1770
|
+
...queryResultErrors.expiry_date,
|
|
1771
|
+
range: {
|
|
1772
|
+
expected: queryResult.expiry_date.range.expected,
|
|
1773
|
+
received: [minDate, maxDate],
|
|
1774
|
+
message: "Expiry date is not in the expected range"
|
|
1775
|
+
}
|
|
1700
1776
|
};
|
|
1701
1777
|
}
|
|
1702
1778
|
}
|
|
1703
1779
|
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1704
1780
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1705
1781
|
isCorrect = false;
|
|
1706
|
-
queryResultErrors.expiry_date
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1782
|
+
queryResultErrors.expiry_date = {
|
|
1783
|
+
...queryResultErrors.expiry_date,
|
|
1784
|
+
disclose: {
|
|
1785
|
+
expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
|
|
1786
|
+
received: `${maxDate.toISOString()}`,
|
|
1787
|
+
message: "Maximum expiry date should be equal to default date value"
|
|
1788
|
+
}
|
|
1710
1789
|
};
|
|
1711
1790
|
}
|
|
1712
1791
|
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1713
1792
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1714
1793
|
isCorrect = false;
|
|
1715
|
-
queryResultErrors.expiry_date
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1794
|
+
queryResultErrors.expiry_date = {
|
|
1795
|
+
...queryResultErrors.expiry_date,
|
|
1796
|
+
disclose: {
|
|
1797
|
+
expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
|
|
1798
|
+
received: `${minDate.toISOString()}`,
|
|
1799
|
+
message: "Minimum expiry date should be equal to default date value"
|
|
1800
|
+
}
|
|
1719
1801
|
};
|
|
1720
1802
|
}
|
|
1721
1803
|
} else {
|
|
1722
1804
|
console.warn("Expiry date is not set in the query result");
|
|
1723
1805
|
isCorrect = false;
|
|
1724
|
-
queryResultErrors.expiry_date
|
|
1725
|
-
|
|
1806
|
+
queryResultErrors.expiry_date = {
|
|
1807
|
+
...queryResultErrors.expiry_date,
|
|
1808
|
+
disclose: {
|
|
1809
|
+
message: "Expiry date is not set in the query result"
|
|
1810
|
+
}
|
|
1726
1811
|
};
|
|
1727
1812
|
}
|
|
1728
1813
|
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1729
1814
|
console.warn("Current date in the proof is too old");
|
|
1730
1815
|
isCorrect = false;
|
|
1731
|
-
queryResultErrors.
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1816
|
+
queryResultErrors.expiry_date = {
|
|
1817
|
+
...queryResultErrors.expiry_date,
|
|
1818
|
+
disclose: {
|
|
1819
|
+
expected: `${today.toISOString()}`,
|
|
1820
|
+
received: `${currentDate.toISOString()}`,
|
|
1821
|
+
message: "Current date in the proof is too old"
|
|
1822
|
+
}
|
|
1735
1823
|
};
|
|
1736
1824
|
}
|
|
1737
1825
|
return { isCorrect, queryResultErrors };
|
|
1738
1826
|
}
|
|
1739
1827
|
checkNationalityExclusionPublicInputs(queryResult, countryList) {
|
|
1740
|
-
const queryResultErrors = {
|
|
1741
|
-
sig_check_dsc: {},
|
|
1742
|
-
sig_check_id_data: {},
|
|
1743
|
-
data_check_integrity: {},
|
|
1744
|
-
disclose: {},
|
|
1745
|
-
age: {},
|
|
1746
|
-
birthdate: {},
|
|
1747
|
-
expiry_date: {},
|
|
1748
|
-
document_type: {},
|
|
1749
|
-
issuing_country: {},
|
|
1750
|
-
gender: {},
|
|
1751
|
-
nationality: {},
|
|
1752
|
-
firstname: {},
|
|
1753
|
-
lastname: {},
|
|
1754
|
-
fullname: {},
|
|
1755
|
-
document_number: {},
|
|
1756
|
-
outer: {},
|
|
1757
|
-
bind: {}
|
|
1758
|
-
};
|
|
1828
|
+
const queryResultErrors = {};
|
|
1759
1829
|
let isCorrect = true;
|
|
1760
1830
|
if (queryResult.nationality && queryResult.nationality.out && queryResult.nationality.out.result) {
|
|
1761
1831
|
if (!queryResult.nationality.out.expected?.every((country) => countryList.includes(country))) {
|
|
1762
1832
|
console.warn("Nationality exclusion list does not match the one from the query results");
|
|
1763
1833
|
isCorrect = false;
|
|
1764
|
-
queryResultErrors.nationality
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1834
|
+
queryResultErrors.nationality = {
|
|
1835
|
+
...queryResultErrors.nationality,
|
|
1836
|
+
out: {
|
|
1837
|
+
expected: queryResult.nationality.out.expected,
|
|
1838
|
+
received: countryList,
|
|
1839
|
+
message: "Nationality exclusion list does not match the one from the query results"
|
|
1840
|
+
}
|
|
1768
1841
|
};
|
|
1769
1842
|
}
|
|
1770
1843
|
} else if (!queryResult.nationality || !queryResult.nationality.out) {
|
|
1771
1844
|
console.warn("Nationality exclusion is not set in the query result");
|
|
1772
1845
|
isCorrect = false;
|
|
1773
|
-
queryResultErrors.nationality
|
|
1774
|
-
|
|
1846
|
+
queryResultErrors.nationality = {
|
|
1847
|
+
...queryResultErrors.nationality,
|
|
1848
|
+
out: {
|
|
1849
|
+
message: "Nationality exclusion is not set in the query result"
|
|
1850
|
+
}
|
|
1775
1851
|
};
|
|
1776
1852
|
}
|
|
1777
1853
|
for (let i = 1; i < countryList.length; i++) {
|
|
@@ -1780,49 +1856,40 @@ var ZKPassport = class {
|
|
|
1780
1856
|
"The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
|
|
1781
1857
|
);
|
|
1782
1858
|
isCorrect = false;
|
|
1783
|
-
queryResultErrors.nationality
|
|
1784
|
-
|
|
1859
|
+
queryResultErrors.nationality = {
|
|
1860
|
+
...queryResultErrors.nationality,
|
|
1861
|
+
out: {
|
|
1862
|
+
message: "The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
|
|
1863
|
+
}
|
|
1785
1864
|
};
|
|
1786
1865
|
}
|
|
1787
1866
|
}
|
|
1788
1867
|
return { isCorrect, queryResultErrors };
|
|
1789
1868
|
}
|
|
1790
1869
|
checkIssuingCountryExclusionPublicInputs(queryResult, countryList) {
|
|
1791
|
-
const queryResultErrors = {
|
|
1792
|
-
sig_check_dsc: {},
|
|
1793
|
-
sig_check_id_data: {},
|
|
1794
|
-
data_check_integrity: {},
|
|
1795
|
-
disclose: {},
|
|
1796
|
-
age: {},
|
|
1797
|
-
birthdate: {},
|
|
1798
|
-
expiry_date: {},
|
|
1799
|
-
document_type: {},
|
|
1800
|
-
issuing_country: {},
|
|
1801
|
-
gender: {},
|
|
1802
|
-
nationality: {},
|
|
1803
|
-
firstname: {},
|
|
1804
|
-
lastname: {},
|
|
1805
|
-
fullname: {},
|
|
1806
|
-
document_number: {},
|
|
1807
|
-
outer: {},
|
|
1808
|
-
bind: {}
|
|
1809
|
-
};
|
|
1870
|
+
const queryResultErrors = {};
|
|
1810
1871
|
let isCorrect = true;
|
|
1811
1872
|
if (queryResult.issuing_country && queryResult.issuing_country.out && queryResult.issuing_country.out.result) {
|
|
1812
1873
|
if (!queryResult.issuing_country.out.expected?.every((country) => countryList.includes(country))) {
|
|
1813
1874
|
console.warn("Issuing country exclusion list does not match the one from the query results");
|
|
1814
1875
|
isCorrect = false;
|
|
1815
|
-
queryResultErrors.issuing_country
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1876
|
+
queryResultErrors.issuing_country = {
|
|
1877
|
+
...queryResultErrors.issuing_country,
|
|
1878
|
+
out: {
|
|
1879
|
+
expected: queryResult.issuing_country.out.expected,
|
|
1880
|
+
received: countryList,
|
|
1881
|
+
message: "Issuing country exclusion list does not match the one from the query results"
|
|
1882
|
+
}
|
|
1819
1883
|
};
|
|
1820
1884
|
}
|
|
1821
1885
|
} else if (!queryResult.issuing_country || !queryResult.issuing_country.out) {
|
|
1822
1886
|
console.warn("Issuing country exclusion is not set in the query result");
|
|
1823
1887
|
isCorrect = false;
|
|
1824
|
-
queryResultErrors.issuing_country
|
|
1825
|
-
|
|
1888
|
+
queryResultErrors.issuing_country = {
|
|
1889
|
+
...queryResultErrors.issuing_country,
|
|
1890
|
+
out: {
|
|
1891
|
+
message: "Issuing country exclusion is not set in the query result"
|
|
1892
|
+
}
|
|
1826
1893
|
};
|
|
1827
1894
|
}
|
|
1828
1895
|
for (let i = 1; i < countryList.length; i++) {
|
|
@@ -1831,98 +1898,80 @@ var ZKPassport = class {
|
|
|
1831
1898
|
"The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
|
|
1832
1899
|
);
|
|
1833
1900
|
isCorrect = false;
|
|
1834
|
-
queryResultErrors.issuing_country
|
|
1835
|
-
|
|
1901
|
+
queryResultErrors.issuing_country = {
|
|
1902
|
+
...queryResultErrors.issuing_country,
|
|
1903
|
+
out: {
|
|
1904
|
+
message: "The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
|
|
1905
|
+
}
|
|
1836
1906
|
};
|
|
1837
1907
|
}
|
|
1838
1908
|
}
|
|
1839
1909
|
return { isCorrect, queryResultErrors };
|
|
1840
1910
|
}
|
|
1841
1911
|
checkNationalityInclusionPublicInputs(queryResult, countryList) {
|
|
1842
|
-
const queryResultErrors = {
|
|
1843
|
-
sig_check_dsc: {},
|
|
1844
|
-
sig_check_id_data: {},
|
|
1845
|
-
data_check_integrity: {},
|
|
1846
|
-
disclose: {},
|
|
1847
|
-
age: {},
|
|
1848
|
-
birthdate: {},
|
|
1849
|
-
expiry_date: {},
|
|
1850
|
-
document_type: {},
|
|
1851
|
-
issuing_country: {},
|
|
1852
|
-
gender: {},
|
|
1853
|
-
nationality: {},
|
|
1854
|
-
firstname: {},
|
|
1855
|
-
lastname: {},
|
|
1856
|
-
fullname: {},
|
|
1857
|
-
document_number: {},
|
|
1858
|
-
outer: {},
|
|
1859
|
-
bind: {}
|
|
1860
|
-
};
|
|
1912
|
+
const queryResultErrors = {};
|
|
1861
1913
|
let isCorrect = true;
|
|
1862
1914
|
if (queryResult.nationality && queryResult.nationality.in && queryResult.nationality.in.result) {
|
|
1863
1915
|
if (!queryResult.nationality.in.expected?.every((country) => countryList.includes(country))) {
|
|
1864
1916
|
console.warn("Nationality inclusion list does not match the one from the query results");
|
|
1865
1917
|
isCorrect = false;
|
|
1866
|
-
queryResultErrors.nationality
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1918
|
+
queryResultErrors.nationality = {
|
|
1919
|
+
...queryResultErrors.nationality,
|
|
1920
|
+
in: {
|
|
1921
|
+
expected: queryResult.nationality.in.expected,
|
|
1922
|
+
received: countryList,
|
|
1923
|
+
message: "Nationality inclusion list does not match the one from the query results"
|
|
1924
|
+
}
|
|
1870
1925
|
};
|
|
1871
1926
|
}
|
|
1872
1927
|
} else if (!queryResult.nationality || !queryResult.nationality.in) {
|
|
1873
1928
|
console.warn("Nationality inclusion is not set in the query result");
|
|
1874
1929
|
isCorrect = false;
|
|
1875
|
-
queryResultErrors.nationality
|
|
1876
|
-
|
|
1930
|
+
queryResultErrors.nationality = {
|
|
1931
|
+
...queryResultErrors.nationality,
|
|
1932
|
+
in: {
|
|
1933
|
+
message: "Nationality inclusion is not set in the query result"
|
|
1934
|
+
}
|
|
1877
1935
|
};
|
|
1878
1936
|
}
|
|
1879
1937
|
return { isCorrect, queryResultErrors };
|
|
1880
1938
|
}
|
|
1881
1939
|
checkIssuingCountryInclusionPublicInputs(queryResult, countryList) {
|
|
1882
|
-
const queryResultErrors = {
|
|
1883
|
-
sig_check_dsc: {},
|
|
1884
|
-
sig_check_id_data: {},
|
|
1885
|
-
data_check_integrity: {},
|
|
1886
|
-
disclose: {},
|
|
1887
|
-
age: {},
|
|
1888
|
-
birthdate: {},
|
|
1889
|
-
expiry_date: {},
|
|
1890
|
-
document_type: {},
|
|
1891
|
-
issuing_country: {},
|
|
1892
|
-
gender: {},
|
|
1893
|
-
nationality: {},
|
|
1894
|
-
firstname: {},
|
|
1895
|
-
lastname: {},
|
|
1896
|
-
fullname: {},
|
|
1897
|
-
document_number: {},
|
|
1898
|
-
outer: {},
|
|
1899
|
-
bind: {}
|
|
1900
|
-
};
|
|
1940
|
+
const queryResultErrors = {};
|
|
1901
1941
|
let isCorrect = true;
|
|
1902
1942
|
if (queryResult.issuing_country && queryResult.issuing_country.in && queryResult.issuing_country.in.result) {
|
|
1903
1943
|
if (!queryResult.issuing_country.in.expected?.every((country) => countryList.includes(country))) {
|
|
1904
1944
|
console.warn("Issuing country inclusion list does not match the one from the query results");
|
|
1905
1945
|
isCorrect = false;
|
|
1906
|
-
queryResultErrors.issuing_country
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1946
|
+
queryResultErrors.issuing_country = {
|
|
1947
|
+
...queryResultErrors.issuing_country,
|
|
1948
|
+
in: {
|
|
1949
|
+
expected: queryResult.issuing_country.in.expected,
|
|
1950
|
+
received: countryList,
|
|
1951
|
+
message: "Issuing country inclusion list does not match the one from the query results"
|
|
1952
|
+
}
|
|
1910
1953
|
};
|
|
1911
1954
|
}
|
|
1912
1955
|
} else if (!queryResult.issuing_country || !queryResult.issuing_country.in) {
|
|
1913
1956
|
console.warn("Issuing country inclusion is not set in the query result");
|
|
1914
1957
|
isCorrect = false;
|
|
1915
|
-
queryResultErrors.issuing_country
|
|
1916
|
-
|
|
1958
|
+
queryResultErrors.issuing_country = {
|
|
1959
|
+
...queryResultErrors.issuing_country,
|
|
1960
|
+
in: {
|
|
1961
|
+
message: "Issuing country inclusion is not set in the query result"
|
|
1962
|
+
}
|
|
1917
1963
|
};
|
|
1918
1964
|
}
|
|
1919
1965
|
return { isCorrect, queryResultErrors };
|
|
1920
1966
|
}
|
|
1921
|
-
checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope
|
|
1967
|
+
checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope) {
|
|
1922
1968
|
let isCorrect = true;
|
|
1923
1969
|
if (this.domain && getServiceScopeHash(this.domain) !== BigInt(proofData.publicInputs[1])) {
|
|
1924
1970
|
console.warn("The proof comes from a different domain than the one expected");
|
|
1925
1971
|
isCorrect = false;
|
|
1972
|
+
if (!queryResultErrors[key]) {
|
|
1973
|
+
queryResultErrors[key] = {};
|
|
1974
|
+
}
|
|
1926
1975
|
queryResultErrors[key].scope = {
|
|
1927
1976
|
expected: `Scope: ${getServiceScopeHash(this.domain).toString()}`,
|
|
1928
1977
|
received: `Scope: ${BigInt(proofData.publicInputs[1]).toString()}`,
|
|
@@ -1932,6 +1981,9 @@ var ZKPassport = class {
|
|
|
1932
1981
|
if (scope && getScopeHash(scope) !== BigInt(proofData.publicInputs[2])) {
|
|
1933
1982
|
console.warn("The proof uses a different scope than the one expected");
|
|
1934
1983
|
isCorrect = false;
|
|
1984
|
+
if (!queryResultErrors[key]) {
|
|
1985
|
+
queryResultErrors[key] = {};
|
|
1986
|
+
}
|
|
1935
1987
|
queryResultErrors[key].scope = {
|
|
1936
1988
|
expected: `Scope: ${getScopeHash(scope).toString()}`,
|
|
1937
1989
|
received: `Scope: ${BigInt(proofData.publicInputs[2]).toString()}`,
|
|
@@ -1948,6 +2000,9 @@ var ZKPassport = class {
|
|
|
1948
2000
|
if (!isValid) {
|
|
1949
2001
|
console.warn("The ID was signed by an unrecognized root certificate");
|
|
1950
2002
|
isCorrect = false;
|
|
2003
|
+
if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
|
|
2004
|
+
queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
|
|
2005
|
+
}
|
|
1951
2006
|
queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
|
|
1952
2007
|
expected: `A valid root from ZKPassport Registry`,
|
|
1953
2008
|
received: `Got invalid certificate registry root: ${root}`,
|
|
@@ -1958,6 +2013,9 @@ var ZKPassport = class {
|
|
|
1958
2013
|
console.warn(error);
|
|
1959
2014
|
console.warn("The ID was signed by an unrecognized root certificate");
|
|
1960
2015
|
isCorrect = false;
|
|
2016
|
+
if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
|
|
2017
|
+
queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
|
|
2018
|
+
}
|
|
1961
2019
|
queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
|
|
1962
2020
|
expected: `A valid root from ZKPassport Registry`,
|
|
1963
2021
|
received: `Got invalid certificate registry root: ${root}`,
|
|
@@ -1993,52 +2051,63 @@ var ZKPassport = class {
|
|
|
1993
2051
|
return { isCorrect, queryResultErrors };
|
|
1994
2052
|
}
|
|
1995
2053
|
checkBindPublicInputs(queryResult, boundData) {
|
|
1996
|
-
const queryResultErrors = {
|
|
1997
|
-
sig_check_dsc: {},
|
|
1998
|
-
sig_check_id_data: {},
|
|
1999
|
-
data_check_integrity: {},
|
|
2000
|
-
disclose: {},
|
|
2001
|
-
age: {},
|
|
2002
|
-
birthdate: {},
|
|
2003
|
-
expiry_date: {},
|
|
2004
|
-
document_type: {},
|
|
2005
|
-
issuing_country: {},
|
|
2006
|
-
gender: {},
|
|
2007
|
-
nationality: {},
|
|
2008
|
-
firstname: {},
|
|
2009
|
-
lastname: {},
|
|
2010
|
-
fullname: {},
|
|
2011
|
-
document_number: {},
|
|
2012
|
-
outer: {},
|
|
2013
|
-
bind: {}
|
|
2014
|
-
};
|
|
2054
|
+
const queryResultErrors = {};
|
|
2015
2055
|
let isCorrect = true;
|
|
2016
2056
|
if (queryResult.bind) {
|
|
2017
2057
|
if (queryResult.bind.user_address?.toLowerCase().replace("0x", "") !== boundData.user_address?.toLowerCase().replace("0x", "")) {
|
|
2018
2058
|
console.warn("Bound user address does not match the one from the query results");
|
|
2019
2059
|
isCorrect = false;
|
|
2020
|
-
queryResultErrors.bind
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2060
|
+
queryResultErrors.bind = {
|
|
2061
|
+
...queryResultErrors.bind,
|
|
2062
|
+
eq: {
|
|
2063
|
+
expected: queryResult.bind.user_address,
|
|
2064
|
+
received: boundData.user_address,
|
|
2065
|
+
message: "Bound user address does not match the one from the query results"
|
|
2066
|
+
}
|
|
2024
2067
|
};
|
|
2025
2068
|
}
|
|
2026
2069
|
if (queryResult.bind.chain !== boundData.chain) {
|
|
2027
2070
|
console.warn("Bound chain id does not match the one from the query results");
|
|
2028
2071
|
isCorrect = false;
|
|
2029
|
-
queryResultErrors.bind
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2072
|
+
queryResultErrors.bind = {
|
|
2073
|
+
...queryResultErrors.bind,
|
|
2074
|
+
eq: {
|
|
2075
|
+
expected: queryResult.bind.chain,
|
|
2076
|
+
received: boundData.chain,
|
|
2077
|
+
message: "Bound chain id does not match the one from the query results"
|
|
2078
|
+
}
|
|
2033
2079
|
};
|
|
2034
2080
|
}
|
|
2035
2081
|
if (queryResult.bind.custom_data?.trim().toLowerCase() !== boundData.custom_data?.trim().toLowerCase()) {
|
|
2036
2082
|
console.warn("Bound custom data does not match the one from the query results");
|
|
2037
2083
|
isCorrect = false;
|
|
2038
|
-
queryResultErrors.bind
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2084
|
+
queryResultErrors.bind = {
|
|
2085
|
+
...queryResultErrors.bind,
|
|
2086
|
+
eq: {
|
|
2087
|
+
expected: queryResult.bind.custom_data,
|
|
2088
|
+
received: boundData.custom_data,
|
|
2089
|
+
message: "Bound custom data does not match the one from the query results"
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
return { isCorrect, queryResultErrors };
|
|
2095
|
+
}
|
|
2096
|
+
async checkSanctionsExclusionPublicInputs(queryResult, root, sanctionsBuilder) {
|
|
2097
|
+
const queryResultErrors = {};
|
|
2098
|
+
let isCorrect = true;
|
|
2099
|
+
if (queryResult.sanctions && queryResult.sanctions.passed) {
|
|
2100
|
+
const EXPECTED_ROOT = await sanctionsBuilder.getRoot();
|
|
2101
|
+
if (root !== BigInt(EXPECTED_ROOT)) {
|
|
2102
|
+
console.warn("Invalid sanctions registry root");
|
|
2103
|
+
isCorrect = false;
|
|
2104
|
+
queryResultErrors.sanctions = {
|
|
2105
|
+
...queryResultErrors.sanctions,
|
|
2106
|
+
eq: {
|
|
2107
|
+
expected: EXPECTED_ROOT,
|
|
2108
|
+
received: root.toString(16),
|
|
2109
|
+
message: "Invalid sanctions registry root"
|
|
2110
|
+
}
|
|
2042
2111
|
};
|
|
2043
2112
|
}
|
|
2044
2113
|
}
|
|
@@ -2059,25 +2128,7 @@ var ZKPassport = class {
|
|
|
2059
2128
|
0,
|
|
2060
2129
|
0
|
|
2061
2130
|
);
|
|
2062
|
-
let queryResultErrors = {
|
|
2063
|
-
sig_check_dsc: {},
|
|
2064
|
-
sig_check_id_data: {},
|
|
2065
|
-
data_check_integrity: {},
|
|
2066
|
-
disclose: {},
|
|
2067
|
-
age: {},
|
|
2068
|
-
birthdate: {},
|
|
2069
|
-
expiry_date: {},
|
|
2070
|
-
document_type: {},
|
|
2071
|
-
issuing_country: {},
|
|
2072
|
-
gender: {},
|
|
2073
|
-
nationality: {},
|
|
2074
|
-
firstname: {},
|
|
2075
|
-
lastname: {},
|
|
2076
|
-
fullname: {},
|
|
2077
|
-
document_number: {},
|
|
2078
|
-
outer: {},
|
|
2079
|
-
bind: {}
|
|
2080
|
-
};
|
|
2131
|
+
let queryResultErrors = {};
|
|
2081
2132
|
const sortedProofs = proofs.sort((a, b) => {
|
|
2082
2133
|
const proofOrder = [
|
|
2083
2134
|
"sig_check_dsc",
|
|
@@ -2091,7 +2142,8 @@ var ZKPassport = class {
|
|
|
2091
2142
|
"inclusion_check_nationality",
|
|
2092
2143
|
"exclusion_check_issuing_country",
|
|
2093
2144
|
"inclusion_check_issuing_country",
|
|
2094
|
-
"bind"
|
|
2145
|
+
"bind",
|
|
2146
|
+
"exclusion_check_sanctions"
|
|
2095
2147
|
];
|
|
2096
2148
|
const getIndex = (proof) => {
|
|
2097
2149
|
const name = proof.name || "";
|
|
@@ -2129,18 +2181,20 @@ var ZKPassport = class {
|
|
|
2129
2181
|
};
|
|
2130
2182
|
const currentDate = getCurrentDateFromOuterProof(proofData);
|
|
2131
2183
|
const todayToCurrentDate = today.getTime() - currentDate.getTime();
|
|
2132
|
-
const
|
|
2133
|
-
const expectedDifference = differenceInDays * 864e5;
|
|
2184
|
+
const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
|
|
2134
2185
|
const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
|
|
2135
2186
|
if (todayToCurrentDate >= actualDifference) {
|
|
2136
2187
|
console.warn(
|
|
2137
|
-
`The date used to check the validity of the ID is older than
|
|
2188
|
+
`The date used to check the validity of the ID is older than the validity period`
|
|
2138
2189
|
);
|
|
2139
2190
|
isCorrect = false;
|
|
2140
|
-
queryResultErrors.outer
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2191
|
+
queryResultErrors.outer = {
|
|
2192
|
+
...queryResultErrors.outer,
|
|
2193
|
+
date: {
|
|
2194
|
+
expected: `Difference: ${validity} seconds`,
|
|
2195
|
+
received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
|
|
2196
|
+
message: "The date used to check the validity of the ID is older than the validity period"
|
|
2197
|
+
}
|
|
2144
2198
|
};
|
|
2145
2199
|
}
|
|
2146
2200
|
const paramCommitments = getParamCommitmentsFromOuterProof(proofData);
|
|
@@ -2149,48 +2203,60 @@ var ZKPassport = class {
|
|
|
2149
2203
|
if (keysInCommittedInputs.length !== paramCommitments.length) {
|
|
2150
2204
|
console.warn("The proof does not verify all the requested conditions and information");
|
|
2151
2205
|
isCorrect = false;
|
|
2152
|
-
queryResultErrors.outer
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2206
|
+
queryResultErrors.outer = {
|
|
2207
|
+
...queryResultErrors.outer,
|
|
2208
|
+
commitment: {
|
|
2209
|
+
expected: `Number of parameter commitments: ${paramCommitments.length}`,
|
|
2210
|
+
received: `Number of disclosure proofs provided: ${keysInCommittedInputs.length}`,
|
|
2211
|
+
message: "The proof does not verify all the requested conditions and information"
|
|
2212
|
+
}
|
|
2156
2213
|
};
|
|
2157
2214
|
}
|
|
2158
2215
|
if (this.domain && getServiceScopeHash(this.domain) !== getScopeFromOuterProof(proofData)) {
|
|
2159
2216
|
console.warn("The proof comes from a different domain than the one expected");
|
|
2160
2217
|
isCorrect = false;
|
|
2161
|
-
queryResultErrors.outer
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2218
|
+
queryResultErrors.outer = {
|
|
2219
|
+
...queryResultErrors.outer,
|
|
2220
|
+
scope: {
|
|
2221
|
+
expected: `Scope: ${getServiceScopeHash(this.domain).toString()}`,
|
|
2222
|
+
received: `Scope: ${getScopeFromOuterProof(proofData).toString()}`,
|
|
2223
|
+
message: "The proof comes from a different domain than the one expected"
|
|
2224
|
+
}
|
|
2165
2225
|
};
|
|
2166
2226
|
}
|
|
2167
2227
|
if (scope && getScopeHash(scope) !== getSubscopeFromOuterProof(proofData)) {
|
|
2168
2228
|
console.warn("The proof uses a different scope than the one expected");
|
|
2169
2229
|
isCorrect = false;
|
|
2170
|
-
queryResultErrors.outer
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2230
|
+
queryResultErrors.outer = {
|
|
2231
|
+
...queryResultErrors.outer,
|
|
2232
|
+
scope: {
|
|
2233
|
+
expected: `Scope: ${getScopeHash(scope).toString()}`,
|
|
2234
|
+
received: `Scope: ${getSubscopeFromOuterProof(proofData).toString()}`,
|
|
2235
|
+
message: "The proof uses a different scope than the one expected"
|
|
2236
|
+
}
|
|
2174
2237
|
};
|
|
2175
2238
|
}
|
|
2176
2239
|
if (!!committedInputs?.compare_age) {
|
|
2177
2240
|
const ageCommittedInputs = committedInputs?.compare_age;
|
|
2178
2241
|
const ageParameterCommitment = isForEVM ? await getAgeEVMParameterCommitment(
|
|
2179
|
-
ageCommittedInputs.
|
|
2242
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2180
2243
|
ageCommittedInputs.minAge,
|
|
2181
2244
|
ageCommittedInputs.maxAge
|
|
2182
2245
|
) : await getAgeParameterCommitment(
|
|
2183
|
-
ageCommittedInputs.
|
|
2246
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2184
2247
|
ageCommittedInputs.minAge,
|
|
2185
2248
|
ageCommittedInputs.maxAge
|
|
2186
2249
|
);
|
|
2187
2250
|
if (!paramCommitments.includes(ageParameterCommitment)) {
|
|
2188
2251
|
console.warn("This proof does not verify the age");
|
|
2189
2252
|
isCorrect = false;
|
|
2190
|
-
queryResultErrors.age
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2253
|
+
queryResultErrors.age = {
|
|
2254
|
+
...queryResultErrors.age,
|
|
2255
|
+
commitment: {
|
|
2256
|
+
expected: `Age parameter commitment: ${ageParameterCommitment.toString()}`,
|
|
2257
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2258
|
+
message: "This proof does not verify the age"
|
|
2259
|
+
}
|
|
2194
2260
|
};
|
|
2195
2261
|
}
|
|
2196
2262
|
const { isCorrect: isCorrectAge, queryResultErrors: queryResultErrorsAge } = this.checkAgePublicInputs(proof, queryResult);
|
|
@@ -2203,22 +2269,25 @@ var ZKPassport = class {
|
|
|
2203
2269
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate;
|
|
2204
2270
|
const birthdateParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2205
2271
|
ProofType.BIRTHDATE,
|
|
2206
|
-
birthdateCommittedInputs.
|
|
2207
|
-
birthdateCommittedInputs.
|
|
2208
|
-
birthdateCommittedInputs.
|
|
2272
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2273
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2274
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2209
2275
|
) : await getDateParameterCommitment(
|
|
2210
2276
|
ProofType.BIRTHDATE,
|
|
2211
|
-
birthdateCommittedInputs.
|
|
2212
|
-
birthdateCommittedInputs.
|
|
2213
|
-
birthdateCommittedInputs.
|
|
2277
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2278
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2279
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2214
2280
|
);
|
|
2215
2281
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
2216
2282
|
console.warn("This proof does not verify the birthdate");
|
|
2217
2283
|
isCorrect = false;
|
|
2218
|
-
queryResultErrors.birthdate
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2284
|
+
queryResultErrors.birthdate = {
|
|
2285
|
+
...queryResultErrors.birthdate,
|
|
2286
|
+
commitment: {
|
|
2287
|
+
expected: `Birthdate parameter commitment: ${birthdateParameterCommitment.toString()}`,
|
|
2288
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2289
|
+
message: "This proof does not verify the birthdate"
|
|
2290
|
+
}
|
|
2222
2291
|
};
|
|
2223
2292
|
}
|
|
2224
2293
|
const { isCorrect: isCorrectBirthdate, queryResultErrors: queryResultErrorsBirthdate } = this.checkBirthdatePublicInputs(proof, queryResult);
|
|
@@ -2231,22 +2300,25 @@ var ZKPassport = class {
|
|
|
2231
2300
|
const expiryCommittedInputs = committedInputs?.compare_expiry;
|
|
2232
2301
|
const expiryParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2233
2302
|
ProofType.EXPIRY_DATE,
|
|
2234
|
-
expiryCommittedInputs.
|
|
2235
|
-
expiryCommittedInputs.
|
|
2236
|
-
expiryCommittedInputs.
|
|
2303
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2304
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2305
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2237
2306
|
) : await getDateParameterCommitment(
|
|
2238
2307
|
ProofType.EXPIRY_DATE,
|
|
2239
|
-
expiryCommittedInputs.
|
|
2240
|
-
expiryCommittedInputs.
|
|
2241
|
-
expiryCommittedInputs.
|
|
2308
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2309
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2310
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2242
2311
|
);
|
|
2243
2312
|
if (!paramCommitments.includes(expiryParameterCommitment)) {
|
|
2244
2313
|
console.warn("This proof does not verify the expiry date");
|
|
2245
2314
|
isCorrect = false;
|
|
2246
|
-
queryResultErrors.expiry_date
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2315
|
+
queryResultErrors.expiry_date = {
|
|
2316
|
+
...queryResultErrors.expiry_date,
|
|
2317
|
+
commitment: {
|
|
2318
|
+
expected: `Expiry date parameter commitment: ${expiryParameterCommitment.toString()}`,
|
|
2319
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2320
|
+
message: "This proof does not verify the expiry date"
|
|
2321
|
+
}
|
|
2250
2322
|
};
|
|
2251
2323
|
}
|
|
2252
2324
|
const { isCorrect: isCorrectExpiryDate, queryResultErrors: queryResultErrorsExpiryDate } = this.checkExpiryDatePublicInputs(proof, queryResult);
|
|
@@ -2267,10 +2339,13 @@ var ZKPassport = class {
|
|
|
2267
2339
|
if (!paramCommitments.includes(discloseParameterCommitment)) {
|
|
2268
2340
|
console.warn("This proof does not verify any of the data disclosed");
|
|
2269
2341
|
isCorrect = false;
|
|
2270
|
-
queryResultErrors.disclose
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2342
|
+
queryResultErrors.disclose = {
|
|
2343
|
+
...queryResultErrors.disclose,
|
|
2344
|
+
commitment: {
|
|
2345
|
+
expected: `Disclosure parameter commitment: ${discloseParameterCommitment.toString()}`,
|
|
2346
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2347
|
+
message: "This proof does not verify any of the data disclosed"
|
|
2348
|
+
}
|
|
2274
2349
|
};
|
|
2275
2350
|
}
|
|
2276
2351
|
const { isCorrect: isCorrectDisclose, queryResultErrors: queryResultErrorsDisclose } = this.checkDiscloseBytesPublicInputs(proof, queryResult);
|
|
@@ -2291,10 +2366,13 @@ var ZKPassport = class {
|
|
|
2291
2366
|
if (!paramCommitments.includes(inclusionCheckNationalityParameterCommitment)) {
|
|
2292
2367
|
console.warn("This proof does not verify the inclusion of the nationality");
|
|
2293
2368
|
isCorrect = false;
|
|
2294
|
-
queryResultErrors.nationality
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2369
|
+
queryResultErrors.nationality = {
|
|
2370
|
+
...queryResultErrors.nationality,
|
|
2371
|
+
commitment: {
|
|
2372
|
+
expected: `Nationality parameter commitment: ${inclusionCheckNationalityParameterCommitment.toString()}`,
|
|
2373
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2374
|
+
message: "This proof does not verify the inclusion of the nationality"
|
|
2375
|
+
}
|
|
2298
2376
|
};
|
|
2299
2377
|
}
|
|
2300
2378
|
const countryList = inclusionCheckNationalityCommittedInputs.countries;
|
|
@@ -2319,10 +2397,13 @@ var ZKPassport = class {
|
|
|
2319
2397
|
if (!paramCommitments.includes(inclusionCheckIssuingCountryParameterCommitment)) {
|
|
2320
2398
|
console.warn("This proof does not verify the inclusion of the issuing country");
|
|
2321
2399
|
isCorrect = false;
|
|
2322
|
-
queryResultErrors.issuing_country
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2400
|
+
queryResultErrors.issuing_country = {
|
|
2401
|
+
...queryResultErrors.issuing_country,
|
|
2402
|
+
commitment: {
|
|
2403
|
+
expected: `Issuing country parameter commitment: ${inclusionCheckIssuingCountryParameterCommitment.toString()}`,
|
|
2404
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2405
|
+
message: "This proof does not verify the inclusion of the issuing country"
|
|
2406
|
+
}
|
|
2326
2407
|
};
|
|
2327
2408
|
}
|
|
2328
2409
|
const countryList = inclusionCheckIssuingCountryCommittedInputs.countries;
|
|
@@ -2347,10 +2428,13 @@ var ZKPassport = class {
|
|
|
2347
2428
|
if (!paramCommitments.includes(exclusionCheckNationalityParameterCommitment)) {
|
|
2348
2429
|
console.warn("This proof does not verify the exclusion of the nationality");
|
|
2349
2430
|
isCorrect = false;
|
|
2350
|
-
queryResultErrors.nationality
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2431
|
+
queryResultErrors.nationality = {
|
|
2432
|
+
...queryResultErrors.nationality,
|
|
2433
|
+
commitment: {
|
|
2434
|
+
expected: `Nationality parameter commitment: ${exclusionCheckNationalityParameterCommitment.toString()}`,
|
|
2435
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2436
|
+
message: "This proof does not verify the exclusion of the nationality"
|
|
2437
|
+
}
|
|
2354
2438
|
};
|
|
2355
2439
|
}
|
|
2356
2440
|
const countryList = exclusionCheckNationalityCommittedInputs.countries;
|
|
@@ -2375,10 +2459,13 @@ var ZKPassport = class {
|
|
|
2375
2459
|
if (!paramCommitments.includes(exclusionCheckIssuingCountryParameterCommitment)) {
|
|
2376
2460
|
console.warn("This proof does not verify the exclusion of the issuing country");
|
|
2377
2461
|
isCorrect = false;
|
|
2378
|
-
queryResultErrors.issuing_country
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2462
|
+
queryResultErrors.issuing_country = {
|
|
2463
|
+
...queryResultErrors.issuing_country,
|
|
2464
|
+
commitment: {
|
|
2465
|
+
expected: `Issuing country parameter commitment: ${exclusionCheckIssuingCountryParameterCommitment.toString()}`,
|
|
2466
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2467
|
+
message: "This proof does not verify the exclusion of the issuing country"
|
|
2468
|
+
}
|
|
2382
2469
|
};
|
|
2383
2470
|
}
|
|
2384
2471
|
const countryList = exclusionCheckIssuingCountryCommittedInputs.countries;
|
|
@@ -2397,10 +2484,13 @@ var ZKPassport = class {
|
|
|
2397
2484
|
if (!paramCommitments.includes(bindParameterCommitment)) {
|
|
2398
2485
|
console.warn("This proof does not verify the bound data");
|
|
2399
2486
|
isCorrect = false;
|
|
2400
|
-
queryResultErrors.bind
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2487
|
+
queryResultErrors.bind = {
|
|
2488
|
+
...queryResultErrors.bind,
|
|
2489
|
+
commitment: {
|
|
2490
|
+
expected: `Bind parameter commitment: ${bindParameterCommitment.toString()}`,
|
|
2491
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2492
|
+
message: "This proof does not verify the bound data"
|
|
2493
|
+
}
|
|
2404
2494
|
};
|
|
2405
2495
|
}
|
|
2406
2496
|
const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
|
|
@@ -2409,6 +2499,35 @@ var ZKPassport = class {
|
|
|
2409
2499
|
...queryResultErrors,
|
|
2410
2500
|
...queryResultErrorsBind
|
|
2411
2501
|
};
|
|
2502
|
+
} else if (!!committedInputs?.exclusion_check_sanctions) {
|
|
2503
|
+
const sanctionsBuilder = await SanctionsBuilder.create();
|
|
2504
|
+
const exclusionCheckSanctionsCommittedInputs = committedInputs?.exclusion_check_sanctions;
|
|
2505
|
+
const exclusionCheckSanctionsParameterCommitment = isForEVM ? await sanctionsBuilder.getSanctionsEvmParameterCommitment() : await sanctionsBuilder.getSanctionsParameterCommitment();
|
|
2506
|
+
if (!paramCommitments.includes(exclusionCheckSanctionsParameterCommitment)) {
|
|
2507
|
+
console.warn("This proof does not verify the exclusion from the sanction lists");
|
|
2508
|
+
isCorrect = false;
|
|
2509
|
+
queryResultErrors.sanctions = {
|
|
2510
|
+
...queryResultErrors.sanctions,
|
|
2511
|
+
commitment: {
|
|
2512
|
+
expected: `Sanctions parameter commitment: ${exclusionCheckSanctionsParameterCommitment.toString()}`,
|
|
2513
|
+
received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
|
|
2514
|
+
message: "This proof does not verify the exclusion from the sanction lists"
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
const {
|
|
2519
|
+
isCorrect: isCorrectSanctionsExclusion,
|
|
2520
|
+
queryResultErrors: queryResultErrorsSanctionsExclusion
|
|
2521
|
+
} = await this.checkSanctionsExclusionPublicInputs(
|
|
2522
|
+
queryResult,
|
|
2523
|
+
BigInt(exclusionCheckSanctionsCommittedInputs.rootHash),
|
|
2524
|
+
sanctionsBuilder
|
|
2525
|
+
);
|
|
2526
|
+
isCorrect = isCorrect && isCorrectSanctionsExclusion;
|
|
2527
|
+
queryResultErrors = {
|
|
2528
|
+
...queryResultErrors,
|
|
2529
|
+
...queryResultErrorsSanctionsExclusion
|
|
2530
|
+
};
|
|
2412
2531
|
}
|
|
2413
2532
|
uniqueIdentifier = getNullifierFromOuterProof(proofData).toString(10);
|
|
2414
2533
|
} else if (proof.name?.startsWith("sig_check_dsc")) {
|
|
@@ -2434,10 +2553,13 @@ var ZKPassport = class {
|
|
|
2434
2553
|
"Failed to check the link between the certificate signature and ID signature"
|
|
2435
2554
|
);
|
|
2436
2555
|
isCorrect = false;
|
|
2437
|
-
queryResultErrors.sig_check_id_data
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2556
|
+
queryResultErrors.sig_check_id_data = {
|
|
2557
|
+
...queryResultErrors.sig_check_id_data,
|
|
2558
|
+
commitment: {
|
|
2559
|
+
expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
|
|
2560
|
+
received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
|
|
2561
|
+
message: "Failed to check the link between the certificate signature and ID signature"
|
|
2562
|
+
}
|
|
2441
2563
|
};
|
|
2442
2564
|
}
|
|
2443
2565
|
commitmentOut = getCommitmentOutFromIDDataProof(proofData);
|
|
@@ -2446,27 +2568,32 @@ var ZKPassport = class {
|
|
|
2446
2568
|
if (commitmentIn !== commitmentOut) {
|
|
2447
2569
|
console.warn("Failed to check the link between the ID signature and the data signed");
|
|
2448
2570
|
isCorrect = false;
|
|
2449
|
-
queryResultErrors.data_check_integrity
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2571
|
+
queryResultErrors.data_check_integrity = {
|
|
2572
|
+
...queryResultErrors.data_check_integrity,
|
|
2573
|
+
commitment: {
|
|
2574
|
+
expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
|
|
2575
|
+
received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
|
|
2576
|
+
message: "Failed to check the link between the ID signature and the data signed"
|
|
2577
|
+
}
|
|
2453
2578
|
};
|
|
2454
2579
|
}
|
|
2455
2580
|
commitmentOut = getCommitmentOutFromIntegrityProof(proofData);
|
|
2456
2581
|
const currentDate = getCurrentDateFromIntegrityProof(proofData);
|
|
2457
2582
|
const todayToCurrentDate = today.getTime() - currentDate.getTime();
|
|
2458
|
-
const
|
|
2459
|
-
const expectedDifference = differenceInDays * 864e5;
|
|
2583
|
+
const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
|
|
2460
2584
|
const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
|
|
2461
2585
|
if (todayToCurrentDate >= actualDifference) {
|
|
2462
2586
|
console.warn(
|
|
2463
|
-
`The date used to check the validity of the ID is older than
|
|
2587
|
+
`The date used to check the validity of the ID is older than the validity period`
|
|
2464
2588
|
);
|
|
2465
2589
|
isCorrect = false;
|
|
2466
|
-
queryResultErrors.data_check_integrity
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2590
|
+
queryResultErrors.data_check_integrity = {
|
|
2591
|
+
...queryResultErrors.data_check_integrity,
|
|
2592
|
+
date: {
|
|
2593
|
+
expected: `Difference: ${validity} seconds`,
|
|
2594
|
+
received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
|
|
2595
|
+
message: "The date used to check the validity of the ID is older than the validity period"
|
|
2596
|
+
}
|
|
2470
2597
|
};
|
|
2471
2598
|
}
|
|
2472
2599
|
} else if (proof.name === "disclose_bytes") {
|
|
@@ -2476,10 +2603,13 @@ var ZKPassport = class {
|
|
|
2476
2603
|
"Failed to check the link between the validity of the ID and the data to disclose"
|
|
2477
2604
|
);
|
|
2478
2605
|
isCorrect = false;
|
|
2479
|
-
queryResultErrors.disclose
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2606
|
+
queryResultErrors.disclose = {
|
|
2607
|
+
...queryResultErrors.disclose,
|
|
2608
|
+
commitment: {
|
|
2609
|
+
expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
|
|
2610
|
+
received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
|
|
2611
|
+
message: "Failed to check the link between the validity of the ID and the data to disclose"
|
|
2612
|
+
}
|
|
2483
2613
|
};
|
|
2484
2614
|
}
|
|
2485
2615
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
@@ -2490,10 +2620,13 @@ var ZKPassport = class {
|
|
|
2490
2620
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2491
2621
|
console.warn("The disclosed data does not match the data committed by the proof");
|
|
2492
2622
|
isCorrect = false;
|
|
2493
|
-
queryResultErrors.disclose
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2623
|
+
queryResultErrors.disclose = {
|
|
2624
|
+
...queryResultErrors.disclose,
|
|
2625
|
+
commitment: {
|
|
2626
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2627
|
+
received: `Commitment: ${paramCommitment}`,
|
|
2628
|
+
message: "The disclosed data does not match the data committed by the proof"
|
|
2629
|
+
}
|
|
2497
2630
|
};
|
|
2498
2631
|
}
|
|
2499
2632
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "disclose", scope);
|
|
@@ -2517,16 +2650,19 @@ var ZKPassport = class {
|
|
|
2517
2650
|
"Failed to check the link between the validity of the ID and the age derived from it"
|
|
2518
2651
|
);
|
|
2519
2652
|
isCorrect = false;
|
|
2520
|
-
queryResultErrors.age
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2653
|
+
queryResultErrors.age = {
|
|
2654
|
+
...queryResultErrors.age,
|
|
2655
|
+
commitment: {
|
|
2656
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2657
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2658
|
+
message: "Failed to check the link between the validity of the ID and the age derived from it"
|
|
2659
|
+
}
|
|
2524
2660
|
};
|
|
2525
2661
|
}
|
|
2526
2662
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2527
2663
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
2528
2664
|
const calculatedParamCommitment = await getAgeParameterCommitment(
|
|
2529
|
-
committedInputs.
|
|
2665
|
+
committedInputs.currentDateTimestamp,
|
|
2530
2666
|
committedInputs.minAge,
|
|
2531
2667
|
committedInputs.maxAge
|
|
2532
2668
|
);
|
|
@@ -2535,10 +2671,13 @@ var ZKPassport = class {
|
|
|
2535
2671
|
"The conditions for the age check do not match the conditions checked by the proof"
|
|
2536
2672
|
);
|
|
2537
2673
|
isCorrect = false;
|
|
2538
|
-
queryResultErrors.age
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2674
|
+
queryResultErrors.age = {
|
|
2675
|
+
...queryResultErrors.age,
|
|
2676
|
+
commitment: {
|
|
2677
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2678
|
+
received: `Commitment: ${paramCommitment}`,
|
|
2679
|
+
message: "The conditions for the age check do not match the conditions checked by the proof"
|
|
2680
|
+
}
|
|
2542
2681
|
};
|
|
2543
2682
|
}
|
|
2544
2683
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "age", scope);
|
|
@@ -2557,29 +2696,35 @@ var ZKPassport = class {
|
|
|
2557
2696
|
"Failed to check the link between the validity of the ID and the birthdate derived from it"
|
|
2558
2697
|
);
|
|
2559
2698
|
isCorrect = false;
|
|
2560
|
-
queryResultErrors.birthdate
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2699
|
+
queryResultErrors.birthdate = {
|
|
2700
|
+
...queryResultErrors.birthdate,
|
|
2701
|
+
commitment: {
|
|
2702
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2703
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2704
|
+
message: "Failed to check the link between the validity of the ID and the birthdate derived from it"
|
|
2705
|
+
}
|
|
2564
2706
|
};
|
|
2565
2707
|
}
|
|
2566
2708
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2567
2709
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
2568
2710
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2569
2711
|
ProofType.BIRTHDATE,
|
|
2570
|
-
committedInputs.
|
|
2571
|
-
committedInputs.
|
|
2572
|
-
committedInputs.
|
|
2712
|
+
committedInputs.currentDateTimestamp,
|
|
2713
|
+
committedInputs.minDateTimestamp,
|
|
2714
|
+
committedInputs.maxDateTimestamp
|
|
2573
2715
|
);
|
|
2574
2716
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2575
2717
|
console.warn(
|
|
2576
2718
|
"The conditions for the birthdate check do not match the conditions checked by the proof"
|
|
2577
2719
|
);
|
|
2578
2720
|
isCorrect = false;
|
|
2579
|
-
queryResultErrors.birthdate
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2721
|
+
queryResultErrors.birthdate = {
|
|
2722
|
+
...queryResultErrors.birthdate,
|
|
2723
|
+
commitment: {
|
|
2724
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2725
|
+
received: `Commitment: ${paramCommitment}`,
|
|
2726
|
+
message: "The conditions for the birthdate check do not match the conditions checked by the proof"
|
|
2727
|
+
}
|
|
2583
2728
|
};
|
|
2584
2729
|
}
|
|
2585
2730
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "birthdate", scope);
|
|
@@ -2598,29 +2743,35 @@ var ZKPassport = class {
|
|
|
2598
2743
|
"Failed to check the link between the validity of the ID and its expiry date"
|
|
2599
2744
|
);
|
|
2600
2745
|
isCorrect = false;
|
|
2601
|
-
queryResultErrors.expiry_date
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2746
|
+
queryResultErrors.expiry_date = {
|
|
2747
|
+
...queryResultErrors.expiry_date,
|
|
2748
|
+
commitment: {
|
|
2749
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2750
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2751
|
+
message: "Failed to check the link between the validity of the ID and its expiry date"
|
|
2752
|
+
}
|
|
2605
2753
|
};
|
|
2606
2754
|
}
|
|
2607
2755
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2608
2756
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
2609
2757
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2610
2758
|
ProofType.EXPIRY_DATE,
|
|
2611
|
-
committedInputs.
|
|
2612
|
-
committedInputs.
|
|
2613
|
-
committedInputs.
|
|
2759
|
+
committedInputs.currentDateTimestamp,
|
|
2760
|
+
committedInputs.minDateTimestamp,
|
|
2761
|
+
committedInputs.maxDateTimestamp
|
|
2614
2762
|
);
|
|
2615
2763
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2616
2764
|
console.warn(
|
|
2617
2765
|
"The conditions for the expiry date check do not match the conditions checked by the proof"
|
|
2618
2766
|
);
|
|
2619
2767
|
isCorrect = false;
|
|
2620
|
-
queryResultErrors.expiry_date
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2768
|
+
queryResultErrors.expiry_date = {
|
|
2769
|
+
...queryResultErrors.expiry_date,
|
|
2770
|
+
commitment: {
|
|
2771
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2772
|
+
received: `Commitment: ${paramCommitment}`,
|
|
2773
|
+
message: "The conditions for the expiry date check do not match the conditions checked by the proof"
|
|
2774
|
+
}
|
|
2624
2775
|
};
|
|
2625
2776
|
}
|
|
2626
2777
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "expiry_date", scope);
|
|
@@ -2639,10 +2790,13 @@ var ZKPassport = class {
|
|
|
2639
2790
|
"Failed to check the link between the validity of the ID and the nationality exclusion check"
|
|
2640
2791
|
);
|
|
2641
2792
|
isCorrect = false;
|
|
2642
|
-
queryResultErrors.nationality
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2793
|
+
queryResultErrors.nationality = {
|
|
2794
|
+
...queryResultErrors.nationality,
|
|
2795
|
+
commitment: {
|
|
2796
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2797
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2798
|
+
message: "Failed to check the link between the validity of the ID and the nationality exclusion check"
|
|
2799
|
+
}
|
|
2646
2800
|
};
|
|
2647
2801
|
}
|
|
2648
2802
|
const countryList = (proof.committedInputs?.exclusion_check_nationality).countries;
|
|
@@ -2657,10 +2811,13 @@ var ZKPassport = class {
|
|
|
2657
2811
|
"The committed country list for the exclusion check does not match the one from the proof"
|
|
2658
2812
|
);
|
|
2659
2813
|
isCorrect = false;
|
|
2660
|
-
queryResultErrors.nationality
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2814
|
+
queryResultErrors.nationality = {
|
|
2815
|
+
...queryResultErrors.nationality,
|
|
2816
|
+
commitment: {
|
|
2817
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2818
|
+
received: `Commitment: ${paramCommittment}`,
|
|
2819
|
+
message: "The committed country list for the exclusion check does not match the one from the proof"
|
|
2820
|
+
}
|
|
2664
2821
|
};
|
|
2665
2822
|
}
|
|
2666
2823
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
|
|
@@ -2682,10 +2839,13 @@ var ZKPassport = class {
|
|
|
2682
2839
|
"Failed to check the link between the validity of the ID and the issuing country exclusion check"
|
|
2683
2840
|
);
|
|
2684
2841
|
isCorrect = false;
|
|
2685
|
-
queryResultErrors.nationality
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2842
|
+
queryResultErrors.nationality = {
|
|
2843
|
+
...queryResultErrors.nationality,
|
|
2844
|
+
commitment: {
|
|
2845
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2846
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2847
|
+
message: "Failed to check the link between the validity of the ID and the issuing country exclusion check"
|
|
2848
|
+
}
|
|
2689
2849
|
};
|
|
2690
2850
|
}
|
|
2691
2851
|
const countryList = (proof.committedInputs?.exclusion_check_issuing_country).countries;
|
|
@@ -2700,10 +2860,13 @@ var ZKPassport = class {
|
|
|
2700
2860
|
"The committed country list for the issuing country exclusion check does not match the one from the proof"
|
|
2701
2861
|
);
|
|
2702
2862
|
isCorrect = false;
|
|
2703
|
-
queryResultErrors.issuing_country
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2863
|
+
queryResultErrors.issuing_country = {
|
|
2864
|
+
...queryResultErrors.issuing_country,
|
|
2865
|
+
commitment: {
|
|
2866
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2867
|
+
received: `Commitment: ${paramCommittment}`,
|
|
2868
|
+
message: "The committed country list for the issuing country exclusion check does not match the one from the proof"
|
|
2869
|
+
}
|
|
2707
2870
|
};
|
|
2708
2871
|
}
|
|
2709
2872
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
|
|
@@ -2725,10 +2888,13 @@ var ZKPassport = class {
|
|
|
2725
2888
|
"Failed to check the link between the validity of the ID and the nationality inclusion check"
|
|
2726
2889
|
);
|
|
2727
2890
|
isCorrect = false;
|
|
2728
|
-
queryResultErrors.nationality
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2891
|
+
queryResultErrors.nationality = {
|
|
2892
|
+
...queryResultErrors.nationality,
|
|
2893
|
+
commitment: {
|
|
2894
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2895
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2896
|
+
message: "Failed to check the link between the validity of the ID and the nationality inclusion check"
|
|
2897
|
+
}
|
|
2732
2898
|
};
|
|
2733
2899
|
}
|
|
2734
2900
|
const countryList = (proof.committedInputs?.inclusion_check_nationality).countries;
|
|
@@ -2743,10 +2909,13 @@ var ZKPassport = class {
|
|
|
2743
2909
|
"The committed country list for the nationality inclusion check does not match the one from the proof"
|
|
2744
2910
|
);
|
|
2745
2911
|
isCorrect = false;
|
|
2746
|
-
queryResultErrors.nationality
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2912
|
+
queryResultErrors.nationality = {
|
|
2913
|
+
...queryResultErrors.nationality,
|
|
2914
|
+
commitment: {
|
|
2915
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2916
|
+
received: `Commitment: ${paramCommittment}`,
|
|
2917
|
+
message: "The committed country list for the nationality inclusion check does not match the one from the proof"
|
|
2918
|
+
}
|
|
2750
2919
|
};
|
|
2751
2920
|
}
|
|
2752
2921
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
|
|
@@ -2768,10 +2937,13 @@ var ZKPassport = class {
|
|
|
2768
2937
|
"Failed to check the link between the validity of the ID and the issuing country inclusion check"
|
|
2769
2938
|
);
|
|
2770
2939
|
isCorrect = false;
|
|
2771
|
-
queryResultErrors.nationality
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2940
|
+
queryResultErrors.nationality = {
|
|
2941
|
+
...queryResultErrors.nationality,
|
|
2942
|
+
commitment: {
|
|
2943
|
+
expected: `Commitment: ${commitmentOut}`,
|
|
2944
|
+
received: `Commitment: ${commitmentIn}`,
|
|
2945
|
+
message: "Failed to check the link between the validity of the ID and the issuing country inclusion check"
|
|
2946
|
+
}
|
|
2775
2947
|
};
|
|
2776
2948
|
}
|
|
2777
2949
|
const countryList = (proof.committedInputs?.inclusion_check_issuing_country).countries;
|
|
@@ -2786,10 +2958,13 @@ var ZKPassport = class {
|
|
|
2786
2958
|
"The committed country list for the issuing country inclusion check does not match the one from the proof"
|
|
2787
2959
|
);
|
|
2788
2960
|
isCorrect = false;
|
|
2789
|
-
queryResultErrors.issuing_country
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2961
|
+
queryResultErrors.issuing_country = {
|
|
2962
|
+
...queryResultErrors.issuing_country,
|
|
2963
|
+
commitment: {
|
|
2964
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2965
|
+
received: `Commitment: ${paramCommittment}`,
|
|
2966
|
+
message: "The committed country list for the issuing country inclusion check does not match the one from the proof"
|
|
2967
|
+
}
|
|
2793
2968
|
};
|
|
2794
2969
|
}
|
|
2795
2970
|
const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
|
|
@@ -2813,10 +2988,13 @@ var ZKPassport = class {
|
|
|
2813
2988
|
if (paramCommittment !== calculatedParamCommitment) {
|
|
2814
2989
|
console.warn("The bound data does not match the one from the proof");
|
|
2815
2990
|
isCorrect = false;
|
|
2816
|
-
queryResultErrors.bind
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2991
|
+
queryResultErrors.bind = {
|
|
2992
|
+
...queryResultErrors.bind,
|
|
2993
|
+
commitment: {
|
|
2994
|
+
expected: `Commitment: ${calculatedParamCommitment}`,
|
|
2995
|
+
received: `Commitment: ${paramCommittment}`,
|
|
2996
|
+
message: "The bound data does not match the one from the proof"
|
|
2997
|
+
}
|
|
2820
2998
|
};
|
|
2821
2999
|
}
|
|
2822
3000
|
const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
|
|
@@ -2826,6 +3004,39 @@ var ZKPassport = class {
|
|
|
2826
3004
|
...queryResultErrorsBind
|
|
2827
3005
|
};
|
|
2828
3006
|
uniqueIdentifier = getNullifierFromDisclosureProof(proofData).toString(10);
|
|
3007
|
+
} else if (proof.name === "exclusion_check_sanctions") {
|
|
3008
|
+
const sanctionsBuilder = await SanctionsBuilder.create();
|
|
3009
|
+
const exclusionCheckSanctionsCommittedInputs = proof.committedInputs?.exclusion_check_sanctions;
|
|
3010
|
+
const calculatedParamCommitment = await sanctionsBuilder.getSanctionsParameterCommitment();
|
|
3011
|
+
const paramCommittment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
3012
|
+
if (paramCommittment !== calculatedParamCommitment) {
|
|
3013
|
+
console.warn(
|
|
3014
|
+
"The sanction lists check against do not match the sanction lists from the proof"
|
|
3015
|
+
);
|
|
3016
|
+
isCorrect = false;
|
|
3017
|
+
queryResultErrors.sanctions = {
|
|
3018
|
+
...queryResultErrors.sanctions,
|
|
3019
|
+
commitment: {
|
|
3020
|
+
expected: `Commitment: ${calculatedParamCommitment.toString()}`,
|
|
3021
|
+
received: `Commitment: ${paramCommittment.toString()}`,
|
|
3022
|
+
message: "The sanction lists check against do not match the sanction lists from the proof"
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
const {
|
|
3027
|
+
isCorrect: isCorrectSanctionsExclusion,
|
|
3028
|
+
queryResultErrors: queryResultErrorsSanctionsExclusion
|
|
3029
|
+
} = await this.checkSanctionsExclusionPublicInputs(
|
|
3030
|
+
queryResult,
|
|
3031
|
+
BigInt(exclusionCheckSanctionsCommittedInputs.rootHash),
|
|
3032
|
+
sanctionsBuilder
|
|
3033
|
+
);
|
|
3034
|
+
isCorrect = isCorrect && isCorrectSanctionsExclusion;
|
|
3035
|
+
queryResultErrors = {
|
|
3036
|
+
...queryResultErrors,
|
|
3037
|
+
...queryResultErrorsSanctionsExclusion
|
|
3038
|
+
};
|
|
3039
|
+
uniqueIdentifier = getNullifierFromDisclosureProof(proofData).toString(10);
|
|
2829
3040
|
}
|
|
2830
3041
|
}
|
|
2831
3042
|
return { isCorrect, uniqueIdentifier, queryResultErrors };
|
|
@@ -2834,7 +3045,7 @@ var ZKPassport = class {
|
|
|
2834
3045
|
* @notice Verify the proofs received from the mobile app.
|
|
2835
3046
|
* @param proofs The proofs to verify.
|
|
2836
3047
|
* @param queryResult The query result to verify against
|
|
2837
|
-
* @param validity How many
|
|
3048
|
+
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
2838
3049
|
* @param scope Scope this request to a specific use case
|
|
2839
3050
|
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
2840
3051
|
* @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
|
|
@@ -2965,7 +3176,7 @@ var ZKPassport = class {
|
|
|
2965
3176
|
}
|
|
2966
3177
|
getSolidityVerifierParameters({
|
|
2967
3178
|
proof,
|
|
2968
|
-
|
|
3179
|
+
validityPeriodInSeconds = DEFAULT_VALIDITY,
|
|
2969
3180
|
domain,
|
|
2970
3181
|
scope,
|
|
2971
3182
|
devMode = false
|
|
@@ -3007,19 +3218,19 @@ var ZKPassport = class {
|
|
|
3007
3218
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3008
3219
|
} else if (circuitName === "compare_age_evm") {
|
|
3009
3220
|
const value = proof.committedInputs[circuitName];
|
|
3010
|
-
const currentDateBytes = Array.from(
|
|
3221
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 8));
|
|
3011
3222
|
compressedCommittedInputs2 = ProofType.AGE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + value.minAge.toString(16).padStart(2, "0") + value.maxAge.toString(16).padStart(2, "0");
|
|
3012
3223
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3013
3224
|
const value = proof.committedInputs[circuitName];
|
|
3014
|
-
const currentDateBytes = Array.from(
|
|
3015
|
-
const minDateBytes = Array.from(
|
|
3016
|
-
const maxDateBytes = Array.from(
|
|
3225
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 8));
|
|
3226
|
+
const minDateBytes = Array.from(numberToBytesBE(value.minDateTimestamp, 8));
|
|
3227
|
+
const maxDateBytes = Array.from(numberToBytesBE(value.maxDateTimestamp, 8));
|
|
3017
3228
|
compressedCommittedInputs2 = ProofType.BIRTHDATE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + minDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + maxDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3018
3229
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3019
3230
|
const value = proof.committedInputs[circuitName];
|
|
3020
|
-
const currentDateBytes = Array.from(
|
|
3021
|
-
const minDateBytes = Array.from(
|
|
3022
|
-
const maxDateBytes = Array.from(
|
|
3231
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 8));
|
|
3232
|
+
const minDateBytes = Array.from(numberToBytesBE(value.minDateTimestamp, 8));
|
|
3233
|
+
const maxDateBytes = Array.from(numberToBytesBE(value.maxDateTimestamp, 8));
|
|
3023
3234
|
compressedCommittedInputs2 = ProofType.EXPIRY_DATE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + minDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + maxDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3024
3235
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3025
3236
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3066,7 +3277,7 @@ var ZKPassport = class {
|
|
|
3066
3277
|
publicInputs: proofData.publicInputs,
|
|
3067
3278
|
committedInputs: `0x${compressedCommittedInputs}`,
|
|
3068
3279
|
committedInputCounts: committedInputCountsArray,
|
|
3069
|
-
|
|
3280
|
+
validityPeriodInSeconds,
|
|
3070
3281
|
domain: domain ?? this.domain,
|
|
3071
3282
|
scope: scope ?? "",
|
|
3072
3283
|
devMode
|
|
@@ -3081,7 +3292,8 @@ var ZKPassport = class {
|
|
|
3081
3292
|
"base64"
|
|
3082
3293
|
);
|
|
3083
3294
|
const pubkey = this.topicToPublicKey[requestId];
|
|
3084
|
-
|
|
3295
|
+
const timestamp = Math.floor(Date.now() / 1e3) - this.topicToLocalConfig[requestId].validity;
|
|
3296
|
+
return `https://zkpassport.id/r?d=${this.domain}&t=${requestId}&c=${base64Config}&s=${base64Service}&p=${pubkey}&m=${this.topicToLocalConfig[requestId].mode}&v=${VERSION}&d=${timestamp}`;
|
|
3085
3297
|
}
|
|
3086
3298
|
/**
|
|
3087
3299
|
* @notice Returns the URL of the request.
|