xwing-wasm 0.1.0 → 0.2.1
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 +6 -6
- package/bundler/xwing_bg.js +39 -30
- package/node/xwing.d.ts +6 -6
- package/node/xwing.js +41 -31
- package/package.json +2 -1
- package/web/xwing.d.ts +6 -6
- package/web/xwing.js +41 -31
- package/xwing_bg.js +214 -0
- package/xwing_bg.wasm +0 -0
package/bundler/xwing.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export interface EncapsulateResult {
|
|
4
|
-
ciphertext:
|
|
5
|
-
sharedKey:
|
|
4
|
+
ciphertext: Uint8Array;
|
|
5
|
+
sharedKey: Uint8Array;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface GenerateKeypairResult {
|
|
9
|
-
secretKey:
|
|
10
|
-
publicKey:
|
|
9
|
+
secretKey: Uint8Array;
|
|
10
|
+
publicKey: Uint8Array;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk:
|
|
14
|
+
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk:
|
|
16
|
+
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
package/bundler/xwing_bg.js
CHANGED
|
@@ -1,37 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {
|
|
3
|
-
* @param {
|
|
4
|
-
* @returns {
|
|
2
|
+
* @param {Uint8Array} sk
|
|
3
|
+
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @returns {Uint8Array}
|
|
5
5
|
*/
|
|
6
6
|
export function decapsulate(sk, ciphertext) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
15
|
-
var ptr3 = ret[0];
|
|
16
|
-
var len3 = ret[1];
|
|
17
|
-
if (ret[3]) {
|
|
18
|
-
ptr3 = 0; len3 = 0;
|
|
19
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
20
|
-
}
|
|
21
|
-
deferred4_0 = ptr3;
|
|
22
|
-
deferred4_1 = len3;
|
|
23
|
-
return getStringFromWasm0(ptr3, len3);
|
|
24
|
-
} finally {
|
|
25
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
7
|
+
const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
8
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
10
|
+
const len1 = WASM_VECTOR_LEN;
|
|
11
|
+
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
|
+
if (ret[3]) {
|
|
13
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
26
14
|
}
|
|
15
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
16
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
17
|
+
return v3;
|
|
27
18
|
}
|
|
28
19
|
|
|
29
20
|
/**
|
|
30
|
-
* @param {
|
|
21
|
+
* @param {Uint8Array} pk
|
|
31
22
|
* @returns {EncapsulateResult}
|
|
32
23
|
*/
|
|
33
24
|
export function encapsulate(pk) {
|
|
34
|
-
const ptr0 =
|
|
25
|
+
const ptr0 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc);
|
|
35
26
|
const len0 = WASM_VECTOR_LEN;
|
|
36
27
|
const ret = wasm.encapsulate(ptr0, len0);
|
|
37
28
|
if (ret[2]) {
|
|
@@ -47,7 +38,7 @@ export function generateKeypair() {
|
|
|
47
38
|
const ret = wasm.generateKeypair();
|
|
48
39
|
return ret;
|
|
49
40
|
}
|
|
50
|
-
export function
|
|
41
|
+
export function __wbg_Error_9dc85fe1bc224456(arg0, arg1) {
|
|
51
42
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
52
43
|
return ret;
|
|
53
44
|
}
|
|
@@ -58,20 +49,32 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
58
49
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
59
50
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
60
51
|
}
|
|
61
|
-
export function
|
|
52
|
+
export function __wbg___wbindgen_throw_bbadd78c1bac3a77(arg0, arg1) {
|
|
62
53
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
63
54
|
}
|
|
64
55
|
export function __wbg_getRandomValues_76dfc69825c9c552() { return handleError(function (arg0, arg1) {
|
|
65
56
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
66
57
|
}, arguments); }
|
|
67
|
-
export function
|
|
58
|
+
export function __wbg_new_0b303268aa395a38() {
|
|
59
|
+
const ret = new Array();
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
export function __wbg_new_20b778a4c5c691c3() {
|
|
68
63
|
const ret = new Object();
|
|
69
64
|
return ret;
|
|
70
65
|
}
|
|
71
66
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
72
67
|
arg0[arg1] = arg2;
|
|
73
68
|
}
|
|
74
|
-
export function
|
|
69
|
+
export function __wbg_set_da33c120a6584674(arg0, arg1, arg2) {
|
|
70
|
+
arg0[arg1 >>> 0] = arg2;
|
|
71
|
+
}
|
|
72
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
73
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
74
|
+
const ret = arg0;
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
77
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
75
78
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
76
79
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
77
80
|
return ret;
|
|
@@ -105,8 +108,7 @@ function getDataViewMemory0() {
|
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
function getStringFromWasm0(ptr, len) {
|
|
108
|
-
|
|
109
|
-
return decodeText(ptr, len);
|
|
111
|
+
return decodeText(ptr >>> 0, len);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -126,6 +128,13 @@ function handleError(f, args) {
|
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
132
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
133
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
134
|
+
WASM_VECTOR_LEN = arg.length;
|
|
135
|
+
return ptr;
|
|
136
|
+
}
|
|
137
|
+
|
|
129
138
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
130
139
|
if (realloc === undefined) {
|
|
131
140
|
const buf = cachedTextEncoder.encode(arg);
|
package/node/xwing.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export interface EncapsulateResult {
|
|
4
|
-
ciphertext:
|
|
5
|
-
sharedKey:
|
|
4
|
+
ciphertext: Uint8Array;
|
|
5
|
+
sharedKey: Uint8Array;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface GenerateKeypairResult {
|
|
9
|
-
secretKey:
|
|
10
|
-
publicKey:
|
|
9
|
+
secretKey: Uint8Array;
|
|
10
|
+
publicKey: Uint8Array;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk:
|
|
14
|
+
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk:
|
|
16
|
+
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
package/node/xwing.js
CHANGED
|
@@ -1,40 +1,31 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
4
|
+
* @param {Uint8Array} sk
|
|
5
|
+
* @param {Uint8Array} ciphertext
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
17
|
-
var ptr3 = ret[0];
|
|
18
|
-
var len3 = ret[1];
|
|
19
|
-
if (ret[3]) {
|
|
20
|
-
ptr3 = 0; len3 = 0;
|
|
21
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
-
}
|
|
23
|
-
deferred4_0 = ptr3;
|
|
24
|
-
deferred4_1 = len3;
|
|
25
|
-
return getStringFromWasm0(ptr3, len3);
|
|
26
|
-
} finally {
|
|
27
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
9
|
+
const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
const len0 = WASM_VECTOR_LEN;
|
|
11
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
const len1 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
|
+
if (ret[3]) {
|
|
15
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
28
16
|
}
|
|
17
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
18
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
19
|
+
return v3;
|
|
29
20
|
}
|
|
30
21
|
exports.decapsulate = decapsulate;
|
|
31
22
|
|
|
32
23
|
/**
|
|
33
|
-
* @param {
|
|
24
|
+
* @param {Uint8Array} pk
|
|
34
25
|
* @returns {EncapsulateResult}
|
|
35
26
|
*/
|
|
36
27
|
function encapsulate(pk) {
|
|
37
|
-
const ptr0 =
|
|
28
|
+
const ptr0 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc);
|
|
38
29
|
const len0 = WASM_VECTOR_LEN;
|
|
39
30
|
const ret = wasm.encapsulate(ptr0, len0);
|
|
40
31
|
if (ret[2]) {
|
|
@@ -55,7 +46,7 @@ exports.generateKeypair = generateKeypair;
|
|
|
55
46
|
function __wbg_get_imports() {
|
|
56
47
|
const import0 = {
|
|
57
48
|
__proto__: null,
|
|
58
|
-
|
|
49
|
+
__wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
|
|
59
50
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
60
51
|
return ret;
|
|
61
52
|
},
|
|
@@ -66,20 +57,32 @@ function __wbg_get_imports() {
|
|
|
66
57
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
67
58
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
68
59
|
},
|
|
69
|
-
|
|
60
|
+
__wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
|
|
70
61
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
71
62
|
},
|
|
72
63
|
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
73
64
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
74
65
|
}, arguments); },
|
|
75
|
-
|
|
66
|
+
__wbg_new_0b303268aa395a38: function() {
|
|
67
|
+
const ret = new Array();
|
|
68
|
+
return ret;
|
|
69
|
+
},
|
|
70
|
+
__wbg_new_20b778a4c5c691c3: function() {
|
|
76
71
|
const ret = new Object();
|
|
77
72
|
return ret;
|
|
78
73
|
},
|
|
79
74
|
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
80
75
|
arg0[arg1] = arg2;
|
|
81
76
|
},
|
|
82
|
-
|
|
77
|
+
__wbg_set_da33c120a6584674: function(arg0, arg1, arg2) {
|
|
78
|
+
arg0[arg1 >>> 0] = arg2;
|
|
79
|
+
},
|
|
80
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
81
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
82
|
+
const ret = arg0;
|
|
83
|
+
return ret;
|
|
84
|
+
},
|
|
85
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
83
86
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
84
87
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
85
88
|
return ret;
|
|
@@ -120,8 +123,7 @@ function getDataViewMemory0() {
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
function getStringFromWasm0(ptr, len) {
|
|
123
|
-
|
|
124
|
-
return decodeText(ptr, len);
|
|
126
|
+
return decodeText(ptr >>> 0, len);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -141,6 +143,13 @@ function handleError(f, args) {
|
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
147
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
148
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
149
|
+
WASM_VECTOR_LEN = arg.length;
|
|
150
|
+
return ptr;
|
|
151
|
+
}
|
|
152
|
+
|
|
144
153
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
145
154
|
if (realloc === undefined) {
|
|
146
155
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -208,5 +217,6 @@ let WASM_VECTOR_LEN = 0;
|
|
|
208
217
|
const wasmPath = `${__dirname}/../xwing_bg.wasm`;
|
|
209
218
|
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
210
219
|
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
211
|
-
let
|
|
220
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
221
|
+
let wasm = wasmInstance.exports;
|
|
212
222
|
wasm.__wbindgen_start();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xwing-wasm",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "X-Wing hybrid KEM (ML-KEM-768 + X25519) via Rust/WASM",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"index.js",
|
|
27
27
|
"index.d.ts",
|
|
28
28
|
"xwing_bg.wasm",
|
|
29
|
+
"xwing_bg.js",
|
|
29
30
|
"README.md",
|
|
30
31
|
"LICENSE-MIT",
|
|
31
32
|
"LICENSE-APACHE"
|
package/web/xwing.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export interface EncapsulateResult {
|
|
4
|
-
ciphertext:
|
|
5
|
-
sharedKey:
|
|
4
|
+
ciphertext: Uint8Array;
|
|
5
|
+
sharedKey: Uint8Array;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface GenerateKeypairResult {
|
|
9
|
-
secretKey:
|
|
10
|
-
publicKey:
|
|
9
|
+
secretKey: Uint8Array;
|
|
10
|
+
publicKey: Uint8Array;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export function decapsulate(sk:
|
|
14
|
+
export function decapsulate(sk: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
15
15
|
|
|
16
|
-
export function encapsulate(pk:
|
|
16
|
+
export function encapsulate(pk: Uint8Array): EncapsulateResult;
|
|
17
17
|
|
|
18
18
|
export function generateKeypair(): GenerateKeypairResult;
|
|
19
19
|
|
package/web/xwing.js
CHANGED
|
@@ -1,39 +1,30 @@
|
|
|
1
1
|
/* @ts-self-types="./xwing.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
4
|
+
* @param {Uint8Array} sk
|
|
5
|
+
* @param {Uint8Array} ciphertext
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
8
8
|
export function decapsulate(sk, ciphertext) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
17
|
-
var ptr3 = ret[0];
|
|
18
|
-
var len3 = ret[1];
|
|
19
|
-
if (ret[3]) {
|
|
20
|
-
ptr3 = 0; len3 = 0;
|
|
21
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
-
}
|
|
23
|
-
deferred4_0 = ptr3;
|
|
24
|
-
deferred4_1 = len3;
|
|
25
|
-
return getStringFromWasm0(ptr3, len3);
|
|
26
|
-
} finally {
|
|
27
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
9
|
+
const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
10
|
+
const len0 = WASM_VECTOR_LEN;
|
|
11
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
12
|
+
const len1 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
14
|
+
if (ret[3]) {
|
|
15
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
28
16
|
}
|
|
17
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
18
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
19
|
+
return v3;
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
/**
|
|
32
|
-
* @param {
|
|
23
|
+
* @param {Uint8Array} pk
|
|
33
24
|
* @returns {EncapsulateResult}
|
|
34
25
|
*/
|
|
35
26
|
export function encapsulate(pk) {
|
|
36
|
-
const ptr0 =
|
|
27
|
+
const ptr0 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc);
|
|
37
28
|
const len0 = WASM_VECTOR_LEN;
|
|
38
29
|
const ret = wasm.encapsulate(ptr0, len0);
|
|
39
30
|
if (ret[2]) {
|
|
@@ -52,7 +43,7 @@ export function generateKeypair() {
|
|
|
52
43
|
function __wbg_get_imports() {
|
|
53
44
|
const import0 = {
|
|
54
45
|
__proto__: null,
|
|
55
|
-
|
|
46
|
+
__wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
|
|
56
47
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
57
48
|
return ret;
|
|
58
49
|
},
|
|
@@ -63,20 +54,32 @@ function __wbg_get_imports() {
|
|
|
63
54
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
64
55
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
65
56
|
},
|
|
66
|
-
|
|
57
|
+
__wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
|
|
67
58
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
68
59
|
},
|
|
69
60
|
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
70
61
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
71
62
|
}, arguments); },
|
|
72
|
-
|
|
63
|
+
__wbg_new_0b303268aa395a38: function() {
|
|
64
|
+
const ret = new Array();
|
|
65
|
+
return ret;
|
|
66
|
+
},
|
|
67
|
+
__wbg_new_20b778a4c5c691c3: function() {
|
|
73
68
|
const ret = new Object();
|
|
74
69
|
return ret;
|
|
75
70
|
},
|
|
76
71
|
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
77
72
|
arg0[arg1] = arg2;
|
|
78
73
|
},
|
|
79
|
-
|
|
74
|
+
__wbg_set_da33c120a6584674: function(arg0, arg1, arg2) {
|
|
75
|
+
arg0[arg1 >>> 0] = arg2;
|
|
76
|
+
},
|
|
77
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
78
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
79
|
+
const ret = arg0;
|
|
80
|
+
return ret;
|
|
81
|
+
},
|
|
82
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
80
83
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
81
84
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
82
85
|
return ret;
|
|
@@ -117,8 +120,7 @@ function getDataViewMemory0() {
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
function getStringFromWasm0(ptr, len) {
|
|
120
|
-
|
|
121
|
-
return decodeText(ptr, len);
|
|
123
|
+
return decodeText(ptr >>> 0, len);
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
let cachedUint8ArrayMemory0 = null;
|
|
@@ -138,6 +140,13 @@ function handleError(f, args) {
|
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
144
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
145
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
146
|
+
WASM_VECTOR_LEN = arg.length;
|
|
147
|
+
return ptr;
|
|
148
|
+
}
|
|
149
|
+
|
|
141
150
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
142
151
|
if (realloc === undefined) {
|
|
143
152
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -210,8 +219,9 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
210
219
|
|
|
211
220
|
let WASM_VECTOR_LEN = 0;
|
|
212
221
|
|
|
213
|
-
let wasmModule, wasm;
|
|
222
|
+
let wasmModule, wasmInstance, wasm;
|
|
214
223
|
function __wbg_finalize_init(instance, module) {
|
|
224
|
+
wasmInstance = instance;
|
|
215
225
|
wasm = instance.exports;
|
|
216
226
|
wasmModule = module;
|
|
217
227
|
cachedDataViewMemory0 = null;
|
package/xwing_bg.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} sk
|
|
3
|
+
* @param {Uint8Array} ciphertext
|
|
4
|
+
* @returns {Uint8Array}
|
|
5
|
+
*/
|
|
6
|
+
export function decapsulate(sk, ciphertext) {
|
|
7
|
+
const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc);
|
|
8
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
10
|
+
const len1 = WASM_VECTOR_LEN;
|
|
11
|
+
const ret = wasm.decapsulate(ptr0, len0, ptr1, len1);
|
|
12
|
+
if (ret[3]) {
|
|
13
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
14
|
+
}
|
|
15
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
16
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
17
|
+
return v3;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {Uint8Array} pk
|
|
22
|
+
* @returns {EncapsulateResult}
|
|
23
|
+
*/
|
|
24
|
+
export function encapsulate(pk) {
|
|
25
|
+
const ptr0 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc);
|
|
26
|
+
const len0 = WASM_VECTOR_LEN;
|
|
27
|
+
const ret = wasm.encapsulate(ptr0, len0);
|
|
28
|
+
if (ret[2]) {
|
|
29
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
30
|
+
}
|
|
31
|
+
return takeFromExternrefTable0(ret[0]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @returns {GenerateKeypairResult}
|
|
36
|
+
*/
|
|
37
|
+
export function generateKeypair() {
|
|
38
|
+
const ret = wasm.generateKeypair();
|
|
39
|
+
return ret;
|
|
40
|
+
}
|
|
41
|
+
export function __wbg_Error_9dc85fe1bc224456(arg0, arg1) {
|
|
42
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
45
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
46
|
+
const ret = String(arg1);
|
|
47
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
48
|
+
const len1 = WASM_VECTOR_LEN;
|
|
49
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
50
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
51
|
+
}
|
|
52
|
+
export function __wbg___wbindgen_throw_bbadd78c1bac3a77(arg0, arg1) {
|
|
53
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
54
|
+
}
|
|
55
|
+
export function __wbg_getRandomValues_76dfc69825c9c552() { return handleError(function (arg0, arg1) {
|
|
56
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
57
|
+
}, arguments); }
|
|
58
|
+
export function __wbg_new_0b303268aa395a38() {
|
|
59
|
+
const ret = new Array();
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
export function __wbg_new_20b778a4c5c691c3() {
|
|
63
|
+
const ret = new Object();
|
|
64
|
+
return ret;
|
|
65
|
+
}
|
|
66
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
67
|
+
arg0[arg1] = arg2;
|
|
68
|
+
}
|
|
69
|
+
export function __wbg_set_da33c120a6584674(arg0, arg1, arg2) {
|
|
70
|
+
arg0[arg1 >>> 0] = arg2;
|
|
71
|
+
}
|
|
72
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
73
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
74
|
+
const ret = arg0;
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
77
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
78
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
79
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
80
|
+
return ret;
|
|
81
|
+
}
|
|
82
|
+
export function __wbindgen_init_externref_table() {
|
|
83
|
+
const table = wasm.__wbindgen_externrefs;
|
|
84
|
+
const offset = table.grow(4);
|
|
85
|
+
table.set(0, undefined);
|
|
86
|
+
table.set(offset + 0, undefined);
|
|
87
|
+
table.set(offset + 1, null);
|
|
88
|
+
table.set(offset + 2, true);
|
|
89
|
+
table.set(offset + 3, false);
|
|
90
|
+
}
|
|
91
|
+
function addToExternrefTable0(obj) {
|
|
92
|
+
const idx = wasm.__externref_table_alloc();
|
|
93
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
94
|
+
return idx;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
98
|
+
ptr = ptr >>> 0;
|
|
99
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let cachedDataViewMemory0 = null;
|
|
103
|
+
function getDataViewMemory0() {
|
|
104
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
105
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
106
|
+
}
|
|
107
|
+
return cachedDataViewMemory0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getStringFromWasm0(ptr, len) {
|
|
111
|
+
return decodeText(ptr >>> 0, len);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let cachedUint8ArrayMemory0 = null;
|
|
115
|
+
function getUint8ArrayMemory0() {
|
|
116
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
117
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
118
|
+
}
|
|
119
|
+
return cachedUint8ArrayMemory0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function handleError(f, args) {
|
|
123
|
+
try {
|
|
124
|
+
return f.apply(this, args);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
const idx = addToExternrefTable0(e);
|
|
127
|
+
wasm.__wbindgen_exn_store(idx);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
132
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
133
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
134
|
+
WASM_VECTOR_LEN = arg.length;
|
|
135
|
+
return ptr;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
139
|
+
if (realloc === undefined) {
|
|
140
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
141
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
142
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
143
|
+
WASM_VECTOR_LEN = buf.length;
|
|
144
|
+
return ptr;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let len = arg.length;
|
|
148
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
149
|
+
|
|
150
|
+
const mem = getUint8ArrayMemory0();
|
|
151
|
+
|
|
152
|
+
let offset = 0;
|
|
153
|
+
|
|
154
|
+
for (; offset < len; offset++) {
|
|
155
|
+
const code = arg.charCodeAt(offset);
|
|
156
|
+
if (code > 0x7F) break;
|
|
157
|
+
mem[ptr + offset] = code;
|
|
158
|
+
}
|
|
159
|
+
if (offset !== len) {
|
|
160
|
+
if (offset !== 0) {
|
|
161
|
+
arg = arg.slice(offset);
|
|
162
|
+
}
|
|
163
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
164
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
165
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
166
|
+
|
|
167
|
+
offset += ret.written;
|
|
168
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
WASM_VECTOR_LEN = offset;
|
|
172
|
+
return ptr;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function takeFromExternrefTable0(idx) {
|
|
176
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
177
|
+
wasm.__externref_table_dealloc(idx);
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
182
|
+
cachedTextDecoder.decode();
|
|
183
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
184
|
+
let numBytesDecoded = 0;
|
|
185
|
+
function decodeText(ptr, len) {
|
|
186
|
+
numBytesDecoded += len;
|
|
187
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
188
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
189
|
+
cachedTextDecoder.decode();
|
|
190
|
+
numBytesDecoded = len;
|
|
191
|
+
}
|
|
192
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const cachedTextEncoder = new TextEncoder();
|
|
196
|
+
|
|
197
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
198
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
199
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
200
|
+
view.set(buf);
|
|
201
|
+
return {
|
|
202
|
+
read: arg.length,
|
|
203
|
+
written: buf.length
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let WASM_VECTOR_LEN = 0;
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
let wasm;
|
|
212
|
+
export function __wbg_set_wasm(val) {
|
|
213
|
+
wasm = val;
|
|
214
|
+
}
|
package/xwing_bg.wasm
CHANGED
|
Binary file
|