cojson-core-wasm 0.20.14 → 0.20.15
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/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cojson-core-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.20.
|
|
4
|
+
"version": "0.20.15",
|
|
5
5
|
"files": [
|
|
6
6
|
"public/cojson_core_wasm.js",
|
|
7
7
|
"public/cojson_core_wasm.d.ts",
|
|
8
8
|
"public/cojson_core_wasm.wasm.js",
|
|
9
9
|
"public/cojson_core_wasm.wasm.d.ts",
|
|
10
10
|
"public/cojson_core_wasm.wasm",
|
|
11
|
+
"public/snippets",
|
|
11
12
|
"edge-lite.js",
|
|
12
13
|
"index.js",
|
|
13
14
|
"index.d.ts"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export function init(): void;
|
|
3
4
|
/**
|
|
4
5
|
* WASM-exposed function for unsealing a message using X25519 + XSalsa20-Poly1305.
|
|
5
6
|
* Provides authenticated decryption with perfect forward secrecy.
|
|
@@ -38,6 +39,31 @@ export function seal(message: Uint8Array, sender_secret: string, recipient_id: s
|
|
|
38
39
|
* Returns unsealed bytes or throws JsError if unsealing fails.
|
|
39
40
|
*/
|
|
40
41
|
export function unsealForGroup(sealed_message: Uint8Array, recipient_secret: string, nonce_material: Uint8Array): Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* WASM-exposed function to derive a sealer ID from a sealer secret.
|
|
44
|
+
* - `secret`: Raw bytes of the sealer secret
|
|
45
|
+
* Returns a base58-encoded sealer ID with "sealer_z" prefix or throws JsError if derivation fails.
|
|
46
|
+
*/
|
|
47
|
+
export function getSealerId(secret: Uint8Array): string;
|
|
48
|
+
/**
|
|
49
|
+
* Generate a new X25519 private key using secure random number generation.
|
|
50
|
+
* Returns 32 bytes of raw key material suitable for use with other X25519 functions.
|
|
51
|
+
* This key can be reused for multiple Diffie-Hellman exchanges.
|
|
52
|
+
*/
|
|
53
|
+
export function newX25519PrivateKey(): Uint8Array;
|
|
54
|
+
/**
|
|
55
|
+
* WASM-exposed function to derive an X25519 public key from a private key.
|
|
56
|
+
* - `private_key`: 32 bytes of private key material
|
|
57
|
+
* Returns 32 bytes of public key material or throws JsError if key is invalid.
|
|
58
|
+
*/
|
|
59
|
+
export function x25519PublicKey(private_key: Uint8Array): Uint8Array;
|
|
60
|
+
/**
|
|
61
|
+
* WASM-exposed function to perform X25519 Diffie-Hellman key exchange.
|
|
62
|
+
* - `private_key`: 32 bytes of private key material
|
|
63
|
+
* - `public_key`: 32 bytes of public key material
|
|
64
|
+
* Returns 32 bytes of shared secret material or throws JsError if key exchange fails.
|
|
65
|
+
*/
|
|
66
|
+
export function x25519DiffieHellman(private_key: Uint8Array, public_key: Uint8Array): Uint8Array;
|
|
41
67
|
/**
|
|
42
68
|
* WASM-exposed function to encrypt bytes with a key secret and nonce material.
|
|
43
69
|
* - `value`: The raw bytes to encrypt
|
|
@@ -54,6 +80,24 @@ export function encrypt(value: Uint8Array, key_secret: string, nonce_material: U
|
|
|
54
80
|
* Returns the decrypted bytes or throws a JsError if decryption fails.
|
|
55
81
|
*/
|
|
56
82
|
export function decrypt(ciphertext: Uint8Array, key_secret: string, nonce_material: Uint8Array): Uint8Array;
|
|
83
|
+
/**
|
|
84
|
+
* WASM-exposed function for XSalsa20 decryption without authentication.
|
|
85
|
+
* - `key`: 32-byte key for decryption (must match encryption key)
|
|
86
|
+
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce (must match encryption)
|
|
87
|
+
* - `ciphertext`: Encrypted bytes to decrypt
|
|
88
|
+
* Returns the decrypted bytes or throws a JsError if decryption fails.
|
|
89
|
+
* Note: This function does not provide authentication. Use decrypt_xsalsa20_poly1305 for authenticated decryption.
|
|
90
|
+
*/
|
|
91
|
+
export function decryptXsalsa20(key: Uint8Array, nonce_material: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
92
|
+
/**
|
|
93
|
+
* WASM-exposed function for XSalsa20 encryption without authentication.
|
|
94
|
+
* - `key`: 32-byte key for encryption
|
|
95
|
+
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce via BLAKE3
|
|
96
|
+
* - `plaintext`: Raw bytes to encrypt
|
|
97
|
+
* Returns the encrypted bytes or throws a JsError if encryption fails.
|
|
98
|
+
* Note: This function does not provide authentication. Use encrypt_xsalsa20_poly1305 for authenticated encryption.
|
|
99
|
+
*/
|
|
100
|
+
export function encryptXsalsa20(key: Uint8Array, nonce_material: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
57
101
|
/**
|
|
58
102
|
* WASM-exposed function to sign a message using Ed25519.
|
|
59
103
|
* - `message`: Raw bytes to sign
|
|
@@ -103,49 +147,6 @@ export function shortHash(value: string): string;
|
|
|
103
147
|
* This is useful for domain separation - the same data hashed with different contexts will produce different outputs.
|
|
104
148
|
*/
|
|
105
149
|
export function blake3HashOnceWithContext(data: Uint8Array, context: Uint8Array): Uint8Array;
|
|
106
|
-
/**
|
|
107
|
-
* WASM-exposed function to derive a sealer ID from a sealer secret.
|
|
108
|
-
* - `secret`: Raw bytes of the sealer secret
|
|
109
|
-
* Returns a base58-encoded sealer ID with "sealer_z" prefix or throws JsError if derivation fails.
|
|
110
|
-
*/
|
|
111
|
-
export function getSealerId(secret: Uint8Array): string;
|
|
112
|
-
/**
|
|
113
|
-
* Generate a new X25519 private key using secure random number generation.
|
|
114
|
-
* Returns 32 bytes of raw key material suitable for use with other X25519 functions.
|
|
115
|
-
* This key can be reused for multiple Diffie-Hellman exchanges.
|
|
116
|
-
*/
|
|
117
|
-
export function newX25519PrivateKey(): Uint8Array;
|
|
118
|
-
/**
|
|
119
|
-
* WASM-exposed function to derive an X25519 public key from a private key.
|
|
120
|
-
* - `private_key`: 32 bytes of private key material
|
|
121
|
-
* Returns 32 bytes of public key material or throws JsError if key is invalid.
|
|
122
|
-
*/
|
|
123
|
-
export function x25519PublicKey(private_key: Uint8Array): Uint8Array;
|
|
124
|
-
/**
|
|
125
|
-
* WASM-exposed function to perform X25519 Diffie-Hellman key exchange.
|
|
126
|
-
* - `private_key`: 32 bytes of private key material
|
|
127
|
-
* - `public_key`: 32 bytes of public key material
|
|
128
|
-
* Returns 32 bytes of shared secret material or throws JsError if key exchange fails.
|
|
129
|
-
*/
|
|
130
|
-
export function x25519DiffieHellman(private_key: Uint8Array, public_key: Uint8Array): Uint8Array;
|
|
131
|
-
/**
|
|
132
|
-
* WASM-exposed function for XSalsa20 decryption without authentication.
|
|
133
|
-
* - `key`: 32-byte key for decryption (must match encryption key)
|
|
134
|
-
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce (must match encryption)
|
|
135
|
-
* - `ciphertext`: Encrypted bytes to decrypt
|
|
136
|
-
* Returns the decrypted bytes or throws a JsError if decryption fails.
|
|
137
|
-
* Note: This function does not provide authentication. Use decrypt_xsalsa20_poly1305 for authenticated decryption.
|
|
138
|
-
*/
|
|
139
|
-
export function decryptXsalsa20(key: Uint8Array, nonce_material: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
140
|
-
/**
|
|
141
|
-
* WASM-exposed function for XSalsa20 encryption without authentication.
|
|
142
|
-
* - `key`: 32-byte key for encryption
|
|
143
|
-
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce via BLAKE3
|
|
144
|
-
* - `plaintext`: Raw bytes to encrypt
|
|
145
|
-
* Returns the encrypted bytes or throws a JsError if encryption fails.
|
|
146
|
-
* Note: This function does not provide authentication. Use encrypt_xsalsa20_poly1305 for authenticated encryption.
|
|
147
|
-
*/
|
|
148
|
-
export function encryptXsalsa20(key: Uint8Array, nonce_material: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
149
150
|
/**
|
|
150
151
|
* WASM-exposed function to verify an Ed25519 signature.
|
|
151
152
|
* - `verifying_key`: 32 bytes of verifying key material
|
|
@@ -326,12 +327,19 @@ export interface InitOutput {
|
|
|
326
327
|
readonly sessionmap_markAsDeleted: (a: number) => void;
|
|
327
328
|
readonly sessionmap_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
328
329
|
readonly sessionmap_setStreamingKnownState: (a: number, b: number, c: number) => [number, number];
|
|
330
|
+
readonly init: () => void;
|
|
329
331
|
readonly decrypt: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
332
|
+
readonly decryptXsalsa20: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
330
333
|
readonly encrypt: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
334
|
+
readonly encryptXsalsa20: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
335
|
+
readonly getSealerId: (a: number, b: number) => [number, number, number, number];
|
|
336
|
+
readonly newX25519PrivateKey: () => [number, number];
|
|
331
337
|
readonly seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
332
338
|
readonly sealForGroup: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
333
339
|
readonly unseal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
334
340
|
readonly unsealForGroup: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
341
|
+
readonly x25519DiffieHellman: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
342
|
+
readonly x25519PublicKey: (a: number, b: number) => [number, number, number, number];
|
|
335
343
|
readonly getSignerId: (a: number, b: number) => [number, number, number, number];
|
|
336
344
|
readonly sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
337
345
|
readonly verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
@@ -344,12 +352,6 @@ export interface InitOutput {
|
|
|
344
352
|
readonly blake3hasher_update: (a: number, b: number, c: number) => void;
|
|
345
353
|
readonly generateNonce: (a: number, b: number) => [number, number];
|
|
346
354
|
readonly shortHash: (a: number, b: number) => [number, number];
|
|
347
|
-
readonly decryptXsalsa20: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
348
|
-
readonly encryptXsalsa20: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
349
|
-
readonly getSealerId: (a: number, b: number) => [number, number, number, number];
|
|
350
|
-
readonly newX25519PrivateKey: () => [number, number];
|
|
351
|
-
readonly x25519DiffieHellman: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
352
|
-
readonly x25519PublicKey: (a: number, b: number) => [number, number, number, number];
|
|
353
355
|
readonly ed25519Sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
354
356
|
readonly ed25519SignatureFromBytes: (a: number, b: number) => [number, number, number, number];
|
|
355
357
|
readonly ed25519SigningKeyFromBytes: (a: number, b: number) => [number, number, number, number];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dumpWasmPanic } from './snippets/cojson-core-wasm-130f84f2109aae70/inline0.js';
|
|
2
|
+
|
|
1
3
|
let wasm;
|
|
2
4
|
|
|
3
5
|
let WASM_VECTOR_LEN = 0;
|
|
@@ -184,6 +186,10 @@ function takeFromExternrefTable0(idx) {
|
|
|
184
186
|
return value;
|
|
185
187
|
}
|
|
186
188
|
|
|
189
|
+
export function init() {
|
|
190
|
+
wasm.init();
|
|
191
|
+
}
|
|
192
|
+
|
|
187
193
|
function passArray8ToWasm0(arg, malloc) {
|
|
188
194
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
189
195
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -315,6 +321,89 @@ export function unsealForGroup(sealed_message, recipient_secret, nonce_material)
|
|
|
315
321
|
return v4;
|
|
316
322
|
}
|
|
317
323
|
|
|
324
|
+
/**
|
|
325
|
+
* WASM-exposed function to derive a sealer ID from a sealer secret.
|
|
326
|
+
* - `secret`: Raw bytes of the sealer secret
|
|
327
|
+
* Returns a base58-encoded sealer ID with "sealer_z" prefix or throws JsError if derivation fails.
|
|
328
|
+
* @param {Uint8Array} secret
|
|
329
|
+
* @returns {string}
|
|
330
|
+
*/
|
|
331
|
+
export function getSealerId(secret) {
|
|
332
|
+
let deferred3_0;
|
|
333
|
+
let deferred3_1;
|
|
334
|
+
try {
|
|
335
|
+
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
336
|
+
const len0 = WASM_VECTOR_LEN;
|
|
337
|
+
const ret = wasm.getSealerId(ptr0, len0);
|
|
338
|
+
var ptr2 = ret[0];
|
|
339
|
+
var len2 = ret[1];
|
|
340
|
+
if (ret[3]) {
|
|
341
|
+
ptr2 = 0; len2 = 0;
|
|
342
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
343
|
+
}
|
|
344
|
+
deferred3_0 = ptr2;
|
|
345
|
+
deferred3_1 = len2;
|
|
346
|
+
return getStringFromWasm0(ptr2, len2);
|
|
347
|
+
} finally {
|
|
348
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Generate a new X25519 private key using secure random number generation.
|
|
354
|
+
* Returns 32 bytes of raw key material suitable for use with other X25519 functions.
|
|
355
|
+
* This key can be reused for multiple Diffie-Hellman exchanges.
|
|
356
|
+
* @returns {Uint8Array}
|
|
357
|
+
*/
|
|
358
|
+
export function newX25519PrivateKey() {
|
|
359
|
+
const ret = wasm.newX25519PrivateKey();
|
|
360
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
361
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
362
|
+
return v1;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* WASM-exposed function to derive an X25519 public key from a private key.
|
|
367
|
+
* - `private_key`: 32 bytes of private key material
|
|
368
|
+
* Returns 32 bytes of public key material or throws JsError if key is invalid.
|
|
369
|
+
* @param {Uint8Array} private_key
|
|
370
|
+
* @returns {Uint8Array}
|
|
371
|
+
*/
|
|
372
|
+
export function x25519PublicKey(private_key) {
|
|
373
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
374
|
+
const len0 = WASM_VECTOR_LEN;
|
|
375
|
+
const ret = wasm.x25519PublicKey(ptr0, len0);
|
|
376
|
+
if (ret[3]) {
|
|
377
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
378
|
+
}
|
|
379
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
380
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
381
|
+
return v2;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* WASM-exposed function to perform X25519 Diffie-Hellman key exchange.
|
|
386
|
+
* - `private_key`: 32 bytes of private key material
|
|
387
|
+
* - `public_key`: 32 bytes of public key material
|
|
388
|
+
* Returns 32 bytes of shared secret material or throws JsError if key exchange fails.
|
|
389
|
+
* @param {Uint8Array} private_key
|
|
390
|
+
* @param {Uint8Array} public_key
|
|
391
|
+
* @returns {Uint8Array}
|
|
392
|
+
*/
|
|
393
|
+
export function x25519DiffieHellman(private_key, public_key) {
|
|
394
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
395
|
+
const len0 = WASM_VECTOR_LEN;
|
|
396
|
+
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
397
|
+
const len1 = WASM_VECTOR_LEN;
|
|
398
|
+
const ret = wasm.x25519DiffieHellman(ptr0, len0, ptr1, len1);
|
|
399
|
+
if (ret[3]) {
|
|
400
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
401
|
+
}
|
|
402
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
403
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
404
|
+
return v3;
|
|
405
|
+
}
|
|
406
|
+
|
|
318
407
|
/**
|
|
319
408
|
* WASM-exposed function to encrypt bytes with a key secret and nonce material.
|
|
320
409
|
* - `value`: The raw bytes to encrypt
|
|
@@ -369,6 +458,62 @@ export function decrypt(ciphertext, key_secret, nonce_material) {
|
|
|
369
458
|
return v4;
|
|
370
459
|
}
|
|
371
460
|
|
|
461
|
+
/**
|
|
462
|
+
* WASM-exposed function for XSalsa20 decryption without authentication.
|
|
463
|
+
* - `key`: 32-byte key for decryption (must match encryption key)
|
|
464
|
+
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce (must match encryption)
|
|
465
|
+
* - `ciphertext`: Encrypted bytes to decrypt
|
|
466
|
+
* Returns the decrypted bytes or throws a JsError if decryption fails.
|
|
467
|
+
* Note: This function does not provide authentication. Use decrypt_xsalsa20_poly1305 for authenticated decryption.
|
|
468
|
+
* @param {Uint8Array} key
|
|
469
|
+
* @param {Uint8Array} nonce_material
|
|
470
|
+
* @param {Uint8Array} ciphertext
|
|
471
|
+
* @returns {Uint8Array}
|
|
472
|
+
*/
|
|
473
|
+
export function decryptXsalsa20(key, nonce_material, ciphertext) {
|
|
474
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
475
|
+
const len0 = WASM_VECTOR_LEN;
|
|
476
|
+
const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
|
|
477
|
+
const len1 = WASM_VECTOR_LEN;
|
|
478
|
+
const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
479
|
+
const len2 = WASM_VECTOR_LEN;
|
|
480
|
+
const ret = wasm.decryptXsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
481
|
+
if (ret[3]) {
|
|
482
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
483
|
+
}
|
|
484
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
485
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
486
|
+
return v4;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* WASM-exposed function for XSalsa20 encryption without authentication.
|
|
491
|
+
* - `key`: 32-byte key for encryption
|
|
492
|
+
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce via BLAKE3
|
|
493
|
+
* - `plaintext`: Raw bytes to encrypt
|
|
494
|
+
* Returns the encrypted bytes or throws a JsError if encryption fails.
|
|
495
|
+
* Note: This function does not provide authentication. Use encrypt_xsalsa20_poly1305 for authenticated encryption.
|
|
496
|
+
* @param {Uint8Array} key
|
|
497
|
+
* @param {Uint8Array} nonce_material
|
|
498
|
+
* @param {Uint8Array} plaintext
|
|
499
|
+
* @returns {Uint8Array}
|
|
500
|
+
*/
|
|
501
|
+
export function encryptXsalsa20(key, nonce_material, plaintext) {
|
|
502
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
503
|
+
const len0 = WASM_VECTOR_LEN;
|
|
504
|
+
const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
|
|
505
|
+
const len1 = WASM_VECTOR_LEN;
|
|
506
|
+
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
507
|
+
const len2 = WASM_VECTOR_LEN;
|
|
508
|
+
const ret = wasm.encryptXsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
509
|
+
if (ret[3]) {
|
|
510
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
511
|
+
}
|
|
512
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
513
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
514
|
+
return v4;
|
|
515
|
+
}
|
|
516
|
+
|
|
372
517
|
/**
|
|
373
518
|
* WASM-exposed function to sign a message using Ed25519.
|
|
374
519
|
* - `message`: Raw bytes to sign
|
|
@@ -531,145 +676,6 @@ export function blake3HashOnceWithContext(data, context) {
|
|
|
531
676
|
return v3;
|
|
532
677
|
}
|
|
533
678
|
|
|
534
|
-
/**
|
|
535
|
-
* WASM-exposed function to derive a sealer ID from a sealer secret.
|
|
536
|
-
* - `secret`: Raw bytes of the sealer secret
|
|
537
|
-
* Returns a base58-encoded sealer ID with "sealer_z" prefix or throws JsError if derivation fails.
|
|
538
|
-
* @param {Uint8Array} secret
|
|
539
|
-
* @returns {string}
|
|
540
|
-
*/
|
|
541
|
-
export function getSealerId(secret) {
|
|
542
|
-
let deferred3_0;
|
|
543
|
-
let deferred3_1;
|
|
544
|
-
try {
|
|
545
|
-
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
546
|
-
const len0 = WASM_VECTOR_LEN;
|
|
547
|
-
const ret = wasm.getSealerId(ptr0, len0);
|
|
548
|
-
var ptr2 = ret[0];
|
|
549
|
-
var len2 = ret[1];
|
|
550
|
-
if (ret[3]) {
|
|
551
|
-
ptr2 = 0; len2 = 0;
|
|
552
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
553
|
-
}
|
|
554
|
-
deferred3_0 = ptr2;
|
|
555
|
-
deferred3_1 = len2;
|
|
556
|
-
return getStringFromWasm0(ptr2, len2);
|
|
557
|
-
} finally {
|
|
558
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Generate a new X25519 private key using secure random number generation.
|
|
564
|
-
* Returns 32 bytes of raw key material suitable for use with other X25519 functions.
|
|
565
|
-
* This key can be reused for multiple Diffie-Hellman exchanges.
|
|
566
|
-
* @returns {Uint8Array}
|
|
567
|
-
*/
|
|
568
|
-
export function newX25519PrivateKey() {
|
|
569
|
-
const ret = wasm.newX25519PrivateKey();
|
|
570
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
571
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
572
|
-
return v1;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* WASM-exposed function to derive an X25519 public key from a private key.
|
|
577
|
-
* - `private_key`: 32 bytes of private key material
|
|
578
|
-
* Returns 32 bytes of public key material or throws JsError if key is invalid.
|
|
579
|
-
* @param {Uint8Array} private_key
|
|
580
|
-
* @returns {Uint8Array}
|
|
581
|
-
*/
|
|
582
|
-
export function x25519PublicKey(private_key) {
|
|
583
|
-
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
584
|
-
const len0 = WASM_VECTOR_LEN;
|
|
585
|
-
const ret = wasm.x25519PublicKey(ptr0, len0);
|
|
586
|
-
if (ret[3]) {
|
|
587
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
588
|
-
}
|
|
589
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
590
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
591
|
-
return v2;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* WASM-exposed function to perform X25519 Diffie-Hellman key exchange.
|
|
596
|
-
* - `private_key`: 32 bytes of private key material
|
|
597
|
-
* - `public_key`: 32 bytes of public key material
|
|
598
|
-
* Returns 32 bytes of shared secret material or throws JsError if key exchange fails.
|
|
599
|
-
* @param {Uint8Array} private_key
|
|
600
|
-
* @param {Uint8Array} public_key
|
|
601
|
-
* @returns {Uint8Array}
|
|
602
|
-
*/
|
|
603
|
-
export function x25519DiffieHellman(private_key, public_key) {
|
|
604
|
-
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
605
|
-
const len0 = WASM_VECTOR_LEN;
|
|
606
|
-
const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
607
|
-
const len1 = WASM_VECTOR_LEN;
|
|
608
|
-
const ret = wasm.x25519DiffieHellman(ptr0, len0, ptr1, len1);
|
|
609
|
-
if (ret[3]) {
|
|
610
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
611
|
-
}
|
|
612
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
613
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
614
|
-
return v3;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* WASM-exposed function for XSalsa20 decryption without authentication.
|
|
619
|
-
* - `key`: 32-byte key for decryption (must match encryption key)
|
|
620
|
-
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce (must match encryption)
|
|
621
|
-
* - `ciphertext`: Encrypted bytes to decrypt
|
|
622
|
-
* Returns the decrypted bytes or throws a JsError if decryption fails.
|
|
623
|
-
* Note: This function does not provide authentication. Use decrypt_xsalsa20_poly1305 for authenticated decryption.
|
|
624
|
-
* @param {Uint8Array} key
|
|
625
|
-
* @param {Uint8Array} nonce_material
|
|
626
|
-
* @param {Uint8Array} ciphertext
|
|
627
|
-
* @returns {Uint8Array}
|
|
628
|
-
*/
|
|
629
|
-
export function decryptXsalsa20(key, nonce_material, ciphertext) {
|
|
630
|
-
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
631
|
-
const len0 = WASM_VECTOR_LEN;
|
|
632
|
-
const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
|
|
633
|
-
const len1 = WASM_VECTOR_LEN;
|
|
634
|
-
const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
635
|
-
const len2 = WASM_VECTOR_LEN;
|
|
636
|
-
const ret = wasm.decryptXsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
637
|
-
if (ret[3]) {
|
|
638
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
639
|
-
}
|
|
640
|
-
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
641
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
642
|
-
return v4;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* WASM-exposed function for XSalsa20 encryption without authentication.
|
|
647
|
-
* - `key`: 32-byte key for encryption
|
|
648
|
-
* - `nonce_material`: Raw bytes used to generate a 24-byte nonce via BLAKE3
|
|
649
|
-
* - `plaintext`: Raw bytes to encrypt
|
|
650
|
-
* Returns the encrypted bytes or throws a JsError if encryption fails.
|
|
651
|
-
* Note: This function does not provide authentication. Use encrypt_xsalsa20_poly1305 for authenticated encryption.
|
|
652
|
-
* @param {Uint8Array} key
|
|
653
|
-
* @param {Uint8Array} nonce_material
|
|
654
|
-
* @param {Uint8Array} plaintext
|
|
655
|
-
* @returns {Uint8Array}
|
|
656
|
-
*/
|
|
657
|
-
export function encryptXsalsa20(key, nonce_material, plaintext) {
|
|
658
|
-
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
659
|
-
const len0 = WASM_VECTOR_LEN;
|
|
660
|
-
const ptr1 = passArray8ToWasm0(nonce_material, wasm.__wbindgen_malloc);
|
|
661
|
-
const len1 = WASM_VECTOR_LEN;
|
|
662
|
-
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
663
|
-
const len2 = WASM_VECTOR_LEN;
|
|
664
|
-
const ret = wasm.encryptXsalsa20(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
665
|
-
if (ret[3]) {
|
|
666
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
667
|
-
}
|
|
668
|
-
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
669
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
670
|
-
return v4;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
679
|
/**
|
|
674
680
|
* WASM-exposed function to verify an Ed25519 signature.
|
|
675
681
|
* - `verifying_key`: 32 bytes of verifying key material
|
|
@@ -1317,6 +1323,20 @@ function __wbg_get_imports() {
|
|
|
1317
1323
|
const ret = arg0.crypto;
|
|
1318
1324
|
return ret;
|
|
1319
1325
|
};
|
|
1326
|
+
imports.wbg.__wbg_dumpWasmPanic_a39b8272e193aa3d = function(arg0, arg1) {
|
|
1327
|
+
dumpWasmPanic(getStringFromWasm0(arg0, arg1));
|
|
1328
|
+
};
|
|
1329
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
1330
|
+
let deferred0_0;
|
|
1331
|
+
let deferred0_1;
|
|
1332
|
+
try {
|
|
1333
|
+
deferred0_0 = arg0;
|
|
1334
|
+
deferred0_1 = arg1;
|
|
1335
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1336
|
+
} finally {
|
|
1337
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1320
1340
|
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
1321
1341
|
arg0.getRandomValues(arg1);
|
|
1322
1342
|
}, arguments) };
|
|
@@ -1332,6 +1352,10 @@ function __wbg_get_imports() {
|
|
|
1332
1352
|
const ret = new Map();
|
|
1333
1353
|
return ret;
|
|
1334
1354
|
};
|
|
1355
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
1356
|
+
const ret = new Error();
|
|
1357
|
+
return ret;
|
|
1358
|
+
};
|
|
1335
1359
|
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
1336
1360
|
const ret = new Uint8Array(arg0);
|
|
1337
1361
|
return ret;
|
|
@@ -1373,6 +1397,13 @@ function __wbg_get_imports() {
|
|
|
1373
1397
|
const ret = arg0.set(arg1, arg2);
|
|
1374
1398
|
return ret;
|
|
1375
1399
|
};
|
|
1400
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
1401
|
+
const ret = arg1.stack;
|
|
1402
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1403
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1404
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1405
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1406
|
+
};
|
|
1376
1407
|
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
1377
1408
|
const ret = typeof global === 'undefined' ? null : global;
|
|
1378
1409
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
Binary file
|