@zkpassport/sdk 0.2.1 → 0.2.3
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/encryption.d.ts +4 -4
- package/dist/cjs/encryption.js +10 -20
- package/dist/cjs/index.d.ts +7 -7
- package/dist/cjs/index.js +150 -124
- package/dist/cjs/json-rpc.d.ts +2 -2
- package/dist/cjs/json-rpc.js +11 -12
- package/dist/cjs/logger.d.ts +7 -2
- package/dist/cjs/logger.js +8 -32
- package/dist/cjs/mobile.js +23 -24
- package/dist/cjs/websocket.js +3 -3
- package/dist/esm/encryption.d.ts +4 -4
- package/dist/esm/encryption.js +5 -5
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +132 -128
- package/dist/esm/json-rpc.d.ts +2 -2
- package/dist/esm/json-rpc.js +13 -13
- package/dist/esm/logger.d.ts +7 -2
- package/dist/esm/logger.js +7 -32
- package/dist/esm/mobile.js +25 -25
- package/dist/esm/websocket.js +3 -3
- package/package.json +17 -7
- package/src/encryption.ts +5 -5
- package/src/index.ts +144 -140
- package/src/json-rpc.ts +15 -15
- package/src/logger.ts +7 -38
- package/src/mobile.ts +26 -26
- package/src/websocket.ts +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.ZKPassport = exports.MERCOSUR_COUNTRIES = exports.ASEAN_COUNTRIES = exports.SCHENGEN_COUNTRIES = exports.EEA_COUNTRIES = exports.EU_COUNTRIES = exports.SANCTIONED_COUNTRIES = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
27
|
const crypto_1 = require("crypto");
|
|
6
28
|
const i18n_iso_countries_1 = require("i18n-iso-countries");
|
|
7
29
|
const utils_1 = require("@zkpassport/utils");
|
|
@@ -9,14 +31,14 @@ const utils_2 = require("@noble/ciphers/utils");
|
|
|
9
31
|
const websocket_1 = require("./websocket");
|
|
10
32
|
const json_rpc_1 = require("./json-rpc");
|
|
11
33
|
const encryption_1 = require("./encryption");
|
|
12
|
-
const logger_1 =
|
|
34
|
+
const logger_1 = require("./logger");
|
|
13
35
|
const node_gzip_1 = require("node-gzip");
|
|
14
36
|
//import initNoirC from '@noir-lang/noirc_abi'
|
|
15
37
|
//import initACVM from '@noir-lang/acvm_js'
|
|
16
|
-
(0, i18n_iso_countries_1.registerLocale)(require(
|
|
38
|
+
(0, i18n_iso_countries_1.registerLocale)(require("i18n-iso-countries/langs/en.json"));
|
|
17
39
|
function normalizeCountry(country) {
|
|
18
40
|
let normalizedCountry;
|
|
19
|
-
const alpha3 = (0, i18n_iso_countries_1.getAlpha3Code)(country,
|
|
41
|
+
const alpha3 = (0, i18n_iso_countries_1.getAlpha3Code)(country, "en");
|
|
20
42
|
normalizedCountry = alpha3 || country;
|
|
21
43
|
return normalizedCountry;
|
|
22
44
|
}
|
|
@@ -62,8 +84,8 @@ class ZKPassport {
|
|
|
62
84
|
this.onResultCallbacks = {};
|
|
63
85
|
this.onRejectCallbacks = {};
|
|
64
86
|
this.onErrorCallbacks = {};
|
|
65
|
-
if (!_domain && typeof window ===
|
|
66
|
-
throw new Error(
|
|
87
|
+
if (!_domain && typeof window === "undefined") {
|
|
88
|
+
throw new Error("Domain argument is required in Node.js environment");
|
|
67
89
|
}
|
|
68
90
|
this.domain = _domain || window.location.hostname;
|
|
69
91
|
}
|
|
@@ -79,19 +101,19 @@ class ZKPassport {
|
|
|
79
101
|
* @param outerRequest The outer request.
|
|
80
102
|
*/
|
|
81
103
|
async handleEncryptedMessage(topic, request, outerRequest) {
|
|
82
|
-
logger_1.
|
|
83
|
-
if (request.method ===
|
|
84
|
-
logger_1.
|
|
104
|
+
logger_1.noLogger.debug("Received encrypted message:", request);
|
|
105
|
+
if (request.method === "accept") {
|
|
106
|
+
logger_1.noLogger.debug(`User accepted the request and is generating a proof`);
|
|
85
107
|
await Promise.all(this.onGeneratingProofCallbacks[topic].map((callback) => callback(topic)));
|
|
86
108
|
}
|
|
87
|
-
else if (request.method ===
|
|
88
|
-
logger_1.
|
|
109
|
+
else if (request.method === "reject") {
|
|
110
|
+
logger_1.noLogger.debug(`User rejected the request`);
|
|
89
111
|
await Promise.all(this.onRejectCallbacks[topic].map((callback) => callback()));
|
|
90
112
|
}
|
|
91
|
-
else if (request.method ===
|
|
92
|
-
logger_1.
|
|
113
|
+
else if (request.method === "proof") {
|
|
114
|
+
logger_1.noLogger.debug(`User generated proof`);
|
|
93
115
|
// Uncompress the proof and convert it to a hex string
|
|
94
|
-
const bytesProof = Buffer.from(request.params.proof,
|
|
116
|
+
const bytesProof = Buffer.from(request.params.proof, "base64");
|
|
95
117
|
const uncompressedProof = await (0, node_gzip_1.ungzip)(bytesProof);
|
|
96
118
|
// The gzip lib in the app compress the proof as ASCII
|
|
97
119
|
// and since the app passes the proof as a hex string, we can
|
|
@@ -106,8 +128,8 @@ class ZKPassport {
|
|
|
106
128
|
this.topicToProofs[topic].push(processedProof);
|
|
107
129
|
await Promise.all(this.onProofGeneratedCallbacks[topic].map((callback) => callback(processedProof)));
|
|
108
130
|
}
|
|
109
|
-
else if (request.method ===
|
|
110
|
-
logger_1.
|
|
131
|
+
else if (request.method === "done") {
|
|
132
|
+
logger_1.noLogger.debug(`User sent the query result`);
|
|
111
133
|
// Verify the proofs and extract the unique identifier (aka nullifier) and the verification result
|
|
112
134
|
const { uniqueIdentifier, verified } = await this.verify(topic, this.topicToProofs[topic], request.params);
|
|
113
135
|
await Promise.all(this.onResultCallbacks[topic].map((callback) => callback({
|
|
@@ -116,21 +138,21 @@ class ZKPassport {
|
|
|
116
138
|
result: request.params,
|
|
117
139
|
})));
|
|
118
140
|
}
|
|
119
|
-
else if (request.method ===
|
|
141
|
+
else if (request.method === "error") {
|
|
120
142
|
await Promise.all(this.onErrorCallbacks[topic].map((callback) => callback(request.params.error)));
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
getZkPassportRequest(topic) {
|
|
124
146
|
return {
|
|
125
147
|
eq: (key, value) => {
|
|
126
|
-
if (key ===
|
|
148
|
+
if (key === "issuing_country" || key === "nationality") {
|
|
127
149
|
value = normalizeCountry(value);
|
|
128
150
|
}
|
|
129
|
-
generalCompare(
|
|
151
|
+
generalCompare("eq", key, value, topic, this.topicToConfig);
|
|
130
152
|
return this.getZkPassportRequest(topic);
|
|
131
153
|
},
|
|
132
154
|
gte: (key, value) => {
|
|
133
|
-
numericalCompare(
|
|
155
|
+
numericalCompare("gte", key, value, topic, this.topicToConfig);
|
|
134
156
|
return this.getZkPassportRequest(topic);
|
|
135
157
|
},
|
|
136
158
|
/*gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => {
|
|
@@ -138,11 +160,11 @@ class ZKPassport {
|
|
|
138
160
|
return this.getZkPassportRequest(topic)
|
|
139
161
|
},*/
|
|
140
162
|
lte: (key, value) => {
|
|
141
|
-
numericalCompare(
|
|
163
|
+
numericalCompare("lte", key, value, topic, this.topicToConfig);
|
|
142
164
|
return this.getZkPassportRequest(topic);
|
|
143
165
|
},
|
|
144
166
|
lt: (key, value) => {
|
|
145
|
-
numericalCompare(
|
|
167
|
+
numericalCompare("lt", key, value, topic, this.topicToConfig);
|
|
146
168
|
return this.getZkPassportRequest(topic);
|
|
147
169
|
},
|
|
148
170
|
range: (key, start, end) => {
|
|
@@ -151,12 +173,12 @@ class ZKPassport {
|
|
|
151
173
|
},
|
|
152
174
|
in: (key, value) => {
|
|
153
175
|
value = value.map((v) => normalizeCountry(v));
|
|
154
|
-
generalCompare(
|
|
176
|
+
generalCompare("in", key, value, topic, this.topicToConfig);
|
|
155
177
|
return this.getZkPassportRequest(topic);
|
|
156
178
|
},
|
|
157
179
|
out: (key, value) => {
|
|
158
180
|
value = value.map((v) => normalizeCountry(v));
|
|
159
|
-
generalCompare(
|
|
181
|
+
generalCompare("out", key, value, topic, this.topicToConfig);
|
|
160
182
|
return this.getZkPassportRequest(topic);
|
|
161
183
|
},
|
|
162
184
|
disclose: (key) => {
|
|
@@ -170,8 +192,8 @@ class ZKPassport {
|
|
|
170
192
|
return this.getZkPassportRequest(topic)
|
|
171
193
|
},*/
|
|
172
194
|
done: () => {
|
|
173
|
-
const base64Config = Buffer.from(JSON.stringify(this.topicToConfig[topic])).toString(
|
|
174
|
-
const base64Service = Buffer.from(JSON.stringify(this.topicToService[topic])).toString(
|
|
195
|
+
const base64Config = Buffer.from(JSON.stringify(this.topicToConfig[topic])).toString("base64");
|
|
196
|
+
const base64Service = Buffer.from(JSON.stringify(this.topicToService[topic])).toString("base64");
|
|
175
197
|
const pubkey = (0, utils_2.bytesToHex)(this.topicToKeyPair[topic].publicKey);
|
|
176
198
|
return {
|
|
177
199
|
url: `https://zkpassport.id/r?d=${this.domain}&t=${topic}&c=${base64Config}&s=${base64Service}&p=${pubkey}`,
|
|
@@ -194,7 +216,7 @@ class ZKPassport {
|
|
|
194
216
|
* @returns The query builder object.
|
|
195
217
|
*/
|
|
196
218
|
async request({ name, logo, purpose, scope, topicOverride, keyPairOverride, }) {
|
|
197
|
-
const topic = topicOverride || (0, crypto_1.randomBytes)(16).toString(
|
|
219
|
+
const topic = topicOverride || (0, crypto_1.randomBytes)(16).toString("hex");
|
|
198
220
|
const keyPair = keyPairOverride || (await (0, encryption_1.generateECDHKeyPair)());
|
|
199
221
|
this.topicToKeyPair[topic] = {
|
|
200
222
|
privateKey: keyPair.privateKey,
|
|
@@ -213,30 +235,30 @@ class ZKPassport {
|
|
|
213
235
|
const wsClient = (0, websocket_1.getWebSocketClient)(`wss://bridge.zkpassport.id?topic=${topic}`, this.domain);
|
|
214
236
|
this.topicToWebSocketClient[topic] = wsClient;
|
|
215
237
|
wsClient.onopen = async () => {
|
|
216
|
-
logger_1.
|
|
238
|
+
logger_1.noLogger.info("[frontend] WebSocket connection established");
|
|
217
239
|
await Promise.all(this.onBridgeConnectCallbacks[topic].map((callback) => callback()));
|
|
218
240
|
};
|
|
219
|
-
wsClient.addEventListener(
|
|
220
|
-
logger_1.
|
|
241
|
+
wsClient.addEventListener("message", async (event) => {
|
|
242
|
+
logger_1.noLogger.debug("[frontend] Received message:", event.data);
|
|
221
243
|
try {
|
|
222
244
|
const data = JSON.parse(event.data);
|
|
223
245
|
// Handshake happens when the mobile app scans the QR code and connects to the bridge
|
|
224
|
-
if (data.method ===
|
|
225
|
-
logger_1.
|
|
246
|
+
if (data.method === "handshake") {
|
|
247
|
+
logger_1.noLogger.debug("[frontend] Received handshake:", event.data);
|
|
226
248
|
this.topicToRequestReceived[topic] = true;
|
|
227
249
|
this.topicToSharedSecret[topic] = await (0, encryption_1.getSharedSecret)((0, utils_2.bytesToHex)(keyPair.privateKey), data.params.pubkey);
|
|
228
|
-
logger_1.
|
|
229
|
-
const encryptedMessage = await (0, json_rpc_1.createEncryptedJsonRpcRequest)(
|
|
230
|
-
logger_1.
|
|
250
|
+
logger_1.noLogger.debug("[frontend] Shared secret:", Buffer.from(this.topicToSharedSecret[topic]).toString("hex"));
|
|
251
|
+
const encryptedMessage = await (0, json_rpc_1.createEncryptedJsonRpcRequest)("hello", null, this.topicToSharedSecret[topic], topic);
|
|
252
|
+
logger_1.noLogger.debug("[frontend] Sending encrypted message:", encryptedMessage);
|
|
231
253
|
wsClient.send(JSON.stringify(encryptedMessage));
|
|
232
254
|
await Promise.all(this.onRequestReceivedCallbacks[topic].map((callback) => callback()));
|
|
233
255
|
return;
|
|
234
256
|
}
|
|
235
257
|
// Handle encrypted messages
|
|
236
|
-
if (data.method ===
|
|
258
|
+
if (data.method === "encryptedMessage") {
|
|
237
259
|
// Decode the payload from base64 to Uint8Array
|
|
238
260
|
const payload = new Uint8Array(atob(data.params.payload)
|
|
239
|
-
.split(
|
|
261
|
+
.split("")
|
|
240
262
|
.map((c) => c.charCodeAt(0)));
|
|
241
263
|
try {
|
|
242
264
|
// Decrypt the payload using the shared secret
|
|
@@ -245,17 +267,17 @@ class ZKPassport {
|
|
|
245
267
|
this.handleEncryptedMessage(topic, decryptedJson, data);
|
|
246
268
|
}
|
|
247
269
|
catch (error) {
|
|
248
|
-
logger_1.
|
|
270
|
+
logger_1.noLogger.error("[frontend] Error decrypting message:", error);
|
|
249
271
|
}
|
|
250
272
|
return;
|
|
251
273
|
}
|
|
252
274
|
}
|
|
253
275
|
catch (error) {
|
|
254
|
-
logger_1.
|
|
276
|
+
logger_1.noLogger.error("[frontend] Error:", error);
|
|
255
277
|
}
|
|
256
278
|
});
|
|
257
279
|
wsClient.onerror = (error) => {
|
|
258
|
-
logger_1.
|
|
280
|
+
logger_1.noLogger.error("[frontend] WebSocket error:", error);
|
|
259
281
|
};
|
|
260
282
|
return this.getZkPassportRequest(topic);
|
|
261
283
|
}
|
|
@@ -264,7 +286,7 @@ class ZKPassport {
|
|
|
264
286
|
let commitmentOut;
|
|
265
287
|
let isCorrect = true;
|
|
266
288
|
let uniqueIdentifier;
|
|
267
|
-
const expectedMerkleRoot = BigInt(
|
|
289
|
+
const expectedMerkleRoot = BigInt("21301853597069384763054217328384418971999152625381818922211526730996340553696");
|
|
268
290
|
const defaultDateValue = new Date(1111, 10, 11);
|
|
269
291
|
const currentTime = new Date();
|
|
270
292
|
const today = new Date(currentTime.getFullYear(), currentTime.getMonth(), currentTime.getDate(), 0, 0, 0, 0);
|
|
@@ -272,46 +294,46 @@ class ZKPassport {
|
|
|
272
294
|
// by their expected order: root signature check -> ID signature check -> integrity check -> disclosure
|
|
273
295
|
const sortedProofs = proofs.sort((a, b) => {
|
|
274
296
|
const proofOrder = [
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
297
|
+
"sig_check_dsc",
|
|
298
|
+
"sig_check_id_data",
|
|
299
|
+
"data_check_integrity",
|
|
300
|
+
"disclose_bytes",
|
|
301
|
+
"compare_age",
|
|
302
|
+
"compare_birthdate",
|
|
303
|
+
"compare_expiry",
|
|
304
|
+
"exclusion_check_country",
|
|
305
|
+
"inclusion_check_country",
|
|
284
306
|
];
|
|
285
307
|
const getIndex = (proof) => {
|
|
286
|
-
const name = proof.name ||
|
|
308
|
+
const name = proof.name || "";
|
|
287
309
|
return proofOrder.findIndex((p) => name.startsWith(p));
|
|
288
310
|
};
|
|
289
311
|
return getIndex(a) - getIndex(b);
|
|
290
312
|
});
|
|
291
313
|
for (const proof of sortedProofs) {
|
|
292
314
|
const proofData = (0, utils_1.getProofData)(proof.proof, true);
|
|
293
|
-
if (proof.name?.startsWith(
|
|
315
|
+
if (proof.name?.startsWith("sig_check_dsc")) {
|
|
294
316
|
commitmentOut = (0, utils_1.getCommitmentFromDSCProof)(proofData);
|
|
295
317
|
const merkleRoot = (0, utils_1.getMerkleRootFromDSCProof)(proofData);
|
|
296
318
|
if (merkleRoot !== expectedMerkleRoot) {
|
|
297
|
-
console.warn(
|
|
319
|
+
console.warn("The ID was signed by an unrecognized root certificate");
|
|
298
320
|
isCorrect = false;
|
|
299
321
|
break;
|
|
300
322
|
}
|
|
301
323
|
}
|
|
302
|
-
else if (proof.name?.startsWith(
|
|
324
|
+
else if (proof.name?.startsWith("sig_check_id_data")) {
|
|
303
325
|
commitmentIn = (0, utils_1.getCommitmentInFromIDDataProof)(proofData);
|
|
304
326
|
if (commitmentIn !== commitmentOut) {
|
|
305
|
-
console.warn(
|
|
327
|
+
console.warn("Failed to check the link between the certificate signature and ID signature");
|
|
306
328
|
isCorrect = false;
|
|
307
329
|
break;
|
|
308
330
|
}
|
|
309
331
|
commitmentOut = (0, utils_1.getCommitmentOutFromIDDataProof)(proofData);
|
|
310
332
|
}
|
|
311
|
-
else if (proof.name?.startsWith(
|
|
333
|
+
else if (proof.name?.startsWith("data_check_integrity")) {
|
|
312
334
|
commitmentIn = (0, utils_1.getCommitmentInFromIntegrityProof)(proofData);
|
|
313
335
|
if (commitmentIn !== commitmentOut) {
|
|
314
|
-
console.warn(
|
|
336
|
+
console.warn("Failed to check the link between the ID signature and the data signed");
|
|
315
337
|
isCorrect = false;
|
|
316
338
|
break;
|
|
317
339
|
}
|
|
@@ -321,33 +343,33 @@ class ZKPassport {
|
|
|
321
343
|
// (if the proof request was requested just before midnight and is finalized after)
|
|
322
344
|
if (currentDate.getTime() !== today.getTime() &&
|
|
323
345
|
currentDate.getTime() !== today.getTime() - 86400000) {
|
|
324
|
-
console.warn(
|
|
346
|
+
console.warn("Current date used to check the validity of the ID is too old");
|
|
325
347
|
isCorrect = false;
|
|
326
348
|
break;
|
|
327
349
|
}
|
|
328
350
|
}
|
|
329
|
-
else if (proof.name ===
|
|
351
|
+
else if (proof.name === "disclose_bytes") {
|
|
330
352
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
331
353
|
if (commitmentIn !== commitmentOut) {
|
|
332
|
-
console.warn(
|
|
354
|
+
console.warn("Failed to check the link between the validity of the ID and the data to disclose");
|
|
333
355
|
isCorrect = false;
|
|
334
356
|
break;
|
|
335
357
|
}
|
|
336
358
|
// We can't be certain that the disclosed data is for a passport or an ID card
|
|
337
359
|
// so we need to check both (unless the document type is revealed)
|
|
338
|
-
const disclosedDataPassport = utils_1.DisclosedData.fromBytesProof(proofData,
|
|
339
|
-
const disclosedDataIDCard = utils_1.DisclosedData.fromBytesProof(proofData,
|
|
360
|
+
const disclosedDataPassport = utils_1.DisclosedData.fromBytesProof(proofData, "passport");
|
|
361
|
+
const disclosedDataIDCard = utils_1.DisclosedData.fromBytesProof(proofData, "id_card");
|
|
340
362
|
if (queryResult.document_type) {
|
|
341
363
|
// Document type is always at the same index in the disclosed data
|
|
342
364
|
if (queryResult.document_type.eq &&
|
|
343
365
|
queryResult.document_type.eq.result &&
|
|
344
366
|
queryResult.document_type.eq.expected !== disclosedDataPassport.documentType) {
|
|
345
|
-
console.warn(
|
|
367
|
+
console.warn("Document type does not match the expected document type");
|
|
346
368
|
isCorrect = false;
|
|
347
369
|
break;
|
|
348
370
|
}
|
|
349
371
|
if (queryResult.document_type.disclose?.result !== disclosedDataIDCard.documentType) {
|
|
350
|
-
console.warn(
|
|
372
|
+
console.warn("Document type does not match the disclosed document type in query result");
|
|
351
373
|
isCorrect = false;
|
|
352
374
|
break;
|
|
353
375
|
}
|
|
@@ -359,14 +381,14 @@ class ZKPassport {
|
|
|
359
381
|
queryResult.birthdate.eq.result &&
|
|
360
382
|
queryResult.birthdate.eq.expected.getTime() !== birthdatePassport.getTime() &&
|
|
361
383
|
queryResult.birthdate.eq.expected.getTime() !== birthdateIDCard.getTime()) {
|
|
362
|
-
console.warn(
|
|
384
|
+
console.warn("Birthdate does not match the expected birthdate");
|
|
363
385
|
isCorrect = false;
|
|
364
386
|
break;
|
|
365
387
|
}
|
|
366
388
|
if (queryResult.birthdate.disclose &&
|
|
367
389
|
queryResult.birthdate.disclose.result.getTime() !== birthdatePassport.getTime() &&
|
|
368
390
|
queryResult.birthdate.disclose.result.getTime() !== birthdateIDCard.getTime()) {
|
|
369
|
-
console.warn(
|
|
391
|
+
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
370
392
|
isCorrect = false;
|
|
371
393
|
break;
|
|
372
394
|
}
|
|
@@ -378,14 +400,14 @@ class ZKPassport {
|
|
|
378
400
|
queryResult.expiry_date.eq.result &&
|
|
379
401
|
queryResult.expiry_date.eq.expected.getTime() !== expiryDatePassport.getTime() &&
|
|
380
402
|
queryResult.expiry_date.eq.expected.getTime() !== expiryDateIDCard.getTime()) {
|
|
381
|
-
console.warn(
|
|
403
|
+
console.warn("Expiry date does not match the expected expiry date");
|
|
382
404
|
isCorrect = false;
|
|
383
405
|
break;
|
|
384
406
|
}
|
|
385
407
|
if (queryResult.expiry_date.disclose &&
|
|
386
408
|
queryResult.expiry_date.disclose.result.getTime() !== expiryDatePassport.getTime() &&
|
|
387
409
|
queryResult.expiry_date.disclose.result.getTime() !== expiryDateIDCard.getTime()) {
|
|
388
|
-
console.warn(
|
|
410
|
+
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
389
411
|
isCorrect = false;
|
|
390
412
|
break;
|
|
391
413
|
}
|
|
@@ -397,14 +419,14 @@ class ZKPassport {
|
|
|
397
419
|
queryResult.nationality.eq.result &&
|
|
398
420
|
queryResult.nationality.eq.expected !== nationalityPassport &&
|
|
399
421
|
queryResult.nationality.eq.expected !== nationalityIDCard) {
|
|
400
|
-
console.warn(
|
|
422
|
+
console.warn("Nationality does not match the expected nationality");
|
|
401
423
|
isCorrect = false;
|
|
402
424
|
break;
|
|
403
425
|
}
|
|
404
426
|
if (queryResult.nationality.disclose &&
|
|
405
427
|
queryResult.nationality.disclose.result !== nationalityPassport &&
|
|
406
428
|
queryResult.nationality.disclose.result !== nationalityIDCard) {
|
|
407
|
-
console.warn(
|
|
429
|
+
console.warn("Nationality does not match the disclosed nationality in query result");
|
|
408
430
|
isCorrect = false;
|
|
409
431
|
break;
|
|
410
432
|
}
|
|
@@ -416,14 +438,14 @@ class ZKPassport {
|
|
|
416
438
|
queryResult.document_number.eq.result &&
|
|
417
439
|
queryResult.document_number.eq.expected !== documentNumberPassport &&
|
|
418
440
|
queryResult.document_number.eq.expected !== documentNumberIDCard) {
|
|
419
|
-
console.warn(
|
|
441
|
+
console.warn("Document number does not match the expected document number");
|
|
420
442
|
isCorrect = false;
|
|
421
443
|
break;
|
|
422
444
|
}
|
|
423
445
|
if (queryResult.document_number.disclose &&
|
|
424
446
|
queryResult.document_number.disclose.result !== documentNumberPassport &&
|
|
425
447
|
queryResult.document_number.disclose.result !== documentNumberIDCard) {
|
|
426
|
-
console.warn(
|
|
448
|
+
console.warn("Document number does not match the disclosed document number in query result");
|
|
427
449
|
isCorrect = false;
|
|
428
450
|
break;
|
|
429
451
|
}
|
|
@@ -435,14 +457,14 @@ class ZKPassport {
|
|
|
435
457
|
queryResult.gender.eq.result &&
|
|
436
458
|
queryResult.gender.eq.expected !== genderPassport &&
|
|
437
459
|
queryResult.gender.eq.expected !== genderIDCard) {
|
|
438
|
-
console.warn(
|
|
460
|
+
console.warn("Gender does not match the expected gender");
|
|
439
461
|
isCorrect = false;
|
|
440
462
|
break;
|
|
441
463
|
}
|
|
442
464
|
if (queryResult.gender.disclose &&
|
|
443
465
|
queryResult.gender.disclose.result !== genderPassport &&
|
|
444
466
|
queryResult.gender.disclose.result !== genderIDCard) {
|
|
445
|
-
console.warn(
|
|
467
|
+
console.warn("Gender does not match the disclosed gender in query result");
|
|
446
468
|
isCorrect = false;
|
|
447
469
|
break;
|
|
448
470
|
}
|
|
@@ -454,14 +476,14 @@ class ZKPassport {
|
|
|
454
476
|
queryResult.issuing_country.eq.result &&
|
|
455
477
|
queryResult.issuing_country.eq.expected !== issuingCountryPassport &&
|
|
456
478
|
queryResult.issuing_country.eq.expected !== issuingCountryIDCard) {
|
|
457
|
-
console.warn(
|
|
479
|
+
console.warn("Issuing country does not match the expected issuing country");
|
|
458
480
|
isCorrect = false;
|
|
459
481
|
break;
|
|
460
482
|
}
|
|
461
483
|
if (queryResult.issuing_country.disclose &&
|
|
462
484
|
queryResult.issuing_country.disclose.result !== issuingCountryPassport &&
|
|
463
485
|
queryResult.issuing_country.disclose.result !== issuingCountryIDCard) {
|
|
464
|
-
console.warn(
|
|
486
|
+
console.warn("Issuing country does not match the disclosed issuing country in query result");
|
|
465
487
|
isCorrect = false;
|
|
466
488
|
break;
|
|
467
489
|
}
|
|
@@ -475,7 +497,7 @@ class ZKPassport {
|
|
|
475
497
|
fullnamePassport.toLowerCase() &&
|
|
476
498
|
(0, utils_1.formatName)(queryResult.fullname.eq.expected).toLowerCase() !==
|
|
477
499
|
fullnameIDCard.toLowerCase()) {
|
|
478
|
-
console.warn(
|
|
500
|
+
console.warn("Fullname does not match the expected fullname");
|
|
479
501
|
isCorrect = false;
|
|
480
502
|
break;
|
|
481
503
|
}
|
|
@@ -484,7 +506,7 @@ class ZKPassport {
|
|
|
484
506
|
fullnamePassport.toLowerCase() &&
|
|
485
507
|
(0, utils_1.formatName)(queryResult.fullname.disclose.result).toLowerCase() !==
|
|
486
508
|
fullnameIDCard.toLowerCase()) {
|
|
487
|
-
console.warn(
|
|
509
|
+
console.warn("Fullname does not match the disclosed fullname in query result");
|
|
488
510
|
isCorrect = false;
|
|
489
511
|
break;
|
|
490
512
|
}
|
|
@@ -503,7 +525,7 @@ class ZKPassport {
|
|
|
503
525
|
firstnamePassport.toLowerCase() &&
|
|
504
526
|
(0, utils_1.formatName)(queryResult.firstname.eq.expected).toLowerCase() !==
|
|
505
527
|
firstnameIDCard.toLowerCase()) {
|
|
506
|
-
console.warn(
|
|
528
|
+
console.warn("Firstname does not match the expected firstname");
|
|
507
529
|
isCorrect = false;
|
|
508
530
|
break;
|
|
509
531
|
}
|
|
@@ -512,7 +534,7 @@ class ZKPassport {
|
|
|
512
534
|
firstnamePassport.toLowerCase() &&
|
|
513
535
|
(0, utils_1.formatName)(queryResult.firstname.disclose.result).toLowerCase() !==
|
|
514
536
|
firstnameIDCard.toLowerCase()) {
|
|
515
|
-
console.warn(
|
|
537
|
+
console.warn("Firstname does not match the disclosed firstname in query result");
|
|
516
538
|
isCorrect = false;
|
|
517
539
|
break;
|
|
518
540
|
}
|
|
@@ -531,7 +553,7 @@ class ZKPassport {
|
|
|
531
553
|
lastnamePassport.toLowerCase() &&
|
|
532
554
|
(0, utils_1.formatName)(queryResult.lastname.eq.expected).toLowerCase() !==
|
|
533
555
|
lastnameIDCard.toLowerCase()) {
|
|
534
|
-
console.warn(
|
|
556
|
+
console.warn("Lastname does not match the expected lastname");
|
|
535
557
|
isCorrect = false;
|
|
536
558
|
break;
|
|
537
559
|
}
|
|
@@ -540,17 +562,17 @@ class ZKPassport {
|
|
|
540
562
|
lastnamePassport.toLowerCase() &&
|
|
541
563
|
(0, utils_1.formatName)(queryResult.lastname.disclose.result).toLowerCase() !==
|
|
542
564
|
lastnameIDCard.toLowerCase()) {
|
|
543
|
-
console.warn(
|
|
565
|
+
console.warn("Lastname does not match the disclosed lastname in query result");
|
|
544
566
|
isCorrect = false;
|
|
545
567
|
break;
|
|
546
568
|
}
|
|
547
569
|
}
|
|
548
570
|
uniqueIdentifier = (0, utils_1.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
549
571
|
}
|
|
550
|
-
else if (proof.name ===
|
|
572
|
+
else if (proof.name === "compare_age") {
|
|
551
573
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
552
574
|
if (commitmentIn !== commitmentOut) {
|
|
553
|
-
console.warn(
|
|
575
|
+
console.warn("Failed to check the link between the validity of the ID and the age derived from it");
|
|
554
576
|
isCorrect = false;
|
|
555
577
|
break;
|
|
556
578
|
}
|
|
@@ -560,14 +582,14 @@ class ZKPassport {
|
|
|
560
582
|
if (queryResult.age.gte &&
|
|
561
583
|
queryResult.age.gte.result &&
|
|
562
584
|
minAge < queryResult.age.gte.expected) {
|
|
563
|
-
console.warn(
|
|
585
|
+
console.warn("Age is not greater than or equal to the expected age");
|
|
564
586
|
isCorrect = false;
|
|
565
587
|
break;
|
|
566
588
|
}
|
|
567
589
|
if (queryResult.age.lt &&
|
|
568
590
|
queryResult.age.lt.result &&
|
|
569
591
|
maxAge >= queryResult.age.lt.expected) {
|
|
570
|
-
console.warn(
|
|
592
|
+
console.warn("Age is not less than the expected age");
|
|
571
593
|
isCorrect = false;
|
|
572
594
|
break;
|
|
573
595
|
}
|
|
@@ -575,47 +597,47 @@ class ZKPassport {
|
|
|
575
597
|
if (queryResult.age.range.result &&
|
|
576
598
|
(minAge < queryResult.age.range.expected[0] ||
|
|
577
599
|
maxAge >= queryResult.age.range.expected[1])) {
|
|
578
|
-
console.warn(
|
|
600
|
+
console.warn("Age is not in the expected range");
|
|
579
601
|
isCorrect = false;
|
|
580
602
|
break;
|
|
581
603
|
}
|
|
582
604
|
}
|
|
583
605
|
if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
|
|
584
|
-
console.warn(
|
|
606
|
+
console.warn("Maximum age should be equal to 0");
|
|
585
607
|
isCorrect = false;
|
|
586
608
|
break;
|
|
587
609
|
}
|
|
588
610
|
if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
|
|
589
|
-
console.warn(
|
|
611
|
+
console.warn("Minimum age should be equal to 0");
|
|
590
612
|
isCorrect = false;
|
|
591
613
|
break;
|
|
592
614
|
}
|
|
593
615
|
if (queryResult.age.disclose &&
|
|
594
616
|
(queryResult.age.disclose.result !== minAge ||
|
|
595
617
|
queryResult.age.disclose.result !== maxAge)) {
|
|
596
|
-
console.warn(
|
|
618
|
+
console.warn("Age does not match the disclosed age in query result");
|
|
597
619
|
isCorrect = false;
|
|
598
620
|
break;
|
|
599
621
|
}
|
|
600
622
|
}
|
|
601
623
|
else {
|
|
602
|
-
console.warn(
|
|
624
|
+
console.warn("Age is not set in the query result");
|
|
603
625
|
isCorrect = false;
|
|
604
626
|
break;
|
|
605
627
|
}
|
|
606
628
|
const currentDate = (0, utils_1.getCurrentDateFromAgeProof)(proofData);
|
|
607
629
|
if (currentDate.getTime() !== today.getTime() &&
|
|
608
630
|
currentDate.getTime() !== today.getTime() - 86400000) {
|
|
609
|
-
console.warn(
|
|
631
|
+
console.warn("Current date in the proof is too old");
|
|
610
632
|
isCorrect = false;
|
|
611
633
|
break;
|
|
612
634
|
}
|
|
613
635
|
uniqueIdentifier = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData).toString(10);
|
|
614
636
|
}
|
|
615
|
-
else if (proof.name ===
|
|
637
|
+
else if (proof.name === "compare_birthdate") {
|
|
616
638
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
617
639
|
if (commitmentIn !== commitmentOut) {
|
|
618
|
-
console.warn(
|
|
640
|
+
console.warn("Failed to check the link between the validity of the ID and the birthdate derived from it");
|
|
619
641
|
isCorrect = false;
|
|
620
642
|
break;
|
|
621
643
|
}
|
|
@@ -625,14 +647,14 @@ class ZKPassport {
|
|
|
625
647
|
if (queryResult.birthdate.gte &&
|
|
626
648
|
queryResult.birthdate.gte.result &&
|
|
627
649
|
minDate < queryResult.birthdate.gte.expected) {
|
|
628
|
-
console.warn(
|
|
650
|
+
console.warn("Birthdate is not greater than or equal to the expected birthdate");
|
|
629
651
|
isCorrect = false;
|
|
630
652
|
break;
|
|
631
653
|
}
|
|
632
654
|
if (queryResult.birthdate.lte &&
|
|
633
655
|
queryResult.birthdate.lte.result &&
|
|
634
656
|
maxDate > queryResult.birthdate.lte.expected) {
|
|
635
|
-
console.warn(
|
|
657
|
+
console.warn("Birthdate is not less than the expected birthdate");
|
|
636
658
|
isCorrect = false;
|
|
637
659
|
break;
|
|
638
660
|
}
|
|
@@ -640,7 +662,7 @@ class ZKPassport {
|
|
|
640
662
|
if (queryResult.birthdate.range.result &&
|
|
641
663
|
(minDate < queryResult.birthdate.range.expected[0] ||
|
|
642
664
|
maxDate > queryResult.birthdate.range.expected[1])) {
|
|
643
|
-
console.warn(
|
|
665
|
+
console.warn("Birthdate is not in the expected range");
|
|
644
666
|
isCorrect = false;
|
|
645
667
|
break;
|
|
646
668
|
}
|
|
@@ -648,29 +670,29 @@ class ZKPassport {
|
|
|
648
670
|
if (!queryResult.birthdate.lte &&
|
|
649
671
|
!queryResult.birthdate.range &&
|
|
650
672
|
maxDate.getTime() != defaultDateValue.getTime()) {
|
|
651
|
-
console.warn(
|
|
673
|
+
console.warn("Maximum birthdate should be equal to default date value");
|
|
652
674
|
isCorrect = false;
|
|
653
675
|
break;
|
|
654
676
|
}
|
|
655
677
|
if (!queryResult.birthdate.gte &&
|
|
656
678
|
!queryResult.birthdate.range &&
|
|
657
679
|
minDate.getTime() != defaultDateValue.getTime()) {
|
|
658
|
-
console.warn(
|
|
680
|
+
console.warn("Minimum birthdate should be equal to default date value");
|
|
659
681
|
isCorrect = false;
|
|
660
682
|
break;
|
|
661
683
|
}
|
|
662
684
|
}
|
|
663
685
|
else {
|
|
664
|
-
console.warn(
|
|
686
|
+
console.warn("Birthdate is not set in the query result");
|
|
665
687
|
isCorrect = false;
|
|
666
688
|
break;
|
|
667
689
|
}
|
|
668
690
|
uniqueIdentifier = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData).toString(10);
|
|
669
691
|
}
|
|
670
|
-
else if (proof.name ===
|
|
692
|
+
else if (proof.name === "compare_expiry") {
|
|
671
693
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
672
694
|
if (commitmentIn !== commitmentOut) {
|
|
673
|
-
console.warn(
|
|
695
|
+
console.warn("Failed to check the link between the validity of the ID and its expiry date");
|
|
674
696
|
isCorrect = false;
|
|
675
697
|
break;
|
|
676
698
|
}
|
|
@@ -680,14 +702,14 @@ class ZKPassport {
|
|
|
680
702
|
if (queryResult.expiry_date.gte &&
|
|
681
703
|
queryResult.expiry_date.gte.result &&
|
|
682
704
|
minDate < queryResult.expiry_date.gte.expected) {
|
|
683
|
-
console.warn(
|
|
705
|
+
console.warn("Expiry date is not greater than or equal to the expected expiry date");
|
|
684
706
|
isCorrect = false;
|
|
685
707
|
break;
|
|
686
708
|
}
|
|
687
709
|
if (queryResult.expiry_date.lte &&
|
|
688
710
|
queryResult.expiry_date.lte.result &&
|
|
689
711
|
maxDate > queryResult.expiry_date.lte.expected) {
|
|
690
|
-
console.warn(
|
|
712
|
+
console.warn("Expiry date is not less than the expected expiry date");
|
|
691
713
|
isCorrect = false;
|
|
692
714
|
break;
|
|
693
715
|
}
|
|
@@ -695,7 +717,7 @@ class ZKPassport {
|
|
|
695
717
|
if (queryResult.expiry_date.range.result &&
|
|
696
718
|
(minDate < queryResult.expiry_date.range.expected[0] ||
|
|
697
719
|
maxDate > queryResult.expiry_date.range.expected[1])) {
|
|
698
|
-
console.warn(
|
|
720
|
+
console.warn("Expiry date is not in the expected range");
|
|
699
721
|
isCorrect = false;
|
|
700
722
|
break;
|
|
701
723
|
}
|
|
@@ -703,29 +725,29 @@ class ZKPassport {
|
|
|
703
725
|
if (!queryResult.expiry_date.lte &&
|
|
704
726
|
!queryResult.expiry_date.range &&
|
|
705
727
|
maxDate.getTime() != defaultDateValue.getTime()) {
|
|
706
|
-
console.warn(
|
|
728
|
+
console.warn("Maximum expiry date should be equal to default date value");
|
|
707
729
|
isCorrect = false;
|
|
708
730
|
break;
|
|
709
731
|
}
|
|
710
732
|
if (!queryResult.expiry_date.gte &&
|
|
711
733
|
!queryResult.expiry_date.range &&
|
|
712
734
|
minDate.getTime() != defaultDateValue.getTime()) {
|
|
713
|
-
console.warn(
|
|
735
|
+
console.warn("Minimum expiry date should be equal to default date value");
|
|
714
736
|
isCorrect = false;
|
|
715
737
|
break;
|
|
716
738
|
}
|
|
717
739
|
}
|
|
718
740
|
else {
|
|
719
|
-
console.warn(
|
|
741
|
+
console.warn("Expiry date is not set in the query result");
|
|
720
742
|
isCorrect = false;
|
|
721
743
|
break;
|
|
722
744
|
}
|
|
723
745
|
uniqueIdentifier = (0, utils_1.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
724
746
|
}
|
|
725
|
-
else if (proof.name ===
|
|
747
|
+
else if (proof.name === "exclusion_check_country") {
|
|
726
748
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
727
749
|
if (commitmentIn !== commitmentOut) {
|
|
728
|
-
console.warn(
|
|
750
|
+
console.warn("Failed to check the link between the validity of the ID and the country exclusion check");
|
|
729
751
|
isCorrect = false;
|
|
730
752
|
break;
|
|
731
753
|
}
|
|
@@ -734,22 +756,22 @@ class ZKPassport {
|
|
|
734
756
|
queryResult.nationality.out &&
|
|
735
757
|
queryResult.nationality.out.result) {
|
|
736
758
|
if (!queryResult.nationality.out.expected?.every((country) => countryList.includes(country))) {
|
|
737
|
-
console.warn(
|
|
759
|
+
console.warn("Country exclusion list does not match the one from the query results");
|
|
738
760
|
isCorrect = false;
|
|
739
761
|
break;
|
|
740
762
|
}
|
|
741
763
|
}
|
|
742
764
|
else if (!queryResult.nationality || !queryResult.nationality.out) {
|
|
743
|
-
console.warn(
|
|
765
|
+
console.warn("Nationality exclusion is not set in the query result");
|
|
744
766
|
isCorrect = false;
|
|
745
767
|
break;
|
|
746
768
|
}
|
|
747
769
|
uniqueIdentifier = (0, utils_1.getNullifierFromDisclosureProof)(proofData).toString(10);
|
|
748
770
|
}
|
|
749
|
-
else if (proof.name ===
|
|
771
|
+
else if (proof.name === "inclusion_check_country") {
|
|
750
772
|
commitmentIn = (0, utils_1.getCommitmentInFromDisclosureProof)(proofData);
|
|
751
773
|
if (commitmentIn !== commitmentOut) {
|
|
752
|
-
console.warn(
|
|
774
|
+
console.warn("Failed to check the link between the validity of the ID and the country inclusion check");
|
|
753
775
|
isCorrect = false;
|
|
754
776
|
break;
|
|
755
777
|
}
|
|
@@ -758,13 +780,13 @@ class ZKPassport {
|
|
|
758
780
|
queryResult.nationality.in &&
|
|
759
781
|
queryResult.nationality.in.result) {
|
|
760
782
|
if (!queryResult.nationality.in.expected?.every((country) => countryList.includes(country))) {
|
|
761
|
-
console.warn(
|
|
783
|
+
console.warn("Country inclusion list does not match the one from the query results");
|
|
762
784
|
isCorrect = false;
|
|
763
785
|
break;
|
|
764
786
|
}
|
|
765
787
|
}
|
|
766
788
|
else if (!queryResult.nationality || !queryResult.nationality.in) {
|
|
767
|
-
console.warn(
|
|
789
|
+
console.warn("Nationality inclusion is not set in the query result");
|
|
768
790
|
isCorrect = false;
|
|
769
791
|
break;
|
|
770
792
|
}
|
|
@@ -783,13 +805,17 @@ class ZKPassport {
|
|
|
783
805
|
*/
|
|
784
806
|
async verify(requestId, proofs, queryResult) {
|
|
785
807
|
let proofsToVerify = proofs;
|
|
786
|
-
|
|
808
|
+
// There is a minimum of 4 subproofs to make a complete proof
|
|
809
|
+
if (!proofs || proofs.length < 4) {
|
|
787
810
|
proofsToVerify = this.topicToProofs[requestId];
|
|
788
|
-
if (!proofsToVerify || proofsToVerify.length
|
|
789
|
-
|
|
811
|
+
if (!proofsToVerify || proofsToVerify.length < 4) {
|
|
812
|
+
// It may happen that a request returns a result without proofs
|
|
813
|
+
// Meaning the ID is supported yet by ZKPassport circuits,
|
|
814
|
+
// so the results has to be trusted and cannot be independently verified
|
|
815
|
+
return { uniqueIdentifier: undefined, verified: false };
|
|
790
816
|
}
|
|
791
817
|
}
|
|
792
|
-
const { BarretenbergVerifier } = await Promise.resolve().then(() =>
|
|
818
|
+
const { BarretenbergVerifier } = await Promise.resolve().then(() => __importStar(require("@aztec/bb.js")));
|
|
793
819
|
const verifier = new BarretenbergVerifier();
|
|
794
820
|
/*if (!this.wasmVerifierInit) {
|
|
795
821
|
await this.initWasmVerifier()
|
|
@@ -806,12 +832,12 @@ class ZKPassport {
|
|
|
806
832
|
for (const proof of proofsToVerify) {
|
|
807
833
|
const proofData = (0, utils_1.getProofData)(proof.proof, true);
|
|
808
834
|
const hostedPackagedCircuit = await (0, utils_1.getHostedPackagedCircuitByName)(proof.version, proof.name);
|
|
809
|
-
const vkeyBytes = Buffer.from(hostedPackagedCircuit.vkey,
|
|
835
|
+
const vkeyBytes = Buffer.from(hostedPackagedCircuit.vkey, "base64");
|
|
810
836
|
try {
|
|
811
837
|
verified = await verifier.verifyUltraHonkProof(proofData, new Uint8Array(vkeyBytes));
|
|
812
838
|
}
|
|
813
839
|
catch (e) {
|
|
814
|
-
console.warn(
|
|
840
|
+
console.warn("Error verifying proof", e);
|
|
815
841
|
verified = false;
|
|
816
842
|
}
|
|
817
843
|
if (!verified) {
|
|
@@ -831,8 +857,8 @@ class ZKPassport {
|
|
|
831
857
|
*/
|
|
832
858
|
getUrl(requestId) {
|
|
833
859
|
const pubkey = (0, utils_2.bytesToHex)(this.topicToKeyPair[requestId].publicKey);
|
|
834
|
-
const base64Config = Buffer.from(JSON.stringify(this.topicToConfig[requestId])).toString(
|
|
835
|
-
const base64Service = Buffer.from(JSON.stringify(this.topicToService[requestId])).toString(
|
|
860
|
+
const base64Config = Buffer.from(JSON.stringify(this.topicToConfig[requestId])).toString("base64");
|
|
861
|
+
const base64Service = Buffer.from(JSON.stringify(this.topicToService[requestId])).toString("base64");
|
|
836
862
|
return `https://zkpassport.id/r?d=${this.domain}&t=${requestId}&c=${base64Config}&s=${base64Service}&p=${pubkey}`;
|
|
837
863
|
}
|
|
838
864
|
/**
|