@stenvault/pqc-wasm 0.1.0 → 0.1.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/package.json +4 -3
- package/pkg-bundler/README.md +91 -0
- package/pkg-bundler/package.json +19 -0
- package/pkg-bundler/stenvault_pqc.d.ts +38 -0
- package/pkg-bundler/stenvault_pqc.js +9 -0
- package/pkg-bundler/stenvault_pqc_bg.js +393 -0
- package/pkg-bundler/stenvault_pqc_bg.wasm +0 -0
- package/pkg-bundler/stenvault_pqc_bg.wasm.d.ts +25 -0
- package/pkg-nodejs/README.md +91 -0
- package/pkg-nodejs/package.json +13 -0
- package/pkg-nodejs/stenvault_pqc.d.ts +38 -0
- package/pkg-nodejs/stenvault_pqc.js +407 -0
- package/pkg-nodejs/stenvault_pqc_bg.wasm +0 -0
- package/pkg-nodejs/stenvault_pqc_bg.wasm.d.ts +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stenvault/pqc-wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "ML-KEM-768 + ML-DSA-65 WASM wrapper — RustCrypto compiled to WebAssembly",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build:bundler": "wasm-pack build --target bundler --release --out-dir pkg-bundler",
|
|
37
37
|
"build:nodejs": "wasm-pack build --target nodejs --release --out-dir pkg-nodejs",
|
|
38
|
-
"build:wasm": "npm run build:bundler && npm run build:nodejs",
|
|
38
|
+
"build:wasm": "npm run build:bundler && npm run build:nodejs && npm run postbuild:wasm",
|
|
39
|
+
"postbuild:wasm": "rm -f pkg-bundler/.gitignore pkg-nodejs/.gitignore",
|
|
39
40
|
"build:ts": "tsc",
|
|
40
41
|
"build": "npm run build:wasm && npm run build:ts",
|
|
41
42
|
"test": "npx tsx tests/interop.ts"
|
|
@@ -43,6 +44,6 @@
|
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@openforge-sh/liboqs": "^0.14.3",
|
|
45
46
|
"tsx": "^4.21.0",
|
|
46
|
-
"typescript": "^5.
|
|
47
|
+
"typescript": "^5.9.3"
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @stenvault/pqc-wasm
|
|
2
|
+
|
|
3
|
+
Post-quantum cryptography WASM wrapper for StenVault — ML-KEM-768 (FIPS 203) and ML-DSA-65 (FIPS 204) compiled from RustCrypto crates to WebAssembly.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
Replaces `@openforge-sh/liboqs` (unofficial C wrapper, single anonymous maintainer, 0 stars) with a self-maintained Rust→WASM build using the RustCrypto ecosystem (`ml-kem` + `ml-dsa` crates).
|
|
8
|
+
|
|
9
|
+
WASM preserves constant-time properties from the Rust `subtle` crate — pure JS alternatives (noble-post-quantum, mlkem) cannot guarantee this due to V8 JIT and GC interference.
|
|
10
|
+
|
|
11
|
+
## Build
|
|
12
|
+
|
|
13
|
+
Requires Rust toolchain with `wasm32-unknown-unknown` target and `wasm-pack`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
rustup target add wasm32-unknown-unknown
|
|
17
|
+
cargo install wasm-pack
|
|
18
|
+
|
|
19
|
+
# Build both targets
|
|
20
|
+
wasm-pack build --target bundler --release --out-dir pkg-bundler
|
|
21
|
+
wasm-pack build --target nodejs --release --out-dir pkg-nodejs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import {
|
|
28
|
+
generateKemKeyPair,
|
|
29
|
+
encapsulate,
|
|
30
|
+
decapsulate,
|
|
31
|
+
generateSignatureKeyPair,
|
|
32
|
+
sign,
|
|
33
|
+
verify,
|
|
34
|
+
} from '@stenvault/pqc-wasm'
|
|
35
|
+
|
|
36
|
+
// ML-KEM-768
|
|
37
|
+
const kp = await generateKemKeyPair()
|
|
38
|
+
// kp.publicKey: Uint8Array (1,184 bytes)
|
|
39
|
+
// kp.secretKey: Uint8Array (2,400 bytes)
|
|
40
|
+
|
|
41
|
+
const { ciphertext, sharedSecret } = await encapsulate(kp.publicKey)
|
|
42
|
+
const decrypted = await decapsulate(ciphertext, kp.secretKey)
|
|
43
|
+
// sharedSecret === decrypted (32 bytes)
|
|
44
|
+
|
|
45
|
+
// ML-DSA-65
|
|
46
|
+
const sigKp = await generateSignatureKeyPair()
|
|
47
|
+
// sigKp.publicKey: Uint8Array (1,952 bytes)
|
|
48
|
+
// sigKp.secretKey: Uint8Array (4,032 bytes)
|
|
49
|
+
|
|
50
|
+
const signature = await sign(message, sigKp.secretKey)
|
|
51
|
+
// signature: Uint8Array (3,309 bytes)
|
|
52
|
+
|
|
53
|
+
const valid = await verify(message, signature, sigKp.publicKey)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Architecture
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Consumer (StenVault)
|
|
60
|
+
↓ imports from "@stenvault/pqc-wasm"
|
|
61
|
+
index.browser.ts / index.node.ts ← ensurePqcInit() + re-export
|
|
62
|
+
↓
|
|
63
|
+
core.ts ← free() in try/finally, param order normalization
|
|
64
|
+
↓
|
|
65
|
+
pkg-bundler/ or pkg-nodejs/ ← wasm-bindgen generated bindings
|
|
66
|
+
↓
|
|
67
|
+
src/lib.rs ← 7 Rust functions, zeroize on Drop
|
|
68
|
+
↓
|
|
69
|
+
ml-kem + ml-dsa (RustCrypto) ← FIPS 203/204 implementations
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The consumer never calls `free()`, never calls `init()`, and never imports from `pkg-*` directly. The `exports` field in `package.json` routes `browser` to `pkg-bundler` and `node`/`default` to `pkg-nodejs` automatically.
|
|
73
|
+
|
|
74
|
+
## Key sizes (FIPS)
|
|
75
|
+
|
|
76
|
+
| Algorithm | Public Key | Secret Key | Ciphertext | Signature | Shared Secret |
|
|
77
|
+
|-----------|-----------|-----------|-----------|----------|--------------|
|
|
78
|
+
| ML-KEM-768 | 1,184 B | 2,400 B | 1,088 B | — | 32 B |
|
|
79
|
+
| ML-DSA-65 | 1,952 B | 4,032 B | — | 3,309 B | — |
|
|
80
|
+
|
|
81
|
+
## Security
|
|
82
|
+
|
|
83
|
+
- **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
|
|
84
|
+
- **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
|
|
85
|
+
- **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this. See `PLAN_stenvault_pqc_wasm.md` section 10 for full risk analysis.
|
|
86
|
+
- **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction). Cargo.toml pins `>= 0.1.0-rc.3, < 0.2`.
|
|
87
|
+
- **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "stenvault-pqc",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "ML-KEM-768 + ML-DSA-65 WASM wrapper for StenVault",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"stenvault_pqc_bg.wasm",
|
|
9
|
+
"stenvault_pqc.js",
|
|
10
|
+
"stenvault_pqc_bg.js",
|
|
11
|
+
"stenvault_pqc.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"main": "stenvault_pqc.js",
|
|
14
|
+
"types": "stenvault_pqc.d.ts",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"./stenvault_pqc.js",
|
|
17
|
+
"./snippets/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class MlDsa65KeyPair {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
readonly signing_key: Uint8Array;
|
|
9
|
+
readonly verifying_key: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class MlKem768EncapResult {
|
|
13
|
+
private constructor();
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
readonly ciphertext: Uint8Array;
|
|
17
|
+
readonly shared_secret: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class MlKem768KeyPair {
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
readonly decapsulation_key: Uint8Array;
|
|
25
|
+
readonly encapsulation_key: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function ml_dsa_65_generate(): MlDsa65KeyPair;
|
|
29
|
+
|
|
30
|
+
export function ml_dsa_65_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8Array;
|
|
31
|
+
|
|
32
|
+
export function ml_dsa_65_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
33
|
+
|
|
34
|
+
export function ml_kem_768_decapsulate(dk_bytes: Uint8Array, ct_bytes: Uint8Array): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export function ml_kem_768_encapsulate(ek_bytes: Uint8Array): MlKem768EncapResult;
|
|
37
|
+
|
|
38
|
+
export function ml_kem_768_generate(): MlKem768KeyPair;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./stenvault_pqc.d.ts" */
|
|
2
|
+
|
|
3
|
+
import * as wasm from "./stenvault_pqc_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./stenvault_pqc_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
MlDsa65KeyPair, MlKem768EncapResult, MlKem768KeyPair, ml_dsa_65_generate, ml_dsa_65_sign, ml_dsa_65_verify, ml_kem_768_decapsulate, ml_kem_768_encapsulate, ml_kem_768_generate
|
|
9
|
+
} from "./stenvault_pqc_bg.js";
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
export class MlDsa65KeyPair {
|
|
2
|
+
static __wrap(ptr) {
|
|
3
|
+
ptr = ptr >>> 0;
|
|
4
|
+
const obj = Object.create(MlDsa65KeyPair.prototype);
|
|
5
|
+
obj.__wbg_ptr = ptr;
|
|
6
|
+
MlDsa65KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
MlDsa65KeyPairFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_mldsa65keypair_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @returns {Uint8Array}
|
|
21
|
+
*/
|
|
22
|
+
get signing_key() {
|
|
23
|
+
const ret = wasm.mldsa65keypair_signing_key(this.__wbg_ptr);
|
|
24
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
25
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
26
|
+
return v1;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @returns {Uint8Array}
|
|
30
|
+
*/
|
|
31
|
+
get verifying_key() {
|
|
32
|
+
const ret = wasm.mldsa65keypair_verifying_key(this.__wbg_ptr);
|
|
33
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
34
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
35
|
+
return v1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (Symbol.dispose) MlDsa65KeyPair.prototype[Symbol.dispose] = MlDsa65KeyPair.prototype.free;
|
|
39
|
+
|
|
40
|
+
export class MlKem768EncapResult {
|
|
41
|
+
static __wrap(ptr) {
|
|
42
|
+
ptr = ptr >>> 0;
|
|
43
|
+
const obj = Object.create(MlKem768EncapResult.prototype);
|
|
44
|
+
obj.__wbg_ptr = ptr;
|
|
45
|
+
MlKem768EncapResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
__destroy_into_raw() {
|
|
49
|
+
const ptr = this.__wbg_ptr;
|
|
50
|
+
this.__wbg_ptr = 0;
|
|
51
|
+
MlKem768EncapResultFinalization.unregister(this);
|
|
52
|
+
return ptr;
|
|
53
|
+
}
|
|
54
|
+
free() {
|
|
55
|
+
const ptr = this.__destroy_into_raw();
|
|
56
|
+
wasm.__wbg_mlkem768encapresult_free(ptr, 0);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @returns {Uint8Array}
|
|
60
|
+
*/
|
|
61
|
+
get ciphertext() {
|
|
62
|
+
const ret = wasm.mlkem768encapresult_ciphertext(this.__wbg_ptr);
|
|
63
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
64
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
65
|
+
return v1;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @returns {Uint8Array}
|
|
69
|
+
*/
|
|
70
|
+
get shared_secret() {
|
|
71
|
+
const ret = wasm.mlkem768encapresult_shared_secret(this.__wbg_ptr);
|
|
72
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
73
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
74
|
+
return v1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (Symbol.dispose) MlKem768EncapResult.prototype[Symbol.dispose] = MlKem768EncapResult.prototype.free;
|
|
78
|
+
|
|
79
|
+
export class MlKem768KeyPair {
|
|
80
|
+
static __wrap(ptr) {
|
|
81
|
+
ptr = ptr >>> 0;
|
|
82
|
+
const obj = Object.create(MlKem768KeyPair.prototype);
|
|
83
|
+
obj.__wbg_ptr = ptr;
|
|
84
|
+
MlKem768KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
__destroy_into_raw() {
|
|
88
|
+
const ptr = this.__wbg_ptr;
|
|
89
|
+
this.__wbg_ptr = 0;
|
|
90
|
+
MlKem768KeyPairFinalization.unregister(this);
|
|
91
|
+
return ptr;
|
|
92
|
+
}
|
|
93
|
+
free() {
|
|
94
|
+
const ptr = this.__destroy_into_raw();
|
|
95
|
+
wasm.__wbg_mlkem768keypair_free(ptr, 0);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @returns {Uint8Array}
|
|
99
|
+
*/
|
|
100
|
+
get decapsulation_key() {
|
|
101
|
+
const ret = wasm.mlkem768keypair_decapsulation_key(this.__wbg_ptr);
|
|
102
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
103
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
104
|
+
return v1;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @returns {Uint8Array}
|
|
108
|
+
*/
|
|
109
|
+
get encapsulation_key() {
|
|
110
|
+
const ret = wasm.mlkem768keypair_encapsulation_key(this.__wbg_ptr);
|
|
111
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
112
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
113
|
+
return v1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (Symbol.dispose) MlKem768KeyPair.prototype[Symbol.dispose] = MlKem768KeyPair.prototype.free;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @returns {MlDsa65KeyPair}
|
|
120
|
+
*/
|
|
121
|
+
export function ml_dsa_65_generate() {
|
|
122
|
+
const ret = wasm.ml_dsa_65_generate();
|
|
123
|
+
return MlDsa65KeyPair.__wrap(ret);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {Uint8Array} sk_bytes
|
|
128
|
+
* @param {Uint8Array} message
|
|
129
|
+
* @returns {Uint8Array}
|
|
130
|
+
*/
|
|
131
|
+
export function ml_dsa_65_sign(sk_bytes, message) {
|
|
132
|
+
const ptr0 = passArray8ToWasm0(sk_bytes, wasm.__wbindgen_malloc);
|
|
133
|
+
const len0 = WASM_VECTOR_LEN;
|
|
134
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
135
|
+
const len1 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.ml_dsa_65_sign(ptr0, len0, ptr1, len1);
|
|
137
|
+
if (ret[3]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
139
|
+
}
|
|
140
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
141
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
142
|
+
return v3;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {Uint8Array} vk_bytes
|
|
147
|
+
* @param {Uint8Array} message
|
|
148
|
+
* @param {Uint8Array} signature
|
|
149
|
+
* @returns {boolean}
|
|
150
|
+
*/
|
|
151
|
+
export function ml_dsa_65_verify(vk_bytes, message, signature) {
|
|
152
|
+
const ptr0 = passArray8ToWasm0(vk_bytes, wasm.__wbindgen_malloc);
|
|
153
|
+
const len0 = WASM_VECTOR_LEN;
|
|
154
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
155
|
+
const len1 = WASM_VECTOR_LEN;
|
|
156
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
157
|
+
const len2 = WASM_VECTOR_LEN;
|
|
158
|
+
const ret = wasm.ml_dsa_65_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
159
|
+
if (ret[2]) {
|
|
160
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
161
|
+
}
|
|
162
|
+
return ret[0] !== 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param {Uint8Array} dk_bytes
|
|
167
|
+
* @param {Uint8Array} ct_bytes
|
|
168
|
+
* @returns {Uint8Array}
|
|
169
|
+
*/
|
|
170
|
+
export function ml_kem_768_decapsulate(dk_bytes, ct_bytes) {
|
|
171
|
+
const ptr0 = passArray8ToWasm0(dk_bytes, wasm.__wbindgen_malloc);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ptr1 = passArray8ToWasm0(ct_bytes, wasm.__wbindgen_malloc);
|
|
174
|
+
const len1 = WASM_VECTOR_LEN;
|
|
175
|
+
const ret = wasm.ml_kem_768_decapsulate(ptr0, len0, ptr1, len1);
|
|
176
|
+
if (ret[3]) {
|
|
177
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
178
|
+
}
|
|
179
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
180
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
181
|
+
return v3;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @param {Uint8Array} ek_bytes
|
|
186
|
+
* @returns {MlKem768EncapResult}
|
|
187
|
+
*/
|
|
188
|
+
export function ml_kem_768_encapsulate(ek_bytes) {
|
|
189
|
+
const ptr0 = passArray8ToWasm0(ek_bytes, wasm.__wbindgen_malloc);
|
|
190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
191
|
+
const ret = wasm.ml_kem_768_encapsulate(ptr0, len0);
|
|
192
|
+
if (ret[2]) {
|
|
193
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
194
|
+
}
|
|
195
|
+
return MlKem768EncapResult.__wrap(ret[0]);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @returns {MlKem768KeyPair}
|
|
200
|
+
*/
|
|
201
|
+
export function ml_kem_768_generate() {
|
|
202
|
+
const ret = wasm.ml_kem_768_generate();
|
|
203
|
+
return MlKem768KeyPair.__wrap(ret);
|
|
204
|
+
}
|
|
205
|
+
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
206
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
207
|
+
return ret;
|
|
208
|
+
}
|
|
209
|
+
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
210
|
+
const ret = typeof(arg0) === 'function';
|
|
211
|
+
return ret;
|
|
212
|
+
}
|
|
213
|
+
export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
214
|
+
const val = arg0;
|
|
215
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
216
|
+
return ret;
|
|
217
|
+
}
|
|
218
|
+
export function __wbg___wbindgen_is_string_7ef6b97b02428fae(arg0) {
|
|
219
|
+
const ret = typeof(arg0) === 'string';
|
|
220
|
+
return ret;
|
|
221
|
+
}
|
|
222
|
+
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
223
|
+
const ret = arg0 === undefined;
|
|
224
|
+
return ret;
|
|
225
|
+
}
|
|
226
|
+
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
227
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
228
|
+
}
|
|
229
|
+
export function __wbg_call_2d781c1f4d5c0ef8() { return handleError(function (arg0, arg1, arg2) {
|
|
230
|
+
const ret = arg0.call(arg1, arg2);
|
|
231
|
+
return ret;
|
|
232
|
+
}, arguments); }
|
|
233
|
+
export function __wbg_crypto_38df2bab126b63dc(arg0) {
|
|
234
|
+
const ret = arg0.crypto;
|
|
235
|
+
return ret;
|
|
236
|
+
}
|
|
237
|
+
export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
|
|
238
|
+
arg0.getRandomValues(arg1);
|
|
239
|
+
}, arguments); }
|
|
240
|
+
export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
241
|
+
const ret = arg0.length;
|
|
242
|
+
return ret;
|
|
243
|
+
}
|
|
244
|
+
export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
|
|
245
|
+
const ret = arg0.msCrypto;
|
|
246
|
+
return ret;
|
|
247
|
+
}
|
|
248
|
+
export function __wbg_new_with_length_825018a1616e9e55(arg0) {
|
|
249
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
250
|
+
return ret;
|
|
251
|
+
}
|
|
252
|
+
export function __wbg_node_84ea875411254db1(arg0) {
|
|
253
|
+
const ret = arg0.node;
|
|
254
|
+
return ret;
|
|
255
|
+
}
|
|
256
|
+
export function __wbg_process_44c7a14e11e9f69e(arg0) {
|
|
257
|
+
const ret = arg0.process;
|
|
258
|
+
return ret;
|
|
259
|
+
}
|
|
260
|
+
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
261
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
262
|
+
}
|
|
263
|
+
export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) {
|
|
264
|
+
arg0.randomFillSync(arg1);
|
|
265
|
+
}, arguments); }
|
|
266
|
+
export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () {
|
|
267
|
+
const ret = module.require;
|
|
268
|
+
return ret;
|
|
269
|
+
}, arguments); }
|
|
270
|
+
export function __wbg_static_accessor_GLOBAL_8adb955bd33fac2f() {
|
|
271
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
272
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
273
|
+
}
|
|
274
|
+
export function __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913() {
|
|
275
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
276
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
277
|
+
}
|
|
278
|
+
export function __wbg_static_accessor_SELF_f207c857566db248() {
|
|
279
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
280
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
281
|
+
}
|
|
282
|
+
export function __wbg_static_accessor_WINDOW_bb9f1ba69d61b386() {
|
|
283
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
284
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
285
|
+
}
|
|
286
|
+
export function __wbg_subarray_a068d24e39478a8a(arg0, arg1, arg2) {
|
|
287
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
288
|
+
return ret;
|
|
289
|
+
}
|
|
290
|
+
export function __wbg_versions_276b2795b1c6a219(arg0) {
|
|
291
|
+
const ret = arg0.versions;
|
|
292
|
+
return ret;
|
|
293
|
+
}
|
|
294
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
295
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
296
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
297
|
+
return ret;
|
|
298
|
+
}
|
|
299
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
300
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
301
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
export function __wbindgen_init_externref_table() {
|
|
305
|
+
const table = wasm.__wbindgen_externrefs;
|
|
306
|
+
const offset = table.grow(4);
|
|
307
|
+
table.set(0, undefined);
|
|
308
|
+
table.set(offset + 0, undefined);
|
|
309
|
+
table.set(offset + 1, null);
|
|
310
|
+
table.set(offset + 2, true);
|
|
311
|
+
table.set(offset + 3, false);
|
|
312
|
+
}
|
|
313
|
+
const MlDsa65KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
314
|
+
? { register: () => {}, unregister: () => {} }
|
|
315
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mldsa65keypair_free(ptr >>> 0, 1));
|
|
316
|
+
const MlKem768EncapResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
317
|
+
? { register: () => {}, unregister: () => {} }
|
|
318
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkem768encapresult_free(ptr >>> 0, 1));
|
|
319
|
+
const MlKem768KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
320
|
+
? { register: () => {}, unregister: () => {} }
|
|
321
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkem768keypair_free(ptr >>> 0, 1));
|
|
322
|
+
|
|
323
|
+
function addToExternrefTable0(obj) {
|
|
324
|
+
const idx = wasm.__externref_table_alloc();
|
|
325
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
326
|
+
return idx;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
330
|
+
ptr = ptr >>> 0;
|
|
331
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function getStringFromWasm0(ptr, len) {
|
|
335
|
+
ptr = ptr >>> 0;
|
|
336
|
+
return decodeText(ptr, len);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let cachedUint8ArrayMemory0 = null;
|
|
340
|
+
function getUint8ArrayMemory0() {
|
|
341
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
342
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
343
|
+
}
|
|
344
|
+
return cachedUint8ArrayMemory0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function handleError(f, args) {
|
|
348
|
+
try {
|
|
349
|
+
return f.apply(this, args);
|
|
350
|
+
} catch (e) {
|
|
351
|
+
const idx = addToExternrefTable0(e);
|
|
352
|
+
wasm.__wbindgen_exn_store(idx);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function isLikeNone(x) {
|
|
357
|
+
return x === undefined || x === null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
361
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
362
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
363
|
+
WASM_VECTOR_LEN = arg.length;
|
|
364
|
+
return ptr;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function takeFromExternrefTable0(idx) {
|
|
368
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
369
|
+
wasm.__externref_table_dealloc(idx);
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
374
|
+
cachedTextDecoder.decode();
|
|
375
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
376
|
+
let numBytesDecoded = 0;
|
|
377
|
+
function decodeText(ptr, len) {
|
|
378
|
+
numBytesDecoded += len;
|
|
379
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
380
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
381
|
+
cachedTextDecoder.decode();
|
|
382
|
+
numBytesDecoded = len;
|
|
383
|
+
}
|
|
384
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
let WASM_VECTOR_LEN = 0;
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
let wasm;
|
|
391
|
+
export function __wbg_set_wasm(val) {
|
|
392
|
+
wasm = val;
|
|
393
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_mldsa65keypair_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
6
|
+
export const ml_dsa_65_generate: () => number;
|
|
7
|
+
export const ml_dsa_65_sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
8
|
+
export const ml_dsa_65_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
9
|
+
export const ml_kem_768_decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
+
export const ml_kem_768_encapsulate: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const ml_kem_768_generate: () => number;
|
|
12
|
+
export const mldsa65keypair_signing_key: (a: number) => [number, number];
|
|
13
|
+
export const mldsa65keypair_verifying_key: (a: number) => [number, number];
|
|
14
|
+
export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
|
|
15
|
+
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
16
|
+
export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
|
|
17
|
+
export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
|
|
18
|
+
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
19
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
20
|
+
export const __externref_table_alloc: () => number;
|
|
21
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
22
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
23
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
24
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @stenvault/pqc-wasm
|
|
2
|
+
|
|
3
|
+
Post-quantum cryptography WASM wrapper for StenVault — ML-KEM-768 (FIPS 203) and ML-DSA-65 (FIPS 204) compiled from RustCrypto crates to WebAssembly.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
Replaces `@openforge-sh/liboqs` (unofficial C wrapper, single anonymous maintainer, 0 stars) with a self-maintained Rust→WASM build using the RustCrypto ecosystem (`ml-kem` + `ml-dsa` crates).
|
|
8
|
+
|
|
9
|
+
WASM preserves constant-time properties from the Rust `subtle` crate — pure JS alternatives (noble-post-quantum, mlkem) cannot guarantee this due to V8 JIT and GC interference.
|
|
10
|
+
|
|
11
|
+
## Build
|
|
12
|
+
|
|
13
|
+
Requires Rust toolchain with `wasm32-unknown-unknown` target and `wasm-pack`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
rustup target add wasm32-unknown-unknown
|
|
17
|
+
cargo install wasm-pack
|
|
18
|
+
|
|
19
|
+
# Build both targets
|
|
20
|
+
wasm-pack build --target bundler --release --out-dir pkg-bundler
|
|
21
|
+
wasm-pack build --target nodejs --release --out-dir pkg-nodejs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import {
|
|
28
|
+
generateKemKeyPair,
|
|
29
|
+
encapsulate,
|
|
30
|
+
decapsulate,
|
|
31
|
+
generateSignatureKeyPair,
|
|
32
|
+
sign,
|
|
33
|
+
verify,
|
|
34
|
+
} from '@stenvault/pqc-wasm'
|
|
35
|
+
|
|
36
|
+
// ML-KEM-768
|
|
37
|
+
const kp = await generateKemKeyPair()
|
|
38
|
+
// kp.publicKey: Uint8Array (1,184 bytes)
|
|
39
|
+
// kp.secretKey: Uint8Array (2,400 bytes)
|
|
40
|
+
|
|
41
|
+
const { ciphertext, sharedSecret } = await encapsulate(kp.publicKey)
|
|
42
|
+
const decrypted = await decapsulate(ciphertext, kp.secretKey)
|
|
43
|
+
// sharedSecret === decrypted (32 bytes)
|
|
44
|
+
|
|
45
|
+
// ML-DSA-65
|
|
46
|
+
const sigKp = await generateSignatureKeyPair()
|
|
47
|
+
// sigKp.publicKey: Uint8Array (1,952 bytes)
|
|
48
|
+
// sigKp.secretKey: Uint8Array (4,032 bytes)
|
|
49
|
+
|
|
50
|
+
const signature = await sign(message, sigKp.secretKey)
|
|
51
|
+
// signature: Uint8Array (3,309 bytes)
|
|
52
|
+
|
|
53
|
+
const valid = await verify(message, signature, sigKp.publicKey)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Architecture
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Consumer (StenVault)
|
|
60
|
+
↓ imports from "@stenvault/pqc-wasm"
|
|
61
|
+
index.browser.ts / index.node.ts ← ensurePqcInit() + re-export
|
|
62
|
+
↓
|
|
63
|
+
core.ts ← free() in try/finally, param order normalization
|
|
64
|
+
↓
|
|
65
|
+
pkg-bundler/ or pkg-nodejs/ ← wasm-bindgen generated bindings
|
|
66
|
+
↓
|
|
67
|
+
src/lib.rs ← 7 Rust functions, zeroize on Drop
|
|
68
|
+
↓
|
|
69
|
+
ml-kem + ml-dsa (RustCrypto) ← FIPS 203/204 implementations
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The consumer never calls `free()`, never calls `init()`, and never imports from `pkg-*` directly. The `exports` field in `package.json` routes `browser` to `pkg-bundler` and `node`/`default` to `pkg-nodejs` automatically.
|
|
73
|
+
|
|
74
|
+
## Key sizes (FIPS)
|
|
75
|
+
|
|
76
|
+
| Algorithm | Public Key | Secret Key | Ciphertext | Signature | Shared Secret |
|
|
77
|
+
|-----------|-----------|-----------|-----------|----------|--------------|
|
|
78
|
+
| ML-KEM-768 | 1,184 B | 2,400 B | 1,088 B | — | 32 B |
|
|
79
|
+
| ML-DSA-65 | 1,952 B | 4,032 B | — | 3,309 B | — |
|
|
80
|
+
|
|
81
|
+
## Security
|
|
82
|
+
|
|
83
|
+
- **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
|
|
84
|
+
- **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
|
|
85
|
+
- **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this. See `PLAN_stenvault_pqc_wasm.md` section 10 for full risk analysis.
|
|
86
|
+
- **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction). Cargo.toml pins `>= 0.1.0-rc.3, < 0.2`.
|
|
87
|
+
- **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "stenvault-pqc",
|
|
3
|
+
"description": "ML-KEM-768 + ML-DSA-65 WASM wrapper for StenVault",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"stenvault_pqc_bg.wasm",
|
|
8
|
+
"stenvault_pqc.js",
|
|
9
|
+
"stenvault_pqc.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "stenvault_pqc.js",
|
|
12
|
+
"types": "stenvault_pqc.d.ts"
|
|
13
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class MlDsa65KeyPair {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
readonly signing_key: Uint8Array;
|
|
9
|
+
readonly verifying_key: Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class MlKem768EncapResult {
|
|
13
|
+
private constructor();
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
readonly ciphertext: Uint8Array;
|
|
17
|
+
readonly shared_secret: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class MlKem768KeyPair {
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
readonly decapsulation_key: Uint8Array;
|
|
25
|
+
readonly encapsulation_key: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function ml_dsa_65_generate(): MlDsa65KeyPair;
|
|
29
|
+
|
|
30
|
+
export function ml_dsa_65_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8Array;
|
|
31
|
+
|
|
32
|
+
export function ml_dsa_65_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
33
|
+
|
|
34
|
+
export function ml_kem_768_decapsulate(dk_bytes: Uint8Array, ct_bytes: Uint8Array): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export function ml_kem_768_encapsulate(ek_bytes: Uint8Array): MlKem768EncapResult;
|
|
37
|
+
|
|
38
|
+
export function ml_kem_768_generate(): MlKem768KeyPair;
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/* @ts-self-types="./stenvault_pqc.d.ts" */
|
|
2
|
+
|
|
3
|
+
class MlDsa65KeyPair {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
ptr = ptr >>> 0;
|
|
6
|
+
const obj = Object.create(MlDsa65KeyPair.prototype);
|
|
7
|
+
obj.__wbg_ptr = ptr;
|
|
8
|
+
MlDsa65KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
MlDsa65KeyPairFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_mldsa65keypair_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @returns {Uint8Array}
|
|
23
|
+
*/
|
|
24
|
+
get signing_key() {
|
|
25
|
+
const ret = wasm.mldsa65keypair_signing_key(this.__wbg_ptr);
|
|
26
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
27
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
28
|
+
return v1;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @returns {Uint8Array}
|
|
32
|
+
*/
|
|
33
|
+
get verifying_key() {
|
|
34
|
+
const ret = wasm.mldsa65keypair_verifying_key(this.__wbg_ptr);
|
|
35
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
36
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
37
|
+
return v1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (Symbol.dispose) MlDsa65KeyPair.prototype[Symbol.dispose] = MlDsa65KeyPair.prototype.free;
|
|
41
|
+
exports.MlDsa65KeyPair = MlDsa65KeyPair;
|
|
42
|
+
|
|
43
|
+
class MlKem768EncapResult {
|
|
44
|
+
static __wrap(ptr) {
|
|
45
|
+
ptr = ptr >>> 0;
|
|
46
|
+
const obj = Object.create(MlKem768EncapResult.prototype);
|
|
47
|
+
obj.__wbg_ptr = ptr;
|
|
48
|
+
MlKem768EncapResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
__destroy_into_raw() {
|
|
52
|
+
const ptr = this.__wbg_ptr;
|
|
53
|
+
this.__wbg_ptr = 0;
|
|
54
|
+
MlKem768EncapResultFinalization.unregister(this);
|
|
55
|
+
return ptr;
|
|
56
|
+
}
|
|
57
|
+
free() {
|
|
58
|
+
const ptr = this.__destroy_into_raw();
|
|
59
|
+
wasm.__wbg_mlkem768encapresult_free(ptr, 0);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @returns {Uint8Array}
|
|
63
|
+
*/
|
|
64
|
+
get ciphertext() {
|
|
65
|
+
const ret = wasm.mlkem768encapresult_ciphertext(this.__wbg_ptr);
|
|
66
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
67
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
68
|
+
return v1;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @returns {Uint8Array}
|
|
72
|
+
*/
|
|
73
|
+
get shared_secret() {
|
|
74
|
+
const ret = wasm.mlkem768encapresult_shared_secret(this.__wbg_ptr);
|
|
75
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
76
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
77
|
+
return v1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (Symbol.dispose) MlKem768EncapResult.prototype[Symbol.dispose] = MlKem768EncapResult.prototype.free;
|
|
81
|
+
exports.MlKem768EncapResult = MlKem768EncapResult;
|
|
82
|
+
|
|
83
|
+
class MlKem768KeyPair {
|
|
84
|
+
static __wrap(ptr) {
|
|
85
|
+
ptr = ptr >>> 0;
|
|
86
|
+
const obj = Object.create(MlKem768KeyPair.prototype);
|
|
87
|
+
obj.__wbg_ptr = ptr;
|
|
88
|
+
MlKem768KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
89
|
+
return obj;
|
|
90
|
+
}
|
|
91
|
+
__destroy_into_raw() {
|
|
92
|
+
const ptr = this.__wbg_ptr;
|
|
93
|
+
this.__wbg_ptr = 0;
|
|
94
|
+
MlKem768KeyPairFinalization.unregister(this);
|
|
95
|
+
return ptr;
|
|
96
|
+
}
|
|
97
|
+
free() {
|
|
98
|
+
const ptr = this.__destroy_into_raw();
|
|
99
|
+
wasm.__wbg_mlkem768keypair_free(ptr, 0);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @returns {Uint8Array}
|
|
103
|
+
*/
|
|
104
|
+
get decapsulation_key() {
|
|
105
|
+
const ret = wasm.mlkem768keypair_decapsulation_key(this.__wbg_ptr);
|
|
106
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
107
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
108
|
+
return v1;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @returns {Uint8Array}
|
|
112
|
+
*/
|
|
113
|
+
get encapsulation_key() {
|
|
114
|
+
const ret = wasm.mlkem768keypair_encapsulation_key(this.__wbg_ptr);
|
|
115
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
116
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
117
|
+
return v1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (Symbol.dispose) MlKem768KeyPair.prototype[Symbol.dispose] = MlKem768KeyPair.prototype.free;
|
|
121
|
+
exports.MlKem768KeyPair = MlKem768KeyPair;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @returns {MlDsa65KeyPair}
|
|
125
|
+
*/
|
|
126
|
+
function ml_dsa_65_generate() {
|
|
127
|
+
const ret = wasm.ml_dsa_65_generate();
|
|
128
|
+
return MlDsa65KeyPair.__wrap(ret);
|
|
129
|
+
}
|
|
130
|
+
exports.ml_dsa_65_generate = ml_dsa_65_generate;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {Uint8Array} sk_bytes
|
|
134
|
+
* @param {Uint8Array} message
|
|
135
|
+
* @returns {Uint8Array}
|
|
136
|
+
*/
|
|
137
|
+
function ml_dsa_65_sign(sk_bytes, message) {
|
|
138
|
+
const ptr0 = passArray8ToWasm0(sk_bytes, wasm.__wbindgen_malloc);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
141
|
+
const len1 = WASM_VECTOR_LEN;
|
|
142
|
+
const ret = wasm.ml_dsa_65_sign(ptr0, len0, ptr1, len1);
|
|
143
|
+
if (ret[3]) {
|
|
144
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
145
|
+
}
|
|
146
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
147
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
148
|
+
return v3;
|
|
149
|
+
}
|
|
150
|
+
exports.ml_dsa_65_sign = ml_dsa_65_sign;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param {Uint8Array} vk_bytes
|
|
154
|
+
* @param {Uint8Array} message
|
|
155
|
+
* @param {Uint8Array} signature
|
|
156
|
+
* @returns {boolean}
|
|
157
|
+
*/
|
|
158
|
+
function ml_dsa_65_verify(vk_bytes, message, signature) {
|
|
159
|
+
const ptr0 = passArray8ToWasm0(vk_bytes, wasm.__wbindgen_malloc);
|
|
160
|
+
const len0 = WASM_VECTOR_LEN;
|
|
161
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
162
|
+
const len1 = WASM_VECTOR_LEN;
|
|
163
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
164
|
+
const len2 = WASM_VECTOR_LEN;
|
|
165
|
+
const ret = wasm.ml_dsa_65_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
166
|
+
if (ret[2]) {
|
|
167
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
168
|
+
}
|
|
169
|
+
return ret[0] !== 0;
|
|
170
|
+
}
|
|
171
|
+
exports.ml_dsa_65_verify = ml_dsa_65_verify;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @param {Uint8Array} dk_bytes
|
|
175
|
+
* @param {Uint8Array} ct_bytes
|
|
176
|
+
* @returns {Uint8Array}
|
|
177
|
+
*/
|
|
178
|
+
function ml_kem_768_decapsulate(dk_bytes, ct_bytes) {
|
|
179
|
+
const ptr0 = passArray8ToWasm0(dk_bytes, wasm.__wbindgen_malloc);
|
|
180
|
+
const len0 = WASM_VECTOR_LEN;
|
|
181
|
+
const ptr1 = passArray8ToWasm0(ct_bytes, wasm.__wbindgen_malloc);
|
|
182
|
+
const len1 = WASM_VECTOR_LEN;
|
|
183
|
+
const ret = wasm.ml_kem_768_decapsulate(ptr0, len0, ptr1, len1);
|
|
184
|
+
if (ret[3]) {
|
|
185
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
186
|
+
}
|
|
187
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
188
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
189
|
+
return v3;
|
|
190
|
+
}
|
|
191
|
+
exports.ml_kem_768_decapsulate = ml_kem_768_decapsulate;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @param {Uint8Array} ek_bytes
|
|
195
|
+
* @returns {MlKem768EncapResult}
|
|
196
|
+
*/
|
|
197
|
+
function ml_kem_768_encapsulate(ek_bytes) {
|
|
198
|
+
const ptr0 = passArray8ToWasm0(ek_bytes, wasm.__wbindgen_malloc);
|
|
199
|
+
const len0 = WASM_VECTOR_LEN;
|
|
200
|
+
const ret = wasm.ml_kem_768_encapsulate(ptr0, len0);
|
|
201
|
+
if (ret[2]) {
|
|
202
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
203
|
+
}
|
|
204
|
+
return MlKem768EncapResult.__wrap(ret[0]);
|
|
205
|
+
}
|
|
206
|
+
exports.ml_kem_768_encapsulate = ml_kem_768_encapsulate;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @returns {MlKem768KeyPair}
|
|
210
|
+
*/
|
|
211
|
+
function ml_kem_768_generate() {
|
|
212
|
+
const ret = wasm.ml_kem_768_generate();
|
|
213
|
+
return MlKem768KeyPair.__wrap(ret);
|
|
214
|
+
}
|
|
215
|
+
exports.ml_kem_768_generate = ml_kem_768_generate;
|
|
216
|
+
|
|
217
|
+
function __wbg_get_imports() {
|
|
218
|
+
const import0 = {
|
|
219
|
+
__proto__: null,
|
|
220
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
221
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
222
|
+
return ret;
|
|
223
|
+
},
|
|
224
|
+
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
|
225
|
+
const ret = typeof(arg0) === 'function';
|
|
226
|
+
return ret;
|
|
227
|
+
},
|
|
228
|
+
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
229
|
+
const val = arg0;
|
|
230
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
231
|
+
return ret;
|
|
232
|
+
},
|
|
233
|
+
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
|
234
|
+
const ret = typeof(arg0) === 'string';
|
|
235
|
+
return ret;
|
|
236
|
+
},
|
|
237
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
238
|
+
const ret = arg0 === undefined;
|
|
239
|
+
return ret;
|
|
240
|
+
},
|
|
241
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
242
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
243
|
+
},
|
|
244
|
+
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
245
|
+
const ret = arg0.call(arg1, arg2);
|
|
246
|
+
return ret;
|
|
247
|
+
}, arguments); },
|
|
248
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
249
|
+
const ret = arg0.crypto;
|
|
250
|
+
return ret;
|
|
251
|
+
},
|
|
252
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
253
|
+
arg0.getRandomValues(arg1);
|
|
254
|
+
}, arguments); },
|
|
255
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
256
|
+
const ret = arg0.length;
|
|
257
|
+
return ret;
|
|
258
|
+
},
|
|
259
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
260
|
+
const ret = arg0.msCrypto;
|
|
261
|
+
return ret;
|
|
262
|
+
},
|
|
263
|
+
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
|
264
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
265
|
+
return ret;
|
|
266
|
+
},
|
|
267
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
268
|
+
const ret = arg0.node;
|
|
269
|
+
return ret;
|
|
270
|
+
},
|
|
271
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
272
|
+
const ret = arg0.process;
|
|
273
|
+
return ret;
|
|
274
|
+
},
|
|
275
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
276
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
277
|
+
},
|
|
278
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
279
|
+
arg0.randomFillSync(arg1);
|
|
280
|
+
}, arguments); },
|
|
281
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
282
|
+
const ret = module.require;
|
|
283
|
+
return ret;
|
|
284
|
+
}, arguments); },
|
|
285
|
+
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
|
|
286
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
287
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
288
|
+
},
|
|
289
|
+
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
|
|
290
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
291
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
292
|
+
},
|
|
293
|
+
__wbg_static_accessor_SELF_f207c857566db248: function() {
|
|
294
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
295
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
296
|
+
},
|
|
297
|
+
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
|
|
298
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
299
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
300
|
+
},
|
|
301
|
+
__wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
|
|
302
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
303
|
+
return ret;
|
|
304
|
+
},
|
|
305
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
306
|
+
const ret = arg0.versions;
|
|
307
|
+
return ret;
|
|
308
|
+
},
|
|
309
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
310
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
311
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
312
|
+
return ret;
|
|
313
|
+
},
|
|
314
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
315
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
316
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
317
|
+
return ret;
|
|
318
|
+
},
|
|
319
|
+
__wbindgen_init_externref_table: function() {
|
|
320
|
+
const table = wasm.__wbindgen_externrefs;
|
|
321
|
+
const offset = table.grow(4);
|
|
322
|
+
table.set(0, undefined);
|
|
323
|
+
table.set(offset + 0, undefined);
|
|
324
|
+
table.set(offset + 1, null);
|
|
325
|
+
table.set(offset + 2, true);
|
|
326
|
+
table.set(offset + 3, false);
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
return {
|
|
330
|
+
__proto__: null,
|
|
331
|
+
"./stenvault_pqc_bg.js": import0,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const MlDsa65KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
336
|
+
? { register: () => {}, unregister: () => {} }
|
|
337
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mldsa65keypair_free(ptr >>> 0, 1));
|
|
338
|
+
const MlKem768EncapResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
339
|
+
? { register: () => {}, unregister: () => {} }
|
|
340
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkem768encapresult_free(ptr >>> 0, 1));
|
|
341
|
+
const MlKem768KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
342
|
+
? { register: () => {}, unregister: () => {} }
|
|
343
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mlkem768keypair_free(ptr >>> 0, 1));
|
|
344
|
+
|
|
345
|
+
function addToExternrefTable0(obj) {
|
|
346
|
+
const idx = wasm.__externref_table_alloc();
|
|
347
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
348
|
+
return idx;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
352
|
+
ptr = ptr >>> 0;
|
|
353
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function getStringFromWasm0(ptr, len) {
|
|
357
|
+
ptr = ptr >>> 0;
|
|
358
|
+
return decodeText(ptr, len);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
let cachedUint8ArrayMemory0 = null;
|
|
362
|
+
function getUint8ArrayMemory0() {
|
|
363
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
364
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
365
|
+
}
|
|
366
|
+
return cachedUint8ArrayMemory0;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function handleError(f, args) {
|
|
370
|
+
try {
|
|
371
|
+
return f.apply(this, args);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
const idx = addToExternrefTable0(e);
|
|
374
|
+
wasm.__wbindgen_exn_store(idx);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function isLikeNone(x) {
|
|
379
|
+
return x === undefined || x === null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
383
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
384
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
385
|
+
WASM_VECTOR_LEN = arg.length;
|
|
386
|
+
return ptr;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function takeFromExternrefTable0(idx) {
|
|
390
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
391
|
+
wasm.__externref_table_dealloc(idx);
|
|
392
|
+
return value;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
396
|
+
cachedTextDecoder.decode();
|
|
397
|
+
function decodeText(ptr, len) {
|
|
398
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
let WASM_VECTOR_LEN = 0;
|
|
402
|
+
|
|
403
|
+
const wasmPath = `${__dirname}/stenvault_pqc_bg.wasm`;
|
|
404
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
405
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
406
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
407
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_mldsa65keypair_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
6
|
+
export const ml_dsa_65_generate: () => number;
|
|
7
|
+
export const ml_dsa_65_sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
8
|
+
export const ml_dsa_65_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
9
|
+
export const ml_kem_768_decapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
+
export const ml_kem_768_encapsulate: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const ml_kem_768_generate: () => number;
|
|
12
|
+
export const mldsa65keypair_signing_key: (a: number) => [number, number];
|
|
13
|
+
export const mldsa65keypair_verifying_key: (a: number) => [number, number];
|
|
14
|
+
export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
|
|
15
|
+
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
16
|
+
export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
|
|
17
|
+
export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
|
|
18
|
+
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
19
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
20
|
+
export const __externref_table_alloc: () => number;
|
|
21
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
22
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
23
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
24
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const __wbindgen_start: () => void;
|