pqc-binary-format 1.0.7
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 +661 -0
- package/package.json +34 -0
- package/pqc_binary_format.d.ts +236 -0
- package/pqc_binary_format.js +5 -0
- package/pqc_binary_format_bg.js +827 -0
- package/pqc_binary_format_bg.wasm +0 -0
|
@@ -0,0 +1,827 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function _assertClass(instance, klass) {
|
|
7
|
+
if (!(instance instanceof klass)) {
|
|
8
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
13
|
+
ptr = ptr >>> 0;
|
|
14
|
+
const mem = getDataViewMemory0();
|
|
15
|
+
const result = [];
|
|
16
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
17
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
18
|
+
}
|
|
19
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
24
|
+
ptr = ptr >>> 0;
|
|
25
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let cachedDataViewMemory0 = null;
|
|
29
|
+
function getDataViewMemory0() {
|
|
30
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
31
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
32
|
+
}
|
|
33
|
+
return cachedDataViewMemory0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getStringFromWasm0(ptr, len) {
|
|
37
|
+
ptr = ptr >>> 0;
|
|
38
|
+
return decodeText(ptr, len);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let cachedUint8ArrayMemory0 = null;
|
|
42
|
+
function getUint8ArrayMemory0() {
|
|
43
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
44
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
45
|
+
}
|
|
46
|
+
return cachedUint8ArrayMemory0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
50
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
51
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
52
|
+
WASM_VECTOR_LEN = arg.length;
|
|
53
|
+
return ptr;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
57
|
+
if (realloc === undefined) {
|
|
58
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
59
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
60
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
61
|
+
WASM_VECTOR_LEN = buf.length;
|
|
62
|
+
return ptr;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let len = arg.length;
|
|
66
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
67
|
+
|
|
68
|
+
const mem = getUint8ArrayMemory0();
|
|
69
|
+
|
|
70
|
+
let offset = 0;
|
|
71
|
+
|
|
72
|
+
for (; offset < len; offset++) {
|
|
73
|
+
const code = arg.charCodeAt(offset);
|
|
74
|
+
if (code > 0x7F) break;
|
|
75
|
+
mem[ptr + offset] = code;
|
|
76
|
+
}
|
|
77
|
+
if (offset !== len) {
|
|
78
|
+
if (offset !== 0) {
|
|
79
|
+
arg = arg.slice(offset);
|
|
80
|
+
}
|
|
81
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
82
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
83
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
84
|
+
|
|
85
|
+
offset += ret.written;
|
|
86
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
WASM_VECTOR_LEN = offset;
|
|
90
|
+
return ptr;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function takeFromExternrefTable0(idx) {
|
|
94
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
95
|
+
wasm.__externref_table_dealloc(idx);
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
100
|
+
cachedTextDecoder.decode();
|
|
101
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
102
|
+
let numBytesDecoded = 0;
|
|
103
|
+
function decodeText(ptr, len) {
|
|
104
|
+
numBytesDecoded += len;
|
|
105
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
106
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
107
|
+
cachedTextDecoder.decode();
|
|
108
|
+
numBytesDecoded = len;
|
|
109
|
+
}
|
|
110
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const cachedTextEncoder = new TextEncoder();
|
|
114
|
+
|
|
115
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
116
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
117
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
118
|
+
view.set(buf);
|
|
119
|
+
return {
|
|
120
|
+
read: arg.length,
|
|
121
|
+
written: buf.length
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let WASM_VECTOR_LEN = 0;
|
|
127
|
+
|
|
128
|
+
const WasmAlgorithmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
129
|
+
? { register: () => {}, unregister: () => {} }
|
|
130
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmalgorithm_free(ptr >>> 0, 1));
|
|
131
|
+
|
|
132
|
+
const WasmCompressionParametersFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
133
|
+
? { register: () => {}, unregister: () => {} }
|
|
134
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcompressionparameters_free(ptr >>> 0, 1));
|
|
135
|
+
|
|
136
|
+
const WasmEncParametersFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
137
|
+
? { register: () => {}, unregister: () => {} }
|
|
138
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmencparameters_free(ptr >>> 0, 1));
|
|
139
|
+
|
|
140
|
+
const WasmFormatFlagsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
141
|
+
? { register: () => {}, unregister: () => {} }
|
|
142
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmformatflags_free(ptr >>> 0, 1));
|
|
143
|
+
|
|
144
|
+
const WasmKemParametersFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
145
|
+
? { register: () => {}, unregister: () => {} }
|
|
146
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmkemparameters_free(ptr >>> 0, 1));
|
|
147
|
+
|
|
148
|
+
const WasmPqcBinaryFormatFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
149
|
+
? { register: () => {}, unregister: () => {} }
|
|
150
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpqcbinaryformat_free(ptr >>> 0, 1));
|
|
151
|
+
|
|
152
|
+
const WasmPqcMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
153
|
+
? { register: () => {}, unregister: () => {} }
|
|
154
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpqcmetadata_free(ptr >>> 0, 1));
|
|
155
|
+
|
|
156
|
+
const WasmSigParametersFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
157
|
+
? { register: () => {}, unregister: () => {} }
|
|
158
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsigparameters_free(ptr >>> 0, 1));
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* WebAssembly wrapper for Algorithm
|
|
162
|
+
*/
|
|
163
|
+
export class WasmAlgorithm {
|
|
164
|
+
static __wrap(ptr) {
|
|
165
|
+
ptr = ptr >>> 0;
|
|
166
|
+
const obj = Object.create(WasmAlgorithm.prototype);
|
|
167
|
+
obj.__wbg_ptr = ptr;
|
|
168
|
+
WasmAlgorithmFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
169
|
+
return obj;
|
|
170
|
+
}
|
|
171
|
+
__destroy_into_raw() {
|
|
172
|
+
const ptr = this.__wbg_ptr;
|
|
173
|
+
this.__wbg_ptr = 0;
|
|
174
|
+
WasmAlgorithmFinalization.unregister(this);
|
|
175
|
+
return ptr;
|
|
176
|
+
}
|
|
177
|
+
free() {
|
|
178
|
+
const ptr = this.__destroy_into_raw();
|
|
179
|
+
wasm.__wbg_wasmalgorithm_free(ptr, 0);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get all supported algorithm names
|
|
183
|
+
* @returns {any[]}
|
|
184
|
+
*/
|
|
185
|
+
static supportedAlgorithms() {
|
|
186
|
+
const ret = wasm.wasmalgorithm_supportedAlgorithms();
|
|
187
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
188
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
189
|
+
return v1;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get algorithm ID
|
|
193
|
+
* @returns {number}
|
|
194
|
+
*/
|
|
195
|
+
get id() {
|
|
196
|
+
const ret = wasm.wasmalgorithm_id(this.__wbg_ptr);
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Create a new algorithm from name
|
|
201
|
+
* @param {string} name
|
|
202
|
+
*/
|
|
203
|
+
constructor(name) {
|
|
204
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len0 = WASM_VECTOR_LEN;
|
|
206
|
+
const ret = wasm.wasmalgorithm_new(ptr0, len0);
|
|
207
|
+
if (ret[2]) {
|
|
208
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
209
|
+
}
|
|
210
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
211
|
+
WasmAlgorithmFinalization.register(this, this.__wbg_ptr, this);
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get algorithm name
|
|
216
|
+
* @returns {string}
|
|
217
|
+
*/
|
|
218
|
+
get name() {
|
|
219
|
+
let deferred1_0;
|
|
220
|
+
let deferred1_1;
|
|
221
|
+
try {
|
|
222
|
+
const ret = wasm.wasmalgorithm_name(this.__wbg_ptr);
|
|
223
|
+
deferred1_0 = ret[0];
|
|
224
|
+
deferred1_1 = ret[1];
|
|
225
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
226
|
+
} finally {
|
|
227
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (Symbol.dispose) WasmAlgorithm.prototype[Symbol.dispose] = WasmAlgorithm.prototype.free;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* WebAssembly wrapper for CompressionParameters
|
|
235
|
+
*/
|
|
236
|
+
export class WasmCompressionParameters {
|
|
237
|
+
__destroy_into_raw() {
|
|
238
|
+
const ptr = this.__wbg_ptr;
|
|
239
|
+
this.__wbg_ptr = 0;
|
|
240
|
+
WasmCompressionParametersFinalization.unregister(this);
|
|
241
|
+
return ptr;
|
|
242
|
+
}
|
|
243
|
+
free() {
|
|
244
|
+
const ptr = this.__destroy_into_raw();
|
|
245
|
+
wasm.__wbg_wasmcompressionparameters_free(ptr, 0);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Get original size
|
|
249
|
+
* @returns {bigint}
|
|
250
|
+
*/
|
|
251
|
+
get original_size() {
|
|
252
|
+
const ret = wasm.wasmcompressionparameters_original_size(this.__wbg_ptr);
|
|
253
|
+
return BigInt.asUintN(64, ret);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create new compression parameters
|
|
257
|
+
* @param {string} algorithm
|
|
258
|
+
* @param {number} level
|
|
259
|
+
* @param {bigint} original_size
|
|
260
|
+
*/
|
|
261
|
+
constructor(algorithm, level, original_size) {
|
|
262
|
+
const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
263
|
+
const len0 = WASM_VECTOR_LEN;
|
|
264
|
+
const ret = wasm.wasmcompressionparameters_new(ptr0, len0, level, original_size);
|
|
265
|
+
this.__wbg_ptr = ret >>> 0;
|
|
266
|
+
WasmCompressionParametersFinalization.register(this, this.__wbg_ptr, this);
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Get compression level
|
|
271
|
+
* @returns {number}
|
|
272
|
+
*/
|
|
273
|
+
get level() {
|
|
274
|
+
const ret = wasm.wasmcompressionparameters_level(this.__wbg_ptr);
|
|
275
|
+
return ret;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get compression algorithm
|
|
279
|
+
* @returns {string}
|
|
280
|
+
*/
|
|
281
|
+
get algorithm() {
|
|
282
|
+
let deferred1_0;
|
|
283
|
+
let deferred1_1;
|
|
284
|
+
try {
|
|
285
|
+
const ret = wasm.wasmcompressionparameters_algorithm(this.__wbg_ptr);
|
|
286
|
+
deferred1_0 = ret[0];
|
|
287
|
+
deferred1_1 = ret[1];
|
|
288
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
289
|
+
} finally {
|
|
290
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (Symbol.dispose) WasmCompressionParameters.prototype[Symbol.dispose] = WasmCompressionParameters.prototype.free;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* WebAssembly wrapper for EncParameters
|
|
298
|
+
*/
|
|
299
|
+
export class WasmEncParameters {
|
|
300
|
+
__destroy_into_raw() {
|
|
301
|
+
const ptr = this.__wbg_ptr;
|
|
302
|
+
this.__wbg_ptr = 0;
|
|
303
|
+
WasmEncParametersFinalization.unregister(this);
|
|
304
|
+
return ptr;
|
|
305
|
+
}
|
|
306
|
+
free() {
|
|
307
|
+
const ptr = this.__destroy_into_raw();
|
|
308
|
+
wasm.__wbg_wasmencparameters_free(ptr, 0);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get IV/nonce
|
|
312
|
+
* @returns {Uint8Array}
|
|
313
|
+
*/
|
|
314
|
+
get iv() {
|
|
315
|
+
const ret = wasm.wasmencparameters_iv(this.__wbg_ptr);
|
|
316
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
317
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
318
|
+
return v1;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Create new encryption parameters
|
|
322
|
+
* @param {Uint8Array} iv
|
|
323
|
+
* @param {Uint8Array} tag
|
|
324
|
+
*/
|
|
325
|
+
constructor(iv, tag) {
|
|
326
|
+
const ptr0 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
327
|
+
const len0 = WASM_VECTOR_LEN;
|
|
328
|
+
const ptr1 = passArray8ToWasm0(tag, wasm.__wbindgen_malloc);
|
|
329
|
+
const len1 = WASM_VECTOR_LEN;
|
|
330
|
+
const ret = wasm.wasmencparameters_new(ptr0, len0, ptr1, len1);
|
|
331
|
+
this.__wbg_ptr = ret >>> 0;
|
|
332
|
+
WasmEncParametersFinalization.register(this, this.__wbg_ptr, this);
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get authentication tag
|
|
337
|
+
* @returns {Uint8Array}
|
|
338
|
+
*/
|
|
339
|
+
get tag() {
|
|
340
|
+
const ret = wasm.wasmencparameters_tag(this.__wbg_ptr);
|
|
341
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
342
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
343
|
+
return v1;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Set IV/nonce
|
|
347
|
+
* @param {Uint8Array} iv
|
|
348
|
+
*/
|
|
349
|
+
set iv(iv) {
|
|
350
|
+
const ptr0 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
351
|
+
const len0 = WASM_VECTOR_LEN;
|
|
352
|
+
wasm.wasmencparameters_set_iv(this.__wbg_ptr, ptr0, len0);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Set authentication tag
|
|
356
|
+
* @param {Uint8Array} tag
|
|
357
|
+
*/
|
|
358
|
+
set tag(tag) {
|
|
359
|
+
const ptr0 = passArray8ToWasm0(tag, wasm.__wbindgen_malloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
wasm.wasmencparameters_set_tag(this.__wbg_ptr, ptr0, len0);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (Symbol.dispose) WasmEncParameters.prototype[Symbol.dispose] = WasmEncParameters.prototype.free;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* WebAssembly wrapper for FormatFlags
|
|
368
|
+
*/
|
|
369
|
+
export class WasmFormatFlags {
|
|
370
|
+
static __wrap(ptr) {
|
|
371
|
+
ptr = ptr >>> 0;
|
|
372
|
+
const obj = Object.create(WasmFormatFlags.prototype);
|
|
373
|
+
obj.__wbg_ptr = ptr;
|
|
374
|
+
WasmFormatFlagsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
375
|
+
return obj;
|
|
376
|
+
}
|
|
377
|
+
__destroy_into_raw() {
|
|
378
|
+
const ptr = this.__wbg_ptr;
|
|
379
|
+
this.__wbg_ptr = 0;
|
|
380
|
+
WasmFormatFlagsFinalization.unregister(this);
|
|
381
|
+
return ptr;
|
|
382
|
+
}
|
|
383
|
+
free() {
|
|
384
|
+
const ptr = this.__destroy_into_raw();
|
|
385
|
+
wasm.__wbg_wasmformatflags_free(ptr, 0);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Check if streaming is enabled
|
|
389
|
+
* @returns {boolean}
|
|
390
|
+
*/
|
|
391
|
+
hasStreaming() {
|
|
392
|
+
const ret = wasm.wasmformatflags_hasStreaming(this.__wbg_ptr);
|
|
393
|
+
return ret !== 0;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Enable streaming flag
|
|
397
|
+
* @returns {WasmFormatFlags}
|
|
398
|
+
*/
|
|
399
|
+
withStreaming() {
|
|
400
|
+
const ret = wasm.wasmformatflags_withStreaming(this.__wbg_ptr);
|
|
401
|
+
return WasmFormatFlags.__wrap(ret);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Check if compression is enabled
|
|
405
|
+
* @returns {boolean}
|
|
406
|
+
*/
|
|
407
|
+
hasCompression() {
|
|
408
|
+
const ret = wasm.wasmformatflags_hasCompression(this.__wbg_ptr);
|
|
409
|
+
return ret !== 0;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Check if experimental features are enabled
|
|
413
|
+
* @returns {boolean}
|
|
414
|
+
*/
|
|
415
|
+
hasExperimental() {
|
|
416
|
+
const ret = wasm.wasmformatflags_hasExperimental(this.__wbg_ptr);
|
|
417
|
+
return ret !== 0;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Enable compression flag
|
|
421
|
+
* @returns {WasmFormatFlags}
|
|
422
|
+
*/
|
|
423
|
+
withCompression() {
|
|
424
|
+
const ret = wasm.wasmformatflags_withCompression(this.__wbg_ptr);
|
|
425
|
+
return WasmFormatFlags.__wrap(ret);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Enable experimental features flag
|
|
429
|
+
* @returns {WasmFormatFlags}
|
|
430
|
+
*/
|
|
431
|
+
withExperimental() {
|
|
432
|
+
const ret = wasm.wasmformatflags_withExperimental(this.__wbg_ptr);
|
|
433
|
+
return WasmFormatFlags.__wrap(ret);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Check if additional auth is enabled
|
|
437
|
+
* @returns {boolean}
|
|
438
|
+
*/
|
|
439
|
+
hasAdditionalAuth() {
|
|
440
|
+
const ret = wasm.wasmformatflags_hasAdditionalAuth(this.__wbg_ptr);
|
|
441
|
+
return ret !== 0;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Enable additional auth flag
|
|
445
|
+
* @returns {WasmFormatFlags}
|
|
446
|
+
*/
|
|
447
|
+
withAdditionalAuth() {
|
|
448
|
+
const ret = wasm.wasmformatflags_withAdditionalAuth(this.__wbg_ptr);
|
|
449
|
+
return WasmFormatFlags.__wrap(ret);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Create new empty flags
|
|
453
|
+
*/
|
|
454
|
+
constructor() {
|
|
455
|
+
const ret = wasm.wasmformatflags_new();
|
|
456
|
+
this.__wbg_ptr = ret >>> 0;
|
|
457
|
+
WasmFormatFlagsFinalization.register(this, this.__wbg_ptr, this);
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (Symbol.dispose) WasmFormatFlags.prototype[Symbol.dispose] = WasmFormatFlags.prototype.free;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* WebAssembly wrapper for KemParameters
|
|
465
|
+
*/
|
|
466
|
+
export class WasmKemParameters {
|
|
467
|
+
__destroy_into_raw() {
|
|
468
|
+
const ptr = this.__wbg_ptr;
|
|
469
|
+
this.__wbg_ptr = 0;
|
|
470
|
+
WasmKemParametersFinalization.unregister(this);
|
|
471
|
+
return ptr;
|
|
472
|
+
}
|
|
473
|
+
free() {
|
|
474
|
+
const ptr = this.__destroy_into_raw();
|
|
475
|
+
wasm.__wbg_wasmkemparameters_free(ptr, 0);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get ciphertext
|
|
479
|
+
* @returns {Uint8Array}
|
|
480
|
+
*/
|
|
481
|
+
get ciphertext() {
|
|
482
|
+
const ret = wasm.wasmkemparameters_ciphertext(this.__wbg_ptr);
|
|
483
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
484
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
485
|
+
return v1;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Get public key
|
|
489
|
+
* @returns {Uint8Array}
|
|
490
|
+
*/
|
|
491
|
+
get public_key() {
|
|
492
|
+
const ret = wasm.wasmkemparameters_public_key(this.__wbg_ptr);
|
|
493
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
494
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
495
|
+
return v1;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Create new KEM parameters
|
|
499
|
+
* @param {Uint8Array} public_key
|
|
500
|
+
* @param {Uint8Array} ciphertext
|
|
501
|
+
*/
|
|
502
|
+
constructor(public_key, ciphertext) {
|
|
503
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
504
|
+
const len0 = WASM_VECTOR_LEN;
|
|
505
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
506
|
+
const len1 = WASM_VECTOR_LEN;
|
|
507
|
+
const ret = wasm.wasmencparameters_new(ptr0, len0, ptr1, len1);
|
|
508
|
+
this.__wbg_ptr = ret >>> 0;
|
|
509
|
+
WasmKemParametersFinalization.register(this, this.__wbg_ptr, this);
|
|
510
|
+
return this;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (Symbol.dispose) WasmKemParameters.prototype[Symbol.dispose] = WasmKemParameters.prototype.free;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* WebAssembly wrapper for PqcBinaryFormat
|
|
517
|
+
*/
|
|
518
|
+
export class WasmPqcBinaryFormat {
|
|
519
|
+
static __wrap(ptr) {
|
|
520
|
+
ptr = ptr >>> 0;
|
|
521
|
+
const obj = Object.create(WasmPqcBinaryFormat.prototype);
|
|
522
|
+
obj.__wbg_ptr = ptr;
|
|
523
|
+
WasmPqcBinaryFormatFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
524
|
+
return obj;
|
|
525
|
+
}
|
|
526
|
+
__destroy_into_raw() {
|
|
527
|
+
const ptr = this.__wbg_ptr;
|
|
528
|
+
this.__wbg_ptr = 0;
|
|
529
|
+
WasmPqcBinaryFormatFinalization.unregister(this);
|
|
530
|
+
return ptr;
|
|
531
|
+
}
|
|
532
|
+
free() {
|
|
533
|
+
const ptr = this.__destroy_into_raw();
|
|
534
|
+
wasm.__wbg_wasmpqcbinaryformat_free(ptr, 0);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Deserialize from bytes
|
|
538
|
+
*
|
|
539
|
+
* @param {Uint8Array} data - Bytes to deserialize
|
|
540
|
+
* @returns {WasmPqcBinaryFormat} Deserialized instance
|
|
541
|
+
* @throws {Error} If deserialization fails
|
|
542
|
+
* @param {Uint8Array} data
|
|
543
|
+
* @returns {WasmPqcBinaryFormat}
|
|
544
|
+
*/
|
|
545
|
+
static fromBytes(data) {
|
|
546
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
547
|
+
const len0 = WASM_VECTOR_LEN;
|
|
548
|
+
const ret = wasm.wasmpqcbinaryformat_fromBytes(ptr0, len0);
|
|
549
|
+
if (ret[2]) {
|
|
550
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
551
|
+
}
|
|
552
|
+
return WasmPqcBinaryFormat.__wrap(ret[0]);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Get total serialized size
|
|
556
|
+
*
|
|
557
|
+
* @returns {number} Size in bytes
|
|
558
|
+
* @returns {number}
|
|
559
|
+
*/
|
|
560
|
+
totalSize() {
|
|
561
|
+
const ret = wasm.wasmpqcbinaryformat_totalSize(this.__wbg_ptr);
|
|
562
|
+
return ret >>> 0;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Create with specific flags
|
|
566
|
+
*
|
|
567
|
+
* @param {WasmAlgorithm} algorithm - Algorithm to use
|
|
568
|
+
* @param {WasmFormatFlags} flags - Format flags
|
|
569
|
+
* @param {WasmPqcMetadata} metadata - Metadata container
|
|
570
|
+
* @param {Uint8Array} data - Encrypted data bytes
|
|
571
|
+
* @returns {WasmPqcBinaryFormat} New instance
|
|
572
|
+
* @param {WasmAlgorithm} algorithm
|
|
573
|
+
* @param {WasmFormatFlags} flags
|
|
574
|
+
* @param {WasmPqcMetadata} metadata
|
|
575
|
+
* @param {Uint8Array} data
|
|
576
|
+
* @returns {WasmPqcBinaryFormat}
|
|
577
|
+
*/
|
|
578
|
+
static withFlags(algorithm, flags, metadata, data) {
|
|
579
|
+
_assertClass(algorithm, WasmAlgorithm);
|
|
580
|
+
var ptr0 = algorithm.__destroy_into_raw();
|
|
581
|
+
_assertClass(flags, WasmFormatFlags);
|
|
582
|
+
var ptr1 = flags.__destroy_into_raw();
|
|
583
|
+
_assertClass(metadata, WasmPqcMetadata);
|
|
584
|
+
var ptr2 = metadata.__destroy_into_raw();
|
|
585
|
+
const ptr3 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
586
|
+
const len3 = WASM_VECTOR_LEN;
|
|
587
|
+
const ret = wasm.wasmpqcbinaryformat_withFlags(ptr0, ptr1, ptr2, ptr3, len3);
|
|
588
|
+
return WasmPqcBinaryFormat.__wrap(ret);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Create a new PQC Binary Format structure
|
|
592
|
+
*
|
|
593
|
+
* @param {WasmAlgorithm} algorithm - Algorithm to use
|
|
594
|
+
* @param {WasmPqcMetadata} metadata - Metadata container
|
|
595
|
+
* @param {Uint8Array} data - Encrypted data bytes
|
|
596
|
+
* @returns {WasmPqcBinaryFormat} New instance
|
|
597
|
+
* @param {WasmAlgorithm} algorithm
|
|
598
|
+
* @param {WasmPqcMetadata} metadata
|
|
599
|
+
* @param {Uint8Array} data
|
|
600
|
+
*/
|
|
601
|
+
constructor(algorithm, metadata, data) {
|
|
602
|
+
_assertClass(algorithm, WasmAlgorithm);
|
|
603
|
+
var ptr0 = algorithm.__destroy_into_raw();
|
|
604
|
+
_assertClass(metadata, WasmPqcMetadata);
|
|
605
|
+
var ptr1 = metadata.__destroy_into_raw();
|
|
606
|
+
const ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
607
|
+
const len2 = WASM_VECTOR_LEN;
|
|
608
|
+
const ret = wasm.wasmpqcbinaryformat_new(ptr0, ptr1, ptr2, len2);
|
|
609
|
+
this.__wbg_ptr = ret >>> 0;
|
|
610
|
+
WasmPqcBinaryFormatFinalization.register(this, this.__wbg_ptr, this);
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Get encrypted data
|
|
615
|
+
*
|
|
616
|
+
* @returns {Uint8Array} Encrypted data
|
|
617
|
+
* @returns {Uint8Array}
|
|
618
|
+
*/
|
|
619
|
+
get data() {
|
|
620
|
+
const ret = wasm.wasmpqcbinaryformat_data(this.__wbg_ptr);
|
|
621
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
622
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
623
|
+
return v1;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Get format flags
|
|
627
|
+
*
|
|
628
|
+
* @returns {WasmFormatFlags} Format flags
|
|
629
|
+
* @returns {WasmFormatFlags}
|
|
630
|
+
*/
|
|
631
|
+
get flags() {
|
|
632
|
+
const ret = wasm.wasmpqcbinaryformat_flags(this.__wbg_ptr);
|
|
633
|
+
return WasmFormatFlags.__wrap(ret);
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Serialize to bytes
|
|
637
|
+
*
|
|
638
|
+
* @returns {Uint8Array} Serialized bytes
|
|
639
|
+
* @throws {Error} If serialization fails
|
|
640
|
+
* @returns {Uint8Array}
|
|
641
|
+
*/
|
|
642
|
+
toBytes() {
|
|
643
|
+
const ret = wasm.wasmpqcbinaryformat_toBytes(this.__wbg_ptr);
|
|
644
|
+
if (ret[3]) {
|
|
645
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
646
|
+
}
|
|
647
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
648
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
649
|
+
return v1;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Validate the format structure
|
|
653
|
+
*
|
|
654
|
+
* @throws {Error} If validation fails
|
|
655
|
+
*/
|
|
656
|
+
validate() {
|
|
657
|
+
const ret = wasm.wasmpqcbinaryformat_validate(this.__wbg_ptr);
|
|
658
|
+
if (ret[1]) {
|
|
659
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Get algorithm
|
|
664
|
+
*
|
|
665
|
+
* @returns {WasmAlgorithm} Algorithm used
|
|
666
|
+
* @returns {WasmAlgorithm}
|
|
667
|
+
*/
|
|
668
|
+
get algorithm() {
|
|
669
|
+
const ret = wasm.wasmpqcbinaryformat_algorithm(this.__wbg_ptr);
|
|
670
|
+
return WasmAlgorithm.__wrap(ret);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (Symbol.dispose) WasmPqcBinaryFormat.prototype[Symbol.dispose] = WasmPqcBinaryFormat.prototype.free;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* WebAssembly wrapper for PqcMetadata
|
|
677
|
+
*/
|
|
678
|
+
export class WasmPqcMetadata {
|
|
679
|
+
__destroy_into_raw() {
|
|
680
|
+
const ptr = this.__wbg_ptr;
|
|
681
|
+
this.__wbg_ptr = 0;
|
|
682
|
+
WasmPqcMetadataFinalization.unregister(this);
|
|
683
|
+
return ptr;
|
|
684
|
+
}
|
|
685
|
+
free() {
|
|
686
|
+
const ptr = this.__destroy_into_raw();
|
|
687
|
+
wasm.__wbg_wasmpqcmetadata_free(ptr, 0);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Set KEM parameters
|
|
691
|
+
* @param {WasmKemParameters} kem_params
|
|
692
|
+
*/
|
|
693
|
+
setKemParams(kem_params) {
|
|
694
|
+
_assertClass(kem_params, WasmKemParameters);
|
|
695
|
+
var ptr0 = kem_params.__destroy_into_raw();
|
|
696
|
+
wasm.wasmpqcmetadata_setKemParams(this.__wbg_ptr, ptr0);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Set signature parameters
|
|
700
|
+
* @param {WasmSigParameters} sig_params
|
|
701
|
+
*/
|
|
702
|
+
setSigParams(sig_params) {
|
|
703
|
+
_assertClass(sig_params, WasmSigParameters);
|
|
704
|
+
var ptr0 = sig_params.__destroy_into_raw();
|
|
705
|
+
wasm.wasmpqcmetadata_setSigParams(this.__wbg_ptr, ptr0);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Set compression parameters
|
|
709
|
+
* @param {WasmCompressionParameters} compression_params
|
|
710
|
+
*/
|
|
711
|
+
setCompressionParams(compression_params) {
|
|
712
|
+
_assertClass(compression_params, WasmCompressionParameters);
|
|
713
|
+
var ptr0 = compression_params.__destroy_into_raw();
|
|
714
|
+
wasm.wasmpqcmetadata_setCompressionParams(this.__wbg_ptr, ptr0);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Create new metadata
|
|
718
|
+
* @param {WasmEncParameters} enc_params
|
|
719
|
+
*/
|
|
720
|
+
constructor(enc_params) {
|
|
721
|
+
_assertClass(enc_params, WasmEncParameters);
|
|
722
|
+
var ptr0 = enc_params.__destroy_into_raw();
|
|
723
|
+
const ret = wasm.wasmpqcmetadata_new(ptr0);
|
|
724
|
+
this.__wbg_ptr = ret >>> 0;
|
|
725
|
+
WasmPqcMetadataFinalization.register(this, this.__wbg_ptr, this);
|
|
726
|
+
return this;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (Symbol.dispose) WasmPqcMetadata.prototype[Symbol.dispose] = WasmPqcMetadata.prototype.free;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* WebAssembly wrapper for SigParameters
|
|
733
|
+
*/
|
|
734
|
+
export class WasmSigParameters {
|
|
735
|
+
__destroy_into_raw() {
|
|
736
|
+
const ptr = this.__wbg_ptr;
|
|
737
|
+
this.__wbg_ptr = 0;
|
|
738
|
+
WasmSigParametersFinalization.unregister(this);
|
|
739
|
+
return ptr;
|
|
740
|
+
}
|
|
741
|
+
free() {
|
|
742
|
+
const ptr = this.__destroy_into_raw();
|
|
743
|
+
wasm.__wbg_wasmsigparameters_free(ptr, 0);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Get public key
|
|
747
|
+
* @returns {Uint8Array}
|
|
748
|
+
*/
|
|
749
|
+
get public_key() {
|
|
750
|
+
const ret = wasm.wasmsigparameters_public_key(this.__wbg_ptr);
|
|
751
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
752
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
753
|
+
return v1;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Create new signature parameters
|
|
757
|
+
* @param {Uint8Array} public_key
|
|
758
|
+
* @param {Uint8Array} signature
|
|
759
|
+
*/
|
|
760
|
+
constructor(public_key, signature) {
|
|
761
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
762
|
+
const len0 = WASM_VECTOR_LEN;
|
|
763
|
+
const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
764
|
+
const len1 = WASM_VECTOR_LEN;
|
|
765
|
+
const ret = wasm.wasmencparameters_new(ptr0, len0, ptr1, len1);
|
|
766
|
+
this.__wbg_ptr = ret >>> 0;
|
|
767
|
+
WasmSigParametersFinalization.register(this, this.__wbg_ptr, this);
|
|
768
|
+
return this;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Get signature
|
|
772
|
+
* @returns {Uint8Array}
|
|
773
|
+
*/
|
|
774
|
+
get signature() {
|
|
775
|
+
const ret = wasm.wasmsigparameters_signature(this.__wbg_ptr);
|
|
776
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
777
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
778
|
+
return v1;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (Symbol.dispose) WasmSigParameters.prototype[Symbol.dispose] = WasmSigParameters.prototype.free;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Get the PQC Binary Format spec version
|
|
785
|
+
* @returns {number}
|
|
786
|
+
*/
|
|
787
|
+
export function getBinaryVersion() {
|
|
788
|
+
const ret = wasm.getBinaryVersion();
|
|
789
|
+
return ret;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Get the PQC Binary Format version
|
|
794
|
+
* @returns {string}
|
|
795
|
+
*/
|
|
796
|
+
export function getVersion() {
|
|
797
|
+
let deferred1_0;
|
|
798
|
+
let deferred1_1;
|
|
799
|
+
try {
|
|
800
|
+
const ret = wasm.getVersion();
|
|
801
|
+
deferred1_0 = ret[0];
|
|
802
|
+
deferred1_1 = ret[1];
|
|
803
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
804
|
+
} finally {
|
|
805
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
|
|
810
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
814
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
815
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
816
|
+
return ret;
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
export function __wbindgen_init_externref_table() {
|
|
820
|
+
const table = wasm.__wbindgen_externrefs;
|
|
821
|
+
const offset = table.grow(4);
|
|
822
|
+
table.set(0, undefined);
|
|
823
|
+
table.set(offset + 0, undefined);
|
|
824
|
+
table.set(offset + 1, null);
|
|
825
|
+
table.set(offset + 2, true);
|
|
826
|
+
table.set(offset + 3, false);
|
|
827
|
+
};
|