xwing-wasm 0.3.1 → 0.3.2
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/bundler/xwing.d.ts +4 -2
- package/bundler/xwing.js +1 -1
- package/bundler/xwing_bg.js +49 -28
- package/bundler/xwing_bg.wasm.d.ts +2 -1
- package/node/xwing.d.ts +4 -2
- package/node/xwing.js +47 -25
- package/node/xwing_bg.wasm.d.ts +2 -1
- package/package.json +1 -1
- package/web/xwing.d.ts +6 -3
- package/web/xwing.js +57 -28
- package/web/xwing_bg.wasm.d.ts +2 -1
- package/xwing_bg.js +49 -28
- package/xwing_bg.wasm +0 -0
package/bundler/xwing.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
|
+
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
package/bundler/xwing.js
CHANGED
package/bundler/xwing_bg.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Uint8Array} sk
|
|
3
|
-
* @param {Uint8Array} ciphertext
|
|
2
|
+
* @param {Uint8Array | number[]} sk
|
|
3
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
4
4
|
* @returns {Uint8Array}
|
|
5
5
|
*/
|
|
6
6
|
export function decapsulate(sk, ciphertext) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let ptr0, len0, ptr1, len1;
|
|
8
|
+
try {
|
|
9
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
len0 = WASM_VECTOR_LEN;
|
|
11
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
len1 = WASM_VECTOR_LEN;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
15
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
11
18
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
19
|
if (ret[3]) {
|
|
13
20
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -18,7 +25,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
* @param {Uint8Array} pk
|
|
28
|
+
* @param {Uint8Array | number[]} pk
|
|
22
29
|
* @returns {EncapsulateResult}
|
|
23
30
|
*/
|
|
24
31
|
export function encapsulate(pk) {
|
|
@@ -41,7 +48,21 @@ export function generateKeypair() {
|
|
|
41
48
|
}
|
|
42
49
|
return takeFromExternrefTable0(ret[0]);
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Uint8Array | number[]} seed
|
|
54
|
+
* @returns {GenerateKeypairResult}
|
|
55
|
+
*/
|
|
56
|
+
export function generateKeypairFromSeed(seed) {
|
|
57
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
60
|
+
if (ret[2]) {
|
|
61
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
+
}
|
|
63
|
+
return takeFromExternrefTable0(ret[0]);
|
|
64
|
+
}
|
|
65
|
+
export function __wbg_Error_208446807d0d1e30(arg0, arg1) {
|
|
45
66
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
46
67
|
return ret;
|
|
47
68
|
}
|
|
@@ -49,28 +70,28 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
49
70
|
const ret = String(arg1);
|
|
50
71
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
72
|
const len1 = WASM_VECTOR_LEN;
|
|
52
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
53
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
73
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
74
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
54
75
|
}
|
|
55
|
-
export function
|
|
76
|
+
export function __wbg___wbindgen_throw_4c88d8bf264fd984(arg0, arg1) {
|
|
56
77
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
57
78
|
}
|
|
58
|
-
export function
|
|
79
|
+
export function __wbg_from_eac91875c8a5ffa4(arg0) {
|
|
59
80
|
const ret = Array.from(arg0);
|
|
60
81
|
return ret;
|
|
61
82
|
}
|
|
62
|
-
export function
|
|
83
|
+
export function __wbg_getRandomValues_8b6f1f663e6f188d() { return handleError(function (arg0, arg1) {
|
|
63
84
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
64
85
|
}, arguments); }
|
|
65
|
-
export function
|
|
86
|
+
export function __wbg_new_13de428334042d26(arg0) {
|
|
66
87
|
const ret = new Uint8Array(arg0);
|
|
67
88
|
return ret;
|
|
68
89
|
}
|
|
69
|
-
export function
|
|
90
|
+
export function __wbg_new_cd4348290afae586() {
|
|
70
91
|
const ret = new Object();
|
|
71
92
|
return ret;
|
|
72
93
|
}
|
|
73
|
-
export function
|
|
94
|
+
export function __wbg_set_e4b9a833d288759a(arg0, arg1, arg2) {
|
|
74
95
|
arg0[arg1] = arg2;
|
|
75
96
|
}
|
|
76
97
|
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
@@ -85,12 +106,11 @@ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
|
|
|
85
106
|
}
|
|
86
107
|
export function __wbindgen_init_externref_table() {
|
|
87
108
|
const table = wasm.__wbindgen_externrefs;
|
|
88
|
-
const offset = table.grow(4);
|
|
89
109
|
table.set(0, undefined);
|
|
90
|
-
table.set(
|
|
91
|
-
table.set(
|
|
92
|
-
table.set(
|
|
93
|
-
table.set(
|
|
110
|
+
table.set(1024, undefined);
|
|
111
|
+
table.set(1025, null);
|
|
112
|
+
table.set(1026, true);
|
|
113
|
+
table.set(1027, false);
|
|
94
114
|
}
|
|
95
115
|
function addToExternrefTable0(obj) {
|
|
96
116
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -112,7 +132,8 @@ function getDataViewMemory0() {
|
|
|
112
132
|
}
|
|
113
133
|
|
|
114
134
|
function getStringFromWasm0(ptr, len) {
|
|
115
|
-
|
|
135
|
+
ptr = ptr >>> 0;
|
|
136
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -182,18 +203,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
182
203
|
return value;
|
|
183
204
|
}
|
|
184
205
|
|
|
185
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
206
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
186
207
|
cachedTextDecoder.decode();
|
|
187
208
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
188
209
|
let numBytesDecoded = 0;
|
|
189
|
-
function decodeText(
|
|
190
|
-
numBytesDecoded +=
|
|
210
|
+
function decodeText(bytes) {
|
|
211
|
+
numBytesDecoded += bytes.length;
|
|
191
212
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
192
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
213
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
193
214
|
cachedTextDecoder.decode();
|
|
194
|
-
numBytesDecoded =
|
|
215
|
+
numBytesDecoded = bytes.length;
|
|
195
216
|
}
|
|
196
|
-
return cachedTextDecoder.decode(
|
|
217
|
+
return cachedTextDecoder.decode(bytes);
|
|
197
218
|
}
|
|
198
219
|
|
|
199
220
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -4,11 +4,12 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
6
|
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/node/xwing.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
|
+
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
package/node/xwing.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {Uint8Array} sk
|
|
5
|
-
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @param {Uint8Array | number[]} sk
|
|
5
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
6
6
|
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let ptr0, len0, ptr1, len1;
|
|
10
|
+
try {
|
|
11
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
12
|
+
len0 = WASM_VECTOR_LEN;
|
|
13
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
14
|
+
len1 = WASM_VECTOR_LEN;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
17
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
13
20
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
21
|
if (ret[3]) {
|
|
15
22
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -21,7 +28,7 @@ function decapsulate(sk, ciphertext) {
|
|
|
21
28
|
exports.decapsulate = decapsulate;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
|
-
* @param {Uint8Array} pk
|
|
31
|
+
* @param {Uint8Array | number[]} pk
|
|
25
32
|
* @returns {EncapsulateResult}
|
|
26
33
|
*/
|
|
27
34
|
function encapsulate(pk) {
|
|
@@ -46,10 +53,25 @@ function generateKeypair() {
|
|
|
46
53
|
return takeFromExternrefTable0(ret[0]);
|
|
47
54
|
}
|
|
48
55
|
exports.generateKeypair = generateKeypair;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Uint8Array | number[]} seed
|
|
59
|
+
* @returns {GenerateKeypairResult}
|
|
60
|
+
*/
|
|
61
|
+
function generateKeypairFromSeed(seed) {
|
|
62
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
65
|
+
if (ret[2]) {
|
|
66
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
67
|
+
}
|
|
68
|
+
return takeFromExternrefTable0(ret[0]);
|
|
69
|
+
}
|
|
70
|
+
exports.generateKeypairFromSeed = generateKeypairFromSeed;
|
|
49
71
|
function __wbg_get_imports() {
|
|
50
72
|
const import0 = {
|
|
51
73
|
__proto__: null,
|
|
52
|
-
|
|
74
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
53
75
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
54
76
|
return ret;
|
|
55
77
|
},
|
|
@@ -57,28 +79,28 @@ function __wbg_get_imports() {
|
|
|
57
79
|
const ret = String(arg1);
|
|
58
80
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
81
|
const len1 = WASM_VECTOR_LEN;
|
|
60
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
61
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
82
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
83
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
62
84
|
},
|
|
63
|
-
|
|
85
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
64
86
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
65
87
|
},
|
|
66
|
-
|
|
88
|
+
__wbg_from_eac91875c8a5ffa4: function(arg0) {
|
|
67
89
|
const ret = Array.from(arg0);
|
|
68
90
|
return ret;
|
|
69
91
|
},
|
|
70
|
-
|
|
92
|
+
__wbg_getRandomValues_8b6f1f663e6f188d: function() { return handleError(function (arg0, arg1) {
|
|
71
93
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
72
94
|
}, arguments); },
|
|
73
|
-
|
|
95
|
+
__wbg_new_13de428334042d26: function(arg0) {
|
|
74
96
|
const ret = new Uint8Array(arg0);
|
|
75
97
|
return ret;
|
|
76
98
|
},
|
|
77
|
-
|
|
99
|
+
__wbg_new_cd4348290afae586: function() {
|
|
78
100
|
const ret = new Object();
|
|
79
101
|
return ret;
|
|
80
102
|
},
|
|
81
|
-
|
|
103
|
+
__wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
|
|
82
104
|
arg0[arg1] = arg2;
|
|
83
105
|
},
|
|
84
106
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
@@ -93,12 +115,11 @@ function __wbg_get_imports() {
|
|
|
93
115
|
},
|
|
94
116
|
__wbindgen_init_externref_table: function() {
|
|
95
117
|
const table = wasm.__wbindgen_externrefs;
|
|
96
|
-
const offset = table.grow(4);
|
|
97
118
|
table.set(0, undefined);
|
|
98
|
-
table.set(
|
|
99
|
-
table.set(
|
|
100
|
-
table.set(
|
|
101
|
-
table.set(
|
|
119
|
+
table.set(1024, undefined);
|
|
120
|
+
table.set(1025, null);
|
|
121
|
+
table.set(1026, true);
|
|
122
|
+
table.set(1027, false);
|
|
102
123
|
},
|
|
103
124
|
};
|
|
104
125
|
return {
|
|
@@ -127,7 +148,8 @@ function getDataViewMemory0() {
|
|
|
127
148
|
}
|
|
128
149
|
|
|
129
150
|
function getStringFromWasm0(ptr, len) {
|
|
130
|
-
|
|
151
|
+
ptr = ptr >>> 0;
|
|
152
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
131
153
|
}
|
|
132
154
|
|
|
133
155
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -197,10 +219,10 @@ function takeFromExternrefTable0(idx) {
|
|
|
197
219
|
return value;
|
|
198
220
|
}
|
|
199
221
|
|
|
200
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
222
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
201
223
|
cachedTextDecoder.decode();
|
|
202
|
-
function decodeText(
|
|
203
|
-
return cachedTextDecoder.decode(
|
|
224
|
+
function decodeText(bytes) {
|
|
225
|
+
return cachedTextDecoder.decode(bytes);
|
|
204
226
|
}
|
|
205
227
|
|
|
206
228
|
const cachedTextEncoder = new TextEncoder();
|
package/node/xwing_bg.wasm.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
6
|
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
package/web/xwing.d.ts
CHANGED
|
@@ -11,12 +11,14 @@ export interface GenerateKeypairResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
14
|
+
export function decapsulate(sk: Uint8Array | number[], ciphertext: Uint8Array | number[]): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
16
|
+
export function encapsulate(pk: Uint8Array | number[]): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
19
|
|
|
20
|
+
export function generateKeypairFromSeed(seed: Uint8Array | number[]): GenerateKeypairResult;
|
|
21
|
+
|
|
20
22
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
21
23
|
|
|
22
24
|
export interface InitOutput {
|
|
@@ -24,13 +26,14 @@ export interface InitOutput {
|
|
|
24
26
|
readonly decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
25
27
|
readonly encapsulate: (a: number, b: number) => [number, number, number];
|
|
26
28
|
readonly generateKeypair: () => [number, number, number];
|
|
29
|
+
readonly generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
27
30
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
31
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
32
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
33
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
30
34
|
readonly __externref_table_alloc: () => number;
|
|
31
35
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
32
36
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
33
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
34
37
|
readonly __wbindgen_start: () => void;
|
|
35
38
|
}
|
|
36
39
|
|
package/web/xwing.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {Uint8Array} sk
|
|
5
|
-
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @param {Uint8Array | number[]} sk
|
|
5
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
6
6
|
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
export function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let ptr0, len0, ptr1, len1;
|
|
10
|
+
try {
|
|
11
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
12
|
+
len0 = WASM_VECTOR_LEN;
|
|
13
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
14
|
+
len1 = WASM_VECTOR_LEN;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
17
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
13
20
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
21
|
if (ret[3]) {
|
|
15
22
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -20,7 +27,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
|
-
* @param {Uint8Array} pk
|
|
30
|
+
* @param {Uint8Array | number[]} pk
|
|
24
31
|
* @returns {EncapsulateResult}
|
|
25
32
|
*/
|
|
26
33
|
export function encapsulate(pk) {
|
|
@@ -43,10 +50,24 @@ export function generateKeypair() {
|
|
|
43
50
|
}
|
|
44
51
|
return takeFromExternrefTable0(ret[0]);
|
|
45
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {Uint8Array | number[]} seed
|
|
56
|
+
* @returns {GenerateKeypairResult}
|
|
57
|
+
*/
|
|
58
|
+
export function generateKeypairFromSeed(seed) {
|
|
59
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
62
|
+
if (ret[2]) {
|
|
63
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
64
|
+
}
|
|
65
|
+
return takeFromExternrefTable0(ret[0]);
|
|
66
|
+
}
|
|
46
67
|
function __wbg_get_imports() {
|
|
47
68
|
const import0 = {
|
|
48
69
|
__proto__: null,
|
|
49
|
-
|
|
70
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
50
71
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
51
72
|
return ret;
|
|
52
73
|
},
|
|
@@ -54,28 +75,28 @@ function __wbg_get_imports() {
|
|
|
54
75
|
const ret = String(arg1);
|
|
55
76
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
77
|
const len1 = WASM_VECTOR_LEN;
|
|
57
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
58
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
78
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
79
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
59
80
|
},
|
|
60
|
-
|
|
81
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
61
82
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
62
83
|
},
|
|
63
|
-
|
|
84
|
+
__wbg_from_eac91875c8a5ffa4: function(arg0) {
|
|
64
85
|
const ret = Array.from(arg0);
|
|
65
86
|
return ret;
|
|
66
87
|
},
|
|
67
|
-
|
|
88
|
+
__wbg_getRandomValues_8b6f1f663e6f188d: function() { return handleError(function (arg0, arg1) {
|
|
68
89
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
69
90
|
}, arguments); },
|
|
70
|
-
|
|
91
|
+
__wbg_new_13de428334042d26: function(arg0) {
|
|
71
92
|
const ret = new Uint8Array(arg0);
|
|
72
93
|
return ret;
|
|
73
94
|
},
|
|
74
|
-
|
|
95
|
+
__wbg_new_cd4348290afae586: function() {
|
|
75
96
|
const ret = new Object();
|
|
76
97
|
return ret;
|
|
77
98
|
},
|
|
78
|
-
|
|
99
|
+
__wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
|
|
79
100
|
arg0[arg1] = arg2;
|
|
80
101
|
},
|
|
81
102
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
@@ -90,12 +111,11 @@ function __wbg_get_imports() {
|
|
|
90
111
|
},
|
|
91
112
|
__wbindgen_init_externref_table: function() {
|
|
92
113
|
const table = wasm.__wbindgen_externrefs;
|
|
93
|
-
const offset = table.grow(4);
|
|
94
114
|
table.set(0, undefined);
|
|
95
|
-
table.set(
|
|
96
|
-
table.set(
|
|
97
|
-
table.set(
|
|
98
|
-
table.set(
|
|
115
|
+
table.set(1024, undefined);
|
|
116
|
+
table.set(1025, null);
|
|
117
|
+
table.set(1026, true);
|
|
118
|
+
table.set(1027, false);
|
|
99
119
|
},
|
|
100
120
|
};
|
|
101
121
|
return {
|
|
@@ -124,7 +144,8 @@ function getDataViewMemory0() {
|
|
|
124
144
|
}
|
|
125
145
|
|
|
126
146
|
function getStringFromWasm0(ptr, len) {
|
|
127
|
-
|
|
147
|
+
ptr = ptr >>> 0;
|
|
148
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
128
149
|
}
|
|
129
150
|
|
|
130
151
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -194,18 +215,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
194
215
|
return value;
|
|
195
216
|
}
|
|
196
217
|
|
|
197
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
218
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
198
219
|
cachedTextDecoder.decode();
|
|
199
220
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
200
221
|
let numBytesDecoded = 0;
|
|
201
|
-
function decodeText(
|
|
202
|
-
numBytesDecoded +=
|
|
222
|
+
function decodeText(bytes) {
|
|
223
|
+
numBytesDecoded += bytes.length;
|
|
203
224
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
204
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
225
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
205
226
|
cachedTextDecoder.decode();
|
|
206
|
-
numBytesDecoded =
|
|
227
|
+
numBytesDecoded = bytes.length;
|
|
207
228
|
}
|
|
208
|
-
return cachedTextDecoder.decode(
|
|
229
|
+
return cachedTextDecoder.decode(bytes);
|
|
209
230
|
}
|
|
210
231
|
|
|
211
232
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -293,9 +314,17 @@ function initSync(module) {
|
|
|
293
314
|
return __wbg_finalize_init(instance, module);
|
|
294
315
|
}
|
|
295
316
|
|
|
317
|
+
let __wbg_init_promise;
|
|
296
318
|
async function __wbg_init(module_or_path) {
|
|
297
319
|
if (wasm !== undefined) return wasm;
|
|
320
|
+
if (__wbg_init_promise === undefined) {
|
|
321
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
322
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
323
|
+
}
|
|
324
|
+
return __wbg_init_promise;
|
|
325
|
+
}
|
|
298
326
|
|
|
327
|
+
async function __wbg_init_once(module_or_path) {
|
|
299
328
|
|
|
300
329
|
if (module_or_path !== undefined) {
|
|
301
330
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
package/web/xwing_bg.wasm.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
5
|
export const encapsulate: (a: number, b: number) => [number, number, number];
|
|
6
6
|
export const generateKeypair: () => [number, number, number];
|
|
7
|
+
export const generateKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
9
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
10
12
|
export const __externref_table_alloc: () => number;
|
|
11
13
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
14
|
export const __externref_table_dealloc: (a: number) => void;
|
|
13
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const __wbindgen_start: () => void;
|
package/xwing_bg.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Uint8Array} sk
|
|
3
|
-
* @param {Uint8Array} ciphertext
|
|
2
|
+
* @param {Uint8Array | number[]} sk
|
|
3
|
+
* @param {Uint8Array | number[]} ciphertext
|
|
4
4
|
* @returns {Uint8Array}
|
|
5
5
|
*/
|
|
6
6
|
export function decapsulate(sk, ciphertext) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
let ptr0, len0, ptr1, len1;
|
|
8
|
+
try {
|
|
9
|
+
ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
len0 = WASM_VECTOR_LEN;
|
|
11
|
+
ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
len1 = WASM_VECTOR_LEN;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
15
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
11
18
|
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
19
|
if (ret[3]) {
|
|
13
20
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -18,7 +25,7 @@ export function decapsulate(sk, ciphertext) {
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
* @param {Uint8Array} pk
|
|
28
|
+
* @param {Uint8Array | number[]} pk
|
|
22
29
|
* @returns {EncapsulateResult}
|
|
23
30
|
*/
|
|
24
31
|
export function encapsulate(pk) {
|
|
@@ -41,7 +48,21 @@ export function generateKeypair() {
|
|
|
41
48
|
}
|
|
42
49
|
return takeFromExternrefTable0(ret[0]);
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Uint8Array | number[]} seed
|
|
54
|
+
* @returns {GenerateKeypairResult}
|
|
55
|
+
*/
|
|
56
|
+
export function generateKeypairFromSeed(seed) {
|
|
57
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.generateKeypairFromSeed(ptr0, len0);
|
|
60
|
+
if (ret[2]) {
|
|
61
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
+
}
|
|
63
|
+
return takeFromExternrefTable0(ret[0]);
|
|
64
|
+
}
|
|
65
|
+
export function __wbg_Error_208446807d0d1e30(arg0, arg1) {
|
|
45
66
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
46
67
|
return ret;
|
|
47
68
|
}
|
|
@@ -49,28 +70,28 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
49
70
|
const ret = String(arg1);
|
|
50
71
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
72
|
const len1 = WASM_VECTOR_LEN;
|
|
52
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
53
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
73
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
74
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
54
75
|
}
|
|
55
|
-
export function
|
|
76
|
+
export function __wbg___wbindgen_throw_4c88d8bf264fd984(arg0, arg1) {
|
|
56
77
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
57
78
|
}
|
|
58
|
-
export function
|
|
79
|
+
export function __wbg_from_eac91875c8a5ffa4(arg0) {
|
|
59
80
|
const ret = Array.from(arg0);
|
|
60
81
|
return ret;
|
|
61
82
|
}
|
|
62
|
-
export function
|
|
83
|
+
export function __wbg_getRandomValues_8b6f1f663e6f188d() { return handleError(function (arg0, arg1) {
|
|
63
84
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
64
85
|
}, arguments); }
|
|
65
|
-
export function
|
|
86
|
+
export function __wbg_new_13de428334042d26(arg0) {
|
|
66
87
|
const ret = new Uint8Array(arg0);
|
|
67
88
|
return ret;
|
|
68
89
|
}
|
|
69
|
-
export function
|
|
90
|
+
export function __wbg_new_cd4348290afae586() {
|
|
70
91
|
const ret = new Object();
|
|
71
92
|
return ret;
|
|
72
93
|
}
|
|
73
|
-
export function
|
|
94
|
+
export function __wbg_set_e4b9a833d288759a(arg0, arg1, arg2) {
|
|
74
95
|
arg0[arg1] = arg2;
|
|
75
96
|
}
|
|
76
97
|
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
@@ -85,12 +106,11 @@ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
|
|
|
85
106
|
}
|
|
86
107
|
export function __wbindgen_init_externref_table() {
|
|
87
108
|
const table = wasm.__wbindgen_externrefs;
|
|
88
|
-
const offset = table.grow(4);
|
|
89
109
|
table.set(0, undefined);
|
|
90
|
-
table.set(
|
|
91
|
-
table.set(
|
|
92
|
-
table.set(
|
|
93
|
-
table.set(
|
|
110
|
+
table.set(1024, undefined);
|
|
111
|
+
table.set(1025, null);
|
|
112
|
+
table.set(1026, true);
|
|
113
|
+
table.set(1027, false);
|
|
94
114
|
}
|
|
95
115
|
function addToExternrefTable0(obj) {
|
|
96
116
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -112,7 +132,8 @@ function getDataViewMemory0() {
|
|
|
112
132
|
}
|
|
113
133
|
|
|
114
134
|
function getStringFromWasm0(ptr, len) {
|
|
115
|
-
|
|
135
|
+
ptr = ptr >>> 0;
|
|
136
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -182,18 +203,18 @@ function takeFromExternrefTable0(idx) {
|
|
|
182
203
|
return value;
|
|
183
204
|
}
|
|
184
205
|
|
|
185
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
206
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
186
207
|
cachedTextDecoder.decode();
|
|
187
208
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
188
209
|
let numBytesDecoded = 0;
|
|
189
|
-
function decodeText(
|
|
190
|
-
numBytesDecoded +=
|
|
210
|
+
function decodeText(bytes) {
|
|
211
|
+
numBytesDecoded += bytes.length;
|
|
191
212
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
192
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true
|
|
213
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
193
214
|
cachedTextDecoder.decode();
|
|
194
|
-
numBytesDecoded =
|
|
215
|
+
numBytesDecoded = bytes.length;
|
|
195
216
|
}
|
|
196
|
-
return cachedTextDecoder.decode(
|
|
217
|
+
return cachedTextDecoder.decode(bytes);
|
|
197
218
|
}
|
|
198
219
|
|
|
199
220
|
const cachedTextEncoder = new TextEncoder();
|
package/xwing_bg.wasm
CHANGED
|
Binary file
|