@consealdev/conseal 0.0.0-stage → 0.5.1
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/LICENSE +661 -0
- package/README.md +192 -2
- package/dist/.gitkeep +0 -0
- package/dist/index.d.ts +347 -0
- package/dist/index.js +3188 -0
- package/package.json +41 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,3188 @@
|
|
|
1
|
+
// src/aes.ts
|
|
2
|
+
var IV_LENGTH = 12;
|
|
3
|
+
async function seal(key, plaintext, additionalData) {
|
|
4
|
+
if (key.algorithm.name !== "AES-GCM") {
|
|
5
|
+
throw new TypeError(`seal: expected an AES-GCM key, got ${key.algorithm.name}`);
|
|
6
|
+
}
|
|
7
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
|
8
|
+
const algorithm = { name: "AES-GCM", iv, tagLength: 128 };
|
|
9
|
+
if (additionalData !== void 0) algorithm.additionalData = additionalData;
|
|
10
|
+
const ciphertext = await crypto.subtle.encrypt(algorithm, key, plaintext);
|
|
11
|
+
return { ciphertext, iv };
|
|
12
|
+
}
|
|
13
|
+
async function unseal(key, ciphertext, iv, additionalData) {
|
|
14
|
+
if (key.algorithm.name !== "AES-GCM") {
|
|
15
|
+
throw new TypeError(`unseal: expected an AES-GCM key, got ${key.algorithm.name}`);
|
|
16
|
+
}
|
|
17
|
+
if (iv.byteLength !== IV_LENGTH) {
|
|
18
|
+
throw new TypeError(`AES-GCM IV must be ${IV_LENGTH} bytes (96 bits), got ${iv.byteLength}`);
|
|
19
|
+
}
|
|
20
|
+
const algorithm = { name: "AES-GCM", iv, tagLength: 128 };
|
|
21
|
+
if (additionalData !== void 0) algorithm.additionalData = additionalData;
|
|
22
|
+
return crypto.subtle.decrypt(algorithm, key, ciphertext);
|
|
23
|
+
}
|
|
24
|
+
async function generateAesKey(extractable = false) {
|
|
25
|
+
return crypto.subtle.generateKey(
|
|
26
|
+
{ name: "AES-GCM", length: 256 },
|
|
27
|
+
extractable,
|
|
28
|
+
["encrypt", "decrypt"]
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async function importAesKey(raw, extractable = false) {
|
|
32
|
+
if (raw.byteLength !== 32) {
|
|
33
|
+
throw new TypeError(`importAesKey: key must be 32 bytes (256 bits), got ${raw.byteLength}`);
|
|
34
|
+
}
|
|
35
|
+
return crypto.subtle.importKey(
|
|
36
|
+
"raw",
|
|
37
|
+
raw,
|
|
38
|
+
{ name: "AES-GCM", length: 256 },
|
|
39
|
+
extractable,
|
|
40
|
+
["encrypt", "decrypt"]
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/secret-key.ts
|
|
45
|
+
function generateSecretKey() {
|
|
46
|
+
return crypto.getRandomValues(new Uint8Array(16));
|
|
47
|
+
}
|
|
48
|
+
async function combinePassphraseAndSecretKey(passphrase, secretKey) {
|
|
49
|
+
const hmacKey = await crypto.subtle.importKey(
|
|
50
|
+
"raw",
|
|
51
|
+
secretKey.buffer.slice(secretKey.byteOffset, secretKey.byteOffset + secretKey.byteLength),
|
|
52
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
53
|
+
false,
|
|
54
|
+
["sign"]
|
|
55
|
+
);
|
|
56
|
+
const mac = await crypto.subtle.sign("HMAC", hmacKey, new TextEncoder().encode(passphrase));
|
|
57
|
+
return Array.from(new Uint8Array(mac)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/compare.ts
|
|
61
|
+
function buffersEqual(a, b) {
|
|
62
|
+
if (a.length !== b.length) return false;
|
|
63
|
+
let result = 0;
|
|
64
|
+
for (let i = 0; i < a.length; i++) result |= a[i] ^ b[i];
|
|
65
|
+
return result === 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/pbkdf2.ts
|
|
69
|
+
var ITERATIONS = 6e5;
|
|
70
|
+
var SALT_LENGTH = 16;
|
|
71
|
+
var IV_LENGTH2 = 12;
|
|
72
|
+
async function deriveWrappingKey(passphrase, salt) {
|
|
73
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
74
|
+
"raw",
|
|
75
|
+
new TextEncoder().encode(passphrase),
|
|
76
|
+
"PBKDF2",
|
|
77
|
+
false,
|
|
78
|
+
["deriveKey"]
|
|
79
|
+
);
|
|
80
|
+
return crypto.subtle.deriveKey(
|
|
81
|
+
{ name: "PBKDF2", salt, iterations: ITERATIONS, hash: "SHA-256" },
|
|
82
|
+
keyMaterial,
|
|
83
|
+
{ name: "AES-GCM", length: 256 },
|
|
84
|
+
false,
|
|
85
|
+
["encrypt", "decrypt"]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
async function resolvePassphrase(passphrase, secretKey) {
|
|
89
|
+
return secretKey ? combinePassphraseAndSecretKey(passphrase, secretKey) : passphrase;
|
|
90
|
+
}
|
|
91
|
+
async function decryptWrappedKey(wrappingKey, wrappedKey, extractable) {
|
|
92
|
+
const bytes = new Uint8Array(wrappedKey);
|
|
93
|
+
const iv = bytes.slice(0, IV_LENGTH2);
|
|
94
|
+
const ciphertext = bytes.slice(IV_LENGTH2);
|
|
95
|
+
const raw = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, wrappingKey, ciphertext);
|
|
96
|
+
return crypto.subtle.importKey("raw", raw, { name: "AES-GCM", length: 256 }, extractable, ["encrypt", "decrypt"]);
|
|
97
|
+
}
|
|
98
|
+
async function wrapKey(passphrase, key, secretKey) {
|
|
99
|
+
if (!key.extractable) {
|
|
100
|
+
throw new Error("wrapKey: key must be extractable (extractable: true)");
|
|
101
|
+
}
|
|
102
|
+
const effective = await resolvePassphrase(passphrase, secretKey);
|
|
103
|
+
const salt = crypto.getRandomValues(new Uint8Array(SALT_LENGTH));
|
|
104
|
+
const wrappingKey = await deriveWrappingKey(effective, salt);
|
|
105
|
+
const raw = await crypto.subtle.exportKey("raw", key);
|
|
106
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH2));
|
|
107
|
+
const ciphertext = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, wrappingKey, raw);
|
|
108
|
+
const wrapped = new Uint8Array(IV_LENGTH2 + ciphertext.byteLength);
|
|
109
|
+
wrapped.set(iv, 0);
|
|
110
|
+
wrapped.set(new Uint8Array(ciphertext), IV_LENGTH2);
|
|
111
|
+
return { wrappedKey: wrapped.buffer.slice(wrapped.byteOffset, wrapped.byteOffset + wrapped.byteLength), salt };
|
|
112
|
+
}
|
|
113
|
+
async function unwrapKey(passphrase, wrappedKey, salt, secretKey, extractable = false) {
|
|
114
|
+
const effective = await resolvePassphrase(passphrase, secretKey);
|
|
115
|
+
const wrappingKey = await deriveWrappingKey(effective, salt);
|
|
116
|
+
return decryptWrappedKey(wrappingKey, wrappedKey, extractable);
|
|
117
|
+
}
|
|
118
|
+
async function rekey(oldPassphrase, newPassphrase, wrappedKey, salt, secretKey) {
|
|
119
|
+
const effectiveOld = await resolvePassphrase(oldPassphrase, secretKey);
|
|
120
|
+
const oldWrappingKey = await deriveWrappingKey(effectiveOld, salt);
|
|
121
|
+
const aek = await decryptWrappedKey(oldWrappingKey, wrappedKey, true);
|
|
122
|
+
return wrapKey(newPassphrase, aek, secretKey);
|
|
123
|
+
}
|
|
124
|
+
async function rekeySecretKey(passphrase, oldSecretKey, newSecretKey, wrappedKey, salt) {
|
|
125
|
+
if (buffersEqual(oldSecretKey, newSecretKey)) {
|
|
126
|
+
throw new Error("rekeySecretKey: oldSecretKey and newSecretKey must be different");
|
|
127
|
+
}
|
|
128
|
+
const effectiveOld = await resolvePassphrase(passphrase, oldSecretKey);
|
|
129
|
+
const oldWrappingKey = await deriveWrappingKey(effectiveOld, salt);
|
|
130
|
+
const aek = await decryptWrappedKey(oldWrappingKey, wrappedKey, true);
|
|
131
|
+
return wrapKey(passphrase, aek, newSecretKey);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/jwk.ts
|
|
135
|
+
async function exportPublicKeyAsJwk(key) {
|
|
136
|
+
return crypto.subtle.exportKey("jwk", key);
|
|
137
|
+
}
|
|
138
|
+
async function importPublicKeyFromJwk(jwk, algorithm) {
|
|
139
|
+
const algorithmParams = algorithm === "ECDH" ? { name: "ECDH", namedCurve: "P-256" } : { name: "ECDSA", namedCurve: "P-256" };
|
|
140
|
+
const usages = algorithm === "ECDSA" ? ["verify"] : [];
|
|
141
|
+
return crypto.subtle.importKey("jwk", jwk, algorithmParams, true, usages);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/ecdh.ts
|
|
145
|
+
async function generateECDHKeyPair() {
|
|
146
|
+
return crypto.subtle.generateKey(
|
|
147
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
148
|
+
true,
|
|
149
|
+
// extractable: true — public key must be exportable as JWK for the registry
|
|
150
|
+
["deriveKey"]
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
async function deriveSharedKey(privateKey, publicKey) {
|
|
154
|
+
return crypto.subtle.deriveKey(
|
|
155
|
+
{ name: "ECDH", public: publicKey },
|
|
156
|
+
privateKey,
|
|
157
|
+
{ name: "AES-GCM", length: 256 },
|
|
158
|
+
false,
|
|
159
|
+
["encrypt", "decrypt"]
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
async function sealMessage(recipientPublicKey, plaintext) {
|
|
163
|
+
if (recipientPublicKey.algorithm.name !== "ECDH") {
|
|
164
|
+
throw new TypeError(`sealMessage: expected an ECDH public key, got ${recipientPublicKey.algorithm.name}`);
|
|
165
|
+
}
|
|
166
|
+
const ephemeral = await crypto.subtle.generateKey(
|
|
167
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
168
|
+
true,
|
|
169
|
+
// extractable: true — public key must be exported as JWK to send to recipient
|
|
170
|
+
["deriveKey"]
|
|
171
|
+
);
|
|
172
|
+
const sharedKey = await deriveSharedKey(ephemeral.privateKey, recipientPublicKey);
|
|
173
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
174
|
+
const ciphertext = await crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, sharedKey, plaintext);
|
|
175
|
+
const ephemeralPublicKey = await exportPublicKeyAsJwk(ephemeral.publicKey);
|
|
176
|
+
return { ciphertext, iv, ephemeralPublicKey };
|
|
177
|
+
}
|
|
178
|
+
async function unsealMessage(recipientPrivateKey, ciphertext, iv, ephemeralPublicKey) {
|
|
179
|
+
if (recipientPrivateKey.algorithm.name !== "ECDH") {
|
|
180
|
+
throw new TypeError(`unsealMessage: expected an ECDH private key, got ${recipientPrivateKey.algorithm.name}`);
|
|
181
|
+
}
|
|
182
|
+
const ephemeralKey = await importPublicKeyFromJwk(ephemeralPublicKey, "ECDH");
|
|
183
|
+
const sharedKey = await deriveSharedKey(recipientPrivateKey, ephemeralKey);
|
|
184
|
+
return crypto.subtle.decrypt({ name: "AES-GCM", iv, tagLength: 128 }, sharedKey, ciphertext);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/ecdsa.ts
|
|
188
|
+
async function generateECDSAKeyPair() {
|
|
189
|
+
return crypto.subtle.generateKey(
|
|
190
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
191
|
+
true,
|
|
192
|
+
// extractable: true — public key must be exportable as JWK for the registry
|
|
193
|
+
["sign", "verify"]
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
async function sign(privateKey, data) {
|
|
197
|
+
if (privateKey.algorithm.name !== "ECDSA") {
|
|
198
|
+
throw new TypeError(`sign: expected an ECDSA private key, got ${privateKey.algorithm.name}`);
|
|
199
|
+
}
|
|
200
|
+
return crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, privateKey, data);
|
|
201
|
+
}
|
|
202
|
+
async function verify(publicKey, signature, data) {
|
|
203
|
+
if (publicKey.algorithm.name !== "ECDSA") {
|
|
204
|
+
throw new TypeError(`verify: expected an ECDSA public key, got ${publicKey.algorithm.name}`);
|
|
205
|
+
}
|
|
206
|
+
return crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, publicKey, signature, data);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/storage.ts
|
|
210
|
+
var DB_NAME = "conseal-keys";
|
|
211
|
+
var STORE = "keys";
|
|
212
|
+
var VERSION = 1;
|
|
213
|
+
var AEK_KEY_ID = "aek";
|
|
214
|
+
function openDb() {
|
|
215
|
+
return new Promise((resolve, reject) => {
|
|
216
|
+
const req = indexedDB.open(DB_NAME, VERSION);
|
|
217
|
+
req.onupgradeneeded = () => {
|
|
218
|
+
try {
|
|
219
|
+
req.result.createObjectStore(STORE);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
req.result.close();
|
|
222
|
+
reject(e);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
req.onsuccess = () => resolve(req.result);
|
|
226
|
+
req.onerror = () => reject(req.error);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async function saveCryptoKey(name, key) {
|
|
230
|
+
const db = await openDb();
|
|
231
|
+
try {
|
|
232
|
+
return await new Promise((resolve, reject) => {
|
|
233
|
+
const tx = db.transaction(STORE, "readwrite");
|
|
234
|
+
tx.objectStore(STORE).put(key, name);
|
|
235
|
+
tx.oncomplete = () => resolve();
|
|
236
|
+
tx.onerror = () => reject(tx.error);
|
|
237
|
+
});
|
|
238
|
+
} finally {
|
|
239
|
+
db.close();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async function loadCryptoKey(name) {
|
|
243
|
+
const db = await openDb();
|
|
244
|
+
try {
|
|
245
|
+
return await new Promise((resolve, reject) => {
|
|
246
|
+
const tx = db.transaction(STORE, "readonly");
|
|
247
|
+
const req = tx.objectStore(STORE).get(name);
|
|
248
|
+
let result = null;
|
|
249
|
+
req.onsuccess = () => {
|
|
250
|
+
result = req.result ?? null;
|
|
251
|
+
};
|
|
252
|
+
tx.oncomplete = () => resolve(result);
|
|
253
|
+
tx.onerror = () => reject(tx.error);
|
|
254
|
+
});
|
|
255
|
+
} finally {
|
|
256
|
+
db.close();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async function deleteCryptoKey(name) {
|
|
260
|
+
const db = await openDb();
|
|
261
|
+
try {
|
|
262
|
+
return await new Promise((resolve, reject) => {
|
|
263
|
+
const tx = db.transaction(STORE, "readwrite");
|
|
264
|
+
tx.objectStore(STORE).delete(name);
|
|
265
|
+
tx.oncomplete = () => resolve();
|
|
266
|
+
tx.onerror = () => reject(tx.error);
|
|
267
|
+
});
|
|
268
|
+
} finally {
|
|
269
|
+
db.close();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/init.ts
|
|
274
|
+
async function init(wrappedKey, salt, passphrase, secretKey) {
|
|
275
|
+
const aek = await unwrapKey(passphrase, wrappedKey, salt, secretKey);
|
|
276
|
+
await saveCryptoKey(AEK_KEY_ID, aek);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// node_modules/@noble/hashes/utils.js
|
|
280
|
+
function isBytes(a) {
|
|
281
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
282
|
+
}
|
|
283
|
+
function abytes(value, length, title = "") {
|
|
284
|
+
const bytes = isBytes(value);
|
|
285
|
+
const len = value?.length;
|
|
286
|
+
const needsLen = length !== void 0;
|
|
287
|
+
if (!bytes || needsLen && len !== length) {
|
|
288
|
+
const prefix = title && `"${title}" `;
|
|
289
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
290
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
291
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
292
|
+
}
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
function aexists(instance, checkFinished = true) {
|
|
296
|
+
if (instance.destroyed)
|
|
297
|
+
throw new Error("Hash instance has been destroyed");
|
|
298
|
+
if (checkFinished && instance.finished)
|
|
299
|
+
throw new Error("Hash#digest() has already been called");
|
|
300
|
+
}
|
|
301
|
+
function aoutput(out, instance) {
|
|
302
|
+
abytes(out, void 0, "digestInto() output");
|
|
303
|
+
const min = instance.outputLen;
|
|
304
|
+
if (out.length < min) {
|
|
305
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function clean(...arrays) {
|
|
309
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
310
|
+
arrays[i].fill(0);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function createView(arr) {
|
|
314
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
315
|
+
}
|
|
316
|
+
function rotr(word, shift) {
|
|
317
|
+
return word << 32 - shift | word >>> shift;
|
|
318
|
+
}
|
|
319
|
+
function createHasher(hashCons, info = {}) {
|
|
320
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
321
|
+
const tmp = hashCons(void 0);
|
|
322
|
+
hashC.outputLen = tmp.outputLen;
|
|
323
|
+
hashC.blockLen = tmp.blockLen;
|
|
324
|
+
hashC.create = (opts) => hashCons(opts);
|
|
325
|
+
Object.assign(hashC, info);
|
|
326
|
+
return Object.freeze(hashC);
|
|
327
|
+
}
|
|
328
|
+
var oidNist = (suffix) => ({
|
|
329
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// node_modules/@noble/hashes/_md.js
|
|
333
|
+
function Chi(a, b, c) {
|
|
334
|
+
return a & b ^ ~a & c;
|
|
335
|
+
}
|
|
336
|
+
function Maj(a, b, c) {
|
|
337
|
+
return a & b ^ a & c ^ b & c;
|
|
338
|
+
}
|
|
339
|
+
var HashMD = class {
|
|
340
|
+
blockLen;
|
|
341
|
+
outputLen;
|
|
342
|
+
padOffset;
|
|
343
|
+
isLE;
|
|
344
|
+
// For partial updates less than block size
|
|
345
|
+
buffer;
|
|
346
|
+
view;
|
|
347
|
+
finished = false;
|
|
348
|
+
length = 0;
|
|
349
|
+
pos = 0;
|
|
350
|
+
destroyed = false;
|
|
351
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
352
|
+
this.blockLen = blockLen;
|
|
353
|
+
this.outputLen = outputLen;
|
|
354
|
+
this.padOffset = padOffset;
|
|
355
|
+
this.isLE = isLE;
|
|
356
|
+
this.buffer = new Uint8Array(blockLen);
|
|
357
|
+
this.view = createView(this.buffer);
|
|
358
|
+
}
|
|
359
|
+
update(data) {
|
|
360
|
+
aexists(this);
|
|
361
|
+
abytes(data);
|
|
362
|
+
const { view, buffer, blockLen } = this;
|
|
363
|
+
const len = data.length;
|
|
364
|
+
for (let pos = 0; pos < len; ) {
|
|
365
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
366
|
+
if (take === blockLen) {
|
|
367
|
+
const dataView = createView(data);
|
|
368
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
369
|
+
this.process(dataView, pos);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
373
|
+
this.pos += take;
|
|
374
|
+
pos += take;
|
|
375
|
+
if (this.pos === blockLen) {
|
|
376
|
+
this.process(view, 0);
|
|
377
|
+
this.pos = 0;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
this.length += data.length;
|
|
381
|
+
this.roundClean();
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
digestInto(out) {
|
|
385
|
+
aexists(this);
|
|
386
|
+
aoutput(out, this);
|
|
387
|
+
this.finished = true;
|
|
388
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
389
|
+
let { pos } = this;
|
|
390
|
+
buffer[pos++] = 128;
|
|
391
|
+
clean(this.buffer.subarray(pos));
|
|
392
|
+
if (this.padOffset > blockLen - pos) {
|
|
393
|
+
this.process(view, 0);
|
|
394
|
+
pos = 0;
|
|
395
|
+
}
|
|
396
|
+
for (let i = pos; i < blockLen; i++)
|
|
397
|
+
buffer[i] = 0;
|
|
398
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
399
|
+
this.process(view, 0);
|
|
400
|
+
const oview = createView(out);
|
|
401
|
+
const len = this.outputLen;
|
|
402
|
+
if (len % 4)
|
|
403
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
404
|
+
const outLen = len / 4;
|
|
405
|
+
const state = this.get();
|
|
406
|
+
if (outLen > state.length)
|
|
407
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
408
|
+
for (let i = 0; i < outLen; i++)
|
|
409
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
410
|
+
}
|
|
411
|
+
digest() {
|
|
412
|
+
const { buffer, outputLen } = this;
|
|
413
|
+
this.digestInto(buffer);
|
|
414
|
+
const res = buffer.slice(0, outputLen);
|
|
415
|
+
this.destroy();
|
|
416
|
+
return res;
|
|
417
|
+
}
|
|
418
|
+
_cloneInto(to) {
|
|
419
|
+
to ||= new this.constructor();
|
|
420
|
+
to.set(...this.get());
|
|
421
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
422
|
+
to.destroyed = destroyed;
|
|
423
|
+
to.finished = finished;
|
|
424
|
+
to.length = length;
|
|
425
|
+
to.pos = pos;
|
|
426
|
+
if (length % blockLen)
|
|
427
|
+
to.buffer.set(buffer);
|
|
428
|
+
return to;
|
|
429
|
+
}
|
|
430
|
+
clone() {
|
|
431
|
+
return this._cloneInto();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
435
|
+
1779033703,
|
|
436
|
+
3144134277,
|
|
437
|
+
1013904242,
|
|
438
|
+
2773480762,
|
|
439
|
+
1359893119,
|
|
440
|
+
2600822924,
|
|
441
|
+
528734635,
|
|
442
|
+
1541459225
|
|
443
|
+
]);
|
|
444
|
+
|
|
445
|
+
// node_modules/@noble/hashes/sha2.js
|
|
446
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
447
|
+
1116352408,
|
|
448
|
+
1899447441,
|
|
449
|
+
3049323471,
|
|
450
|
+
3921009573,
|
|
451
|
+
961987163,
|
|
452
|
+
1508970993,
|
|
453
|
+
2453635748,
|
|
454
|
+
2870763221,
|
|
455
|
+
3624381080,
|
|
456
|
+
310598401,
|
|
457
|
+
607225278,
|
|
458
|
+
1426881987,
|
|
459
|
+
1925078388,
|
|
460
|
+
2162078206,
|
|
461
|
+
2614888103,
|
|
462
|
+
3248222580,
|
|
463
|
+
3835390401,
|
|
464
|
+
4022224774,
|
|
465
|
+
264347078,
|
|
466
|
+
604807628,
|
|
467
|
+
770255983,
|
|
468
|
+
1249150122,
|
|
469
|
+
1555081692,
|
|
470
|
+
1996064986,
|
|
471
|
+
2554220882,
|
|
472
|
+
2821834349,
|
|
473
|
+
2952996808,
|
|
474
|
+
3210313671,
|
|
475
|
+
3336571891,
|
|
476
|
+
3584528711,
|
|
477
|
+
113926993,
|
|
478
|
+
338241895,
|
|
479
|
+
666307205,
|
|
480
|
+
773529912,
|
|
481
|
+
1294757372,
|
|
482
|
+
1396182291,
|
|
483
|
+
1695183700,
|
|
484
|
+
1986661051,
|
|
485
|
+
2177026350,
|
|
486
|
+
2456956037,
|
|
487
|
+
2730485921,
|
|
488
|
+
2820302411,
|
|
489
|
+
3259730800,
|
|
490
|
+
3345764771,
|
|
491
|
+
3516065817,
|
|
492
|
+
3600352804,
|
|
493
|
+
4094571909,
|
|
494
|
+
275423344,
|
|
495
|
+
430227734,
|
|
496
|
+
506948616,
|
|
497
|
+
659060556,
|
|
498
|
+
883997877,
|
|
499
|
+
958139571,
|
|
500
|
+
1322822218,
|
|
501
|
+
1537002063,
|
|
502
|
+
1747873779,
|
|
503
|
+
1955562222,
|
|
504
|
+
2024104815,
|
|
505
|
+
2227730452,
|
|
506
|
+
2361852424,
|
|
507
|
+
2428436474,
|
|
508
|
+
2756734187,
|
|
509
|
+
3204031479,
|
|
510
|
+
3329325298
|
|
511
|
+
]);
|
|
512
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
513
|
+
var SHA2_32B = class extends HashMD {
|
|
514
|
+
constructor(outputLen) {
|
|
515
|
+
super(64, outputLen, 8, false);
|
|
516
|
+
}
|
|
517
|
+
get() {
|
|
518
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
519
|
+
return [A, B, C, D, E, F, G, H];
|
|
520
|
+
}
|
|
521
|
+
// prettier-ignore
|
|
522
|
+
set(A, B, C, D, E, F, G, H) {
|
|
523
|
+
this.A = A | 0;
|
|
524
|
+
this.B = B | 0;
|
|
525
|
+
this.C = C | 0;
|
|
526
|
+
this.D = D | 0;
|
|
527
|
+
this.E = E | 0;
|
|
528
|
+
this.F = F | 0;
|
|
529
|
+
this.G = G | 0;
|
|
530
|
+
this.H = H | 0;
|
|
531
|
+
}
|
|
532
|
+
process(view, offset) {
|
|
533
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
534
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
535
|
+
for (let i = 16; i < 64; i++) {
|
|
536
|
+
const W15 = SHA256_W[i - 15];
|
|
537
|
+
const W2 = SHA256_W[i - 2];
|
|
538
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
539
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
540
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
541
|
+
}
|
|
542
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
543
|
+
for (let i = 0; i < 64; i++) {
|
|
544
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
545
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
546
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
547
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
548
|
+
H = G;
|
|
549
|
+
G = F;
|
|
550
|
+
F = E;
|
|
551
|
+
E = D + T1 | 0;
|
|
552
|
+
D = C;
|
|
553
|
+
C = B;
|
|
554
|
+
B = A;
|
|
555
|
+
A = T1 + T2 | 0;
|
|
556
|
+
}
|
|
557
|
+
A = A + this.A | 0;
|
|
558
|
+
B = B + this.B | 0;
|
|
559
|
+
C = C + this.C | 0;
|
|
560
|
+
D = D + this.D | 0;
|
|
561
|
+
E = E + this.E | 0;
|
|
562
|
+
F = F + this.F | 0;
|
|
563
|
+
G = G + this.G | 0;
|
|
564
|
+
H = H + this.H | 0;
|
|
565
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
566
|
+
}
|
|
567
|
+
roundClean() {
|
|
568
|
+
clean(SHA256_W);
|
|
569
|
+
}
|
|
570
|
+
destroy() {
|
|
571
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
572
|
+
clean(this.buffer);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
var _SHA256 = class extends SHA2_32B {
|
|
576
|
+
// We cannot use array here since array allows indexing by variable
|
|
577
|
+
// which means optimizer/compiler cannot use registers.
|
|
578
|
+
A = SHA256_IV[0] | 0;
|
|
579
|
+
B = SHA256_IV[1] | 0;
|
|
580
|
+
C = SHA256_IV[2] | 0;
|
|
581
|
+
D = SHA256_IV[3] | 0;
|
|
582
|
+
E = SHA256_IV[4] | 0;
|
|
583
|
+
F = SHA256_IV[5] | 0;
|
|
584
|
+
G = SHA256_IV[6] | 0;
|
|
585
|
+
H = SHA256_IV[7] | 0;
|
|
586
|
+
constructor() {
|
|
587
|
+
super(32);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
var sha256 = /* @__PURE__ */ createHasher(
|
|
591
|
+
() => new _SHA256(),
|
|
592
|
+
/* @__PURE__ */ oidNist(1)
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
// node_modules/@scure/base/index.js
|
|
596
|
+
function isBytes2(a) {
|
|
597
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
598
|
+
}
|
|
599
|
+
function isArrayOf(isString, arr) {
|
|
600
|
+
if (!Array.isArray(arr))
|
|
601
|
+
return false;
|
|
602
|
+
if (arr.length === 0)
|
|
603
|
+
return true;
|
|
604
|
+
if (isString) {
|
|
605
|
+
return arr.every((item) => typeof item === "string");
|
|
606
|
+
} else {
|
|
607
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function afn(input) {
|
|
611
|
+
if (typeof input !== "function")
|
|
612
|
+
throw new Error("function expected");
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
function astr(label, input) {
|
|
616
|
+
if (typeof input !== "string")
|
|
617
|
+
throw new Error(`${label}: string expected`);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
function anumber(n) {
|
|
621
|
+
if (!Number.isSafeInteger(n))
|
|
622
|
+
throw new Error(`invalid integer: ${n}`);
|
|
623
|
+
}
|
|
624
|
+
function aArr(input) {
|
|
625
|
+
if (!Array.isArray(input))
|
|
626
|
+
throw new Error("array expected");
|
|
627
|
+
}
|
|
628
|
+
function astrArr(label, input) {
|
|
629
|
+
if (!isArrayOf(true, input))
|
|
630
|
+
throw new Error(`${label}: array of strings expected`);
|
|
631
|
+
}
|
|
632
|
+
function anumArr(label, input) {
|
|
633
|
+
if (!isArrayOf(false, input))
|
|
634
|
+
throw new Error(`${label}: array of numbers expected`);
|
|
635
|
+
}
|
|
636
|
+
// @__NO_SIDE_EFFECTS__
|
|
637
|
+
function chain(...args) {
|
|
638
|
+
const id = (a) => a;
|
|
639
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
640
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
641
|
+
const decode = args.map((x) => x.decode).reduce(wrap, id);
|
|
642
|
+
return { encode, decode };
|
|
643
|
+
}
|
|
644
|
+
// @__NO_SIDE_EFFECTS__
|
|
645
|
+
function alphabet(letters) {
|
|
646
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
647
|
+
const len = lettersA.length;
|
|
648
|
+
astrArr("alphabet", lettersA);
|
|
649
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
650
|
+
return {
|
|
651
|
+
encode: (digits) => {
|
|
652
|
+
aArr(digits);
|
|
653
|
+
return digits.map((i) => {
|
|
654
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
|
655
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
656
|
+
return lettersA[i];
|
|
657
|
+
});
|
|
658
|
+
},
|
|
659
|
+
decode: (input) => {
|
|
660
|
+
aArr(input);
|
|
661
|
+
return input.map((letter) => {
|
|
662
|
+
astr("alphabet.decode", letter);
|
|
663
|
+
const i = indexes.get(letter);
|
|
664
|
+
if (i === void 0)
|
|
665
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
666
|
+
return i;
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
// @__NO_SIDE_EFFECTS__
|
|
672
|
+
function join(separator = "") {
|
|
673
|
+
astr("join", separator);
|
|
674
|
+
return {
|
|
675
|
+
encode: (from) => {
|
|
676
|
+
astrArr("join.decode", from);
|
|
677
|
+
return from.join(separator);
|
|
678
|
+
},
|
|
679
|
+
decode: (to) => {
|
|
680
|
+
astr("join.decode", to);
|
|
681
|
+
return to.split(separator);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
// @__NO_SIDE_EFFECTS__
|
|
686
|
+
function padding(bits, chr = "=") {
|
|
687
|
+
anumber(bits);
|
|
688
|
+
astr("padding", chr);
|
|
689
|
+
return {
|
|
690
|
+
encode(data) {
|
|
691
|
+
astrArr("padding.encode", data);
|
|
692
|
+
while (data.length * bits % 8)
|
|
693
|
+
data.push(chr);
|
|
694
|
+
return data;
|
|
695
|
+
},
|
|
696
|
+
decode(input) {
|
|
697
|
+
astrArr("padding.decode", input);
|
|
698
|
+
let end = input.length;
|
|
699
|
+
if (end * bits % 8)
|
|
700
|
+
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
701
|
+
for (; end > 0 && input[end - 1] === chr; end--) {
|
|
702
|
+
const last = end - 1;
|
|
703
|
+
const byte = last * bits;
|
|
704
|
+
if (byte % 8 === 0)
|
|
705
|
+
throw new Error("padding: invalid, string has too much padding");
|
|
706
|
+
}
|
|
707
|
+
return input.slice(0, end);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function convertRadix(data, from, to) {
|
|
712
|
+
if (from < 2)
|
|
713
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
714
|
+
if (to < 2)
|
|
715
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
716
|
+
aArr(data);
|
|
717
|
+
if (!data.length)
|
|
718
|
+
return [];
|
|
719
|
+
let pos = 0;
|
|
720
|
+
const res = [];
|
|
721
|
+
const digits = Array.from(data, (d) => {
|
|
722
|
+
anumber(d);
|
|
723
|
+
if (d < 0 || d >= from)
|
|
724
|
+
throw new Error(`invalid integer: ${d}`);
|
|
725
|
+
return d;
|
|
726
|
+
});
|
|
727
|
+
const dlen = digits.length;
|
|
728
|
+
while (true) {
|
|
729
|
+
let carry = 0;
|
|
730
|
+
let done = true;
|
|
731
|
+
for (let i = pos; i < dlen; i++) {
|
|
732
|
+
const digit = digits[i];
|
|
733
|
+
const fromCarry = from * carry;
|
|
734
|
+
const digitBase = fromCarry + digit;
|
|
735
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
|
736
|
+
throw new Error("convertRadix: carry overflow");
|
|
737
|
+
}
|
|
738
|
+
const div = digitBase / to;
|
|
739
|
+
carry = digitBase % to;
|
|
740
|
+
const rounded = Math.floor(div);
|
|
741
|
+
digits[i] = rounded;
|
|
742
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
743
|
+
throw new Error("convertRadix: carry overflow");
|
|
744
|
+
if (!done)
|
|
745
|
+
continue;
|
|
746
|
+
else if (!rounded)
|
|
747
|
+
pos = i;
|
|
748
|
+
else
|
|
749
|
+
done = false;
|
|
750
|
+
}
|
|
751
|
+
res.push(carry);
|
|
752
|
+
if (done)
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
|
756
|
+
res.push(0);
|
|
757
|
+
return res.reverse();
|
|
758
|
+
}
|
|
759
|
+
var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
760
|
+
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
|
|
761
|
+
var powers = /* @__PURE__ */ (() => {
|
|
762
|
+
let res = [];
|
|
763
|
+
for (let i = 0; i < 40; i++)
|
|
764
|
+
res.push(2 ** i);
|
|
765
|
+
return res;
|
|
766
|
+
})();
|
|
767
|
+
function convertRadix2(data, from, to, padding2) {
|
|
768
|
+
aArr(data);
|
|
769
|
+
if (from <= 0 || from > 32)
|
|
770
|
+
throw new Error(`convertRadix2: wrong from=${from}`);
|
|
771
|
+
if (to <= 0 || to > 32)
|
|
772
|
+
throw new Error(`convertRadix2: wrong to=${to}`);
|
|
773
|
+
if (/* @__PURE__ */ radix2carry(from, to) > 32) {
|
|
774
|
+
throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
|
|
775
|
+
}
|
|
776
|
+
let carry = 0;
|
|
777
|
+
let pos = 0;
|
|
778
|
+
const max = powers[from];
|
|
779
|
+
const mask = powers[to] - 1;
|
|
780
|
+
const res = [];
|
|
781
|
+
for (const n of data) {
|
|
782
|
+
anumber(n);
|
|
783
|
+
if (n >= max)
|
|
784
|
+
throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
|
|
785
|
+
carry = carry << from | n;
|
|
786
|
+
if (pos + from > 32)
|
|
787
|
+
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
|
|
788
|
+
pos += from;
|
|
789
|
+
for (; pos >= to; pos -= to)
|
|
790
|
+
res.push((carry >> pos - to & mask) >>> 0);
|
|
791
|
+
const pow = powers[pos];
|
|
792
|
+
if (pow === void 0)
|
|
793
|
+
throw new Error("invalid carry");
|
|
794
|
+
carry &= pow - 1;
|
|
795
|
+
}
|
|
796
|
+
carry = carry << to - pos & mask;
|
|
797
|
+
if (!padding2 && pos >= from)
|
|
798
|
+
throw new Error("Excess padding");
|
|
799
|
+
if (!padding2 && carry > 0)
|
|
800
|
+
throw new Error(`Non-zero padding: ${carry}`);
|
|
801
|
+
if (padding2 && pos > 0)
|
|
802
|
+
res.push(carry >>> 0);
|
|
803
|
+
return res;
|
|
804
|
+
}
|
|
805
|
+
// @__NO_SIDE_EFFECTS__
|
|
806
|
+
function radix(num) {
|
|
807
|
+
anumber(num);
|
|
808
|
+
const _256 = 2 ** 8;
|
|
809
|
+
return {
|
|
810
|
+
encode: (bytes) => {
|
|
811
|
+
if (!isBytes2(bytes))
|
|
812
|
+
throw new Error("radix.encode input should be Uint8Array");
|
|
813
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
814
|
+
},
|
|
815
|
+
decode: (digits) => {
|
|
816
|
+
anumArr("radix.decode", digits);
|
|
817
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
// @__NO_SIDE_EFFECTS__
|
|
822
|
+
function radix2(bits, revPadding = false) {
|
|
823
|
+
anumber(bits);
|
|
824
|
+
if (bits <= 0 || bits > 32)
|
|
825
|
+
throw new Error("radix2: bits should be in (0..32]");
|
|
826
|
+
if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
|
|
827
|
+
throw new Error("radix2: carry overflow");
|
|
828
|
+
return {
|
|
829
|
+
encode: (bytes) => {
|
|
830
|
+
if (!isBytes2(bytes))
|
|
831
|
+
throw new Error("radix2.encode input should be Uint8Array");
|
|
832
|
+
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
|
|
833
|
+
},
|
|
834
|
+
decode: (digits) => {
|
|
835
|
+
anumArr("radix2.decode", digits);
|
|
836
|
+
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function checksum(len, fn) {
|
|
841
|
+
anumber(len);
|
|
842
|
+
afn(fn);
|
|
843
|
+
return {
|
|
844
|
+
encode(data) {
|
|
845
|
+
if (!isBytes2(data))
|
|
846
|
+
throw new Error("checksum.encode: input should be Uint8Array");
|
|
847
|
+
const sum = fn(data).slice(0, len);
|
|
848
|
+
const res = new Uint8Array(data.length + len);
|
|
849
|
+
res.set(data);
|
|
850
|
+
res.set(sum, data.length);
|
|
851
|
+
return res;
|
|
852
|
+
},
|
|
853
|
+
decode(data) {
|
|
854
|
+
if (!isBytes2(data))
|
|
855
|
+
throw new Error("checksum.decode: input should be Uint8Array");
|
|
856
|
+
const payload = data.slice(0, -len);
|
|
857
|
+
const oldChecksum = data.slice(-len);
|
|
858
|
+
const newChecksum = fn(payload).slice(0, len);
|
|
859
|
+
for (let i = 0; i < len; i++)
|
|
860
|
+
if (newChecksum[i] !== oldChecksum[i])
|
|
861
|
+
throw new Error("Invalid checksum");
|
|
862
|
+
return payload;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
var utils = {
|
|
867
|
+
alphabet,
|
|
868
|
+
chain,
|
|
869
|
+
checksum,
|
|
870
|
+
convertRadix,
|
|
871
|
+
convertRadix2,
|
|
872
|
+
radix,
|
|
873
|
+
radix2,
|
|
874
|
+
join,
|
|
875
|
+
padding
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// node_modules/@scure/bip39/index.js
|
|
879
|
+
var isJapanese = (wordlist2) => wordlist2[0] === "\u3042\u3044\u3053\u304F\u3057\u3093";
|
|
880
|
+
function nfkd(str) {
|
|
881
|
+
if (typeof str !== "string")
|
|
882
|
+
throw new TypeError("invalid mnemonic type: " + typeof str);
|
|
883
|
+
return str.normalize("NFKD");
|
|
884
|
+
}
|
|
885
|
+
function normalize(str) {
|
|
886
|
+
const norm = nfkd(str);
|
|
887
|
+
const words = norm.split(" ");
|
|
888
|
+
if (![12, 15, 18, 21, 24].includes(words.length))
|
|
889
|
+
throw new Error("Invalid mnemonic");
|
|
890
|
+
return { nfkd: norm, words };
|
|
891
|
+
}
|
|
892
|
+
function aentropy(ent) {
|
|
893
|
+
abytes(ent);
|
|
894
|
+
if (![16, 20, 24, 28, 32].includes(ent.length))
|
|
895
|
+
throw new Error("invalid entropy length");
|
|
896
|
+
}
|
|
897
|
+
var calcChecksum = (entropy) => {
|
|
898
|
+
const bitsLeft = 8 - entropy.length / 4;
|
|
899
|
+
return new Uint8Array([sha256(entropy)[0] >> bitsLeft << bitsLeft]);
|
|
900
|
+
};
|
|
901
|
+
function getCoder(wordlist2) {
|
|
902
|
+
if (!Array.isArray(wordlist2) || wordlist2.length !== 2048 || typeof wordlist2[0] !== "string")
|
|
903
|
+
throw new Error("Wordlist: expected array of 2048 strings");
|
|
904
|
+
wordlist2.forEach((i) => {
|
|
905
|
+
if (typeof i !== "string")
|
|
906
|
+
throw new Error("wordlist: non-string element: " + i);
|
|
907
|
+
});
|
|
908
|
+
return utils.chain(utils.checksum(1, calcChecksum), utils.radix2(11, true), utils.alphabet(wordlist2));
|
|
909
|
+
}
|
|
910
|
+
function mnemonicToEntropy(mnemonic, wordlist2) {
|
|
911
|
+
const { words } = normalize(mnemonic);
|
|
912
|
+
const entropy = getCoder(wordlist2).decode(words);
|
|
913
|
+
aentropy(entropy);
|
|
914
|
+
return entropy;
|
|
915
|
+
}
|
|
916
|
+
function entropyToMnemonic(entropy, wordlist2) {
|
|
917
|
+
aentropy(entropy);
|
|
918
|
+
const words = getCoder(wordlist2).encode(entropy);
|
|
919
|
+
return words.join(isJapanese(wordlist2) ? "\u3000" : " ");
|
|
920
|
+
}
|
|
921
|
+
function validateMnemonic(mnemonic, wordlist2) {
|
|
922
|
+
try {
|
|
923
|
+
mnemonicToEntropy(mnemonic, wordlist2);
|
|
924
|
+
} catch (e) {
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// node_modules/@scure/bip39/wordlists/english.js
|
|
931
|
+
var wordlist = `abandon
|
|
932
|
+
ability
|
|
933
|
+
able
|
|
934
|
+
about
|
|
935
|
+
above
|
|
936
|
+
absent
|
|
937
|
+
absorb
|
|
938
|
+
abstract
|
|
939
|
+
absurd
|
|
940
|
+
abuse
|
|
941
|
+
access
|
|
942
|
+
accident
|
|
943
|
+
account
|
|
944
|
+
accuse
|
|
945
|
+
achieve
|
|
946
|
+
acid
|
|
947
|
+
acoustic
|
|
948
|
+
acquire
|
|
949
|
+
across
|
|
950
|
+
act
|
|
951
|
+
action
|
|
952
|
+
actor
|
|
953
|
+
actress
|
|
954
|
+
actual
|
|
955
|
+
adapt
|
|
956
|
+
add
|
|
957
|
+
addict
|
|
958
|
+
address
|
|
959
|
+
adjust
|
|
960
|
+
admit
|
|
961
|
+
adult
|
|
962
|
+
advance
|
|
963
|
+
advice
|
|
964
|
+
aerobic
|
|
965
|
+
affair
|
|
966
|
+
afford
|
|
967
|
+
afraid
|
|
968
|
+
again
|
|
969
|
+
age
|
|
970
|
+
agent
|
|
971
|
+
agree
|
|
972
|
+
ahead
|
|
973
|
+
aim
|
|
974
|
+
air
|
|
975
|
+
airport
|
|
976
|
+
aisle
|
|
977
|
+
alarm
|
|
978
|
+
album
|
|
979
|
+
alcohol
|
|
980
|
+
alert
|
|
981
|
+
alien
|
|
982
|
+
all
|
|
983
|
+
alley
|
|
984
|
+
allow
|
|
985
|
+
almost
|
|
986
|
+
alone
|
|
987
|
+
alpha
|
|
988
|
+
already
|
|
989
|
+
also
|
|
990
|
+
alter
|
|
991
|
+
always
|
|
992
|
+
amateur
|
|
993
|
+
amazing
|
|
994
|
+
among
|
|
995
|
+
amount
|
|
996
|
+
amused
|
|
997
|
+
analyst
|
|
998
|
+
anchor
|
|
999
|
+
ancient
|
|
1000
|
+
anger
|
|
1001
|
+
angle
|
|
1002
|
+
angry
|
|
1003
|
+
animal
|
|
1004
|
+
ankle
|
|
1005
|
+
announce
|
|
1006
|
+
annual
|
|
1007
|
+
another
|
|
1008
|
+
answer
|
|
1009
|
+
antenna
|
|
1010
|
+
antique
|
|
1011
|
+
anxiety
|
|
1012
|
+
any
|
|
1013
|
+
apart
|
|
1014
|
+
apology
|
|
1015
|
+
appear
|
|
1016
|
+
apple
|
|
1017
|
+
approve
|
|
1018
|
+
april
|
|
1019
|
+
arch
|
|
1020
|
+
arctic
|
|
1021
|
+
area
|
|
1022
|
+
arena
|
|
1023
|
+
argue
|
|
1024
|
+
arm
|
|
1025
|
+
armed
|
|
1026
|
+
armor
|
|
1027
|
+
army
|
|
1028
|
+
around
|
|
1029
|
+
arrange
|
|
1030
|
+
arrest
|
|
1031
|
+
arrive
|
|
1032
|
+
arrow
|
|
1033
|
+
art
|
|
1034
|
+
artefact
|
|
1035
|
+
artist
|
|
1036
|
+
artwork
|
|
1037
|
+
ask
|
|
1038
|
+
aspect
|
|
1039
|
+
assault
|
|
1040
|
+
asset
|
|
1041
|
+
assist
|
|
1042
|
+
assume
|
|
1043
|
+
asthma
|
|
1044
|
+
athlete
|
|
1045
|
+
atom
|
|
1046
|
+
attack
|
|
1047
|
+
attend
|
|
1048
|
+
attitude
|
|
1049
|
+
attract
|
|
1050
|
+
auction
|
|
1051
|
+
audit
|
|
1052
|
+
august
|
|
1053
|
+
aunt
|
|
1054
|
+
author
|
|
1055
|
+
auto
|
|
1056
|
+
autumn
|
|
1057
|
+
average
|
|
1058
|
+
avocado
|
|
1059
|
+
avoid
|
|
1060
|
+
awake
|
|
1061
|
+
aware
|
|
1062
|
+
away
|
|
1063
|
+
awesome
|
|
1064
|
+
awful
|
|
1065
|
+
awkward
|
|
1066
|
+
axis
|
|
1067
|
+
baby
|
|
1068
|
+
bachelor
|
|
1069
|
+
bacon
|
|
1070
|
+
badge
|
|
1071
|
+
bag
|
|
1072
|
+
balance
|
|
1073
|
+
balcony
|
|
1074
|
+
ball
|
|
1075
|
+
bamboo
|
|
1076
|
+
banana
|
|
1077
|
+
banner
|
|
1078
|
+
bar
|
|
1079
|
+
barely
|
|
1080
|
+
bargain
|
|
1081
|
+
barrel
|
|
1082
|
+
base
|
|
1083
|
+
basic
|
|
1084
|
+
basket
|
|
1085
|
+
battle
|
|
1086
|
+
beach
|
|
1087
|
+
bean
|
|
1088
|
+
beauty
|
|
1089
|
+
because
|
|
1090
|
+
become
|
|
1091
|
+
beef
|
|
1092
|
+
before
|
|
1093
|
+
begin
|
|
1094
|
+
behave
|
|
1095
|
+
behind
|
|
1096
|
+
believe
|
|
1097
|
+
below
|
|
1098
|
+
belt
|
|
1099
|
+
bench
|
|
1100
|
+
benefit
|
|
1101
|
+
best
|
|
1102
|
+
betray
|
|
1103
|
+
better
|
|
1104
|
+
between
|
|
1105
|
+
beyond
|
|
1106
|
+
bicycle
|
|
1107
|
+
bid
|
|
1108
|
+
bike
|
|
1109
|
+
bind
|
|
1110
|
+
biology
|
|
1111
|
+
bird
|
|
1112
|
+
birth
|
|
1113
|
+
bitter
|
|
1114
|
+
black
|
|
1115
|
+
blade
|
|
1116
|
+
blame
|
|
1117
|
+
blanket
|
|
1118
|
+
blast
|
|
1119
|
+
bleak
|
|
1120
|
+
bless
|
|
1121
|
+
blind
|
|
1122
|
+
blood
|
|
1123
|
+
blossom
|
|
1124
|
+
blouse
|
|
1125
|
+
blue
|
|
1126
|
+
blur
|
|
1127
|
+
blush
|
|
1128
|
+
board
|
|
1129
|
+
boat
|
|
1130
|
+
body
|
|
1131
|
+
boil
|
|
1132
|
+
bomb
|
|
1133
|
+
bone
|
|
1134
|
+
bonus
|
|
1135
|
+
book
|
|
1136
|
+
boost
|
|
1137
|
+
border
|
|
1138
|
+
boring
|
|
1139
|
+
borrow
|
|
1140
|
+
boss
|
|
1141
|
+
bottom
|
|
1142
|
+
bounce
|
|
1143
|
+
box
|
|
1144
|
+
boy
|
|
1145
|
+
bracket
|
|
1146
|
+
brain
|
|
1147
|
+
brand
|
|
1148
|
+
brass
|
|
1149
|
+
brave
|
|
1150
|
+
bread
|
|
1151
|
+
breeze
|
|
1152
|
+
brick
|
|
1153
|
+
bridge
|
|
1154
|
+
brief
|
|
1155
|
+
bright
|
|
1156
|
+
bring
|
|
1157
|
+
brisk
|
|
1158
|
+
broccoli
|
|
1159
|
+
broken
|
|
1160
|
+
bronze
|
|
1161
|
+
broom
|
|
1162
|
+
brother
|
|
1163
|
+
brown
|
|
1164
|
+
brush
|
|
1165
|
+
bubble
|
|
1166
|
+
buddy
|
|
1167
|
+
budget
|
|
1168
|
+
buffalo
|
|
1169
|
+
build
|
|
1170
|
+
bulb
|
|
1171
|
+
bulk
|
|
1172
|
+
bullet
|
|
1173
|
+
bundle
|
|
1174
|
+
bunker
|
|
1175
|
+
burden
|
|
1176
|
+
burger
|
|
1177
|
+
burst
|
|
1178
|
+
bus
|
|
1179
|
+
business
|
|
1180
|
+
busy
|
|
1181
|
+
butter
|
|
1182
|
+
buyer
|
|
1183
|
+
buzz
|
|
1184
|
+
cabbage
|
|
1185
|
+
cabin
|
|
1186
|
+
cable
|
|
1187
|
+
cactus
|
|
1188
|
+
cage
|
|
1189
|
+
cake
|
|
1190
|
+
call
|
|
1191
|
+
calm
|
|
1192
|
+
camera
|
|
1193
|
+
camp
|
|
1194
|
+
can
|
|
1195
|
+
canal
|
|
1196
|
+
cancel
|
|
1197
|
+
candy
|
|
1198
|
+
cannon
|
|
1199
|
+
canoe
|
|
1200
|
+
canvas
|
|
1201
|
+
canyon
|
|
1202
|
+
capable
|
|
1203
|
+
capital
|
|
1204
|
+
captain
|
|
1205
|
+
car
|
|
1206
|
+
carbon
|
|
1207
|
+
card
|
|
1208
|
+
cargo
|
|
1209
|
+
carpet
|
|
1210
|
+
carry
|
|
1211
|
+
cart
|
|
1212
|
+
case
|
|
1213
|
+
cash
|
|
1214
|
+
casino
|
|
1215
|
+
castle
|
|
1216
|
+
casual
|
|
1217
|
+
cat
|
|
1218
|
+
catalog
|
|
1219
|
+
catch
|
|
1220
|
+
category
|
|
1221
|
+
cattle
|
|
1222
|
+
caught
|
|
1223
|
+
cause
|
|
1224
|
+
caution
|
|
1225
|
+
cave
|
|
1226
|
+
ceiling
|
|
1227
|
+
celery
|
|
1228
|
+
cement
|
|
1229
|
+
census
|
|
1230
|
+
century
|
|
1231
|
+
cereal
|
|
1232
|
+
certain
|
|
1233
|
+
chair
|
|
1234
|
+
chalk
|
|
1235
|
+
champion
|
|
1236
|
+
change
|
|
1237
|
+
chaos
|
|
1238
|
+
chapter
|
|
1239
|
+
charge
|
|
1240
|
+
chase
|
|
1241
|
+
chat
|
|
1242
|
+
cheap
|
|
1243
|
+
check
|
|
1244
|
+
cheese
|
|
1245
|
+
chef
|
|
1246
|
+
cherry
|
|
1247
|
+
chest
|
|
1248
|
+
chicken
|
|
1249
|
+
chief
|
|
1250
|
+
child
|
|
1251
|
+
chimney
|
|
1252
|
+
choice
|
|
1253
|
+
choose
|
|
1254
|
+
chronic
|
|
1255
|
+
chuckle
|
|
1256
|
+
chunk
|
|
1257
|
+
churn
|
|
1258
|
+
cigar
|
|
1259
|
+
cinnamon
|
|
1260
|
+
circle
|
|
1261
|
+
citizen
|
|
1262
|
+
city
|
|
1263
|
+
civil
|
|
1264
|
+
claim
|
|
1265
|
+
clap
|
|
1266
|
+
clarify
|
|
1267
|
+
claw
|
|
1268
|
+
clay
|
|
1269
|
+
clean
|
|
1270
|
+
clerk
|
|
1271
|
+
clever
|
|
1272
|
+
click
|
|
1273
|
+
client
|
|
1274
|
+
cliff
|
|
1275
|
+
climb
|
|
1276
|
+
clinic
|
|
1277
|
+
clip
|
|
1278
|
+
clock
|
|
1279
|
+
clog
|
|
1280
|
+
close
|
|
1281
|
+
cloth
|
|
1282
|
+
cloud
|
|
1283
|
+
clown
|
|
1284
|
+
club
|
|
1285
|
+
clump
|
|
1286
|
+
cluster
|
|
1287
|
+
clutch
|
|
1288
|
+
coach
|
|
1289
|
+
coast
|
|
1290
|
+
coconut
|
|
1291
|
+
code
|
|
1292
|
+
coffee
|
|
1293
|
+
coil
|
|
1294
|
+
coin
|
|
1295
|
+
collect
|
|
1296
|
+
color
|
|
1297
|
+
column
|
|
1298
|
+
combine
|
|
1299
|
+
come
|
|
1300
|
+
comfort
|
|
1301
|
+
comic
|
|
1302
|
+
common
|
|
1303
|
+
company
|
|
1304
|
+
concert
|
|
1305
|
+
conduct
|
|
1306
|
+
confirm
|
|
1307
|
+
congress
|
|
1308
|
+
connect
|
|
1309
|
+
consider
|
|
1310
|
+
control
|
|
1311
|
+
convince
|
|
1312
|
+
cook
|
|
1313
|
+
cool
|
|
1314
|
+
copper
|
|
1315
|
+
copy
|
|
1316
|
+
coral
|
|
1317
|
+
core
|
|
1318
|
+
corn
|
|
1319
|
+
correct
|
|
1320
|
+
cost
|
|
1321
|
+
cotton
|
|
1322
|
+
couch
|
|
1323
|
+
country
|
|
1324
|
+
couple
|
|
1325
|
+
course
|
|
1326
|
+
cousin
|
|
1327
|
+
cover
|
|
1328
|
+
coyote
|
|
1329
|
+
crack
|
|
1330
|
+
cradle
|
|
1331
|
+
craft
|
|
1332
|
+
cram
|
|
1333
|
+
crane
|
|
1334
|
+
crash
|
|
1335
|
+
crater
|
|
1336
|
+
crawl
|
|
1337
|
+
crazy
|
|
1338
|
+
cream
|
|
1339
|
+
credit
|
|
1340
|
+
creek
|
|
1341
|
+
crew
|
|
1342
|
+
cricket
|
|
1343
|
+
crime
|
|
1344
|
+
crisp
|
|
1345
|
+
critic
|
|
1346
|
+
crop
|
|
1347
|
+
cross
|
|
1348
|
+
crouch
|
|
1349
|
+
crowd
|
|
1350
|
+
crucial
|
|
1351
|
+
cruel
|
|
1352
|
+
cruise
|
|
1353
|
+
crumble
|
|
1354
|
+
crunch
|
|
1355
|
+
crush
|
|
1356
|
+
cry
|
|
1357
|
+
crystal
|
|
1358
|
+
cube
|
|
1359
|
+
culture
|
|
1360
|
+
cup
|
|
1361
|
+
cupboard
|
|
1362
|
+
curious
|
|
1363
|
+
current
|
|
1364
|
+
curtain
|
|
1365
|
+
curve
|
|
1366
|
+
cushion
|
|
1367
|
+
custom
|
|
1368
|
+
cute
|
|
1369
|
+
cycle
|
|
1370
|
+
dad
|
|
1371
|
+
damage
|
|
1372
|
+
damp
|
|
1373
|
+
dance
|
|
1374
|
+
danger
|
|
1375
|
+
daring
|
|
1376
|
+
dash
|
|
1377
|
+
daughter
|
|
1378
|
+
dawn
|
|
1379
|
+
day
|
|
1380
|
+
deal
|
|
1381
|
+
debate
|
|
1382
|
+
debris
|
|
1383
|
+
decade
|
|
1384
|
+
december
|
|
1385
|
+
decide
|
|
1386
|
+
decline
|
|
1387
|
+
decorate
|
|
1388
|
+
decrease
|
|
1389
|
+
deer
|
|
1390
|
+
defense
|
|
1391
|
+
define
|
|
1392
|
+
defy
|
|
1393
|
+
degree
|
|
1394
|
+
delay
|
|
1395
|
+
deliver
|
|
1396
|
+
demand
|
|
1397
|
+
demise
|
|
1398
|
+
denial
|
|
1399
|
+
dentist
|
|
1400
|
+
deny
|
|
1401
|
+
depart
|
|
1402
|
+
depend
|
|
1403
|
+
deposit
|
|
1404
|
+
depth
|
|
1405
|
+
deputy
|
|
1406
|
+
derive
|
|
1407
|
+
describe
|
|
1408
|
+
desert
|
|
1409
|
+
design
|
|
1410
|
+
desk
|
|
1411
|
+
despair
|
|
1412
|
+
destroy
|
|
1413
|
+
detail
|
|
1414
|
+
detect
|
|
1415
|
+
develop
|
|
1416
|
+
device
|
|
1417
|
+
devote
|
|
1418
|
+
diagram
|
|
1419
|
+
dial
|
|
1420
|
+
diamond
|
|
1421
|
+
diary
|
|
1422
|
+
dice
|
|
1423
|
+
diesel
|
|
1424
|
+
diet
|
|
1425
|
+
differ
|
|
1426
|
+
digital
|
|
1427
|
+
dignity
|
|
1428
|
+
dilemma
|
|
1429
|
+
dinner
|
|
1430
|
+
dinosaur
|
|
1431
|
+
direct
|
|
1432
|
+
dirt
|
|
1433
|
+
disagree
|
|
1434
|
+
discover
|
|
1435
|
+
disease
|
|
1436
|
+
dish
|
|
1437
|
+
dismiss
|
|
1438
|
+
disorder
|
|
1439
|
+
display
|
|
1440
|
+
distance
|
|
1441
|
+
divert
|
|
1442
|
+
divide
|
|
1443
|
+
divorce
|
|
1444
|
+
dizzy
|
|
1445
|
+
doctor
|
|
1446
|
+
document
|
|
1447
|
+
dog
|
|
1448
|
+
doll
|
|
1449
|
+
dolphin
|
|
1450
|
+
domain
|
|
1451
|
+
donate
|
|
1452
|
+
donkey
|
|
1453
|
+
donor
|
|
1454
|
+
door
|
|
1455
|
+
dose
|
|
1456
|
+
double
|
|
1457
|
+
dove
|
|
1458
|
+
draft
|
|
1459
|
+
dragon
|
|
1460
|
+
drama
|
|
1461
|
+
drastic
|
|
1462
|
+
draw
|
|
1463
|
+
dream
|
|
1464
|
+
dress
|
|
1465
|
+
drift
|
|
1466
|
+
drill
|
|
1467
|
+
drink
|
|
1468
|
+
drip
|
|
1469
|
+
drive
|
|
1470
|
+
drop
|
|
1471
|
+
drum
|
|
1472
|
+
dry
|
|
1473
|
+
duck
|
|
1474
|
+
dumb
|
|
1475
|
+
dune
|
|
1476
|
+
during
|
|
1477
|
+
dust
|
|
1478
|
+
dutch
|
|
1479
|
+
duty
|
|
1480
|
+
dwarf
|
|
1481
|
+
dynamic
|
|
1482
|
+
eager
|
|
1483
|
+
eagle
|
|
1484
|
+
early
|
|
1485
|
+
earn
|
|
1486
|
+
earth
|
|
1487
|
+
easily
|
|
1488
|
+
east
|
|
1489
|
+
easy
|
|
1490
|
+
echo
|
|
1491
|
+
ecology
|
|
1492
|
+
economy
|
|
1493
|
+
edge
|
|
1494
|
+
edit
|
|
1495
|
+
educate
|
|
1496
|
+
effort
|
|
1497
|
+
egg
|
|
1498
|
+
eight
|
|
1499
|
+
either
|
|
1500
|
+
elbow
|
|
1501
|
+
elder
|
|
1502
|
+
electric
|
|
1503
|
+
elegant
|
|
1504
|
+
element
|
|
1505
|
+
elephant
|
|
1506
|
+
elevator
|
|
1507
|
+
elite
|
|
1508
|
+
else
|
|
1509
|
+
embark
|
|
1510
|
+
embody
|
|
1511
|
+
embrace
|
|
1512
|
+
emerge
|
|
1513
|
+
emotion
|
|
1514
|
+
employ
|
|
1515
|
+
empower
|
|
1516
|
+
empty
|
|
1517
|
+
enable
|
|
1518
|
+
enact
|
|
1519
|
+
end
|
|
1520
|
+
endless
|
|
1521
|
+
endorse
|
|
1522
|
+
enemy
|
|
1523
|
+
energy
|
|
1524
|
+
enforce
|
|
1525
|
+
engage
|
|
1526
|
+
engine
|
|
1527
|
+
enhance
|
|
1528
|
+
enjoy
|
|
1529
|
+
enlist
|
|
1530
|
+
enough
|
|
1531
|
+
enrich
|
|
1532
|
+
enroll
|
|
1533
|
+
ensure
|
|
1534
|
+
enter
|
|
1535
|
+
entire
|
|
1536
|
+
entry
|
|
1537
|
+
envelope
|
|
1538
|
+
episode
|
|
1539
|
+
equal
|
|
1540
|
+
equip
|
|
1541
|
+
era
|
|
1542
|
+
erase
|
|
1543
|
+
erode
|
|
1544
|
+
erosion
|
|
1545
|
+
error
|
|
1546
|
+
erupt
|
|
1547
|
+
escape
|
|
1548
|
+
essay
|
|
1549
|
+
essence
|
|
1550
|
+
estate
|
|
1551
|
+
eternal
|
|
1552
|
+
ethics
|
|
1553
|
+
evidence
|
|
1554
|
+
evil
|
|
1555
|
+
evoke
|
|
1556
|
+
evolve
|
|
1557
|
+
exact
|
|
1558
|
+
example
|
|
1559
|
+
excess
|
|
1560
|
+
exchange
|
|
1561
|
+
excite
|
|
1562
|
+
exclude
|
|
1563
|
+
excuse
|
|
1564
|
+
execute
|
|
1565
|
+
exercise
|
|
1566
|
+
exhaust
|
|
1567
|
+
exhibit
|
|
1568
|
+
exile
|
|
1569
|
+
exist
|
|
1570
|
+
exit
|
|
1571
|
+
exotic
|
|
1572
|
+
expand
|
|
1573
|
+
expect
|
|
1574
|
+
expire
|
|
1575
|
+
explain
|
|
1576
|
+
expose
|
|
1577
|
+
express
|
|
1578
|
+
extend
|
|
1579
|
+
extra
|
|
1580
|
+
eye
|
|
1581
|
+
eyebrow
|
|
1582
|
+
fabric
|
|
1583
|
+
face
|
|
1584
|
+
faculty
|
|
1585
|
+
fade
|
|
1586
|
+
faint
|
|
1587
|
+
faith
|
|
1588
|
+
fall
|
|
1589
|
+
false
|
|
1590
|
+
fame
|
|
1591
|
+
family
|
|
1592
|
+
famous
|
|
1593
|
+
fan
|
|
1594
|
+
fancy
|
|
1595
|
+
fantasy
|
|
1596
|
+
farm
|
|
1597
|
+
fashion
|
|
1598
|
+
fat
|
|
1599
|
+
fatal
|
|
1600
|
+
father
|
|
1601
|
+
fatigue
|
|
1602
|
+
fault
|
|
1603
|
+
favorite
|
|
1604
|
+
feature
|
|
1605
|
+
february
|
|
1606
|
+
federal
|
|
1607
|
+
fee
|
|
1608
|
+
feed
|
|
1609
|
+
feel
|
|
1610
|
+
female
|
|
1611
|
+
fence
|
|
1612
|
+
festival
|
|
1613
|
+
fetch
|
|
1614
|
+
fever
|
|
1615
|
+
few
|
|
1616
|
+
fiber
|
|
1617
|
+
fiction
|
|
1618
|
+
field
|
|
1619
|
+
figure
|
|
1620
|
+
file
|
|
1621
|
+
film
|
|
1622
|
+
filter
|
|
1623
|
+
final
|
|
1624
|
+
find
|
|
1625
|
+
fine
|
|
1626
|
+
finger
|
|
1627
|
+
finish
|
|
1628
|
+
fire
|
|
1629
|
+
firm
|
|
1630
|
+
first
|
|
1631
|
+
fiscal
|
|
1632
|
+
fish
|
|
1633
|
+
fit
|
|
1634
|
+
fitness
|
|
1635
|
+
fix
|
|
1636
|
+
flag
|
|
1637
|
+
flame
|
|
1638
|
+
flash
|
|
1639
|
+
flat
|
|
1640
|
+
flavor
|
|
1641
|
+
flee
|
|
1642
|
+
flight
|
|
1643
|
+
flip
|
|
1644
|
+
float
|
|
1645
|
+
flock
|
|
1646
|
+
floor
|
|
1647
|
+
flower
|
|
1648
|
+
fluid
|
|
1649
|
+
flush
|
|
1650
|
+
fly
|
|
1651
|
+
foam
|
|
1652
|
+
focus
|
|
1653
|
+
fog
|
|
1654
|
+
foil
|
|
1655
|
+
fold
|
|
1656
|
+
follow
|
|
1657
|
+
food
|
|
1658
|
+
foot
|
|
1659
|
+
force
|
|
1660
|
+
forest
|
|
1661
|
+
forget
|
|
1662
|
+
fork
|
|
1663
|
+
fortune
|
|
1664
|
+
forum
|
|
1665
|
+
forward
|
|
1666
|
+
fossil
|
|
1667
|
+
foster
|
|
1668
|
+
found
|
|
1669
|
+
fox
|
|
1670
|
+
fragile
|
|
1671
|
+
frame
|
|
1672
|
+
frequent
|
|
1673
|
+
fresh
|
|
1674
|
+
friend
|
|
1675
|
+
fringe
|
|
1676
|
+
frog
|
|
1677
|
+
front
|
|
1678
|
+
frost
|
|
1679
|
+
frown
|
|
1680
|
+
frozen
|
|
1681
|
+
fruit
|
|
1682
|
+
fuel
|
|
1683
|
+
fun
|
|
1684
|
+
funny
|
|
1685
|
+
furnace
|
|
1686
|
+
fury
|
|
1687
|
+
future
|
|
1688
|
+
gadget
|
|
1689
|
+
gain
|
|
1690
|
+
galaxy
|
|
1691
|
+
gallery
|
|
1692
|
+
game
|
|
1693
|
+
gap
|
|
1694
|
+
garage
|
|
1695
|
+
garbage
|
|
1696
|
+
garden
|
|
1697
|
+
garlic
|
|
1698
|
+
garment
|
|
1699
|
+
gas
|
|
1700
|
+
gasp
|
|
1701
|
+
gate
|
|
1702
|
+
gather
|
|
1703
|
+
gauge
|
|
1704
|
+
gaze
|
|
1705
|
+
general
|
|
1706
|
+
genius
|
|
1707
|
+
genre
|
|
1708
|
+
gentle
|
|
1709
|
+
genuine
|
|
1710
|
+
gesture
|
|
1711
|
+
ghost
|
|
1712
|
+
giant
|
|
1713
|
+
gift
|
|
1714
|
+
giggle
|
|
1715
|
+
ginger
|
|
1716
|
+
giraffe
|
|
1717
|
+
girl
|
|
1718
|
+
give
|
|
1719
|
+
glad
|
|
1720
|
+
glance
|
|
1721
|
+
glare
|
|
1722
|
+
glass
|
|
1723
|
+
glide
|
|
1724
|
+
glimpse
|
|
1725
|
+
globe
|
|
1726
|
+
gloom
|
|
1727
|
+
glory
|
|
1728
|
+
glove
|
|
1729
|
+
glow
|
|
1730
|
+
glue
|
|
1731
|
+
goat
|
|
1732
|
+
goddess
|
|
1733
|
+
gold
|
|
1734
|
+
good
|
|
1735
|
+
goose
|
|
1736
|
+
gorilla
|
|
1737
|
+
gospel
|
|
1738
|
+
gossip
|
|
1739
|
+
govern
|
|
1740
|
+
gown
|
|
1741
|
+
grab
|
|
1742
|
+
grace
|
|
1743
|
+
grain
|
|
1744
|
+
grant
|
|
1745
|
+
grape
|
|
1746
|
+
grass
|
|
1747
|
+
gravity
|
|
1748
|
+
great
|
|
1749
|
+
green
|
|
1750
|
+
grid
|
|
1751
|
+
grief
|
|
1752
|
+
grit
|
|
1753
|
+
grocery
|
|
1754
|
+
group
|
|
1755
|
+
grow
|
|
1756
|
+
grunt
|
|
1757
|
+
guard
|
|
1758
|
+
guess
|
|
1759
|
+
guide
|
|
1760
|
+
guilt
|
|
1761
|
+
guitar
|
|
1762
|
+
gun
|
|
1763
|
+
gym
|
|
1764
|
+
habit
|
|
1765
|
+
hair
|
|
1766
|
+
half
|
|
1767
|
+
hammer
|
|
1768
|
+
hamster
|
|
1769
|
+
hand
|
|
1770
|
+
happy
|
|
1771
|
+
harbor
|
|
1772
|
+
hard
|
|
1773
|
+
harsh
|
|
1774
|
+
harvest
|
|
1775
|
+
hat
|
|
1776
|
+
have
|
|
1777
|
+
hawk
|
|
1778
|
+
hazard
|
|
1779
|
+
head
|
|
1780
|
+
health
|
|
1781
|
+
heart
|
|
1782
|
+
heavy
|
|
1783
|
+
hedgehog
|
|
1784
|
+
height
|
|
1785
|
+
hello
|
|
1786
|
+
helmet
|
|
1787
|
+
help
|
|
1788
|
+
hen
|
|
1789
|
+
hero
|
|
1790
|
+
hidden
|
|
1791
|
+
high
|
|
1792
|
+
hill
|
|
1793
|
+
hint
|
|
1794
|
+
hip
|
|
1795
|
+
hire
|
|
1796
|
+
history
|
|
1797
|
+
hobby
|
|
1798
|
+
hockey
|
|
1799
|
+
hold
|
|
1800
|
+
hole
|
|
1801
|
+
holiday
|
|
1802
|
+
hollow
|
|
1803
|
+
home
|
|
1804
|
+
honey
|
|
1805
|
+
hood
|
|
1806
|
+
hope
|
|
1807
|
+
horn
|
|
1808
|
+
horror
|
|
1809
|
+
horse
|
|
1810
|
+
hospital
|
|
1811
|
+
host
|
|
1812
|
+
hotel
|
|
1813
|
+
hour
|
|
1814
|
+
hover
|
|
1815
|
+
hub
|
|
1816
|
+
huge
|
|
1817
|
+
human
|
|
1818
|
+
humble
|
|
1819
|
+
humor
|
|
1820
|
+
hundred
|
|
1821
|
+
hungry
|
|
1822
|
+
hunt
|
|
1823
|
+
hurdle
|
|
1824
|
+
hurry
|
|
1825
|
+
hurt
|
|
1826
|
+
husband
|
|
1827
|
+
hybrid
|
|
1828
|
+
ice
|
|
1829
|
+
icon
|
|
1830
|
+
idea
|
|
1831
|
+
identify
|
|
1832
|
+
idle
|
|
1833
|
+
ignore
|
|
1834
|
+
ill
|
|
1835
|
+
illegal
|
|
1836
|
+
illness
|
|
1837
|
+
image
|
|
1838
|
+
imitate
|
|
1839
|
+
immense
|
|
1840
|
+
immune
|
|
1841
|
+
impact
|
|
1842
|
+
impose
|
|
1843
|
+
improve
|
|
1844
|
+
impulse
|
|
1845
|
+
inch
|
|
1846
|
+
include
|
|
1847
|
+
income
|
|
1848
|
+
increase
|
|
1849
|
+
index
|
|
1850
|
+
indicate
|
|
1851
|
+
indoor
|
|
1852
|
+
industry
|
|
1853
|
+
infant
|
|
1854
|
+
inflict
|
|
1855
|
+
inform
|
|
1856
|
+
inhale
|
|
1857
|
+
inherit
|
|
1858
|
+
initial
|
|
1859
|
+
inject
|
|
1860
|
+
injury
|
|
1861
|
+
inmate
|
|
1862
|
+
inner
|
|
1863
|
+
innocent
|
|
1864
|
+
input
|
|
1865
|
+
inquiry
|
|
1866
|
+
insane
|
|
1867
|
+
insect
|
|
1868
|
+
inside
|
|
1869
|
+
inspire
|
|
1870
|
+
install
|
|
1871
|
+
intact
|
|
1872
|
+
interest
|
|
1873
|
+
into
|
|
1874
|
+
invest
|
|
1875
|
+
invite
|
|
1876
|
+
involve
|
|
1877
|
+
iron
|
|
1878
|
+
island
|
|
1879
|
+
isolate
|
|
1880
|
+
issue
|
|
1881
|
+
item
|
|
1882
|
+
ivory
|
|
1883
|
+
jacket
|
|
1884
|
+
jaguar
|
|
1885
|
+
jar
|
|
1886
|
+
jazz
|
|
1887
|
+
jealous
|
|
1888
|
+
jeans
|
|
1889
|
+
jelly
|
|
1890
|
+
jewel
|
|
1891
|
+
job
|
|
1892
|
+
join
|
|
1893
|
+
joke
|
|
1894
|
+
journey
|
|
1895
|
+
joy
|
|
1896
|
+
judge
|
|
1897
|
+
juice
|
|
1898
|
+
jump
|
|
1899
|
+
jungle
|
|
1900
|
+
junior
|
|
1901
|
+
junk
|
|
1902
|
+
just
|
|
1903
|
+
kangaroo
|
|
1904
|
+
keen
|
|
1905
|
+
keep
|
|
1906
|
+
ketchup
|
|
1907
|
+
key
|
|
1908
|
+
kick
|
|
1909
|
+
kid
|
|
1910
|
+
kidney
|
|
1911
|
+
kind
|
|
1912
|
+
kingdom
|
|
1913
|
+
kiss
|
|
1914
|
+
kit
|
|
1915
|
+
kitchen
|
|
1916
|
+
kite
|
|
1917
|
+
kitten
|
|
1918
|
+
kiwi
|
|
1919
|
+
knee
|
|
1920
|
+
knife
|
|
1921
|
+
knock
|
|
1922
|
+
know
|
|
1923
|
+
lab
|
|
1924
|
+
label
|
|
1925
|
+
labor
|
|
1926
|
+
ladder
|
|
1927
|
+
lady
|
|
1928
|
+
lake
|
|
1929
|
+
lamp
|
|
1930
|
+
language
|
|
1931
|
+
laptop
|
|
1932
|
+
large
|
|
1933
|
+
later
|
|
1934
|
+
latin
|
|
1935
|
+
laugh
|
|
1936
|
+
laundry
|
|
1937
|
+
lava
|
|
1938
|
+
law
|
|
1939
|
+
lawn
|
|
1940
|
+
lawsuit
|
|
1941
|
+
layer
|
|
1942
|
+
lazy
|
|
1943
|
+
leader
|
|
1944
|
+
leaf
|
|
1945
|
+
learn
|
|
1946
|
+
leave
|
|
1947
|
+
lecture
|
|
1948
|
+
left
|
|
1949
|
+
leg
|
|
1950
|
+
legal
|
|
1951
|
+
legend
|
|
1952
|
+
leisure
|
|
1953
|
+
lemon
|
|
1954
|
+
lend
|
|
1955
|
+
length
|
|
1956
|
+
lens
|
|
1957
|
+
leopard
|
|
1958
|
+
lesson
|
|
1959
|
+
letter
|
|
1960
|
+
level
|
|
1961
|
+
liar
|
|
1962
|
+
liberty
|
|
1963
|
+
library
|
|
1964
|
+
license
|
|
1965
|
+
life
|
|
1966
|
+
lift
|
|
1967
|
+
light
|
|
1968
|
+
like
|
|
1969
|
+
limb
|
|
1970
|
+
limit
|
|
1971
|
+
link
|
|
1972
|
+
lion
|
|
1973
|
+
liquid
|
|
1974
|
+
list
|
|
1975
|
+
little
|
|
1976
|
+
live
|
|
1977
|
+
lizard
|
|
1978
|
+
load
|
|
1979
|
+
loan
|
|
1980
|
+
lobster
|
|
1981
|
+
local
|
|
1982
|
+
lock
|
|
1983
|
+
logic
|
|
1984
|
+
lonely
|
|
1985
|
+
long
|
|
1986
|
+
loop
|
|
1987
|
+
lottery
|
|
1988
|
+
loud
|
|
1989
|
+
lounge
|
|
1990
|
+
love
|
|
1991
|
+
loyal
|
|
1992
|
+
lucky
|
|
1993
|
+
luggage
|
|
1994
|
+
lumber
|
|
1995
|
+
lunar
|
|
1996
|
+
lunch
|
|
1997
|
+
luxury
|
|
1998
|
+
lyrics
|
|
1999
|
+
machine
|
|
2000
|
+
mad
|
|
2001
|
+
magic
|
|
2002
|
+
magnet
|
|
2003
|
+
maid
|
|
2004
|
+
mail
|
|
2005
|
+
main
|
|
2006
|
+
major
|
|
2007
|
+
make
|
|
2008
|
+
mammal
|
|
2009
|
+
man
|
|
2010
|
+
manage
|
|
2011
|
+
mandate
|
|
2012
|
+
mango
|
|
2013
|
+
mansion
|
|
2014
|
+
manual
|
|
2015
|
+
maple
|
|
2016
|
+
marble
|
|
2017
|
+
march
|
|
2018
|
+
margin
|
|
2019
|
+
marine
|
|
2020
|
+
market
|
|
2021
|
+
marriage
|
|
2022
|
+
mask
|
|
2023
|
+
mass
|
|
2024
|
+
master
|
|
2025
|
+
match
|
|
2026
|
+
material
|
|
2027
|
+
math
|
|
2028
|
+
matrix
|
|
2029
|
+
matter
|
|
2030
|
+
maximum
|
|
2031
|
+
maze
|
|
2032
|
+
meadow
|
|
2033
|
+
mean
|
|
2034
|
+
measure
|
|
2035
|
+
meat
|
|
2036
|
+
mechanic
|
|
2037
|
+
medal
|
|
2038
|
+
media
|
|
2039
|
+
melody
|
|
2040
|
+
melt
|
|
2041
|
+
member
|
|
2042
|
+
memory
|
|
2043
|
+
mention
|
|
2044
|
+
menu
|
|
2045
|
+
mercy
|
|
2046
|
+
merge
|
|
2047
|
+
merit
|
|
2048
|
+
merry
|
|
2049
|
+
mesh
|
|
2050
|
+
message
|
|
2051
|
+
metal
|
|
2052
|
+
method
|
|
2053
|
+
middle
|
|
2054
|
+
midnight
|
|
2055
|
+
milk
|
|
2056
|
+
million
|
|
2057
|
+
mimic
|
|
2058
|
+
mind
|
|
2059
|
+
minimum
|
|
2060
|
+
minor
|
|
2061
|
+
minute
|
|
2062
|
+
miracle
|
|
2063
|
+
mirror
|
|
2064
|
+
misery
|
|
2065
|
+
miss
|
|
2066
|
+
mistake
|
|
2067
|
+
mix
|
|
2068
|
+
mixed
|
|
2069
|
+
mixture
|
|
2070
|
+
mobile
|
|
2071
|
+
model
|
|
2072
|
+
modify
|
|
2073
|
+
mom
|
|
2074
|
+
moment
|
|
2075
|
+
monitor
|
|
2076
|
+
monkey
|
|
2077
|
+
monster
|
|
2078
|
+
month
|
|
2079
|
+
moon
|
|
2080
|
+
moral
|
|
2081
|
+
more
|
|
2082
|
+
morning
|
|
2083
|
+
mosquito
|
|
2084
|
+
mother
|
|
2085
|
+
motion
|
|
2086
|
+
motor
|
|
2087
|
+
mountain
|
|
2088
|
+
mouse
|
|
2089
|
+
move
|
|
2090
|
+
movie
|
|
2091
|
+
much
|
|
2092
|
+
muffin
|
|
2093
|
+
mule
|
|
2094
|
+
multiply
|
|
2095
|
+
muscle
|
|
2096
|
+
museum
|
|
2097
|
+
mushroom
|
|
2098
|
+
music
|
|
2099
|
+
must
|
|
2100
|
+
mutual
|
|
2101
|
+
myself
|
|
2102
|
+
mystery
|
|
2103
|
+
myth
|
|
2104
|
+
naive
|
|
2105
|
+
name
|
|
2106
|
+
napkin
|
|
2107
|
+
narrow
|
|
2108
|
+
nasty
|
|
2109
|
+
nation
|
|
2110
|
+
nature
|
|
2111
|
+
near
|
|
2112
|
+
neck
|
|
2113
|
+
need
|
|
2114
|
+
negative
|
|
2115
|
+
neglect
|
|
2116
|
+
neither
|
|
2117
|
+
nephew
|
|
2118
|
+
nerve
|
|
2119
|
+
nest
|
|
2120
|
+
net
|
|
2121
|
+
network
|
|
2122
|
+
neutral
|
|
2123
|
+
never
|
|
2124
|
+
news
|
|
2125
|
+
next
|
|
2126
|
+
nice
|
|
2127
|
+
night
|
|
2128
|
+
noble
|
|
2129
|
+
noise
|
|
2130
|
+
nominee
|
|
2131
|
+
noodle
|
|
2132
|
+
normal
|
|
2133
|
+
north
|
|
2134
|
+
nose
|
|
2135
|
+
notable
|
|
2136
|
+
note
|
|
2137
|
+
nothing
|
|
2138
|
+
notice
|
|
2139
|
+
novel
|
|
2140
|
+
now
|
|
2141
|
+
nuclear
|
|
2142
|
+
number
|
|
2143
|
+
nurse
|
|
2144
|
+
nut
|
|
2145
|
+
oak
|
|
2146
|
+
obey
|
|
2147
|
+
object
|
|
2148
|
+
oblige
|
|
2149
|
+
obscure
|
|
2150
|
+
observe
|
|
2151
|
+
obtain
|
|
2152
|
+
obvious
|
|
2153
|
+
occur
|
|
2154
|
+
ocean
|
|
2155
|
+
october
|
|
2156
|
+
odor
|
|
2157
|
+
off
|
|
2158
|
+
offer
|
|
2159
|
+
office
|
|
2160
|
+
often
|
|
2161
|
+
oil
|
|
2162
|
+
okay
|
|
2163
|
+
old
|
|
2164
|
+
olive
|
|
2165
|
+
olympic
|
|
2166
|
+
omit
|
|
2167
|
+
once
|
|
2168
|
+
one
|
|
2169
|
+
onion
|
|
2170
|
+
online
|
|
2171
|
+
only
|
|
2172
|
+
open
|
|
2173
|
+
opera
|
|
2174
|
+
opinion
|
|
2175
|
+
oppose
|
|
2176
|
+
option
|
|
2177
|
+
orange
|
|
2178
|
+
orbit
|
|
2179
|
+
orchard
|
|
2180
|
+
order
|
|
2181
|
+
ordinary
|
|
2182
|
+
organ
|
|
2183
|
+
orient
|
|
2184
|
+
original
|
|
2185
|
+
orphan
|
|
2186
|
+
ostrich
|
|
2187
|
+
other
|
|
2188
|
+
outdoor
|
|
2189
|
+
outer
|
|
2190
|
+
output
|
|
2191
|
+
outside
|
|
2192
|
+
oval
|
|
2193
|
+
oven
|
|
2194
|
+
over
|
|
2195
|
+
own
|
|
2196
|
+
owner
|
|
2197
|
+
oxygen
|
|
2198
|
+
oyster
|
|
2199
|
+
ozone
|
|
2200
|
+
pact
|
|
2201
|
+
paddle
|
|
2202
|
+
page
|
|
2203
|
+
pair
|
|
2204
|
+
palace
|
|
2205
|
+
palm
|
|
2206
|
+
panda
|
|
2207
|
+
panel
|
|
2208
|
+
panic
|
|
2209
|
+
panther
|
|
2210
|
+
paper
|
|
2211
|
+
parade
|
|
2212
|
+
parent
|
|
2213
|
+
park
|
|
2214
|
+
parrot
|
|
2215
|
+
party
|
|
2216
|
+
pass
|
|
2217
|
+
patch
|
|
2218
|
+
path
|
|
2219
|
+
patient
|
|
2220
|
+
patrol
|
|
2221
|
+
pattern
|
|
2222
|
+
pause
|
|
2223
|
+
pave
|
|
2224
|
+
payment
|
|
2225
|
+
peace
|
|
2226
|
+
peanut
|
|
2227
|
+
pear
|
|
2228
|
+
peasant
|
|
2229
|
+
pelican
|
|
2230
|
+
pen
|
|
2231
|
+
penalty
|
|
2232
|
+
pencil
|
|
2233
|
+
people
|
|
2234
|
+
pepper
|
|
2235
|
+
perfect
|
|
2236
|
+
permit
|
|
2237
|
+
person
|
|
2238
|
+
pet
|
|
2239
|
+
phone
|
|
2240
|
+
photo
|
|
2241
|
+
phrase
|
|
2242
|
+
physical
|
|
2243
|
+
piano
|
|
2244
|
+
picnic
|
|
2245
|
+
picture
|
|
2246
|
+
piece
|
|
2247
|
+
pig
|
|
2248
|
+
pigeon
|
|
2249
|
+
pill
|
|
2250
|
+
pilot
|
|
2251
|
+
pink
|
|
2252
|
+
pioneer
|
|
2253
|
+
pipe
|
|
2254
|
+
pistol
|
|
2255
|
+
pitch
|
|
2256
|
+
pizza
|
|
2257
|
+
place
|
|
2258
|
+
planet
|
|
2259
|
+
plastic
|
|
2260
|
+
plate
|
|
2261
|
+
play
|
|
2262
|
+
please
|
|
2263
|
+
pledge
|
|
2264
|
+
pluck
|
|
2265
|
+
plug
|
|
2266
|
+
plunge
|
|
2267
|
+
poem
|
|
2268
|
+
poet
|
|
2269
|
+
point
|
|
2270
|
+
polar
|
|
2271
|
+
pole
|
|
2272
|
+
police
|
|
2273
|
+
pond
|
|
2274
|
+
pony
|
|
2275
|
+
pool
|
|
2276
|
+
popular
|
|
2277
|
+
portion
|
|
2278
|
+
position
|
|
2279
|
+
possible
|
|
2280
|
+
post
|
|
2281
|
+
potato
|
|
2282
|
+
pottery
|
|
2283
|
+
poverty
|
|
2284
|
+
powder
|
|
2285
|
+
power
|
|
2286
|
+
practice
|
|
2287
|
+
praise
|
|
2288
|
+
predict
|
|
2289
|
+
prefer
|
|
2290
|
+
prepare
|
|
2291
|
+
present
|
|
2292
|
+
pretty
|
|
2293
|
+
prevent
|
|
2294
|
+
price
|
|
2295
|
+
pride
|
|
2296
|
+
primary
|
|
2297
|
+
print
|
|
2298
|
+
priority
|
|
2299
|
+
prison
|
|
2300
|
+
private
|
|
2301
|
+
prize
|
|
2302
|
+
problem
|
|
2303
|
+
process
|
|
2304
|
+
produce
|
|
2305
|
+
profit
|
|
2306
|
+
program
|
|
2307
|
+
project
|
|
2308
|
+
promote
|
|
2309
|
+
proof
|
|
2310
|
+
property
|
|
2311
|
+
prosper
|
|
2312
|
+
protect
|
|
2313
|
+
proud
|
|
2314
|
+
provide
|
|
2315
|
+
public
|
|
2316
|
+
pudding
|
|
2317
|
+
pull
|
|
2318
|
+
pulp
|
|
2319
|
+
pulse
|
|
2320
|
+
pumpkin
|
|
2321
|
+
punch
|
|
2322
|
+
pupil
|
|
2323
|
+
puppy
|
|
2324
|
+
purchase
|
|
2325
|
+
purity
|
|
2326
|
+
purpose
|
|
2327
|
+
purse
|
|
2328
|
+
push
|
|
2329
|
+
put
|
|
2330
|
+
puzzle
|
|
2331
|
+
pyramid
|
|
2332
|
+
quality
|
|
2333
|
+
quantum
|
|
2334
|
+
quarter
|
|
2335
|
+
question
|
|
2336
|
+
quick
|
|
2337
|
+
quit
|
|
2338
|
+
quiz
|
|
2339
|
+
quote
|
|
2340
|
+
rabbit
|
|
2341
|
+
raccoon
|
|
2342
|
+
race
|
|
2343
|
+
rack
|
|
2344
|
+
radar
|
|
2345
|
+
radio
|
|
2346
|
+
rail
|
|
2347
|
+
rain
|
|
2348
|
+
raise
|
|
2349
|
+
rally
|
|
2350
|
+
ramp
|
|
2351
|
+
ranch
|
|
2352
|
+
random
|
|
2353
|
+
range
|
|
2354
|
+
rapid
|
|
2355
|
+
rare
|
|
2356
|
+
rate
|
|
2357
|
+
rather
|
|
2358
|
+
raven
|
|
2359
|
+
raw
|
|
2360
|
+
razor
|
|
2361
|
+
ready
|
|
2362
|
+
real
|
|
2363
|
+
reason
|
|
2364
|
+
rebel
|
|
2365
|
+
rebuild
|
|
2366
|
+
recall
|
|
2367
|
+
receive
|
|
2368
|
+
recipe
|
|
2369
|
+
record
|
|
2370
|
+
recycle
|
|
2371
|
+
reduce
|
|
2372
|
+
reflect
|
|
2373
|
+
reform
|
|
2374
|
+
refuse
|
|
2375
|
+
region
|
|
2376
|
+
regret
|
|
2377
|
+
regular
|
|
2378
|
+
reject
|
|
2379
|
+
relax
|
|
2380
|
+
release
|
|
2381
|
+
relief
|
|
2382
|
+
rely
|
|
2383
|
+
remain
|
|
2384
|
+
remember
|
|
2385
|
+
remind
|
|
2386
|
+
remove
|
|
2387
|
+
render
|
|
2388
|
+
renew
|
|
2389
|
+
rent
|
|
2390
|
+
reopen
|
|
2391
|
+
repair
|
|
2392
|
+
repeat
|
|
2393
|
+
replace
|
|
2394
|
+
report
|
|
2395
|
+
require
|
|
2396
|
+
rescue
|
|
2397
|
+
resemble
|
|
2398
|
+
resist
|
|
2399
|
+
resource
|
|
2400
|
+
response
|
|
2401
|
+
result
|
|
2402
|
+
retire
|
|
2403
|
+
retreat
|
|
2404
|
+
return
|
|
2405
|
+
reunion
|
|
2406
|
+
reveal
|
|
2407
|
+
review
|
|
2408
|
+
reward
|
|
2409
|
+
rhythm
|
|
2410
|
+
rib
|
|
2411
|
+
ribbon
|
|
2412
|
+
rice
|
|
2413
|
+
rich
|
|
2414
|
+
ride
|
|
2415
|
+
ridge
|
|
2416
|
+
rifle
|
|
2417
|
+
right
|
|
2418
|
+
rigid
|
|
2419
|
+
ring
|
|
2420
|
+
riot
|
|
2421
|
+
ripple
|
|
2422
|
+
risk
|
|
2423
|
+
ritual
|
|
2424
|
+
rival
|
|
2425
|
+
river
|
|
2426
|
+
road
|
|
2427
|
+
roast
|
|
2428
|
+
robot
|
|
2429
|
+
robust
|
|
2430
|
+
rocket
|
|
2431
|
+
romance
|
|
2432
|
+
roof
|
|
2433
|
+
rookie
|
|
2434
|
+
room
|
|
2435
|
+
rose
|
|
2436
|
+
rotate
|
|
2437
|
+
rough
|
|
2438
|
+
round
|
|
2439
|
+
route
|
|
2440
|
+
royal
|
|
2441
|
+
rubber
|
|
2442
|
+
rude
|
|
2443
|
+
rug
|
|
2444
|
+
rule
|
|
2445
|
+
run
|
|
2446
|
+
runway
|
|
2447
|
+
rural
|
|
2448
|
+
sad
|
|
2449
|
+
saddle
|
|
2450
|
+
sadness
|
|
2451
|
+
safe
|
|
2452
|
+
sail
|
|
2453
|
+
salad
|
|
2454
|
+
salmon
|
|
2455
|
+
salon
|
|
2456
|
+
salt
|
|
2457
|
+
salute
|
|
2458
|
+
same
|
|
2459
|
+
sample
|
|
2460
|
+
sand
|
|
2461
|
+
satisfy
|
|
2462
|
+
satoshi
|
|
2463
|
+
sauce
|
|
2464
|
+
sausage
|
|
2465
|
+
save
|
|
2466
|
+
say
|
|
2467
|
+
scale
|
|
2468
|
+
scan
|
|
2469
|
+
scare
|
|
2470
|
+
scatter
|
|
2471
|
+
scene
|
|
2472
|
+
scheme
|
|
2473
|
+
school
|
|
2474
|
+
science
|
|
2475
|
+
scissors
|
|
2476
|
+
scorpion
|
|
2477
|
+
scout
|
|
2478
|
+
scrap
|
|
2479
|
+
screen
|
|
2480
|
+
script
|
|
2481
|
+
scrub
|
|
2482
|
+
sea
|
|
2483
|
+
search
|
|
2484
|
+
season
|
|
2485
|
+
seat
|
|
2486
|
+
second
|
|
2487
|
+
secret
|
|
2488
|
+
section
|
|
2489
|
+
security
|
|
2490
|
+
seed
|
|
2491
|
+
seek
|
|
2492
|
+
segment
|
|
2493
|
+
select
|
|
2494
|
+
sell
|
|
2495
|
+
seminar
|
|
2496
|
+
senior
|
|
2497
|
+
sense
|
|
2498
|
+
sentence
|
|
2499
|
+
series
|
|
2500
|
+
service
|
|
2501
|
+
session
|
|
2502
|
+
settle
|
|
2503
|
+
setup
|
|
2504
|
+
seven
|
|
2505
|
+
shadow
|
|
2506
|
+
shaft
|
|
2507
|
+
shallow
|
|
2508
|
+
share
|
|
2509
|
+
shed
|
|
2510
|
+
shell
|
|
2511
|
+
sheriff
|
|
2512
|
+
shield
|
|
2513
|
+
shift
|
|
2514
|
+
shine
|
|
2515
|
+
ship
|
|
2516
|
+
shiver
|
|
2517
|
+
shock
|
|
2518
|
+
shoe
|
|
2519
|
+
shoot
|
|
2520
|
+
shop
|
|
2521
|
+
short
|
|
2522
|
+
shoulder
|
|
2523
|
+
shove
|
|
2524
|
+
shrimp
|
|
2525
|
+
shrug
|
|
2526
|
+
shuffle
|
|
2527
|
+
shy
|
|
2528
|
+
sibling
|
|
2529
|
+
sick
|
|
2530
|
+
side
|
|
2531
|
+
siege
|
|
2532
|
+
sight
|
|
2533
|
+
sign
|
|
2534
|
+
silent
|
|
2535
|
+
silk
|
|
2536
|
+
silly
|
|
2537
|
+
silver
|
|
2538
|
+
similar
|
|
2539
|
+
simple
|
|
2540
|
+
since
|
|
2541
|
+
sing
|
|
2542
|
+
siren
|
|
2543
|
+
sister
|
|
2544
|
+
situate
|
|
2545
|
+
six
|
|
2546
|
+
size
|
|
2547
|
+
skate
|
|
2548
|
+
sketch
|
|
2549
|
+
ski
|
|
2550
|
+
skill
|
|
2551
|
+
skin
|
|
2552
|
+
skirt
|
|
2553
|
+
skull
|
|
2554
|
+
slab
|
|
2555
|
+
slam
|
|
2556
|
+
sleep
|
|
2557
|
+
slender
|
|
2558
|
+
slice
|
|
2559
|
+
slide
|
|
2560
|
+
slight
|
|
2561
|
+
slim
|
|
2562
|
+
slogan
|
|
2563
|
+
slot
|
|
2564
|
+
slow
|
|
2565
|
+
slush
|
|
2566
|
+
small
|
|
2567
|
+
smart
|
|
2568
|
+
smile
|
|
2569
|
+
smoke
|
|
2570
|
+
smooth
|
|
2571
|
+
snack
|
|
2572
|
+
snake
|
|
2573
|
+
snap
|
|
2574
|
+
sniff
|
|
2575
|
+
snow
|
|
2576
|
+
soap
|
|
2577
|
+
soccer
|
|
2578
|
+
social
|
|
2579
|
+
sock
|
|
2580
|
+
soda
|
|
2581
|
+
soft
|
|
2582
|
+
solar
|
|
2583
|
+
soldier
|
|
2584
|
+
solid
|
|
2585
|
+
solution
|
|
2586
|
+
solve
|
|
2587
|
+
someone
|
|
2588
|
+
song
|
|
2589
|
+
soon
|
|
2590
|
+
sorry
|
|
2591
|
+
sort
|
|
2592
|
+
soul
|
|
2593
|
+
sound
|
|
2594
|
+
soup
|
|
2595
|
+
source
|
|
2596
|
+
south
|
|
2597
|
+
space
|
|
2598
|
+
spare
|
|
2599
|
+
spatial
|
|
2600
|
+
spawn
|
|
2601
|
+
speak
|
|
2602
|
+
special
|
|
2603
|
+
speed
|
|
2604
|
+
spell
|
|
2605
|
+
spend
|
|
2606
|
+
sphere
|
|
2607
|
+
spice
|
|
2608
|
+
spider
|
|
2609
|
+
spike
|
|
2610
|
+
spin
|
|
2611
|
+
spirit
|
|
2612
|
+
split
|
|
2613
|
+
spoil
|
|
2614
|
+
sponsor
|
|
2615
|
+
spoon
|
|
2616
|
+
sport
|
|
2617
|
+
spot
|
|
2618
|
+
spray
|
|
2619
|
+
spread
|
|
2620
|
+
spring
|
|
2621
|
+
spy
|
|
2622
|
+
square
|
|
2623
|
+
squeeze
|
|
2624
|
+
squirrel
|
|
2625
|
+
stable
|
|
2626
|
+
stadium
|
|
2627
|
+
staff
|
|
2628
|
+
stage
|
|
2629
|
+
stairs
|
|
2630
|
+
stamp
|
|
2631
|
+
stand
|
|
2632
|
+
start
|
|
2633
|
+
state
|
|
2634
|
+
stay
|
|
2635
|
+
steak
|
|
2636
|
+
steel
|
|
2637
|
+
stem
|
|
2638
|
+
step
|
|
2639
|
+
stereo
|
|
2640
|
+
stick
|
|
2641
|
+
still
|
|
2642
|
+
sting
|
|
2643
|
+
stock
|
|
2644
|
+
stomach
|
|
2645
|
+
stone
|
|
2646
|
+
stool
|
|
2647
|
+
story
|
|
2648
|
+
stove
|
|
2649
|
+
strategy
|
|
2650
|
+
street
|
|
2651
|
+
strike
|
|
2652
|
+
strong
|
|
2653
|
+
struggle
|
|
2654
|
+
student
|
|
2655
|
+
stuff
|
|
2656
|
+
stumble
|
|
2657
|
+
style
|
|
2658
|
+
subject
|
|
2659
|
+
submit
|
|
2660
|
+
subway
|
|
2661
|
+
success
|
|
2662
|
+
such
|
|
2663
|
+
sudden
|
|
2664
|
+
suffer
|
|
2665
|
+
sugar
|
|
2666
|
+
suggest
|
|
2667
|
+
suit
|
|
2668
|
+
summer
|
|
2669
|
+
sun
|
|
2670
|
+
sunny
|
|
2671
|
+
sunset
|
|
2672
|
+
super
|
|
2673
|
+
supply
|
|
2674
|
+
supreme
|
|
2675
|
+
sure
|
|
2676
|
+
surface
|
|
2677
|
+
surge
|
|
2678
|
+
surprise
|
|
2679
|
+
surround
|
|
2680
|
+
survey
|
|
2681
|
+
suspect
|
|
2682
|
+
sustain
|
|
2683
|
+
swallow
|
|
2684
|
+
swamp
|
|
2685
|
+
swap
|
|
2686
|
+
swarm
|
|
2687
|
+
swear
|
|
2688
|
+
sweet
|
|
2689
|
+
swift
|
|
2690
|
+
swim
|
|
2691
|
+
swing
|
|
2692
|
+
switch
|
|
2693
|
+
sword
|
|
2694
|
+
symbol
|
|
2695
|
+
symptom
|
|
2696
|
+
syrup
|
|
2697
|
+
system
|
|
2698
|
+
table
|
|
2699
|
+
tackle
|
|
2700
|
+
tag
|
|
2701
|
+
tail
|
|
2702
|
+
talent
|
|
2703
|
+
talk
|
|
2704
|
+
tank
|
|
2705
|
+
tape
|
|
2706
|
+
target
|
|
2707
|
+
task
|
|
2708
|
+
taste
|
|
2709
|
+
tattoo
|
|
2710
|
+
taxi
|
|
2711
|
+
teach
|
|
2712
|
+
team
|
|
2713
|
+
tell
|
|
2714
|
+
ten
|
|
2715
|
+
tenant
|
|
2716
|
+
tennis
|
|
2717
|
+
tent
|
|
2718
|
+
term
|
|
2719
|
+
test
|
|
2720
|
+
text
|
|
2721
|
+
thank
|
|
2722
|
+
that
|
|
2723
|
+
theme
|
|
2724
|
+
then
|
|
2725
|
+
theory
|
|
2726
|
+
there
|
|
2727
|
+
they
|
|
2728
|
+
thing
|
|
2729
|
+
this
|
|
2730
|
+
thought
|
|
2731
|
+
three
|
|
2732
|
+
thrive
|
|
2733
|
+
throw
|
|
2734
|
+
thumb
|
|
2735
|
+
thunder
|
|
2736
|
+
ticket
|
|
2737
|
+
tide
|
|
2738
|
+
tiger
|
|
2739
|
+
tilt
|
|
2740
|
+
timber
|
|
2741
|
+
time
|
|
2742
|
+
tiny
|
|
2743
|
+
tip
|
|
2744
|
+
tired
|
|
2745
|
+
tissue
|
|
2746
|
+
title
|
|
2747
|
+
toast
|
|
2748
|
+
tobacco
|
|
2749
|
+
today
|
|
2750
|
+
toddler
|
|
2751
|
+
toe
|
|
2752
|
+
together
|
|
2753
|
+
toilet
|
|
2754
|
+
token
|
|
2755
|
+
tomato
|
|
2756
|
+
tomorrow
|
|
2757
|
+
tone
|
|
2758
|
+
tongue
|
|
2759
|
+
tonight
|
|
2760
|
+
tool
|
|
2761
|
+
tooth
|
|
2762
|
+
top
|
|
2763
|
+
topic
|
|
2764
|
+
topple
|
|
2765
|
+
torch
|
|
2766
|
+
tornado
|
|
2767
|
+
tortoise
|
|
2768
|
+
toss
|
|
2769
|
+
total
|
|
2770
|
+
tourist
|
|
2771
|
+
toward
|
|
2772
|
+
tower
|
|
2773
|
+
town
|
|
2774
|
+
toy
|
|
2775
|
+
track
|
|
2776
|
+
trade
|
|
2777
|
+
traffic
|
|
2778
|
+
tragic
|
|
2779
|
+
train
|
|
2780
|
+
transfer
|
|
2781
|
+
trap
|
|
2782
|
+
trash
|
|
2783
|
+
travel
|
|
2784
|
+
tray
|
|
2785
|
+
treat
|
|
2786
|
+
tree
|
|
2787
|
+
trend
|
|
2788
|
+
trial
|
|
2789
|
+
tribe
|
|
2790
|
+
trick
|
|
2791
|
+
trigger
|
|
2792
|
+
trim
|
|
2793
|
+
trip
|
|
2794
|
+
trophy
|
|
2795
|
+
trouble
|
|
2796
|
+
truck
|
|
2797
|
+
true
|
|
2798
|
+
truly
|
|
2799
|
+
trumpet
|
|
2800
|
+
trust
|
|
2801
|
+
truth
|
|
2802
|
+
try
|
|
2803
|
+
tube
|
|
2804
|
+
tuition
|
|
2805
|
+
tumble
|
|
2806
|
+
tuna
|
|
2807
|
+
tunnel
|
|
2808
|
+
turkey
|
|
2809
|
+
turn
|
|
2810
|
+
turtle
|
|
2811
|
+
twelve
|
|
2812
|
+
twenty
|
|
2813
|
+
twice
|
|
2814
|
+
twin
|
|
2815
|
+
twist
|
|
2816
|
+
two
|
|
2817
|
+
type
|
|
2818
|
+
typical
|
|
2819
|
+
ugly
|
|
2820
|
+
umbrella
|
|
2821
|
+
unable
|
|
2822
|
+
unaware
|
|
2823
|
+
uncle
|
|
2824
|
+
uncover
|
|
2825
|
+
under
|
|
2826
|
+
undo
|
|
2827
|
+
unfair
|
|
2828
|
+
unfold
|
|
2829
|
+
unhappy
|
|
2830
|
+
uniform
|
|
2831
|
+
unique
|
|
2832
|
+
unit
|
|
2833
|
+
universe
|
|
2834
|
+
unknown
|
|
2835
|
+
unlock
|
|
2836
|
+
until
|
|
2837
|
+
unusual
|
|
2838
|
+
unveil
|
|
2839
|
+
update
|
|
2840
|
+
upgrade
|
|
2841
|
+
uphold
|
|
2842
|
+
upon
|
|
2843
|
+
upper
|
|
2844
|
+
upset
|
|
2845
|
+
urban
|
|
2846
|
+
urge
|
|
2847
|
+
usage
|
|
2848
|
+
use
|
|
2849
|
+
used
|
|
2850
|
+
useful
|
|
2851
|
+
useless
|
|
2852
|
+
usual
|
|
2853
|
+
utility
|
|
2854
|
+
vacant
|
|
2855
|
+
vacuum
|
|
2856
|
+
vague
|
|
2857
|
+
valid
|
|
2858
|
+
valley
|
|
2859
|
+
valve
|
|
2860
|
+
van
|
|
2861
|
+
vanish
|
|
2862
|
+
vapor
|
|
2863
|
+
various
|
|
2864
|
+
vast
|
|
2865
|
+
vault
|
|
2866
|
+
vehicle
|
|
2867
|
+
velvet
|
|
2868
|
+
vendor
|
|
2869
|
+
venture
|
|
2870
|
+
venue
|
|
2871
|
+
verb
|
|
2872
|
+
verify
|
|
2873
|
+
version
|
|
2874
|
+
very
|
|
2875
|
+
vessel
|
|
2876
|
+
veteran
|
|
2877
|
+
viable
|
|
2878
|
+
vibrant
|
|
2879
|
+
vicious
|
|
2880
|
+
victory
|
|
2881
|
+
video
|
|
2882
|
+
view
|
|
2883
|
+
village
|
|
2884
|
+
vintage
|
|
2885
|
+
violin
|
|
2886
|
+
virtual
|
|
2887
|
+
virus
|
|
2888
|
+
visa
|
|
2889
|
+
visit
|
|
2890
|
+
visual
|
|
2891
|
+
vital
|
|
2892
|
+
vivid
|
|
2893
|
+
vocal
|
|
2894
|
+
voice
|
|
2895
|
+
void
|
|
2896
|
+
volcano
|
|
2897
|
+
volume
|
|
2898
|
+
vote
|
|
2899
|
+
voyage
|
|
2900
|
+
wage
|
|
2901
|
+
wagon
|
|
2902
|
+
wait
|
|
2903
|
+
walk
|
|
2904
|
+
wall
|
|
2905
|
+
walnut
|
|
2906
|
+
want
|
|
2907
|
+
warfare
|
|
2908
|
+
warm
|
|
2909
|
+
warrior
|
|
2910
|
+
wash
|
|
2911
|
+
wasp
|
|
2912
|
+
waste
|
|
2913
|
+
water
|
|
2914
|
+
wave
|
|
2915
|
+
way
|
|
2916
|
+
wealth
|
|
2917
|
+
weapon
|
|
2918
|
+
wear
|
|
2919
|
+
weasel
|
|
2920
|
+
weather
|
|
2921
|
+
web
|
|
2922
|
+
wedding
|
|
2923
|
+
weekend
|
|
2924
|
+
weird
|
|
2925
|
+
welcome
|
|
2926
|
+
west
|
|
2927
|
+
wet
|
|
2928
|
+
whale
|
|
2929
|
+
what
|
|
2930
|
+
wheat
|
|
2931
|
+
wheel
|
|
2932
|
+
when
|
|
2933
|
+
where
|
|
2934
|
+
whip
|
|
2935
|
+
whisper
|
|
2936
|
+
wide
|
|
2937
|
+
width
|
|
2938
|
+
wife
|
|
2939
|
+
wild
|
|
2940
|
+
will
|
|
2941
|
+
win
|
|
2942
|
+
window
|
|
2943
|
+
wine
|
|
2944
|
+
wing
|
|
2945
|
+
wink
|
|
2946
|
+
winner
|
|
2947
|
+
winter
|
|
2948
|
+
wire
|
|
2949
|
+
wisdom
|
|
2950
|
+
wise
|
|
2951
|
+
wish
|
|
2952
|
+
witness
|
|
2953
|
+
wolf
|
|
2954
|
+
woman
|
|
2955
|
+
wonder
|
|
2956
|
+
wood
|
|
2957
|
+
wool
|
|
2958
|
+
word
|
|
2959
|
+
work
|
|
2960
|
+
world
|
|
2961
|
+
worry
|
|
2962
|
+
worth
|
|
2963
|
+
wrap
|
|
2964
|
+
wreck
|
|
2965
|
+
wrestle
|
|
2966
|
+
wrist
|
|
2967
|
+
write
|
|
2968
|
+
wrong
|
|
2969
|
+
yard
|
|
2970
|
+
year
|
|
2971
|
+
yellow
|
|
2972
|
+
you
|
|
2973
|
+
young
|
|
2974
|
+
youth
|
|
2975
|
+
zebra
|
|
2976
|
+
zero
|
|
2977
|
+
zone
|
|
2978
|
+
zoo`.split("\n");
|
|
2979
|
+
|
|
2980
|
+
// src/mnemonic.ts
|
|
2981
|
+
function generateMnemonic() {
|
|
2982
|
+
const entropy = crypto.getRandomValues(new Uint8Array(32));
|
|
2983
|
+
return entropyToMnemonic(entropy, wordlist);
|
|
2984
|
+
}
|
|
2985
|
+
async function recoverWithMnemonic(mnemonic, extractable = false) {
|
|
2986
|
+
if (!validateMnemonic(mnemonic, wordlist)) {
|
|
2987
|
+
throw new Error("Invalid mnemonic: phrase does not pass BIP-39 checksum validation");
|
|
2988
|
+
}
|
|
2989
|
+
const entropy = mnemonicToEntropy(mnemonic, wordlist).slice();
|
|
2990
|
+
const hkdfKey = await crypto.subtle.importKey("raw", entropy, "HKDF", false, ["deriveKey"]);
|
|
2991
|
+
return crypto.subtle.deriveKey(
|
|
2992
|
+
{
|
|
2993
|
+
name: "HKDF",
|
|
2994
|
+
hash: "SHA-256",
|
|
2995
|
+
salt: new Uint8Array(0),
|
|
2996
|
+
info: new TextEncoder().encode("conseal-mnemonic-aek-v1")
|
|
2997
|
+
},
|
|
2998
|
+
hkdfKey,
|
|
2999
|
+
{ name: "AES-GCM", length: 256 },
|
|
3000
|
+
extractable,
|
|
3001
|
+
["encrypt", "decrypt"]
|
|
3002
|
+
);
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
// src/base64.ts
|
|
3006
|
+
function toBase64(buf) {
|
|
3007
|
+
const u8 = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
|
|
3008
|
+
let binary = "";
|
|
3009
|
+
for (const byte of u8) binary += String.fromCharCode(byte);
|
|
3010
|
+
return btoa(binary);
|
|
3011
|
+
}
|
|
3012
|
+
function fromBase64(b64) {
|
|
3013
|
+
return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
3014
|
+
}
|
|
3015
|
+
function toBase64Url(buf) {
|
|
3016
|
+
return toBase64(buf).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
3017
|
+
}
|
|
3018
|
+
function fromBase64Url(b64url) {
|
|
3019
|
+
const b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
3020
|
+
return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
// src/envelope.ts
|
|
3024
|
+
async function sealEnvelope(plaintext, passcode) {
|
|
3025
|
+
const dek = await crypto.subtle.generateKey(
|
|
3026
|
+
{ name: "AES-GCM", length: 256 },
|
|
3027
|
+
true,
|
|
3028
|
+
["encrypt", "decrypt"]
|
|
3029
|
+
);
|
|
3030
|
+
const { ciphertext, iv } = await seal(dek, plaintext);
|
|
3031
|
+
const { wrappedKey, salt } = await wrapKey(passcode, dek);
|
|
3032
|
+
return { version: 1, ciphertext, iv, wrappedKey, salt };
|
|
3033
|
+
}
|
|
3034
|
+
async function unsealEnvelope(envelope, passcode) {
|
|
3035
|
+
const dek = await unwrapKey(passcode, envelope.wrappedKey, envelope.salt);
|
|
3036
|
+
return unseal(dek, envelope.ciphertext, envelope.iv);
|
|
3037
|
+
}
|
|
3038
|
+
function encodeEnvelope(envelope) {
|
|
3039
|
+
return JSON.stringify({
|
|
3040
|
+
version: envelope.version,
|
|
3041
|
+
ciphertext: toBase64(envelope.ciphertext),
|
|
3042
|
+
iv: toBase64(envelope.iv),
|
|
3043
|
+
wrappedKey: toBase64(envelope.wrappedKey),
|
|
3044
|
+
salt: toBase64(envelope.salt)
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
function decodeEnvelope(json) {
|
|
3048
|
+
const p = JSON.parse(json);
|
|
3049
|
+
if (p["version"] !== 1) {
|
|
3050
|
+
throw new TypeError(`Invalid envelope: unsupported or missing 'version' field (got ${JSON.stringify(p["version"])})`);
|
|
3051
|
+
}
|
|
3052
|
+
const binaryFields = ["ciphertext", "iv", "wrappedKey", "salt"];
|
|
3053
|
+
for (const field of binaryFields) {
|
|
3054
|
+
if (typeof p[field] !== "string") {
|
|
3055
|
+
throw new TypeError(`Invalid envelope: missing or invalid '${field}' field`);
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
const validated = p;
|
|
3059
|
+
for (const field of binaryFields) {
|
|
3060
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(validated[field])) {
|
|
3061
|
+
throw new TypeError(`Invalid envelope: '${field}' is not valid base64`);
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
const ct = fromBase64(validated.ciphertext);
|
|
3065
|
+
const wk = fromBase64(validated.wrappedKey);
|
|
3066
|
+
return {
|
|
3067
|
+
version: 1,
|
|
3068
|
+
ciphertext: ct.buffer.slice(ct.byteOffset, ct.byteOffset + ct.byteLength),
|
|
3069
|
+
iv: fromBase64(validated.iv),
|
|
3070
|
+
wrappedKey: wk.buffer.slice(wk.byteOffset, wk.byteOffset + wk.byteLength),
|
|
3071
|
+
salt: fromBase64(validated.salt)
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// src/digest.ts
|
|
3076
|
+
async function digest(data) {
|
|
3077
|
+
return crypto.subtle.digest("SHA-256", data);
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
// src/circle.ts
|
|
3081
|
+
var JOIN_TTL_MS = 5 * 60 * 1e3;
|
|
3082
|
+
async function deriveVerificationCode(ephemeralPublicKey) {
|
|
3083
|
+
const key = await importPublicKeyFromJwk(ephemeralPublicKey, "ECDH");
|
|
3084
|
+
const raw = await crypto.subtle.exportKey("raw", key);
|
|
3085
|
+
const hash = await digest(raw);
|
|
3086
|
+
const bytes = new Uint8Array(hash);
|
|
3087
|
+
const hex = (b) => b.toString(16).padStart(2, "0").toUpperCase();
|
|
3088
|
+
return `${hex(bytes[0])}-${hex(bytes[1])}-${hex(bytes[2])}-${hex(bytes[3])}`;
|
|
3089
|
+
}
|
|
3090
|
+
async function initCircle(mnemonic, passphrase, secretKey) {
|
|
3091
|
+
const aek = await recoverWithMnemonic(mnemonic, true);
|
|
3092
|
+
const rawAEK = await crypto.subtle.exportKey("raw", aek);
|
|
3093
|
+
const aekCommitment = await digest(rawAEK);
|
|
3094
|
+
const { wrappedKey, salt } = await wrapKey(passphrase, aek, secretKey);
|
|
3095
|
+
const deviceId = crypto.randomUUID();
|
|
3096
|
+
return { wrappedAEK: { wrappedKey, salt }, aekCommitment, deviceId };
|
|
3097
|
+
}
|
|
3098
|
+
async function createJoinRequest(deviceMeta) {
|
|
3099
|
+
const { publicKey, privateKey } = await generateECDHKeyPair();
|
|
3100
|
+
const ephemeralPublicKey = await exportPublicKeyAsJwk(publicKey);
|
|
3101
|
+
const verificationCode = await deriveVerificationCode(ephemeralPublicKey);
|
|
3102
|
+
const deviceId = crypto.randomUUID();
|
|
3103
|
+
const request = {
|
|
3104
|
+
deviceId,
|
|
3105
|
+
ephemeralPublicKey,
|
|
3106
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3107
|
+
...deviceMeta ? { deviceMeta } : {}
|
|
3108
|
+
};
|
|
3109
|
+
return { request, ephemeralPrivateKey: privateKey, verificationCode };
|
|
3110
|
+
}
|
|
3111
|
+
async function authorizeJoin(joinRequest, wrappedAEK, passphrase, secretKey, serverReceivedAt) {
|
|
3112
|
+
const age = Date.now() - serverReceivedAt;
|
|
3113
|
+
if (age > JOIN_TTL_MS) {
|
|
3114
|
+
throw new Error("authorizeJoin: join request has expired (older than 5 minutes)");
|
|
3115
|
+
}
|
|
3116
|
+
const aek = await unwrapKey(passphrase, wrappedAEK.wrappedKey, wrappedAEK.salt, secretKey, true);
|
|
3117
|
+
const rawAEK = await crypto.subtle.exportKey("raw", aek);
|
|
3118
|
+
const recipientPublicKey = await importPublicKeyFromJwk(joinRequest.ephemeralPublicKey, "ECDH");
|
|
3119
|
+
const { ciphertext, iv, ephemeralPublicKey } = await sealMessage(recipientPublicKey, rawAEK);
|
|
3120
|
+
return { ciphertext, iv, ephemeralPublicKey };
|
|
3121
|
+
}
|
|
3122
|
+
async function finalizeJoin(sealedAEK, ephemeralPrivateKey, passphrase, secretKey, aekCommitment) {
|
|
3123
|
+
const rawAEK = await unsealMessage(
|
|
3124
|
+
ephemeralPrivateKey,
|
|
3125
|
+
sealedAEK.ciphertext,
|
|
3126
|
+
sealedAEK.iv,
|
|
3127
|
+
sealedAEK.ephemeralPublicKey
|
|
3128
|
+
);
|
|
3129
|
+
const actualCommitment = await digest(rawAEK);
|
|
3130
|
+
if (!buffersEqual(new Uint8Array(actualCommitment), new Uint8Array(aekCommitment))) {
|
|
3131
|
+
throw new Error("finalizeJoin: AEK commitment mismatch \u2014 key may have been tampered with");
|
|
3132
|
+
}
|
|
3133
|
+
const aek = await importAesKey(rawAEK, true);
|
|
3134
|
+
const { wrappedKey, salt } = await wrapKey(passphrase, aek, secretKey);
|
|
3135
|
+
return { wrappedAEK: { wrappedKey, salt } };
|
|
3136
|
+
}
|
|
3137
|
+
export {
|
|
3138
|
+
AEK_KEY_ID,
|
|
3139
|
+
authorizeJoin,
|
|
3140
|
+
combinePassphraseAndSecretKey,
|
|
3141
|
+
createJoinRequest,
|
|
3142
|
+
decodeEnvelope,
|
|
3143
|
+
deleteCryptoKey,
|
|
3144
|
+
deriveVerificationCode,
|
|
3145
|
+
digest,
|
|
3146
|
+
encodeEnvelope,
|
|
3147
|
+
exportPublicKeyAsJwk,
|
|
3148
|
+
finalizeJoin,
|
|
3149
|
+
fromBase64,
|
|
3150
|
+
fromBase64Url,
|
|
3151
|
+
generateAesKey,
|
|
3152
|
+
generateECDHKeyPair,
|
|
3153
|
+
generateECDSAKeyPair,
|
|
3154
|
+
generateMnemonic,
|
|
3155
|
+
generateSecretKey,
|
|
3156
|
+
importAesKey,
|
|
3157
|
+
importPublicKeyFromJwk,
|
|
3158
|
+
init,
|
|
3159
|
+
initCircle,
|
|
3160
|
+
loadCryptoKey,
|
|
3161
|
+
recoverWithMnemonic,
|
|
3162
|
+
rekey,
|
|
3163
|
+
rekeySecretKey,
|
|
3164
|
+
saveCryptoKey,
|
|
3165
|
+
seal,
|
|
3166
|
+
sealEnvelope,
|
|
3167
|
+
sealMessage,
|
|
3168
|
+
sign,
|
|
3169
|
+
toBase64,
|
|
3170
|
+
toBase64Url,
|
|
3171
|
+
unseal,
|
|
3172
|
+
unsealEnvelope,
|
|
3173
|
+
unsealMessage,
|
|
3174
|
+
unwrapKey,
|
|
3175
|
+
verify,
|
|
3176
|
+
wrapKey
|
|
3177
|
+
};
|
|
3178
|
+
/*! Bundled license information:
|
|
3179
|
+
|
|
3180
|
+
@noble/hashes/utils.js:
|
|
3181
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3182
|
+
|
|
3183
|
+
@scure/base/index.js:
|
|
3184
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3185
|
+
|
|
3186
|
+
@scure/bip39/index.js:
|
|
3187
|
+
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
3188
|
+
*/
|