@reallyme/crypto 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -0
- package/dist/aead.d.ts +9 -0
- package/dist/aead.js +62 -0
- package/dist/aesKw.d.ts +10 -0
- package/dist/aesKw.js +45 -0
- package/dist/algorithms.d.ts +18 -0
- package/dist/algorithms.js +64 -0
- package/dist/argon2id.d.ts +8 -0
- package/dist/argon2id.js +40 -0
- package/dist/bip340Schnorr.d.ts +26 -0
- package/dist/bip340Schnorr.js +72 -0
- package/dist/codecs.d.ts +35 -0
- package/dist/codecs.js +216 -0
- package/dist/cryptoFacade.d.ts +51 -0
- package/dist/cryptoFacade.js +329 -0
- package/dist/digest.d.ts +14 -0
- package/dist/digest.js +33 -0
- package/dist/ed25519.d.ts +34 -0
- package/dist/ed25519.js +78 -0
- package/dist/encodeEcdsaDer.d.ts +2 -0
- package/dist/encodeEcdsaDer.js +141 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +11 -0
- package/dist/hkdf.d.ts +7 -0
- package/dist/hkdf.js +27 -0
- package/dist/hmac.d.ts +9 -0
- package/dist/hmac.js +50 -0
- package/dist/hpke.d.ts +15 -0
- package/dist/hpke.js +59 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +31 -0
- package/dist/jwk.d.ts +42 -0
- package/dist/jwk.js +289 -0
- package/dist/mlDsa.d.ts +18 -0
- package/dist/mlDsa.js +85 -0
- package/dist/mlKem.d.ts +25 -0
- package/dist/mlKem.js +95 -0
- package/dist/p256Ecdh.d.ts +22 -0
- package/dist/p256Ecdh.js +53 -0
- package/dist/p256Ecdsa.d.ts +25 -0
- package/dist/p256Ecdsa.js +85 -0
- package/dist/p384Ecdsa.d.ts +23 -0
- package/dist/p384Ecdsa.js +83 -0
- package/dist/p521Ecdsa.d.ts +23 -0
- package/dist/p521Ecdsa.js +83 -0
- package/dist/pbkdf2.d.ts +28 -0
- package/dist/pbkdf2.js +57 -0
- package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.d.ts +618 -0
- package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.js +523 -0
- package/dist/proto.d.ts +25 -0
- package/dist/proto.js +342 -0
- package/dist/providerCatalog.d.ts +9 -0
- package/dist/providerCatalog.js +15 -0
- package/dist/rsa.d.ts +13 -0
- package/dist/rsa.js +102 -0
- package/dist/secp256k1.d.ts +47 -0
- package/dist/secp256k1.js +106 -0
- package/dist/slhDsa.d.ts +15 -0
- package/dist/slhDsa.js +54 -0
- package/dist/validateBytes.d.ts +2 -0
- package/dist/validateBytes.js +20 -0
- package/dist/verifySignature.d.ts +1 -0
- package/dist/verifySignature.js +9 -0
- package/dist/wasm/LICENSE +201 -0
- package/dist/wasm/reallyme_crypto_wasm.js +1319 -0
- package/dist/wasm/reallyme_crypto_wasm_bg.wasm +0 -0
- package/dist/wasmModuleTypes.d.ts +72 -0
- package/dist/wasmModuleTypes.js +4 -0
- package/dist/wasmProvider.d.ts +94 -0
- package/dist/wasmProvider.js +173 -0
- package/dist/x25519.d.ts +28 -0
- package/dist/x25519.js +66 -0
- package/dist/xWing.d.ts +23 -0
- package/dist/xWing.js +86 -0
- package/package.json +48 -0
|
@@ -0,0 +1,1319 @@
|
|
|
1
|
+
/* @ts-self-types="./reallyme_crypto_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Open and authenticate an AES-256-GCM `ciphertext || tag`.
|
|
5
|
+
* @param {Uint8Array} key
|
|
6
|
+
* @param {Uint8Array} nonce
|
|
7
|
+
* @param {Uint8Array} aad
|
|
8
|
+
* @param {Uint8Array} ciphertext
|
|
9
|
+
* @returns {Uint8Array}
|
|
10
|
+
*/
|
|
11
|
+
export function aes256GcmOpen(key, nonce, aad, ciphertext) {
|
|
12
|
+
const ret = wasm.aes256GcmOpen(key, nonce, aad, ciphertext);
|
|
13
|
+
if (ret[2]) {
|
|
14
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
15
|
+
}
|
|
16
|
+
return takeFromExternrefTable0(ret[0]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Seal plaintext with AES-256-GCM and return `ciphertext || tag`.
|
|
21
|
+
* @param {Uint8Array} key
|
|
22
|
+
* @param {Uint8Array} nonce
|
|
23
|
+
* @param {Uint8Array} aad
|
|
24
|
+
* @param {Uint8Array} plaintext
|
|
25
|
+
* @returns {Uint8Array}
|
|
26
|
+
*/
|
|
27
|
+
export function aes256GcmSeal(key, nonce, aad, plaintext) {
|
|
28
|
+
const ret = wasm.aes256GcmSeal(key, nonce, aad, plaintext);
|
|
29
|
+
if (ret[2]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
31
|
+
}
|
|
32
|
+
return takeFromExternrefTable0(ret[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Open and authenticate an AES-256-GCM-SIV `ciphertext || tag`.
|
|
37
|
+
* @param {Uint8Array} key
|
|
38
|
+
* @param {Uint8Array} nonce
|
|
39
|
+
* @param {Uint8Array} aad
|
|
40
|
+
* @param {Uint8Array} ciphertext
|
|
41
|
+
* @returns {Uint8Array}
|
|
42
|
+
*/
|
|
43
|
+
export function aes256GcmSivOpen(key, nonce, aad, ciphertext) {
|
|
44
|
+
const ret = wasm.aes256GcmSivOpen(key, nonce, aad, ciphertext);
|
|
45
|
+
if (ret[2]) {
|
|
46
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
47
|
+
}
|
|
48
|
+
return takeFromExternrefTable0(ret[0]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Seal plaintext with AES-256-GCM-SIV and return `ciphertext || tag`.
|
|
53
|
+
* @param {Uint8Array} key
|
|
54
|
+
* @param {Uint8Array} nonce
|
|
55
|
+
* @param {Uint8Array} aad
|
|
56
|
+
* @param {Uint8Array} plaintext
|
|
57
|
+
* @returns {Uint8Array}
|
|
58
|
+
*/
|
|
59
|
+
export function aes256GcmSivSeal(key, nonce, aad, plaintext) {
|
|
60
|
+
const ret = wasm.aes256GcmSivSeal(key, nonce, aad, plaintext);
|
|
61
|
+
if (ret[2]) {
|
|
62
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
63
|
+
}
|
|
64
|
+
return takeFromExternrefTable0(ret[0]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Unwrap an RFC 3394 AES-256-KW wrapped key.
|
|
69
|
+
* @param {Uint8Array} kek
|
|
70
|
+
* @param {Uint8Array} wrapped_key
|
|
71
|
+
* @returns {Uint8Array}
|
|
72
|
+
*/
|
|
73
|
+
export function aes256KwUnwrapKey(kek, wrapped_key) {
|
|
74
|
+
const ret = wasm.aes256KwUnwrapKey(kek, wrapped_key);
|
|
75
|
+
if (ret[2]) {
|
|
76
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
77
|
+
}
|
|
78
|
+
return takeFromExternrefTable0(ret[0]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Wrap key material with AES-256-KW and return the RFC 3394 wrapped key.
|
|
83
|
+
* @param {Uint8Array} kek
|
|
84
|
+
* @param {Uint8Array} key_data
|
|
85
|
+
* @returns {Uint8Array}
|
|
86
|
+
*/
|
|
87
|
+
export function aes256KwWrapKey(kek, key_data) {
|
|
88
|
+
const ret = wasm.aes256KwWrapKey(kek, key_data);
|
|
89
|
+
if (ret[2]) {
|
|
90
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
91
|
+
}
|
|
92
|
+
return takeFromExternrefTable0(ret[0]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Derive the fixed 32-byte Argon2id key for a versioned ReallyMe profile.
|
|
97
|
+
* @param {number} kdf_version
|
|
98
|
+
* @param {Uint8Array} secret
|
|
99
|
+
* @param {Uint8Array} salt
|
|
100
|
+
* @returns {Uint8Array}
|
|
101
|
+
*/
|
|
102
|
+
export function argon2idDeriveKey(kdf_version, secret, salt) {
|
|
103
|
+
const ret = wasm.argon2idDeriveKey(kdf_version, secret, salt);
|
|
104
|
+
if (ret[2]) {
|
|
105
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
106
|
+
}
|
|
107
|
+
return takeFromExternrefTable0(ret[0]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Decode strict, unpadded RFC 4648 URL-safe base64.
|
|
112
|
+
* @param {string} encoded
|
|
113
|
+
* @returns {Uint8Array}
|
|
114
|
+
*/
|
|
115
|
+
export function base64urlDecode(encoded) {
|
|
116
|
+
const ptr0 = passStringToWasm0(encoded, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
118
|
+
const ret = wasm.base64urlDecode(ptr0, len0);
|
|
119
|
+
if (ret[2]) {
|
|
120
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
121
|
+
}
|
|
122
|
+
return takeFromExternrefTable0(ret[0]);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Encode bytes as RFC 4648 URL-safe base64 without padding.
|
|
127
|
+
* @param {Uint8Array} bytes
|
|
128
|
+
* @returns {string}
|
|
129
|
+
*/
|
|
130
|
+
export function base64urlEncode(bytes) {
|
|
131
|
+
let deferred1_0;
|
|
132
|
+
let deferred1_1;
|
|
133
|
+
try {
|
|
134
|
+
const ret = wasm.base64urlEncode(bytes);
|
|
135
|
+
deferred1_0 = ret[0];
|
|
136
|
+
deferred1_1 = ret[1];
|
|
137
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
138
|
+
} finally {
|
|
139
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Open and authenticate a ChaCha20-Poly1305 `ciphertext || tag`.
|
|
145
|
+
* @param {Uint8Array} key
|
|
146
|
+
* @param {Uint8Array} nonce
|
|
147
|
+
* @param {Uint8Array} aad
|
|
148
|
+
* @param {Uint8Array} ciphertext
|
|
149
|
+
* @returns {Uint8Array}
|
|
150
|
+
*/
|
|
151
|
+
export function chacha20Poly1305Open(key, nonce, aad, ciphertext) {
|
|
152
|
+
const ret = wasm.chacha20Poly1305Open(key, nonce, aad, ciphertext);
|
|
153
|
+
if (ret[2]) {
|
|
154
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
155
|
+
}
|
|
156
|
+
return takeFromExternrefTable0(ret[0]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Seal plaintext with ChaCha20-Poly1305 and return `ciphertext || tag`.
|
|
161
|
+
* @param {Uint8Array} key
|
|
162
|
+
* @param {Uint8Array} nonce
|
|
163
|
+
* @param {Uint8Array} aad
|
|
164
|
+
* @param {Uint8Array} plaintext
|
|
165
|
+
* @returns {Uint8Array}
|
|
166
|
+
*/
|
|
167
|
+
export function chacha20Poly1305Seal(key, nonce, aad, plaintext) {
|
|
168
|
+
const ret = wasm.chacha20Poly1305Seal(key, nonce, aad, plaintext);
|
|
169
|
+
if (ret[2]) {
|
|
170
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
171
|
+
}
|
|
172
|
+
return takeFromExternrefTable0(ret[0]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Compute a CIDv1 dag-cbor/sha2-256 string for already-canonical DAG-CBOR bytes.
|
|
177
|
+
* @param {Uint8Array} bytes
|
|
178
|
+
* @returns {string}
|
|
179
|
+
*/
|
|
180
|
+
export function dagCborComputeCid(bytes) {
|
|
181
|
+
let deferred1_0;
|
|
182
|
+
let deferred1_1;
|
|
183
|
+
try {
|
|
184
|
+
const ret = wasm.dagCborComputeCid(bytes);
|
|
185
|
+
deferred1_0 = ret[0];
|
|
186
|
+
deferred1_1 = ret[1];
|
|
187
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
188
|
+
} finally {
|
|
189
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Recompute and compare a CIDv1 dag-cbor/sha2-256 string.
|
|
195
|
+
* @param {string} cid
|
|
196
|
+
* @param {Uint8Array} bytes
|
|
197
|
+
* @returns {any}
|
|
198
|
+
*/
|
|
199
|
+
export function dagCborVerifyCid(cid, bytes) {
|
|
200
|
+
const ptr0 = passStringToWasm0(cid, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
201
|
+
const len0 = WASM_VECTOR_LEN;
|
|
202
|
+
const ret = wasm.dagCborVerifyCid(ptr0, len0, bytes);
|
|
203
|
+
if (ret[2]) {
|
|
204
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
205
|
+
}
|
|
206
|
+
return takeFromExternrefTable0(ret[0]);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Open one RFC 9180 HPKE Base-mode message.
|
|
211
|
+
* @param {number} suite
|
|
212
|
+
* @param {Uint8Array} recipient_secret_key
|
|
213
|
+
* @param {Uint8Array} encapsulated_key
|
|
214
|
+
* @param {Uint8Array} info
|
|
215
|
+
* @param {Uint8Array} aad
|
|
216
|
+
* @param {Uint8Array} ciphertext
|
|
217
|
+
* @returns {Uint8Array}
|
|
218
|
+
*/
|
|
219
|
+
export function hpkeOpenBase(suite, recipient_secret_key, encapsulated_key, info, aad, ciphertext) {
|
|
220
|
+
const ret = wasm.hpkeOpenBase(suite, recipient_secret_key, encapsulated_key, info, aad, ciphertext);
|
|
221
|
+
if (ret[2]) {
|
|
222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
223
|
+
}
|
|
224
|
+
return takeFromExternrefTable0(ret[0]);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Seal one RFC 9180 HPKE Base-mode message.
|
|
229
|
+
* @param {number} suite
|
|
230
|
+
* @param {Uint8Array} recipient_public_key
|
|
231
|
+
* @param {Uint8Array} info
|
|
232
|
+
* @param {Uint8Array} aad
|
|
233
|
+
* @param {Uint8Array} plaintext
|
|
234
|
+
* @returns {any}
|
|
235
|
+
*/
|
|
236
|
+
export function hpkeSealBase(suite, recipient_public_key, info, aad, plaintext) {
|
|
237
|
+
const ret = wasm.hpkeSealBase(suite, recipient_public_key, info, aad, plaintext);
|
|
238
|
+
if (ret[2]) {
|
|
239
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
240
|
+
}
|
|
241
|
+
return takeFromExternrefTable0(ret[0]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Deterministically seal one HPKE Base-mode message for conformance tests.
|
|
246
|
+
* @param {number} suite
|
|
247
|
+
* @param {Uint8Array} recipient_public_key
|
|
248
|
+
* @param {Uint8Array} encapsulation_randomness
|
|
249
|
+
* @param {Uint8Array} info
|
|
250
|
+
* @param {Uint8Array} aad
|
|
251
|
+
* @param {Uint8Array} plaintext
|
|
252
|
+
* @returns {any}
|
|
253
|
+
*/
|
|
254
|
+
export function hpkeSealBaseDerand(suite, recipient_public_key, encapsulation_randomness, info, aad, plaintext) {
|
|
255
|
+
const ret = wasm.hpkeSealBaseDerand(suite, recipient_public_key, encapsulation_randomness, info, aad, plaintext);
|
|
256
|
+
if (ret[2]) {
|
|
257
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
258
|
+
}
|
|
259
|
+
return takeFromExternrefTable0(ret[0]);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Derive an ML-DSA-44 keypair from a 32-byte seed.
|
|
264
|
+
* @param {Uint8Array} secret_key
|
|
265
|
+
* @returns {any}
|
|
266
|
+
*/
|
|
267
|
+
export function mlDsa44DeriveKeypair(secret_key) {
|
|
268
|
+
const ret = wasm.mlDsa44DeriveKeypair(secret_key);
|
|
269
|
+
if (ret[2]) {
|
|
270
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
271
|
+
}
|
|
272
|
+
return takeFromExternrefTable0(ret[0]);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Generate an ML-DSA-44 keypair.
|
|
277
|
+
* @returns {any}
|
|
278
|
+
*/
|
|
279
|
+
export function mlDsa44GenerateKeypair() {
|
|
280
|
+
const ret = wasm.mlDsa44GenerateKeypair();
|
|
281
|
+
if (ret[2]) {
|
|
282
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
283
|
+
}
|
|
284
|
+
return takeFromExternrefTable0(ret[0]);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Sign a message with ML-DSA-44.
|
|
289
|
+
* @param {Uint8Array} secret_key
|
|
290
|
+
* @param {Uint8Array} message
|
|
291
|
+
* @returns {Uint8Array}
|
|
292
|
+
*/
|
|
293
|
+
export function mlDsa44Sign(secret_key, message) {
|
|
294
|
+
const ret = wasm.mlDsa44Sign(secret_key, message);
|
|
295
|
+
if (ret[2]) {
|
|
296
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
297
|
+
}
|
|
298
|
+
return takeFromExternrefTable0(ret[0]);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Verify an ML-DSA-44 detached signature.
|
|
303
|
+
* @param {Uint8Array} public_key
|
|
304
|
+
* @param {Uint8Array} message
|
|
305
|
+
* @param {Uint8Array} signature
|
|
306
|
+
*/
|
|
307
|
+
export function mlDsa44Verify(public_key, message, signature) {
|
|
308
|
+
const ret = wasm.mlDsa44Verify(public_key, message, signature);
|
|
309
|
+
if (ret[1]) {
|
|
310
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Derive an ML-DSA-65 keypair from a 32-byte seed.
|
|
316
|
+
* @param {Uint8Array} secret_key
|
|
317
|
+
* @returns {any}
|
|
318
|
+
*/
|
|
319
|
+
export function mlDsa65DeriveKeypair(secret_key) {
|
|
320
|
+
const ret = wasm.mlDsa65DeriveKeypair(secret_key);
|
|
321
|
+
if (ret[2]) {
|
|
322
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
323
|
+
}
|
|
324
|
+
return takeFromExternrefTable0(ret[0]);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Generate an ML-DSA-65 keypair.
|
|
329
|
+
* @returns {any}
|
|
330
|
+
*/
|
|
331
|
+
export function mlDsa65GenerateKeypair() {
|
|
332
|
+
const ret = wasm.mlDsa65GenerateKeypair();
|
|
333
|
+
if (ret[2]) {
|
|
334
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
335
|
+
}
|
|
336
|
+
return takeFromExternrefTable0(ret[0]);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Sign a message with ML-DSA-65.
|
|
341
|
+
* @param {Uint8Array} secret_key
|
|
342
|
+
* @param {Uint8Array} message
|
|
343
|
+
* @returns {Uint8Array}
|
|
344
|
+
*/
|
|
345
|
+
export function mlDsa65Sign(secret_key, message) {
|
|
346
|
+
const ret = wasm.mlDsa65Sign(secret_key, message);
|
|
347
|
+
if (ret[2]) {
|
|
348
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
349
|
+
}
|
|
350
|
+
return takeFromExternrefTable0(ret[0]);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Verify an ML-DSA-65 detached signature.
|
|
355
|
+
* @param {Uint8Array} public_key
|
|
356
|
+
* @param {Uint8Array} message
|
|
357
|
+
* @param {Uint8Array} signature
|
|
358
|
+
*/
|
|
359
|
+
export function mlDsa65Verify(public_key, message, signature) {
|
|
360
|
+
const ret = wasm.mlDsa65Verify(public_key, message, signature);
|
|
361
|
+
if (ret[1]) {
|
|
362
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Derive an ML-DSA-87 keypair from a 32-byte seed.
|
|
368
|
+
* @param {Uint8Array} secret_key
|
|
369
|
+
* @returns {any}
|
|
370
|
+
*/
|
|
371
|
+
export function mlDsa87DeriveKeypair(secret_key) {
|
|
372
|
+
const ret = wasm.mlDsa87DeriveKeypair(secret_key);
|
|
373
|
+
if (ret[2]) {
|
|
374
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
375
|
+
}
|
|
376
|
+
return takeFromExternrefTable0(ret[0]);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Generate an ML-DSA-87 keypair.
|
|
381
|
+
* @returns {any}
|
|
382
|
+
*/
|
|
383
|
+
export function mlDsa87GenerateKeypair() {
|
|
384
|
+
const ret = wasm.mlDsa87GenerateKeypair();
|
|
385
|
+
if (ret[2]) {
|
|
386
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
387
|
+
}
|
|
388
|
+
return takeFromExternrefTable0(ret[0]);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Sign a message with ML-DSA-87.
|
|
393
|
+
* @param {Uint8Array} secret_key
|
|
394
|
+
* @param {Uint8Array} message
|
|
395
|
+
* @returns {Uint8Array}
|
|
396
|
+
*/
|
|
397
|
+
export function mlDsa87Sign(secret_key, message) {
|
|
398
|
+
const ret = wasm.mlDsa87Sign(secret_key, message);
|
|
399
|
+
if (ret[2]) {
|
|
400
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
401
|
+
}
|
|
402
|
+
return takeFromExternrefTable0(ret[0]);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Verify an ML-DSA-87 detached signature.
|
|
407
|
+
* @param {Uint8Array} public_key
|
|
408
|
+
* @param {Uint8Array} message
|
|
409
|
+
* @param {Uint8Array} signature
|
|
410
|
+
*/
|
|
411
|
+
export function mlDsa87Verify(public_key, message, signature) {
|
|
412
|
+
const ret = wasm.mlDsa87Verify(public_key, message, signature);
|
|
413
|
+
if (ret[1]) {
|
|
414
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Decapsulate an ML-KEM-1024 ciphertext.
|
|
420
|
+
* @param {Uint8Array} ciphertext
|
|
421
|
+
* @param {Uint8Array} secret_key
|
|
422
|
+
* @returns {Uint8Array}
|
|
423
|
+
*/
|
|
424
|
+
export function mlKem1024Decapsulate(ciphertext, secret_key) {
|
|
425
|
+
const ret = wasm.mlKem1024Decapsulate(ciphertext, secret_key);
|
|
426
|
+
if (ret[2]) {
|
|
427
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
428
|
+
}
|
|
429
|
+
return takeFromExternrefTable0(ret[0]);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Derive an ML-KEM-1024 keypair from a 64-byte FIPS 203 seed.
|
|
434
|
+
* @param {Uint8Array} secret_key
|
|
435
|
+
* @returns {any}
|
|
436
|
+
*/
|
|
437
|
+
export function mlKem1024DeriveKeypair(secret_key) {
|
|
438
|
+
const ret = wasm.mlKem1024DeriveKeypair(secret_key);
|
|
439
|
+
if (ret[2]) {
|
|
440
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
441
|
+
}
|
|
442
|
+
return takeFromExternrefTable0(ret[0]);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Encapsulate to an ML-KEM-1024 public key.
|
|
447
|
+
* @param {Uint8Array} public_key
|
|
448
|
+
* @returns {any}
|
|
449
|
+
*/
|
|
450
|
+
export function mlKem1024Encapsulate(public_key) {
|
|
451
|
+
const ret = wasm.mlKem1024Encapsulate(public_key);
|
|
452
|
+
if (ret[2]) {
|
|
453
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
454
|
+
}
|
|
455
|
+
return takeFromExternrefTable0(ret[0]);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Deterministically encapsulate to an ML-KEM-1024 public key.
|
|
460
|
+
* @param {Uint8Array} public_key
|
|
461
|
+
* @param {Uint8Array} randomness
|
|
462
|
+
* @returns {any}
|
|
463
|
+
*/
|
|
464
|
+
export function mlKem1024EncapsulateDerand(public_key, randomness) {
|
|
465
|
+
const ret = wasm.mlKem1024EncapsulateDerand(public_key, randomness);
|
|
466
|
+
if (ret[2]) {
|
|
467
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
468
|
+
}
|
|
469
|
+
return takeFromExternrefTable0(ret[0]);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Generate an ML-KEM-1024 keypair.
|
|
474
|
+
* @returns {any}
|
|
475
|
+
*/
|
|
476
|
+
export function mlKem1024GenerateKeypair() {
|
|
477
|
+
const ret = wasm.mlKem1024GenerateKeypair();
|
|
478
|
+
if (ret[2]) {
|
|
479
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
480
|
+
}
|
|
481
|
+
return takeFromExternrefTable0(ret[0]);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Decapsulate an ML-KEM-512 ciphertext.
|
|
486
|
+
* @param {Uint8Array} ciphertext
|
|
487
|
+
* @param {Uint8Array} secret_key
|
|
488
|
+
* @returns {Uint8Array}
|
|
489
|
+
*/
|
|
490
|
+
export function mlKem512Decapsulate(ciphertext, secret_key) {
|
|
491
|
+
const ret = wasm.mlKem512Decapsulate(ciphertext, secret_key);
|
|
492
|
+
if (ret[2]) {
|
|
493
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
494
|
+
}
|
|
495
|
+
return takeFromExternrefTable0(ret[0]);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Derive an ML-KEM-512 keypair from a 64-byte FIPS 203 seed.
|
|
500
|
+
* @param {Uint8Array} secret_key
|
|
501
|
+
* @returns {any}
|
|
502
|
+
*/
|
|
503
|
+
export function mlKem512DeriveKeypair(secret_key) {
|
|
504
|
+
const ret = wasm.mlKem512DeriveKeypair(secret_key);
|
|
505
|
+
if (ret[2]) {
|
|
506
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
507
|
+
}
|
|
508
|
+
return takeFromExternrefTable0(ret[0]);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Encapsulate to an ML-KEM-512 public key.
|
|
513
|
+
* @param {Uint8Array} public_key
|
|
514
|
+
* @returns {any}
|
|
515
|
+
*/
|
|
516
|
+
export function mlKem512Encapsulate(public_key) {
|
|
517
|
+
const ret = wasm.mlKem512Encapsulate(public_key);
|
|
518
|
+
if (ret[2]) {
|
|
519
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
520
|
+
}
|
|
521
|
+
return takeFromExternrefTable0(ret[0]);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Deterministically encapsulate to an ML-KEM-512 public key.
|
|
526
|
+
* @param {Uint8Array} public_key
|
|
527
|
+
* @param {Uint8Array} randomness
|
|
528
|
+
* @returns {any}
|
|
529
|
+
*/
|
|
530
|
+
export function mlKem512EncapsulateDerand(public_key, randomness) {
|
|
531
|
+
const ret = wasm.mlKem512EncapsulateDerand(public_key, randomness);
|
|
532
|
+
if (ret[2]) {
|
|
533
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
534
|
+
}
|
|
535
|
+
return takeFromExternrefTable0(ret[0]);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Generate an ML-KEM-512 keypair.
|
|
540
|
+
* @returns {any}
|
|
541
|
+
*/
|
|
542
|
+
export function mlKem512GenerateKeypair() {
|
|
543
|
+
const ret = wasm.mlKem512GenerateKeypair();
|
|
544
|
+
if (ret[2]) {
|
|
545
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
546
|
+
}
|
|
547
|
+
return takeFromExternrefTable0(ret[0]);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Decapsulate an ML-KEM-768 ciphertext.
|
|
552
|
+
* @param {Uint8Array} ciphertext
|
|
553
|
+
* @param {Uint8Array} secret_key
|
|
554
|
+
* @returns {Uint8Array}
|
|
555
|
+
*/
|
|
556
|
+
export function mlKem768Decapsulate(ciphertext, secret_key) {
|
|
557
|
+
const ret = wasm.mlKem768Decapsulate(ciphertext, secret_key);
|
|
558
|
+
if (ret[2]) {
|
|
559
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
560
|
+
}
|
|
561
|
+
return takeFromExternrefTable0(ret[0]);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Derive an ML-KEM-768 keypair from a 64-byte FIPS 203 seed.
|
|
566
|
+
* @param {Uint8Array} secret_key
|
|
567
|
+
* @returns {any}
|
|
568
|
+
*/
|
|
569
|
+
export function mlKem768DeriveKeypair(secret_key) {
|
|
570
|
+
const ret = wasm.mlKem768DeriveKeypair(secret_key);
|
|
571
|
+
if (ret[2]) {
|
|
572
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
573
|
+
}
|
|
574
|
+
return takeFromExternrefTable0(ret[0]);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Encapsulate to an ML-KEM-768 public key.
|
|
579
|
+
* @param {Uint8Array} public_key
|
|
580
|
+
* @returns {any}
|
|
581
|
+
*/
|
|
582
|
+
export function mlKem768Encapsulate(public_key) {
|
|
583
|
+
const ret = wasm.mlKem768Encapsulate(public_key);
|
|
584
|
+
if (ret[2]) {
|
|
585
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
586
|
+
}
|
|
587
|
+
return takeFromExternrefTable0(ret[0]);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Deterministically encapsulate to an ML-KEM-768 public key.
|
|
592
|
+
* @param {Uint8Array} public_key
|
|
593
|
+
* @param {Uint8Array} randomness
|
|
594
|
+
* @returns {any}
|
|
595
|
+
*/
|
|
596
|
+
export function mlKem768EncapsulateDerand(public_key, randomness) {
|
|
597
|
+
const ret = wasm.mlKem768EncapsulateDerand(public_key, randomness);
|
|
598
|
+
if (ret[2]) {
|
|
599
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
600
|
+
}
|
|
601
|
+
return takeFromExternrefTable0(ret[0]);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Generate an ML-KEM-768 keypair.
|
|
606
|
+
* @returns {any}
|
|
607
|
+
*/
|
|
608
|
+
export function mlKem768GenerateKeypair() {
|
|
609
|
+
const ret = wasm.mlKem768GenerateKeypair();
|
|
610
|
+
if (ret[2]) {
|
|
611
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
612
|
+
}
|
|
613
|
+
return takeFromExternrefTable0(ret[0]);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Encode bytes with the multibase base58btc prefix.
|
|
618
|
+
* @param {Uint8Array} bytes
|
|
619
|
+
* @returns {string}
|
|
620
|
+
*/
|
|
621
|
+
export function multibaseBase58btcEncode(bytes) {
|
|
622
|
+
let deferred1_0;
|
|
623
|
+
let deferred1_1;
|
|
624
|
+
try {
|
|
625
|
+
const ret = wasm.multibaseBase58btcEncode(bytes);
|
|
626
|
+
deferred1_0 = ret[0];
|
|
627
|
+
deferred1_1 = ret[1];
|
|
628
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
629
|
+
} finally {
|
|
630
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Encode bytes with the multibase base64url prefix.
|
|
636
|
+
* @param {Uint8Array} bytes
|
|
637
|
+
* @returns {string}
|
|
638
|
+
*/
|
|
639
|
+
export function multibaseBase64urlEncode(bytes) {
|
|
640
|
+
let deferred1_0;
|
|
641
|
+
let deferred1_1;
|
|
642
|
+
try {
|
|
643
|
+
const ret = wasm.multibaseBase64urlEncode(bytes);
|
|
644
|
+
deferred1_0 = ret[0];
|
|
645
|
+
deferred1_1 = ret[1];
|
|
646
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
647
|
+
} finally {
|
|
648
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Decode a supported multibase string.
|
|
654
|
+
* @param {string} encoded
|
|
655
|
+
* @returns {Uint8Array}
|
|
656
|
+
*/
|
|
657
|
+
export function multibaseDecode(encoded) {
|
|
658
|
+
const ptr0 = passStringToWasm0(encoded, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
659
|
+
const len0 = WASM_VECTOR_LEN;
|
|
660
|
+
const ret = wasm.multibaseDecode(ptr0, len0);
|
|
661
|
+
if (ret[2]) {
|
|
662
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
663
|
+
}
|
|
664
|
+
return takeFromExternrefTable0(ret[0]);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Resolve a byte slice that starts with a known multicodec prefix.
|
|
669
|
+
* @param {Uint8Array} bytes
|
|
670
|
+
* @returns {any}
|
|
671
|
+
*/
|
|
672
|
+
export function multicodecLookupPrefix(bytes) {
|
|
673
|
+
const ret = wasm.multicodecLookupPrefix(bytes);
|
|
674
|
+
if (ret[2]) {
|
|
675
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
676
|
+
}
|
|
677
|
+
return takeFromExternrefTable0(ret[0]);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Return multicodec metadata for a canonical codec name.
|
|
682
|
+
* @param {string} codec_name
|
|
683
|
+
* @returns {any}
|
|
684
|
+
*/
|
|
685
|
+
export function multicodecPrefixForName(codec_name) {
|
|
686
|
+
const ptr0 = passStringToWasm0(codec_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
687
|
+
const len0 = WASM_VECTOR_LEN;
|
|
688
|
+
const ret = wasm.multicodecPrefixForName(ptr0, len0);
|
|
689
|
+
if (ret[2]) {
|
|
690
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
691
|
+
}
|
|
692
|
+
return takeFromExternrefTable0(ret[0]);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Encode a public key as a multibase base58btc multikey.
|
|
697
|
+
* @param {string} codec_name
|
|
698
|
+
* @param {Uint8Array} public_key
|
|
699
|
+
* @returns {string}
|
|
700
|
+
*/
|
|
701
|
+
export function multikeyEncode(codec_name, public_key) {
|
|
702
|
+
let deferred3_0;
|
|
703
|
+
let deferred3_1;
|
|
704
|
+
try {
|
|
705
|
+
const ptr0 = passStringToWasm0(codec_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
706
|
+
const len0 = WASM_VECTOR_LEN;
|
|
707
|
+
const ret = wasm.multikeyEncode(ptr0, len0, public_key);
|
|
708
|
+
var ptr2 = ret[0];
|
|
709
|
+
var len2 = ret[1];
|
|
710
|
+
if (ret[3]) {
|
|
711
|
+
ptr2 = 0; len2 = 0;
|
|
712
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
713
|
+
}
|
|
714
|
+
deferred3_0 = ptr2;
|
|
715
|
+
deferred3_1 = len2;
|
|
716
|
+
return getStringFromWasm0(ptr2, len2);
|
|
717
|
+
} finally {
|
|
718
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Parse and validate a multikey string.
|
|
724
|
+
* @param {string} multikey
|
|
725
|
+
* @returns {any}
|
|
726
|
+
*/
|
|
727
|
+
export function multikeyParse(multikey) {
|
|
728
|
+
const ptr0 = passStringToWasm0(multikey, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
729
|
+
const len0 = WASM_VECTOR_LEN;
|
|
730
|
+
const ret = wasm.multikeyParse(ptr0, len0);
|
|
731
|
+
if (ret[2]) {
|
|
732
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
733
|
+
}
|
|
734
|
+
return takeFromExternrefTable0(ret[0]);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Verify an RSASSA-PKCS1-v1_5 signature against a DER RSA public key.
|
|
739
|
+
* @param {Uint8Array} public_key_der
|
|
740
|
+
* @param {number} public_key_encoding
|
|
741
|
+
* @param {number} hash_suite
|
|
742
|
+
* @param {Uint8Array} message
|
|
743
|
+
* @param {Uint8Array} signature
|
|
744
|
+
*/
|
|
745
|
+
export function rsaVerifyPkcs1v15(public_key_der, public_key_encoding, hash_suite, message, signature) {
|
|
746
|
+
const ret = wasm.rsaVerifyPkcs1v15(public_key_der, public_key_encoding, hash_suite, message, signature);
|
|
747
|
+
if (ret[1]) {
|
|
748
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Verify an RSASSA-PSS signature against a DER RSA public key.
|
|
754
|
+
* @param {Uint8Array} public_key_der
|
|
755
|
+
* @param {number} public_key_encoding
|
|
756
|
+
* @param {number} message_hash_suite
|
|
757
|
+
* @param {number} mgf1_hash_suite
|
|
758
|
+
* @param {number} salt_len
|
|
759
|
+
* @param {Uint8Array} message
|
|
760
|
+
* @param {Uint8Array} signature
|
|
761
|
+
*/
|
|
762
|
+
export function rsaVerifyPss(public_key_der, public_key_encoding, message_hash_suite, mgf1_hash_suite, salt_len, message, signature) {
|
|
763
|
+
const ret = wasm.rsaVerifyPss(public_key_der, public_key_encoding, message_hash_suite, mgf1_hash_suite, salt_len, message, signature);
|
|
764
|
+
if (ret[1]) {
|
|
765
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Derive an SLH-DSA-SHA2-128s keypair from the three FIPS 205 seeds.
|
|
771
|
+
* @param {Uint8Array} sk_seed
|
|
772
|
+
* @param {Uint8Array} sk_prf
|
|
773
|
+
* @param {Uint8Array} pk_seed
|
|
774
|
+
* @returns {any}
|
|
775
|
+
*/
|
|
776
|
+
export function slhDsaSha2128sDeriveKeypair(sk_seed, sk_prf, pk_seed) {
|
|
777
|
+
const ret = wasm.slhDsaSha2128sDeriveKeypair(sk_seed, sk_prf, pk_seed);
|
|
778
|
+
if (ret[2]) {
|
|
779
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
780
|
+
}
|
|
781
|
+
return takeFromExternrefTable0(ret[0]);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Generate an SLH-DSA-SHA2-128s keypair.
|
|
786
|
+
* @returns {any}
|
|
787
|
+
*/
|
|
788
|
+
export function slhDsaSha2128sGenerateKeypair() {
|
|
789
|
+
const ret = wasm.slhDsaSha2128sGenerateKeypair();
|
|
790
|
+
if (ret[2]) {
|
|
791
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
792
|
+
}
|
|
793
|
+
return takeFromExternrefTable0(ret[0]);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Sign a message with SLH-DSA-SHA2-128s.
|
|
798
|
+
* @param {Uint8Array} secret_key
|
|
799
|
+
* @param {Uint8Array} message
|
|
800
|
+
* @returns {Uint8Array}
|
|
801
|
+
*/
|
|
802
|
+
export function slhDsaSha2128sSign(secret_key, message) {
|
|
803
|
+
const ret = wasm.slhDsaSha2128sSign(secret_key, message);
|
|
804
|
+
if (ret[2]) {
|
|
805
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
806
|
+
}
|
|
807
|
+
return takeFromExternrefTable0(ret[0]);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Verify an SLH-DSA-SHA2-128s detached signature.
|
|
812
|
+
* @param {Uint8Array} public_key
|
|
813
|
+
* @param {Uint8Array} message
|
|
814
|
+
* @param {Uint8Array} signature
|
|
815
|
+
*/
|
|
816
|
+
export function slhDsaSha2128sVerify(public_key, message, signature) {
|
|
817
|
+
const ret = wasm.slhDsaSha2128sVerify(public_key, message, signature);
|
|
818
|
+
if (ret[1]) {
|
|
819
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Decapsulate an X-Wing-1024 ciphertext with a 32-byte secret seed.
|
|
825
|
+
* @param {Uint8Array} ciphertext
|
|
826
|
+
* @param {Uint8Array} secret_key
|
|
827
|
+
* @returns {Uint8Array}
|
|
828
|
+
*/
|
|
829
|
+
export function xWing1024Decapsulate(ciphertext, secret_key) {
|
|
830
|
+
const ret = wasm.xWing1024Decapsulate(ciphertext, secret_key);
|
|
831
|
+
if (ret[2]) {
|
|
832
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
833
|
+
}
|
|
834
|
+
return takeFromExternrefTable0(ret[0]);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Derive an X-Wing-1024 public key from a 32-byte secret seed.
|
|
839
|
+
* @param {Uint8Array} secret_key
|
|
840
|
+
* @returns {any}
|
|
841
|
+
*/
|
|
842
|
+
export function xWing1024DeriveKeypair(secret_key) {
|
|
843
|
+
const ret = wasm.xWing1024DeriveKeypair(secret_key);
|
|
844
|
+
if (ret[2]) {
|
|
845
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
846
|
+
}
|
|
847
|
+
return takeFromExternrefTable0(ret[0]);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Randomly encapsulate to an X-Wing-1024 public key.
|
|
852
|
+
* @param {Uint8Array} public_key
|
|
853
|
+
* @returns {any}
|
|
854
|
+
*/
|
|
855
|
+
export function xWing1024Encapsulate(public_key) {
|
|
856
|
+
const ret = wasm.xWing1024Encapsulate(public_key);
|
|
857
|
+
if (ret[2]) {
|
|
858
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
859
|
+
}
|
|
860
|
+
return takeFromExternrefTable0(ret[0]);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Deterministically encapsulate to an X-Wing-1024 public key for conformance tests.
|
|
865
|
+
* @param {Uint8Array} public_key
|
|
866
|
+
* @param {Uint8Array} seed
|
|
867
|
+
* @returns {any}
|
|
868
|
+
*/
|
|
869
|
+
export function xWing1024EncapsulateDerand(public_key, seed) {
|
|
870
|
+
const ret = wasm.xWing1024EncapsulateDerand(public_key, seed);
|
|
871
|
+
if (ret[2]) {
|
|
872
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
873
|
+
}
|
|
874
|
+
return takeFromExternrefTable0(ret[0]);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Generate a random X-Wing-1024 keypair for the TypeScript WASM provider.
|
|
879
|
+
* @returns {any}
|
|
880
|
+
*/
|
|
881
|
+
export function xWing1024GenerateKeypair() {
|
|
882
|
+
const ret = wasm.xWing1024GenerateKeypair();
|
|
883
|
+
if (ret[2]) {
|
|
884
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
885
|
+
}
|
|
886
|
+
return takeFromExternrefTable0(ret[0]);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Decapsulate an X-Wing-768 ciphertext with a 32-byte secret seed.
|
|
891
|
+
* @param {Uint8Array} ciphertext
|
|
892
|
+
* @param {Uint8Array} secret_key
|
|
893
|
+
* @returns {Uint8Array}
|
|
894
|
+
*/
|
|
895
|
+
export function xWing768Decapsulate(ciphertext, secret_key) {
|
|
896
|
+
const ret = wasm.xWing768Decapsulate(ciphertext, secret_key);
|
|
897
|
+
if (ret[2]) {
|
|
898
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
899
|
+
}
|
|
900
|
+
return takeFromExternrefTable0(ret[0]);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Derive an X-Wing-768 public key from a 32-byte secret seed.
|
|
905
|
+
* @param {Uint8Array} secret_key
|
|
906
|
+
* @returns {any}
|
|
907
|
+
*/
|
|
908
|
+
export function xWing768DeriveKeypair(secret_key) {
|
|
909
|
+
const ret = wasm.xWing768DeriveKeypair(secret_key);
|
|
910
|
+
if (ret[2]) {
|
|
911
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
912
|
+
}
|
|
913
|
+
return takeFromExternrefTable0(ret[0]);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Randomly encapsulate to an X-Wing-768 public key.
|
|
918
|
+
* @param {Uint8Array} public_key
|
|
919
|
+
* @returns {any}
|
|
920
|
+
*/
|
|
921
|
+
export function xWing768Encapsulate(public_key) {
|
|
922
|
+
const ret = wasm.xWing768Encapsulate(public_key);
|
|
923
|
+
if (ret[2]) {
|
|
924
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
925
|
+
}
|
|
926
|
+
return takeFromExternrefTable0(ret[0]);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Deterministically encapsulate to an X-Wing-768 public key for conformance tests.
|
|
931
|
+
* @param {Uint8Array} public_key
|
|
932
|
+
* @param {Uint8Array} seed
|
|
933
|
+
* @returns {any}
|
|
934
|
+
*/
|
|
935
|
+
export function xWing768EncapsulateDerand(public_key, seed) {
|
|
936
|
+
const ret = wasm.xWing768EncapsulateDerand(public_key, seed);
|
|
937
|
+
if (ret[2]) {
|
|
938
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
939
|
+
}
|
|
940
|
+
return takeFromExternrefTable0(ret[0]);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Generate a random X-Wing-768 keypair for the TypeScript WASM provider.
|
|
945
|
+
* @returns {any}
|
|
946
|
+
*/
|
|
947
|
+
export function xWing768GenerateKeypair() {
|
|
948
|
+
const ret = wasm.xWing768GenerateKeypair();
|
|
949
|
+
if (ret[2]) {
|
|
950
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
951
|
+
}
|
|
952
|
+
return takeFromExternrefTable0(ret[0]);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Open and authenticate an XChaCha20-Poly1305 `ciphertext || tag`.
|
|
957
|
+
* @param {Uint8Array} key
|
|
958
|
+
* @param {Uint8Array} nonce
|
|
959
|
+
* @param {Uint8Array} aad
|
|
960
|
+
* @param {Uint8Array} ciphertext
|
|
961
|
+
* @returns {Uint8Array}
|
|
962
|
+
*/
|
|
963
|
+
export function xchacha20Poly1305Open(key, nonce, aad, ciphertext) {
|
|
964
|
+
const ret = wasm.xchacha20Poly1305Open(key, nonce, aad, ciphertext);
|
|
965
|
+
if (ret[2]) {
|
|
966
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
967
|
+
}
|
|
968
|
+
return takeFromExternrefTable0(ret[0]);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Seal plaintext with XChaCha20-Poly1305 and return `ciphertext || tag`.
|
|
973
|
+
* @param {Uint8Array} key
|
|
974
|
+
* @param {Uint8Array} nonce
|
|
975
|
+
* @param {Uint8Array} aad
|
|
976
|
+
* @param {Uint8Array} plaintext
|
|
977
|
+
* @returns {Uint8Array}
|
|
978
|
+
*/
|
|
979
|
+
export function xchacha20Poly1305Seal(key, nonce, aad, plaintext) {
|
|
980
|
+
const ret = wasm.xchacha20Poly1305Seal(key, nonce, aad, plaintext);
|
|
981
|
+
if (ret[2]) {
|
|
982
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
983
|
+
}
|
|
984
|
+
return takeFromExternrefTable0(ret[0]);
|
|
985
|
+
}
|
|
986
|
+
function __wbg_get_imports() {
|
|
987
|
+
const import0 = {
|
|
988
|
+
__proto__: null,
|
|
989
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
990
|
+
const ret = typeof(arg0) === 'function';
|
|
991
|
+
return ret;
|
|
992
|
+
},
|
|
993
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
994
|
+
const val = arg0;
|
|
995
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
996
|
+
return ret;
|
|
997
|
+
},
|
|
998
|
+
__wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
|
|
999
|
+
const ret = typeof(arg0) === 'string';
|
|
1000
|
+
return ret;
|
|
1001
|
+
},
|
|
1002
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
1003
|
+
const ret = arg0 === undefined;
|
|
1004
|
+
return ret;
|
|
1005
|
+
},
|
|
1006
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
1007
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1008
|
+
},
|
|
1009
|
+
__wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1010
|
+
const ret = arg0.call(arg1, arg2);
|
|
1011
|
+
return ret;
|
|
1012
|
+
}, arguments); },
|
|
1013
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
1014
|
+
const ret = arg0.crypto;
|
|
1015
|
+
return ret;
|
|
1016
|
+
},
|
|
1017
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
1018
|
+
arg0.getRandomValues(arg1);
|
|
1019
|
+
}, arguments); },
|
|
1020
|
+
__wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
|
|
1021
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1022
|
+
}, arguments); },
|
|
1023
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
1024
|
+
const ret = arg0.length;
|
|
1025
|
+
return ret;
|
|
1026
|
+
},
|
|
1027
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
1028
|
+
const ret = arg0.msCrypto;
|
|
1029
|
+
return ret;
|
|
1030
|
+
},
|
|
1031
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
1032
|
+
const ret = new Object();
|
|
1033
|
+
return ret;
|
|
1034
|
+
},
|
|
1035
|
+
__wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
|
|
1036
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1037
|
+
return ret;
|
|
1038
|
+
},
|
|
1039
|
+
__wbg_new_with_length_e6785c33c8e4cce8: function(arg0) {
|
|
1040
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
1041
|
+
return ret;
|
|
1042
|
+
},
|
|
1043
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
1044
|
+
const ret = arg0.node;
|
|
1045
|
+
return ret;
|
|
1046
|
+
},
|
|
1047
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
1048
|
+
const ret = arg0.process;
|
|
1049
|
+
return ret;
|
|
1050
|
+
},
|
|
1051
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
1052
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1053
|
+
},
|
|
1054
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
1055
|
+
arg0.randomFillSync(arg1);
|
|
1056
|
+
}, arguments); },
|
|
1057
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
1058
|
+
const ret = module.require;
|
|
1059
|
+
return ret;
|
|
1060
|
+
}, arguments); },
|
|
1061
|
+
__wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1062
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1063
|
+
return ret;
|
|
1064
|
+
}, arguments); },
|
|
1065
|
+
__wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
|
|
1066
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1067
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1068
|
+
},
|
|
1069
|
+
__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
|
|
1070
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1071
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1072
|
+
},
|
|
1073
|
+
__wbg_static_accessor_SELF_146583524fe1469b: function() {
|
|
1074
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1075
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1076
|
+
},
|
|
1077
|
+
__wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
|
|
1078
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1079
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1080
|
+
},
|
|
1081
|
+
__wbg_subarray_3ed232c8a6baee09: function(arg0, arg1, arg2) {
|
|
1082
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1083
|
+
return ret;
|
|
1084
|
+
},
|
|
1085
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
1086
|
+
const ret = arg0.versions;
|
|
1087
|
+
return ret;
|
|
1088
|
+
},
|
|
1089
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1090
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1091
|
+
const ret = arg0;
|
|
1092
|
+
return ret;
|
|
1093
|
+
},
|
|
1094
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1095
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1096
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1097
|
+
return ret;
|
|
1098
|
+
},
|
|
1099
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1100
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1101
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1102
|
+
return ret;
|
|
1103
|
+
},
|
|
1104
|
+
__wbindgen_init_externref_table: function() {
|
|
1105
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1106
|
+
const offset = table.grow(4);
|
|
1107
|
+
table.set(0, undefined);
|
|
1108
|
+
table.set(offset + 0, undefined);
|
|
1109
|
+
table.set(offset + 1, null);
|
|
1110
|
+
table.set(offset + 2, true);
|
|
1111
|
+
table.set(offset + 3, false);
|
|
1112
|
+
},
|
|
1113
|
+
};
|
|
1114
|
+
return {
|
|
1115
|
+
__proto__: null,
|
|
1116
|
+
"./reallyme_crypto_wasm_bg.js": import0,
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function addToExternrefTable0(obj) {
|
|
1121
|
+
const idx = wasm.__externref_table_alloc();
|
|
1122
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1123
|
+
return idx;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1127
|
+
ptr = ptr >>> 0;
|
|
1128
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function getStringFromWasm0(ptr, len) {
|
|
1132
|
+
return decodeText(ptr >>> 0, len);
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1136
|
+
function getUint8ArrayMemory0() {
|
|
1137
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1138
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1139
|
+
}
|
|
1140
|
+
return cachedUint8ArrayMemory0;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
function handleError(f, args) {
|
|
1144
|
+
try {
|
|
1145
|
+
return f.apply(this, args);
|
|
1146
|
+
} catch (e) {
|
|
1147
|
+
const idx = addToExternrefTable0(e);
|
|
1148
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
function isLikeNone(x) {
|
|
1153
|
+
return x === undefined || x === null;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1157
|
+
if (realloc === undefined) {
|
|
1158
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1159
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1160
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1161
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1162
|
+
return ptr;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
let len = arg.length;
|
|
1166
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1167
|
+
|
|
1168
|
+
const mem = getUint8ArrayMemory0();
|
|
1169
|
+
|
|
1170
|
+
let offset = 0;
|
|
1171
|
+
|
|
1172
|
+
for (; offset < len; offset++) {
|
|
1173
|
+
const code = arg.charCodeAt(offset);
|
|
1174
|
+
if (code > 0x7F) break;
|
|
1175
|
+
mem[ptr + offset] = code;
|
|
1176
|
+
}
|
|
1177
|
+
if (offset !== len) {
|
|
1178
|
+
if (offset !== 0) {
|
|
1179
|
+
arg = arg.slice(offset);
|
|
1180
|
+
}
|
|
1181
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1182
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1183
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1184
|
+
|
|
1185
|
+
offset += ret.written;
|
|
1186
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
WASM_VECTOR_LEN = offset;
|
|
1190
|
+
return ptr;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
function takeFromExternrefTable0(idx) {
|
|
1194
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1195
|
+
wasm.__externref_table_dealloc(idx);
|
|
1196
|
+
return value;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1200
|
+
cachedTextDecoder.decode();
|
|
1201
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1202
|
+
let numBytesDecoded = 0;
|
|
1203
|
+
function decodeText(ptr, len) {
|
|
1204
|
+
numBytesDecoded += len;
|
|
1205
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1206
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1207
|
+
cachedTextDecoder.decode();
|
|
1208
|
+
numBytesDecoded = len;
|
|
1209
|
+
}
|
|
1210
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1214
|
+
|
|
1215
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1216
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1217
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1218
|
+
view.set(buf);
|
|
1219
|
+
return {
|
|
1220
|
+
read: arg.length,
|
|
1221
|
+
written: buf.length
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
let WASM_VECTOR_LEN = 0;
|
|
1227
|
+
|
|
1228
|
+
let wasmModule, wasmInstance, wasm;
|
|
1229
|
+
function __wbg_finalize_init(instance, module) {
|
|
1230
|
+
wasmInstance = instance;
|
|
1231
|
+
wasm = instance.exports;
|
|
1232
|
+
wasmModule = module;
|
|
1233
|
+
cachedUint8ArrayMemory0 = null;
|
|
1234
|
+
wasm.__wbindgen_start();
|
|
1235
|
+
return wasm;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
async function __wbg_load(module, imports) {
|
|
1239
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1240
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1241
|
+
try {
|
|
1242
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1243
|
+
} catch (e) {
|
|
1244
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1245
|
+
|
|
1246
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1247
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1248
|
+
|
|
1249
|
+
} else { throw e; }
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
const bytes = await module.arrayBuffer();
|
|
1254
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1255
|
+
} else {
|
|
1256
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1257
|
+
|
|
1258
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1259
|
+
return { instance, module };
|
|
1260
|
+
} else {
|
|
1261
|
+
return instance;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function expectedResponseType(type) {
|
|
1266
|
+
switch (type) {
|
|
1267
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1268
|
+
}
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function initSync(module) {
|
|
1274
|
+
if (wasm !== undefined) return wasm;
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
if (module !== undefined) {
|
|
1278
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1279
|
+
({module} = module)
|
|
1280
|
+
} else {
|
|
1281
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
const imports = __wbg_get_imports();
|
|
1286
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1287
|
+
module = new WebAssembly.Module(module);
|
|
1288
|
+
}
|
|
1289
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1290
|
+
return __wbg_finalize_init(instance, module);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
async function __wbg_init(module_or_path) {
|
|
1294
|
+
if (wasm !== undefined) return wasm;
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
if (module_or_path !== undefined) {
|
|
1298
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1299
|
+
({module_or_path} = module_or_path)
|
|
1300
|
+
} else {
|
|
1301
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (module_or_path === undefined) {
|
|
1306
|
+
module_or_path = new URL('reallyme_crypto_wasm_bg.wasm', import.meta.url);
|
|
1307
|
+
}
|
|
1308
|
+
const imports = __wbg_get_imports();
|
|
1309
|
+
|
|
1310
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1311
|
+
module_or_path = fetch(module_or_path);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1315
|
+
|
|
1316
|
+
return __wbg_finalize_init(instance, module);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
export { initSync, __wbg_init as default };
|