@maatara/core-pqc-wasm 0.1.1 → 0.2.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/core_pqc_wasm.d.ts +58 -0
- package/core_pqc_wasm.js +693 -5
- package/core_pqc_wasm_bg.wasm +0 -0
- package/package.json +2 -11
- package/core_pqc_wasm_bg.js +0 -468
- package/node.js +0 -29
package/core_pqc_wasm.d.ts
CHANGED
|
@@ -10,3 +10,61 @@ export function dilithium_keygen(): string;
|
|
|
10
10
|
export function dilithium_sign(message_b64u: string, secret_b64u: string): string;
|
|
11
11
|
export function dilithium_verify(message_b64u: string, signature_b64u: string, public_b64u: string): string;
|
|
12
12
|
export function start(): void;
|
|
13
|
+
export function jcs_canonicalize(json: string): string;
|
|
14
|
+
export function preimage_governance(policy_json: string): string;
|
|
15
|
+
export function preimage_asset_mint(header_json: string, asset_json: string): string;
|
|
16
|
+
export function preimage_asset_transfer(header_json: string): string;
|
|
17
|
+
export function preimage_anchor(user_id: string, root_hex: string, epoch: string, chains_json: string): string;
|
|
18
|
+
export function validate_royalty(receiver: string, bps: number): string;
|
|
19
|
+
export function verify_attestations(msg_b64u: string, attestations_json: string, allowed_public_keys_json?: string | null): string;
|
|
20
|
+
|
|
21
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
22
|
+
|
|
23
|
+
export interface InitOutput {
|
|
24
|
+
readonly memory: WebAssembly.Memory;
|
|
25
|
+
readonly kyber_keygen: () => [number, number];
|
|
26
|
+
readonly kyber_encaps: (a: number, b: number) => [number, number];
|
|
27
|
+
readonly kyber_decaps: (a: number, b: number, c: number, d: number) => [number, number];
|
|
28
|
+
readonly hkdf_sha256: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
29
|
+
readonly aes_gcm_wrap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
30
|
+
readonly aes_gcm_unwrap: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
31
|
+
readonly dilithium_keygen: () => [number, number];
|
|
32
|
+
readonly dilithium_sign: (a: number, b: number, c: number, d: number) => [number, number];
|
|
33
|
+
readonly dilithium_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
34
|
+
readonly start: () => void;
|
|
35
|
+
readonly jcs_canonicalize: (a: number, b: number) => [number, number];
|
|
36
|
+
readonly preimage_asset_mint: (a: number, b: number, c: number, d: number) => [number, number];
|
|
37
|
+
readonly preimage_asset_transfer: (a: number, b: number) => [number, number];
|
|
38
|
+
readonly preimage_anchor: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
39
|
+
readonly validate_royalty: (a: number, b: number, c: number) => [number, number];
|
|
40
|
+
readonly verify_attestations: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
41
|
+
readonly preimage_governance: (a: number, b: number) => [number, number];
|
|
42
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
43
|
+
readonly __externref_table_alloc: () => number;
|
|
44
|
+
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
45
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
46
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
47
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
48
|
+
readonly __wbindgen_start: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
52
|
+
/**
|
|
53
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
54
|
+
* a precompiled `WebAssembly.Module`.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
57
|
+
*
|
|
58
|
+
* @returns {InitOutput}
|
|
59
|
+
*/
|
|
60
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
64
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
65
|
+
*
|
|
66
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<InitOutput>}
|
|
69
|
+
*/
|
|
70
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/core_pqc_wasm.js
CHANGED
|
@@ -1,5 +1,693 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
wasm.
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
function addToExternrefTable0(obj) {
|
|
4
|
+
const idx = wasm.__externref_table_alloc();
|
|
5
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
6
|
+
return idx;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function handleError(f, args) {
|
|
10
|
+
try {
|
|
11
|
+
return f.apply(this, args);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
const idx = addToExternrefTable0(e);
|
|
14
|
+
wasm.__wbindgen_exn_store(idx);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let cachedUint8ArrayMemory0 = null;
|
|
19
|
+
|
|
20
|
+
function getUint8ArrayMemory0() {
|
|
21
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
22
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
23
|
+
}
|
|
24
|
+
return cachedUint8ArrayMemory0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
28
|
+
|
|
29
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
30
|
+
|
|
31
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
32
|
+
let numBytesDecoded = 0;
|
|
33
|
+
function decodeText(ptr, len) {
|
|
34
|
+
numBytesDecoded += len;
|
|
35
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
36
|
+
cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
37
|
+
cachedTextDecoder.decode();
|
|
38
|
+
numBytesDecoded = len;
|
|
39
|
+
}
|
|
40
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getStringFromWasm0(ptr, len) {
|
|
44
|
+
ptr = ptr >>> 0;
|
|
45
|
+
return decodeText(ptr, len);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isLikeNone(x) {
|
|
49
|
+
return x === undefined || x === null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function kyber_keygen() {
|
|
55
|
+
let deferred1_0;
|
|
56
|
+
let deferred1_1;
|
|
57
|
+
try {
|
|
58
|
+
const ret = wasm.kyber_keygen();
|
|
59
|
+
deferred1_0 = ret[0];
|
|
60
|
+
deferred1_1 = ret[1];
|
|
61
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
62
|
+
} finally {
|
|
63
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let WASM_VECTOR_LEN = 0;
|
|
68
|
+
|
|
69
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
70
|
+
|
|
71
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
72
|
+
? function (arg, view) {
|
|
73
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
74
|
+
}
|
|
75
|
+
: function (arg, view) {
|
|
76
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
77
|
+
view.set(buf);
|
|
78
|
+
return {
|
|
79
|
+
read: arg.length,
|
|
80
|
+
written: buf.length
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
85
|
+
|
|
86
|
+
if (realloc === undefined) {
|
|
87
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
88
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
89
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
90
|
+
WASM_VECTOR_LEN = buf.length;
|
|
91
|
+
return ptr;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let len = arg.length;
|
|
95
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
96
|
+
|
|
97
|
+
const mem = getUint8ArrayMemory0();
|
|
98
|
+
|
|
99
|
+
let offset = 0;
|
|
100
|
+
|
|
101
|
+
for (; offset < len; offset++) {
|
|
102
|
+
const code = arg.charCodeAt(offset);
|
|
103
|
+
if (code > 0x7F) break;
|
|
104
|
+
mem[ptr + offset] = code;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (offset !== len) {
|
|
108
|
+
if (offset !== 0) {
|
|
109
|
+
arg = arg.slice(offset);
|
|
110
|
+
}
|
|
111
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
112
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
113
|
+
const ret = encodeString(arg, view);
|
|
114
|
+
|
|
115
|
+
offset += ret.written;
|
|
116
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
WASM_VECTOR_LEN = offset;
|
|
120
|
+
return ptr;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {string} public_b64u
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
export function kyber_encaps(public_b64u) {
|
|
127
|
+
let deferred2_0;
|
|
128
|
+
let deferred2_1;
|
|
129
|
+
try {
|
|
130
|
+
const ptr0 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
132
|
+
const ret = wasm.kyber_encaps(ptr0, len0);
|
|
133
|
+
deferred2_0 = ret[0];
|
|
134
|
+
deferred2_1 = ret[1];
|
|
135
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
136
|
+
} finally {
|
|
137
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {string} secret_b64u
|
|
143
|
+
* @param {string} kem_ct_b64u
|
|
144
|
+
* @returns {string}
|
|
145
|
+
*/
|
|
146
|
+
export function kyber_decaps(secret_b64u, kem_ct_b64u) {
|
|
147
|
+
let deferred3_0;
|
|
148
|
+
let deferred3_1;
|
|
149
|
+
try {
|
|
150
|
+
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
+
const len0 = WASM_VECTOR_LEN;
|
|
152
|
+
const ptr1 = passStringToWasm0(kem_ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
153
|
+
const len1 = WASM_VECTOR_LEN;
|
|
154
|
+
const ret = wasm.kyber_decaps(ptr0, len0, ptr1, len1);
|
|
155
|
+
deferred3_0 = ret[0];
|
|
156
|
+
deferred3_1 = ret[1];
|
|
157
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
158
|
+
} finally {
|
|
159
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @param {string} secret_b64u
|
|
165
|
+
* @param {string} info_b64u
|
|
166
|
+
* @param {string | null | undefined} salt_b64u
|
|
167
|
+
* @param {number} len
|
|
168
|
+
* @returns {string}
|
|
169
|
+
*/
|
|
170
|
+
export function hkdf_sha256(secret_b64u, info_b64u, salt_b64u, len) {
|
|
171
|
+
let deferred4_0;
|
|
172
|
+
let deferred4_1;
|
|
173
|
+
try {
|
|
174
|
+
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ptr1 = passStringToWasm0(info_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
177
|
+
const len1 = WASM_VECTOR_LEN;
|
|
178
|
+
var ptr2 = isLikeNone(salt_b64u) ? 0 : passStringToWasm0(salt_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
179
|
+
var len2 = WASM_VECTOR_LEN;
|
|
180
|
+
const ret = wasm.hkdf_sha256(ptr0, len0, ptr1, len1, ptr2, len2, len);
|
|
181
|
+
deferred4_0 = ret[0];
|
|
182
|
+
deferred4_1 = ret[1];
|
|
183
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
184
|
+
} finally {
|
|
185
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @param {string} key_b64u
|
|
191
|
+
* @param {string} dek_b64u
|
|
192
|
+
* @param {string} aad_b64u
|
|
193
|
+
* @returns {string}
|
|
194
|
+
*/
|
|
195
|
+
export function aes_gcm_wrap(key_b64u, dek_b64u, aad_b64u) {
|
|
196
|
+
let deferred4_0;
|
|
197
|
+
let deferred4_1;
|
|
198
|
+
try {
|
|
199
|
+
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
200
|
+
const len0 = WASM_VECTOR_LEN;
|
|
201
|
+
const ptr1 = passStringToWasm0(dek_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
202
|
+
const len1 = WASM_VECTOR_LEN;
|
|
203
|
+
const ptr2 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
204
|
+
const len2 = WASM_VECTOR_LEN;
|
|
205
|
+
const ret = wasm.aes_gcm_wrap(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
206
|
+
deferred4_0 = ret[0];
|
|
207
|
+
deferred4_1 = ret[1];
|
|
208
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
209
|
+
} finally {
|
|
210
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @param {string} key_b64u
|
|
216
|
+
* @param {string} iv_b64u
|
|
217
|
+
* @param {string} ct_b64u
|
|
218
|
+
* @param {string} aad_b64u
|
|
219
|
+
* @returns {string}
|
|
220
|
+
*/
|
|
221
|
+
export function aes_gcm_unwrap(key_b64u, iv_b64u, ct_b64u, aad_b64u) {
|
|
222
|
+
let deferred5_0;
|
|
223
|
+
let deferred5_1;
|
|
224
|
+
try {
|
|
225
|
+
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
226
|
+
const len0 = WASM_VECTOR_LEN;
|
|
227
|
+
const ptr1 = passStringToWasm0(iv_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
const len1 = WASM_VECTOR_LEN;
|
|
229
|
+
const ptr2 = passStringToWasm0(ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
const len2 = WASM_VECTOR_LEN;
|
|
231
|
+
const ptr3 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len3 = WASM_VECTOR_LEN;
|
|
233
|
+
const ret = wasm.aes_gcm_unwrap(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
234
|
+
deferred5_0 = ret[0];
|
|
235
|
+
deferred5_1 = ret[1];
|
|
236
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
237
|
+
} finally {
|
|
238
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @returns {string}
|
|
244
|
+
*/
|
|
245
|
+
export function dilithium_keygen() {
|
|
246
|
+
let deferred1_0;
|
|
247
|
+
let deferred1_1;
|
|
248
|
+
try {
|
|
249
|
+
const ret = wasm.dilithium_keygen();
|
|
250
|
+
deferred1_0 = ret[0];
|
|
251
|
+
deferred1_1 = ret[1];
|
|
252
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
253
|
+
} finally {
|
|
254
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @param {string} message_b64u
|
|
260
|
+
* @param {string} secret_b64u
|
|
261
|
+
* @returns {string}
|
|
262
|
+
*/
|
|
263
|
+
export function dilithium_sign(message_b64u, secret_b64u) {
|
|
264
|
+
let deferred3_0;
|
|
265
|
+
let deferred3_1;
|
|
266
|
+
try {
|
|
267
|
+
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr1 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len1 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.dilithium_sign(ptr0, len0, ptr1, len1);
|
|
272
|
+
deferred3_0 = ret[0];
|
|
273
|
+
deferred3_1 = ret[1];
|
|
274
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
275
|
+
} finally {
|
|
276
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @param {string} message_b64u
|
|
282
|
+
* @param {string} signature_b64u
|
|
283
|
+
* @param {string} public_b64u
|
|
284
|
+
* @returns {string}
|
|
285
|
+
*/
|
|
286
|
+
export function dilithium_verify(message_b64u, signature_b64u, public_b64u) {
|
|
287
|
+
let deferred4_0;
|
|
288
|
+
let deferred4_1;
|
|
289
|
+
try {
|
|
290
|
+
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ptr1 = passStringToWasm0(signature_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
293
|
+
const len1 = WASM_VECTOR_LEN;
|
|
294
|
+
const ptr2 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
295
|
+
const len2 = WASM_VECTOR_LEN;
|
|
296
|
+
const ret = wasm.dilithium_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
297
|
+
deferred4_0 = ret[0];
|
|
298
|
+
deferred4_1 = ret[1];
|
|
299
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
300
|
+
} finally {
|
|
301
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function start() {
|
|
306
|
+
wasm.start();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @param {string} json
|
|
311
|
+
* @returns {string}
|
|
312
|
+
*/
|
|
313
|
+
export function jcs_canonicalize(json) {
|
|
314
|
+
let deferred2_0;
|
|
315
|
+
let deferred2_1;
|
|
316
|
+
try {
|
|
317
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
const len0 = WASM_VECTOR_LEN;
|
|
319
|
+
const ret = wasm.jcs_canonicalize(ptr0, len0);
|
|
320
|
+
deferred2_0 = ret[0];
|
|
321
|
+
deferred2_1 = ret[1];
|
|
322
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
323
|
+
} finally {
|
|
324
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @param {string} policy_json
|
|
330
|
+
* @returns {string}
|
|
331
|
+
*/
|
|
332
|
+
export function preimage_governance(policy_json) {
|
|
333
|
+
let deferred2_0;
|
|
334
|
+
let deferred2_1;
|
|
335
|
+
try {
|
|
336
|
+
const ptr0 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
337
|
+
const len0 = WASM_VECTOR_LEN;
|
|
338
|
+
const ret = wasm.preimage_governance(ptr0, len0);
|
|
339
|
+
deferred2_0 = ret[0];
|
|
340
|
+
deferred2_1 = ret[1];
|
|
341
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
342
|
+
} finally {
|
|
343
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @param {string} header_json
|
|
349
|
+
* @param {string} asset_json
|
|
350
|
+
* @returns {string}
|
|
351
|
+
*/
|
|
352
|
+
export function preimage_asset_mint(header_json, asset_json) {
|
|
353
|
+
let deferred3_0;
|
|
354
|
+
let deferred3_1;
|
|
355
|
+
try {
|
|
356
|
+
const ptr0 = passStringToWasm0(header_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
357
|
+
const len0 = WASM_VECTOR_LEN;
|
|
358
|
+
const ptr1 = passStringToWasm0(asset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
359
|
+
const len1 = WASM_VECTOR_LEN;
|
|
360
|
+
const ret = wasm.preimage_asset_mint(ptr0, len0, ptr1, len1);
|
|
361
|
+
deferred3_0 = ret[0];
|
|
362
|
+
deferred3_1 = ret[1];
|
|
363
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
364
|
+
} finally {
|
|
365
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @param {string} header_json
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
export function preimage_asset_transfer(header_json) {
|
|
374
|
+
let deferred2_0;
|
|
375
|
+
let deferred2_1;
|
|
376
|
+
try {
|
|
377
|
+
const ptr0 = passStringToWasm0(header_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.preimage_asset_transfer(ptr0, len0);
|
|
380
|
+
deferred2_0 = ret[0];
|
|
381
|
+
deferred2_1 = ret[1];
|
|
382
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
383
|
+
} finally {
|
|
384
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* @param {string} user_id
|
|
390
|
+
* @param {string} root_hex
|
|
391
|
+
* @param {string} epoch
|
|
392
|
+
* @param {string} chains_json
|
|
393
|
+
* @returns {string}
|
|
394
|
+
*/
|
|
395
|
+
export function preimage_anchor(user_id, root_hex, epoch, chains_json) {
|
|
396
|
+
let deferred5_0;
|
|
397
|
+
let deferred5_1;
|
|
398
|
+
try {
|
|
399
|
+
const ptr0 = passStringToWasm0(user_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
const ptr1 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
402
|
+
const len1 = WASM_VECTOR_LEN;
|
|
403
|
+
const ptr2 = passStringToWasm0(epoch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
404
|
+
const len2 = WASM_VECTOR_LEN;
|
|
405
|
+
const ptr3 = passStringToWasm0(chains_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
|
+
const len3 = WASM_VECTOR_LEN;
|
|
407
|
+
const ret = wasm.preimage_anchor(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
408
|
+
deferred5_0 = ret[0];
|
|
409
|
+
deferred5_1 = ret[1];
|
|
410
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
411
|
+
} finally {
|
|
412
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @param {string} receiver
|
|
418
|
+
* @param {number} bps
|
|
419
|
+
* @returns {string}
|
|
420
|
+
*/
|
|
421
|
+
export function validate_royalty(receiver, bps) {
|
|
422
|
+
let deferred2_0;
|
|
423
|
+
let deferred2_1;
|
|
424
|
+
try {
|
|
425
|
+
const ptr0 = passStringToWasm0(receiver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
426
|
+
const len0 = WASM_VECTOR_LEN;
|
|
427
|
+
const ret = wasm.validate_royalty(ptr0, len0, bps);
|
|
428
|
+
deferred2_0 = ret[0];
|
|
429
|
+
deferred2_1 = ret[1];
|
|
430
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
431
|
+
} finally {
|
|
432
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @param {string} msg_b64u
|
|
438
|
+
* @param {string} attestations_json
|
|
439
|
+
* @param {string | null} [allowed_public_keys_json]
|
|
440
|
+
* @returns {string}
|
|
441
|
+
*/
|
|
442
|
+
export function verify_attestations(msg_b64u, attestations_json, allowed_public_keys_json) {
|
|
443
|
+
let deferred4_0;
|
|
444
|
+
let deferred4_1;
|
|
445
|
+
try {
|
|
446
|
+
const ptr0 = passStringToWasm0(msg_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
447
|
+
const len0 = WASM_VECTOR_LEN;
|
|
448
|
+
const ptr1 = passStringToWasm0(attestations_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
449
|
+
const len1 = WASM_VECTOR_LEN;
|
|
450
|
+
var ptr2 = isLikeNone(allowed_public_keys_json) ? 0 : passStringToWasm0(allowed_public_keys_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
451
|
+
var len2 = WASM_VECTOR_LEN;
|
|
452
|
+
const ret = wasm.verify_attestations(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
453
|
+
deferred4_0 = ret[0];
|
|
454
|
+
deferred4_1 = ret[1];
|
|
455
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
456
|
+
} finally {
|
|
457
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
462
|
+
|
|
463
|
+
async function __wbg_load(module, imports) {
|
|
464
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
465
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
466
|
+
try {
|
|
467
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
468
|
+
|
|
469
|
+
} catch (e) {
|
|
470
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
471
|
+
|
|
472
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
473
|
+
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);
|
|
474
|
+
|
|
475
|
+
} else {
|
|
476
|
+
throw e;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const bytes = await module.arrayBuffer();
|
|
482
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
483
|
+
|
|
484
|
+
} else {
|
|
485
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
486
|
+
|
|
487
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
488
|
+
return { instance, module };
|
|
489
|
+
|
|
490
|
+
} else {
|
|
491
|
+
return instance;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function __wbg_get_imports() {
|
|
497
|
+
const imports = {};
|
|
498
|
+
imports.wbg = {};
|
|
499
|
+
imports.wbg.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
|
|
500
|
+
const ret = arg0.buffer;
|
|
501
|
+
return ret;
|
|
502
|
+
};
|
|
503
|
+
imports.wbg.__wbg_call_f2db6205e5c51dc8 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
504
|
+
const ret = arg0.call(arg1, arg2);
|
|
505
|
+
return ret;
|
|
506
|
+
}, arguments) };
|
|
507
|
+
imports.wbg.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
|
|
508
|
+
const ret = arg0.call(arg1);
|
|
509
|
+
return ret;
|
|
510
|
+
}, arguments) };
|
|
511
|
+
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
512
|
+
const ret = arg0.crypto;
|
|
513
|
+
return ret;
|
|
514
|
+
};
|
|
515
|
+
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
516
|
+
arg0.getRandomValues(arg1);
|
|
517
|
+
}, arguments) };
|
|
518
|
+
imports.wbg.__wbg_log_ea49c7a7eb7689d1 = function(arg0, arg1) {
|
|
519
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
520
|
+
};
|
|
521
|
+
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
522
|
+
const ret = arg0.msCrypto;
|
|
523
|
+
return ret;
|
|
524
|
+
};
|
|
525
|
+
imports.wbg.__wbg_new_e52b3efaaa774f96 = function(arg0) {
|
|
526
|
+
const ret = new Uint8Array(arg0);
|
|
527
|
+
return ret;
|
|
528
|
+
};
|
|
529
|
+
imports.wbg.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
|
|
530
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
531
|
+
return ret;
|
|
532
|
+
};
|
|
533
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8 = function(arg0, arg1, arg2) {
|
|
534
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
535
|
+
return ret;
|
|
536
|
+
};
|
|
537
|
+
imports.wbg.__wbg_newwithlength_08f872dc1e3ada2e = function(arg0) {
|
|
538
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
539
|
+
return ret;
|
|
540
|
+
};
|
|
541
|
+
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
542
|
+
const ret = arg0.node;
|
|
543
|
+
return ret;
|
|
544
|
+
};
|
|
545
|
+
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
546
|
+
const ret = arg0.process;
|
|
547
|
+
return ret;
|
|
548
|
+
};
|
|
549
|
+
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
550
|
+
arg0.randomFillSync(arg1);
|
|
551
|
+
}, arguments) };
|
|
552
|
+
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
553
|
+
const ret = module.require;
|
|
554
|
+
return ret;
|
|
555
|
+
}, arguments) };
|
|
556
|
+
imports.wbg.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
|
|
557
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
558
|
+
};
|
|
559
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_487c52c58d65314d = function() {
|
|
560
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
561
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
562
|
+
};
|
|
563
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291 = function() {
|
|
564
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
565
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
566
|
+
};
|
|
567
|
+
imports.wbg.__wbg_static_accessor_SELF_78c9e3071b912620 = function() {
|
|
568
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
569
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
570
|
+
};
|
|
571
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a093d21393777366 = function() {
|
|
572
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
573
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
574
|
+
};
|
|
575
|
+
imports.wbg.__wbg_subarray_dd4ade7d53bd8e26 = function(arg0, arg1, arg2) {
|
|
576
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
577
|
+
return ret;
|
|
578
|
+
};
|
|
579
|
+
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
580
|
+
const ret = arg0.versions;
|
|
581
|
+
return ret;
|
|
582
|
+
};
|
|
583
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
584
|
+
const table = wasm.__wbindgen_export_2;
|
|
585
|
+
const offset = table.grow(4);
|
|
586
|
+
table.set(0, undefined);
|
|
587
|
+
table.set(offset + 0, undefined);
|
|
588
|
+
table.set(offset + 1, null);
|
|
589
|
+
table.set(offset + 2, true);
|
|
590
|
+
table.set(offset + 3, false);
|
|
591
|
+
;
|
|
592
|
+
};
|
|
593
|
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
594
|
+
const ret = typeof(arg0) === 'function';
|
|
595
|
+
return ret;
|
|
596
|
+
};
|
|
597
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
598
|
+
const val = arg0;
|
|
599
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
600
|
+
return ret;
|
|
601
|
+
};
|
|
602
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
603
|
+
const ret = typeof(arg0) === 'string';
|
|
604
|
+
return ret;
|
|
605
|
+
};
|
|
606
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
607
|
+
const ret = arg0 === undefined;
|
|
608
|
+
return ret;
|
|
609
|
+
};
|
|
610
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
611
|
+
const ret = wasm.memory;
|
|
612
|
+
return ret;
|
|
613
|
+
};
|
|
614
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
615
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
616
|
+
return ret;
|
|
617
|
+
};
|
|
618
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
619
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
return imports;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function __wbg_init_memory(imports, memory) {
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function __wbg_finalize_init(instance, module) {
|
|
630
|
+
wasm = instance.exports;
|
|
631
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
632
|
+
cachedUint8ArrayMemory0 = null;
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
wasm.__wbindgen_start();
|
|
636
|
+
return wasm;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function initSync(module) {
|
|
640
|
+
if (wasm !== undefined) return wasm;
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
if (typeof module !== 'undefined') {
|
|
644
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
645
|
+
({module} = module)
|
|
646
|
+
} else {
|
|
647
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const imports = __wbg_get_imports();
|
|
652
|
+
|
|
653
|
+
__wbg_init_memory(imports);
|
|
654
|
+
|
|
655
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
656
|
+
module = new WebAssembly.Module(module);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
660
|
+
|
|
661
|
+
return __wbg_finalize_init(instance, module);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async function __wbg_init(module_or_path) {
|
|
665
|
+
if (wasm !== undefined) return wasm;
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
if (typeof module_or_path !== 'undefined') {
|
|
669
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
670
|
+
({module_or_path} = module_or_path)
|
|
671
|
+
} else {
|
|
672
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (typeof module_or_path === 'undefined') {
|
|
677
|
+
module_or_path = new URL('core_pqc_wasm_bg.wasm', import.meta.url);
|
|
678
|
+
}
|
|
679
|
+
const imports = __wbg_get_imports();
|
|
680
|
+
|
|
681
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
682
|
+
module_or_path = fetch(module_or_path);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
__wbg_init_memory(imports);
|
|
686
|
+
|
|
687
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
688
|
+
|
|
689
|
+
return __wbg_finalize_init(instance, module);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export { initSync };
|
|
693
|
+
export default __wbg_init;
|
package/core_pqc_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@maatara/core-pqc-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Ma'atara PQC WASM bindings",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -11,19 +11,10 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"core_pqc_wasm_bg.wasm",
|
|
13
13
|
"core_pqc_wasm.js",
|
|
14
|
-
"
|
|
15
|
-
"core_pqc_wasm.d.ts",
|
|
16
|
-
"node.js"
|
|
14
|
+
"core_pqc_wasm.d.ts"
|
|
17
15
|
],
|
|
18
16
|
"main": "core_pqc_wasm.js",
|
|
19
17
|
"types": "core_pqc_wasm.d.ts",
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"types": "./core_pqc_wasm.d.ts",
|
|
23
|
-
"node": "./node.js",
|
|
24
|
-
"default": "./core_pqc_wasm.js"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
18
|
"sideEffects": [
|
|
28
19
|
"./snippets/*"
|
|
29
20
|
]
|
package/core_pqc_wasm_bg.js
DELETED
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function addToExternrefTable0(obj) {
|
|
8
|
-
const idx = wasm.__externref_table_alloc();
|
|
9
|
-
wasm.__wbindgen_export_2.set(idx, obj);
|
|
10
|
-
return idx;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function handleError(f, args) {
|
|
14
|
-
try {
|
|
15
|
-
return f.apply(this, args);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
const idx = addToExternrefTable0(e);
|
|
18
|
-
wasm.__wbindgen_exn_store(idx);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let cachedUint8ArrayMemory0 = null;
|
|
23
|
-
|
|
24
|
-
function getUint8ArrayMemory0() {
|
|
25
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
26
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
27
|
-
}
|
|
28
|
-
return cachedUint8ArrayMemory0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
32
|
-
|
|
33
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
34
|
-
|
|
35
|
-
cachedTextDecoder.decode();
|
|
36
|
-
|
|
37
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
38
|
-
let numBytesDecoded = 0;
|
|
39
|
-
function decodeText(ptr, len) {
|
|
40
|
-
numBytesDecoded += len;
|
|
41
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
42
|
-
cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
43
|
-
cachedTextDecoder.decode();
|
|
44
|
-
numBytesDecoded = len;
|
|
45
|
-
}
|
|
46
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getStringFromWasm0(ptr, len) {
|
|
50
|
-
ptr = ptr >>> 0;
|
|
51
|
-
return decodeText(ptr, len);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function isLikeNone(x) {
|
|
55
|
-
return x === undefined || x === null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @returns {string}
|
|
59
|
-
*/
|
|
60
|
-
export function kyber_keygen() {
|
|
61
|
-
let deferred1_0;
|
|
62
|
-
let deferred1_1;
|
|
63
|
-
try {
|
|
64
|
-
const ret = wasm.kyber_keygen();
|
|
65
|
-
deferred1_0 = ret[0];
|
|
66
|
-
deferred1_1 = ret[1];
|
|
67
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
68
|
-
} finally {
|
|
69
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let WASM_VECTOR_LEN = 0;
|
|
74
|
-
|
|
75
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
76
|
-
|
|
77
|
-
const cachedTextEncoder = new lTextEncoder('utf-8');
|
|
78
|
-
|
|
79
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
80
|
-
? function (arg, view) {
|
|
81
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
82
|
-
}
|
|
83
|
-
: function (arg, view) {
|
|
84
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
85
|
-
view.set(buf);
|
|
86
|
-
return {
|
|
87
|
-
read: arg.length,
|
|
88
|
-
written: buf.length
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
93
|
-
|
|
94
|
-
if (realloc === undefined) {
|
|
95
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
96
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
97
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
98
|
-
WASM_VECTOR_LEN = buf.length;
|
|
99
|
-
return ptr;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let len = arg.length;
|
|
103
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
104
|
-
|
|
105
|
-
const mem = getUint8ArrayMemory0();
|
|
106
|
-
|
|
107
|
-
let offset = 0;
|
|
108
|
-
|
|
109
|
-
for (; offset < len; offset++) {
|
|
110
|
-
const code = arg.charCodeAt(offset);
|
|
111
|
-
if (code > 0x7F) break;
|
|
112
|
-
mem[ptr + offset] = code;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (offset !== len) {
|
|
116
|
-
if (offset !== 0) {
|
|
117
|
-
arg = arg.slice(offset);
|
|
118
|
-
}
|
|
119
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
120
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
121
|
-
const ret = encodeString(arg, view);
|
|
122
|
-
|
|
123
|
-
offset += ret.written;
|
|
124
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
WASM_VECTOR_LEN = offset;
|
|
128
|
-
return ptr;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @param {string} public_b64u
|
|
132
|
-
* @returns {string}
|
|
133
|
-
*/
|
|
134
|
-
export function kyber_encaps(public_b64u) {
|
|
135
|
-
let deferred2_0;
|
|
136
|
-
let deferred2_1;
|
|
137
|
-
try {
|
|
138
|
-
const ptr0 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
139
|
-
const len0 = WASM_VECTOR_LEN;
|
|
140
|
-
const ret = wasm.kyber_encaps(ptr0, len0);
|
|
141
|
-
deferred2_0 = ret[0];
|
|
142
|
-
deferred2_1 = ret[1];
|
|
143
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
144
|
-
} finally {
|
|
145
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* @param {string} secret_b64u
|
|
151
|
-
* @param {string} kem_ct_b64u
|
|
152
|
-
* @returns {string}
|
|
153
|
-
*/
|
|
154
|
-
export function kyber_decaps(secret_b64u, kem_ct_b64u) {
|
|
155
|
-
let deferred3_0;
|
|
156
|
-
let deferred3_1;
|
|
157
|
-
try {
|
|
158
|
-
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
159
|
-
const len0 = WASM_VECTOR_LEN;
|
|
160
|
-
const ptr1 = passStringToWasm0(kem_ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
-
const len1 = WASM_VECTOR_LEN;
|
|
162
|
-
const ret = wasm.kyber_decaps(ptr0, len0, ptr1, len1);
|
|
163
|
-
deferred3_0 = ret[0];
|
|
164
|
-
deferred3_1 = ret[1];
|
|
165
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
166
|
-
} finally {
|
|
167
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @param {string} secret_b64u
|
|
173
|
-
* @param {string} info_b64u
|
|
174
|
-
* @param {string | null | undefined} salt_b64u
|
|
175
|
-
* @param {number} len
|
|
176
|
-
* @returns {string}
|
|
177
|
-
*/
|
|
178
|
-
export function hkdf_sha256(secret_b64u, info_b64u, salt_b64u, len) {
|
|
179
|
-
let deferred4_0;
|
|
180
|
-
let deferred4_1;
|
|
181
|
-
try {
|
|
182
|
-
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
183
|
-
const len0 = WASM_VECTOR_LEN;
|
|
184
|
-
const ptr1 = passStringToWasm0(info_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
185
|
-
const len1 = WASM_VECTOR_LEN;
|
|
186
|
-
var ptr2 = isLikeNone(salt_b64u) ? 0 : passStringToWasm0(salt_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
-
var len2 = WASM_VECTOR_LEN;
|
|
188
|
-
const ret = wasm.hkdf_sha256(ptr0, len0, ptr1, len1, ptr2, len2, len);
|
|
189
|
-
deferred4_0 = ret[0];
|
|
190
|
-
deferred4_1 = ret[1];
|
|
191
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
192
|
-
} finally {
|
|
193
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @param {string} key_b64u
|
|
199
|
-
* @param {string} dek_b64u
|
|
200
|
-
* @param {string} aad_b64u
|
|
201
|
-
* @returns {string}
|
|
202
|
-
*/
|
|
203
|
-
export function aes_gcm_wrap(key_b64u, dek_b64u, aad_b64u) {
|
|
204
|
-
let deferred4_0;
|
|
205
|
-
let deferred4_1;
|
|
206
|
-
try {
|
|
207
|
-
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
-
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
const ptr1 = passStringToWasm0(dek_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
-
const len1 = WASM_VECTOR_LEN;
|
|
211
|
-
const ptr2 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
212
|
-
const len2 = WASM_VECTOR_LEN;
|
|
213
|
-
const ret = wasm.aes_gcm_wrap(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
214
|
-
deferred4_0 = ret[0];
|
|
215
|
-
deferred4_1 = ret[1];
|
|
216
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
217
|
-
} finally {
|
|
218
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @param {string} key_b64u
|
|
224
|
-
* @param {string} iv_b64u
|
|
225
|
-
* @param {string} ct_b64u
|
|
226
|
-
* @param {string} aad_b64u
|
|
227
|
-
* @returns {string}
|
|
228
|
-
*/
|
|
229
|
-
export function aes_gcm_unwrap(key_b64u, iv_b64u, ct_b64u, aad_b64u) {
|
|
230
|
-
let deferred5_0;
|
|
231
|
-
let deferred5_1;
|
|
232
|
-
try {
|
|
233
|
-
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
-
const len0 = WASM_VECTOR_LEN;
|
|
235
|
-
const ptr1 = passStringToWasm0(iv_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
236
|
-
const len1 = WASM_VECTOR_LEN;
|
|
237
|
-
const ptr2 = passStringToWasm0(ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
|
-
const len2 = WASM_VECTOR_LEN;
|
|
239
|
-
const ptr3 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
240
|
-
const len3 = WASM_VECTOR_LEN;
|
|
241
|
-
const ret = wasm.aes_gcm_unwrap(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
242
|
-
deferred5_0 = ret[0];
|
|
243
|
-
deferred5_1 = ret[1];
|
|
244
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
245
|
-
} finally {
|
|
246
|
-
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* @returns {string}
|
|
252
|
-
*/
|
|
253
|
-
export function dilithium_keygen() {
|
|
254
|
-
let deferred1_0;
|
|
255
|
-
let deferred1_1;
|
|
256
|
-
try {
|
|
257
|
-
const ret = wasm.dilithium_keygen();
|
|
258
|
-
deferred1_0 = ret[0];
|
|
259
|
-
deferred1_1 = ret[1];
|
|
260
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
261
|
-
} finally {
|
|
262
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @param {string} message_b64u
|
|
268
|
-
* @param {string} secret_b64u
|
|
269
|
-
* @returns {string}
|
|
270
|
-
*/
|
|
271
|
-
export function dilithium_sign(message_b64u, secret_b64u) {
|
|
272
|
-
let deferred3_0;
|
|
273
|
-
let deferred3_1;
|
|
274
|
-
try {
|
|
275
|
-
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
-
const len0 = WASM_VECTOR_LEN;
|
|
277
|
-
const ptr1 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
-
const len1 = WASM_VECTOR_LEN;
|
|
279
|
-
const ret = wasm.dilithium_sign(ptr0, len0, ptr1, len1);
|
|
280
|
-
deferred3_0 = ret[0];
|
|
281
|
-
deferred3_1 = ret[1];
|
|
282
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
283
|
-
} finally {
|
|
284
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @param {string} message_b64u
|
|
290
|
-
* @param {string} signature_b64u
|
|
291
|
-
* @param {string} public_b64u
|
|
292
|
-
* @returns {string}
|
|
293
|
-
*/
|
|
294
|
-
export function dilithium_verify(message_b64u, signature_b64u, public_b64u) {
|
|
295
|
-
let deferred4_0;
|
|
296
|
-
let deferred4_1;
|
|
297
|
-
try {
|
|
298
|
-
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
299
|
-
const len0 = WASM_VECTOR_LEN;
|
|
300
|
-
const ptr1 = passStringToWasm0(signature_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
301
|
-
const len1 = WASM_VECTOR_LEN;
|
|
302
|
-
const ptr2 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
303
|
-
const len2 = WASM_VECTOR_LEN;
|
|
304
|
-
const ret = wasm.dilithium_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
305
|
-
deferred4_0 = ret[0];
|
|
306
|
-
deferred4_1 = ret[1];
|
|
307
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
308
|
-
} finally {
|
|
309
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export function start() {
|
|
314
|
-
wasm.start();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export function __wbg_buffer_a1a27a0dfa70165d(arg0) {
|
|
318
|
-
const ret = arg0.buffer;
|
|
319
|
-
return ret;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export function __wbg_call_f2db6205e5c51dc8() { return handleError(function (arg0, arg1, arg2) {
|
|
323
|
-
const ret = arg0.call(arg1, arg2);
|
|
324
|
-
return ret;
|
|
325
|
-
}, arguments) };
|
|
326
|
-
|
|
327
|
-
export function __wbg_call_fbe8be8bf6436ce5() { return handleError(function (arg0, arg1) {
|
|
328
|
-
const ret = arg0.call(arg1);
|
|
329
|
-
return ret;
|
|
330
|
-
}, arguments) };
|
|
331
|
-
|
|
332
|
-
export function __wbg_crypto_574e78ad8b13b65f(arg0) {
|
|
333
|
-
const ret = arg0.crypto;
|
|
334
|
-
return ret;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
|
|
338
|
-
arg0.getRandomValues(arg1);
|
|
339
|
-
}, arguments) };
|
|
340
|
-
|
|
341
|
-
export function __wbg_log_8bc1206392c556f3(arg0, arg1) {
|
|
342
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
|
|
346
|
-
const ret = arg0.msCrypto;
|
|
347
|
-
return ret;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
export function __wbg_new_e52b3efaaa774f96(arg0) {
|
|
351
|
-
const ret = new Uint8Array(arg0);
|
|
352
|
-
return ret;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
export function __wbg_newnoargs_ff528e72d35de39a(arg0, arg1) {
|
|
356
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
357
|
-
return ret;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
export function __wbg_newwithbyteoffsetandlength_3b01ecda099177e8(arg0, arg1, arg2) {
|
|
361
|
-
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
362
|
-
return ret;
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
export function __wbg_newwithlength_08f872dc1e3ada2e(arg0) {
|
|
366
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
367
|
-
return ret;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
export function __wbg_node_905d3e251edff8a2(arg0) {
|
|
371
|
-
const ret = arg0.node;
|
|
372
|
-
return ret;
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
|
|
376
|
-
const ret = arg0.process;
|
|
377
|
-
return ret;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
|
|
381
|
-
arg0.randomFillSync(arg1);
|
|
382
|
-
}, arguments) };
|
|
383
|
-
|
|
384
|
-
export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
|
|
385
|
-
const ret = module.require;
|
|
386
|
-
return ret;
|
|
387
|
-
}, arguments) };
|
|
388
|
-
|
|
389
|
-
export function __wbg_set_fe4e79d1ed3b0e9b(arg0, arg1, arg2) {
|
|
390
|
-
arg0.set(arg1, arg2 >>> 0);
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
export function __wbg_static_accessor_GLOBAL_487c52c58d65314d() {
|
|
394
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
395
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
export function __wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291() {
|
|
399
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
400
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
export function __wbg_static_accessor_SELF_78c9e3071b912620() {
|
|
404
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
405
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
export function __wbg_static_accessor_WINDOW_a093d21393777366() {
|
|
409
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
410
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
export function __wbg_subarray_dd4ade7d53bd8e26(arg0, arg1, arg2) {
|
|
414
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
415
|
-
return ret;
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
export function __wbg_versions_c01dfd4722a88165(arg0) {
|
|
419
|
-
const ret = arg0.versions;
|
|
420
|
-
return ret;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
export function __wbindgen_init_externref_table() {
|
|
424
|
-
const table = wasm.__wbindgen_export_2;
|
|
425
|
-
const offset = table.grow(4);
|
|
426
|
-
table.set(0, undefined);
|
|
427
|
-
table.set(offset + 0, undefined);
|
|
428
|
-
table.set(offset + 1, null);
|
|
429
|
-
table.set(offset + 2, true);
|
|
430
|
-
table.set(offset + 3, false);
|
|
431
|
-
;
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
export function __wbindgen_is_function(arg0) {
|
|
435
|
-
const ret = typeof(arg0) === 'function';
|
|
436
|
-
return ret;
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
export function __wbindgen_is_object(arg0) {
|
|
440
|
-
const val = arg0;
|
|
441
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
442
|
-
return ret;
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
export function __wbindgen_is_string(arg0) {
|
|
446
|
-
const ret = typeof(arg0) === 'string';
|
|
447
|
-
return ret;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
export function __wbindgen_is_undefined(arg0) {
|
|
451
|
-
const ret = arg0 === undefined;
|
|
452
|
-
return ret;
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
export function __wbindgen_memory() {
|
|
456
|
-
const ret = wasm.memory;
|
|
457
|
-
return ret;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
export function __wbindgen_string_new(arg0, arg1) {
|
|
461
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
462
|
-
return ret;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
466
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
467
|
-
};
|
|
468
|
-
|
package/node.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import url from 'node:url';
|
|
4
|
-
|
|
5
|
-
// Node-friendly loader: read the .wasm file bytes and initialize the wasm module explicitly.
|
|
6
|
-
import initWasm, * as wasmExports from './core_pqc_wasm.js';
|
|
7
|
-
|
|
8
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
9
|
-
const wasmPath = path.join(__dirname, 'core_pqc_wasm_bg.wasm');
|
|
10
|
-
|
|
11
|
-
let ready;
|
|
12
|
-
async function ensureInit() {
|
|
13
|
-
if (!ready) {
|
|
14
|
-
const bytes = await fs.readFile(wasmPath);
|
|
15
|
-
// initWasm accepts BufferSource in Node 18 via WebAssembly.Module path
|
|
16
|
-
ready = initWasm(bytes);
|
|
17
|
-
}
|
|
18
|
-
return ready;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Re-export all bindings, but ensure initialization is performed first when needed.
|
|
22
|
-
// Consumers can call default() to ensure ready, or functions will work after a top-level init in their lib.
|
|
23
|
-
export default async function() {
|
|
24
|
-
await ensureInit();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Named exports: wrap the start/init-sensitive functions to ensure init has happened when called.
|
|
28
|
-
// For simplicity, re-export everything and rely on consumers to call default() or our higher-level wrapper does it.
|
|
29
|
-
export * from './core_pqc_wasm.js';
|