xwing-wasm 0.3.0 → 0.3.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.
@@ -36,9 +36,12 @@ export function encapsulate(pk) {
36
36
  */
37
37
  export function generateKeypair() {
38
38
  const ret = wasm.generateKeypair();
39
- return ret;
39
+ if (ret[2]) {
40
+ throw takeFromExternrefTable0(ret[1]);
41
+ }
42
+ return takeFromExternrefTable0(ret[0]);
40
43
  }
41
- export function __wbg_Error_92b29b0548f8b746(arg0, arg1) {
44
+ export function __wbg_Error_30c8987f7c2ed4e2(arg0, arg1) {
42
45
  const ret = Error(getStringFromWasm0(arg0, arg1));
43
46
  return ret;
44
47
  }
@@ -49,32 +52,33 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
49
52
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
50
53
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
51
54
  }
52
- export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
55
+ export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
53
56
  throw new Error(getStringFromWasm0(arg0, arg1));
54
57
  }
55
- export function __wbg_getRandomValues_cc7f052a444bb2ce() { return handleError(function (arg0, arg1) {
58
+ export function __wbg_from_296ca31f8d0f1c52(arg0) {
59
+ const ret = Array.from(arg0);
60
+ return ret;
61
+ }
62
+ export function __wbg_getRandomValues_436a51d0629d84e1() { return handleError(function (arg0, arg1) {
56
63
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
57
64
  }, arguments); }
58
- export function __wbg_new_32b398fb48b6d94a() {
59
- const ret = new Array();
65
+ export function __wbg_new_1dbf7428bba60a42(arg0) {
66
+ const ret = new Uint8Array(arg0);
60
67
  return ret;
61
68
  }
62
- export function __wbg_new_da52cf8fe3429cb2() {
69
+ export function __wbg_new_617a8cdb8bb1130e() {
63
70
  const ret = new Object();
64
71
  return ret;
65
72
  }
66
73
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
67
74
  arg0[arg1] = arg2;
68
75
  }
69
- export function __wbg_set_8a16b38e4805b298(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;
76
+ export function __wbindgen_generic_0000000000000001(arg0, arg1) {
77
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
78
+ const ret = getArrayU8FromWasm0(arg0, arg1);
75
79
  return ret;
76
80
  }
77
- export function __wbindgen_cast_0000000000000002(arg0, arg1) {
81
+ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
78
82
  // Cast intrinsic for `Ref(String) -> Externref`.
79
83
  const ret = getStringFromWasm0(arg0, arg1);
80
84
  return ret;
@@ -3,7 +3,7 @@
3
3
  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
- export const generateKeypair: () => any;
6
+ export const generateKeypair: () => [number, number, number];
7
7
  export const __wbindgen_malloc: (a: number, b: number) => number;
8
8
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
9
9
  export const __wbindgen_exn_store: (a: number) => void;
package/node/xwing.js CHANGED
@@ -40,13 +40,16 @@ exports.encapsulate = encapsulate;
40
40
  */
41
41
  function generateKeypair() {
42
42
  const ret = wasm.generateKeypair();
43
- return ret;
43
+ if (ret[2]) {
44
+ throw takeFromExternrefTable0(ret[1]);
45
+ }
46
+ return takeFromExternrefTable0(ret[0]);
44
47
  }
45
48
  exports.generateKeypair = generateKeypair;
46
49
  function __wbg_get_imports() {
47
50
  const import0 = {
48
51
  __proto__: null,
49
- __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
52
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
50
53
  const ret = Error(getStringFromWasm0(arg0, arg1));
51
54
  return ret;
52
55
  },
@@ -57,32 +60,33 @@ function __wbg_get_imports() {
57
60
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
58
61
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
59
62
  },
60
- __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
63
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
61
64
  throw new Error(getStringFromWasm0(arg0, arg1));
62
65
  },
63
- __wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
66
+ __wbg_from_296ca31f8d0f1c52: function(arg0) {
67
+ const ret = Array.from(arg0);
68
+ return ret;
69
+ },
70
+ __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
64
71
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
65
72
  }, arguments); },
66
- __wbg_new_32b398fb48b6d94a: function() {
67
- const ret = new Array();
73
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
74
+ const ret = new Uint8Array(arg0);
68
75
  return ret;
69
76
  },
70
- __wbg_new_da52cf8fe3429cb2: function() {
77
+ __wbg_new_617a8cdb8bb1130e: function() {
71
78
  const ret = new Object();
72
79
  return ret;
73
80
  },
74
81
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
75
82
  arg0[arg1] = arg2;
76
83
  },
77
- __wbg_set_8a16b38e4805b298: 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;
84
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
85
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
86
+ const ret = getArrayU8FromWasm0(arg0, arg1);
83
87
  return ret;
84
88
  },
85
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
89
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
86
90
  // Cast intrinsic for `Ref(String) -> Externref`.
87
91
  const ret = getStringFromWasm0(arg0, arg1);
88
92
  return ret;
@@ -3,7 +3,7 @@
3
3
  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
- export const generateKeypair: () => any;
6
+ export const generateKeypair: () => [number, number, number];
7
7
  export const __wbindgen_malloc: (a: number, b: number) => number;
8
8
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
9
9
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xwing-wasm",
3
- "version": "0.3.0",
3
+ "version": "0.3.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": {
package/web/xwing.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface InitOutput {
23
23
  readonly memory: WebAssembly.Memory;
24
24
  readonly decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
25
25
  readonly encapsulate: (a: number, b: number) => [number, number, number];
26
- readonly generateKeypair: () => any;
26
+ readonly generateKeypair: () => [number, number, number];
27
27
  readonly __wbindgen_malloc: (a: number, b: number) => number;
28
28
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
29
29
  readonly __wbindgen_exn_store: (a: number) => void;
package/web/xwing.js CHANGED
@@ -38,12 +38,15 @@ export function encapsulate(pk) {
38
38
  */
39
39
  export function generateKeypair() {
40
40
  const ret = wasm.generateKeypair();
41
- return ret;
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return takeFromExternrefTable0(ret[0]);
42
45
  }
43
46
  function __wbg_get_imports() {
44
47
  const import0 = {
45
48
  __proto__: null,
46
- __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
49
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
47
50
  const ret = Error(getStringFromWasm0(arg0, arg1));
48
51
  return ret;
49
52
  },
@@ -54,32 +57,33 @@ function __wbg_get_imports() {
54
57
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
55
58
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
56
59
  },
57
- __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
60
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
58
61
  throw new Error(getStringFromWasm0(arg0, arg1));
59
62
  },
60
- __wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
63
+ __wbg_from_296ca31f8d0f1c52: function(arg0) {
64
+ const ret = Array.from(arg0);
65
+ return ret;
66
+ },
67
+ __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
61
68
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
62
69
  }, arguments); },
63
- __wbg_new_32b398fb48b6d94a: function() {
64
- const ret = new Array();
70
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
71
+ const ret = new Uint8Array(arg0);
65
72
  return ret;
66
73
  },
67
- __wbg_new_da52cf8fe3429cb2: function() {
74
+ __wbg_new_617a8cdb8bb1130e: function() {
68
75
  const ret = new Object();
69
76
  return ret;
70
77
  },
71
78
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
72
79
  arg0[arg1] = arg2;
73
80
  },
74
- __wbg_set_8a16b38e4805b298: 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;
81
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
82
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
83
+ const ret = getArrayU8FromWasm0(arg0, arg1);
80
84
  return ret;
81
85
  },
82
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
86
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
83
87
  // Cast intrinsic for `Ref(String) -> Externref`.
84
88
  const ret = getStringFromWasm0(arg0, arg1);
85
89
  return ret;
@@ -232,11 +236,15 @@ function __wbg_finalize_init(instance, module) {
232
236
 
233
237
  async function __wbg_load(module, imports) {
234
238
  if (typeof Response === 'function' && module instanceof Response) {
239
+ if (!module.ok) {
240
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
241
+ }
242
+
235
243
  if (typeof WebAssembly.instantiateStreaming === 'function') {
236
244
  try {
237
245
  return await WebAssembly.instantiateStreaming(module, imports);
238
246
  } catch (e) {
239
- const validResponse = module.ok && expectedResponseType(module.type);
247
+ const validResponse = expectedResponseType(module.type);
240
248
 
241
249
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
242
250
  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);
@@ -3,7 +3,7 @@
3
3
  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
- export const generateKeypair: () => any;
6
+ export const generateKeypair: () => [number, number, number];
7
7
  export const __wbindgen_malloc: (a: number, b: number) => number;
8
8
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
9
9
  export const __wbindgen_exn_store: (a: number) => void;
package/xwing_bg.js CHANGED
@@ -36,9 +36,12 @@ export function encapsulate(pk) {
36
36
  */
37
37
  export function generateKeypair() {
38
38
  const ret = wasm.generateKeypair();
39
- return ret;
39
+ if (ret[2]) {
40
+ throw takeFromExternrefTable0(ret[1]);
41
+ }
42
+ return takeFromExternrefTable0(ret[0]);
40
43
  }
41
- export function __wbg_Error_92b29b0548f8b746(arg0, arg1) {
44
+ export function __wbg_Error_30c8987f7c2ed4e2(arg0, arg1) {
42
45
  const ret = Error(getStringFromWasm0(arg0, arg1));
43
46
  return ret;
44
47
  }
@@ -49,32 +52,33 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
49
52
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
50
53
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
51
54
  }
52
- export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
55
+ export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
53
56
  throw new Error(getStringFromWasm0(arg0, arg1));
54
57
  }
55
- export function __wbg_getRandomValues_cc7f052a444bb2ce() { return handleError(function (arg0, arg1) {
58
+ export function __wbg_from_296ca31f8d0f1c52(arg0) {
59
+ const ret = Array.from(arg0);
60
+ return ret;
61
+ }
62
+ export function __wbg_getRandomValues_436a51d0629d84e1() { return handleError(function (arg0, arg1) {
56
63
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
57
64
  }, arguments); }
58
- export function __wbg_new_32b398fb48b6d94a() {
59
- const ret = new Array();
65
+ export function __wbg_new_1dbf7428bba60a42(arg0) {
66
+ const ret = new Uint8Array(arg0);
60
67
  return ret;
61
68
  }
62
- export function __wbg_new_da52cf8fe3429cb2() {
69
+ export function __wbg_new_617a8cdb8bb1130e() {
63
70
  const ret = new Object();
64
71
  return ret;
65
72
  }
66
73
  export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
67
74
  arg0[arg1] = arg2;
68
75
  }
69
- export function __wbg_set_8a16b38e4805b298(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;
76
+ export function __wbindgen_generic_0000000000000001(arg0, arg1) {
77
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
78
+ const ret = getArrayU8FromWasm0(arg0, arg1);
75
79
  return ret;
76
80
  }
77
- export function __wbindgen_cast_0000000000000002(arg0, arg1) {
81
+ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
78
82
  // Cast intrinsic for `Ref(String) -> Externref`.
79
83
  const ret = getStringFromWasm0(arg0, arg1);
80
84
  return ret;
package/xwing_bg.wasm CHANGED
Binary file