@stenvault/pqc-wasm 0.2.0 → 0.2.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/LICENSE +21 -0
- package/README.md +3 -1
- package/package.json +1 -1
- package/pkg-bundler/LICENSE +21 -0
- package/pkg-bundler/README.md +3 -1
- package/pkg-bundler/package.json +2 -2
- package/pkg-bundler/stenvault_pqc.d.ts +51 -0
- package/pkg-bundler/stenvault_pqc_bg.js +25 -0
- package/pkg-bundler/stenvault_pqc_bg.wasm +0 -0
- package/pkg-bundler/stenvault_pqc_bg.wasm.d.ts +3 -3
- package/pkg-nodejs/LICENSE +21 -0
- package/pkg-nodejs/README.md +3 -1
- package/pkg-nodejs/package.json +2 -2
- package/pkg-nodejs/stenvault_pqc.d.ts +51 -0
- package/pkg-nodejs/stenvault_pqc.js +25 -0
- package/pkg-nodejs/stenvault_pqc_bg.wasm +0 -0
- package/pkg-nodejs/stenvault_pqc_bg.wasm.d.ts +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gefson Costa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -84,7 +84,9 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
|
|
|
84
84
|
- **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
|
|
85
85
|
- **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
|
|
86
86
|
- **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
|
|
87
|
-
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
87
|
+
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
88
|
+
- **GHSA-h37v-hp6w-2pp8**: Off-by-two in `ml-dsa` `use_hint` when `r0 = 0` (FIPS 204 Alg. 40 deviation), patched in `>= 0.1.0-rc.5`.
|
|
89
|
+
- Cargo.toml tracks `ml-dsa = "0.1"` (stable 0.1.1); the FIPS 204 seed API and WASM stack-overflow fix that justified the former `=0.1.0-rc.8` pin shipped in 0.1.0. Signing uses ML-DSA's deterministic variant.
|
|
88
90
|
- **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
|
|
89
91
|
|
|
90
92
|
## License
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gefson Costa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/pkg-bundler/README.md
CHANGED
|
@@ -84,7 +84,9 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
|
|
|
84
84
|
- **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
|
|
85
85
|
- **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
|
|
86
86
|
- **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
|
|
87
|
-
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
87
|
+
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
88
|
+
- **GHSA-h37v-hp6w-2pp8**: Off-by-two in `ml-dsa` `use_hint` when `r0 = 0` (FIPS 204 Alg. 40 deviation), patched in `>= 0.1.0-rc.5`.
|
|
89
|
+
- Cargo.toml tracks `ml-dsa = "0.1"` (stable 0.1.1); the FIPS 204 seed API and WASM stack-overflow fix that justified the former `=0.1.0-rc.8` pin shipped in 0.1.0. Signing uses ML-DSA's deterministic variant.
|
|
88
90
|
- **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
|
|
89
91
|
|
|
90
92
|
## License
|
package/pkg-bundler/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "stenvault-pqc",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "ML-KEM-768 + ML-DSA-65 WASM wrapper for StenVault",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"stenvault_pqc_bg.wasm",
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
"./stenvault_pqc.js",
|
|
17
17
|
"./snippets/*"
|
|
18
18
|
]
|
|
19
|
-
}
|
|
19
|
+
}
|
|
@@ -1,45 +1,96 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* ML-DSA-65 key pair (verifying key + 32-byte signing seed).
|
|
6
|
+
*/
|
|
4
7
|
export class MlDsa65KeyPair {
|
|
5
8
|
private constructor();
|
|
6
9
|
free(): void;
|
|
7
10
|
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Signing key as a 32-byte seed; expanded on demand during signing.
|
|
13
|
+
*/
|
|
8
14
|
readonly signing_key: Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Verifying (public) key, 1952 bytes.
|
|
17
|
+
*/
|
|
9
18
|
readonly verifying_key: Uint8Array;
|
|
10
19
|
}
|
|
11
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Output of ML-KEM-768 decapsulation: the recovered shared secret.
|
|
23
|
+
*/
|
|
12
24
|
export class MlKem768DecapResult {
|
|
13
25
|
private constructor();
|
|
14
26
|
free(): void;
|
|
15
27
|
[Symbol.dispose](): void;
|
|
28
|
+
/**
|
|
29
|
+
* Shared secret recovered from the ciphertext, 32 bytes.
|
|
30
|
+
*/
|
|
16
31
|
readonly shared_secret: Uint8Array;
|
|
17
32
|
}
|
|
18
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Output of ML-KEM-768 encapsulation: ciphertext + shared secret.
|
|
36
|
+
*/
|
|
19
37
|
export class MlKem768EncapResult {
|
|
20
38
|
private constructor();
|
|
21
39
|
free(): void;
|
|
22
40
|
[Symbol.dispose](): void;
|
|
41
|
+
/**
|
|
42
|
+
* Ciphertext to send to the decapsulator, 1088 bytes.
|
|
43
|
+
*/
|
|
23
44
|
readonly ciphertext: Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* Shared secret derived from encapsulation, 32 bytes.
|
|
47
|
+
*/
|
|
24
48
|
readonly shared_secret: Uint8Array;
|
|
25
49
|
}
|
|
26
50
|
|
|
51
|
+
/**
|
|
52
|
+
* ML-KEM-768 key pair (encapsulation + decapsulation key).
|
|
53
|
+
*/
|
|
27
54
|
export class MlKem768KeyPair {
|
|
28
55
|
private constructor();
|
|
29
56
|
free(): void;
|
|
30
57
|
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Decapsulation (private) key, 2400 bytes.
|
|
60
|
+
*/
|
|
31
61
|
readonly decapsulation_key: Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Encapsulation (public) key, 1184 bytes.
|
|
64
|
+
*/
|
|
32
65
|
readonly encapsulation_key: Uint8Array;
|
|
33
66
|
}
|
|
34
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Generate a fresh ML-DSA-65 key pair from 32 random seed bytes.
|
|
70
|
+
*/
|
|
35
71
|
export function ml_dsa_65_generate(): MlDsa65KeyPair;
|
|
36
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Sign `message` with a 32-byte ML-DSA-65 seed, returning a 3309-byte signature.
|
|
75
|
+
*/
|
|
37
76
|
export function ml_dsa_65_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8Array;
|
|
38
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Verify a 3309-byte ML-DSA-65 signature over `message` against a 1952-byte verifying key.
|
|
80
|
+
*/
|
|
39
81
|
export function ml_dsa_65_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
40
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Decapsulate a 1088-byte ciphertext with a 2400-byte decapsulation key.
|
|
85
|
+
*/
|
|
41
86
|
export function ml_kem_768_decapsulate(dk_bytes: Uint8Array, ct_bytes: Uint8Array): MlKem768DecapResult;
|
|
42
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Encapsulate a fresh shared secret to a 1184-byte encapsulation key.
|
|
90
|
+
*/
|
|
43
91
|
export function ml_kem_768_encapsulate(ek_bytes: Uint8Array): MlKem768EncapResult;
|
|
44
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Generate a fresh ML-KEM-768 key pair using OS randomness.
|
|
95
|
+
*/
|
|
45
96
|
export function ml_kem_768_generate(): MlKem768KeyPair;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ML-DSA-65 key pair (verifying key + 32-byte signing seed).
|
|
3
|
+
*/
|
|
1
4
|
export class MlDsa65KeyPair {
|
|
2
5
|
static __wrap(ptr) {
|
|
3
6
|
ptr = ptr >>> 0;
|
|
@@ -17,6 +20,7 @@ export class MlDsa65KeyPair {
|
|
|
17
20
|
wasm.__wbg_mldsa65keypair_free(ptr, 0);
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
23
|
+
* Signing key as a 32-byte seed; expanded on demand during signing.
|
|
20
24
|
* @returns {Uint8Array}
|
|
21
25
|
*/
|
|
22
26
|
get signing_key() {
|
|
@@ -26,6 +30,7 @@ export class MlDsa65KeyPair {
|
|
|
26
30
|
return v1;
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
33
|
+
* Verifying (public) key, 1952 bytes.
|
|
29
34
|
* @returns {Uint8Array}
|
|
30
35
|
*/
|
|
31
36
|
get verifying_key() {
|
|
@@ -37,6 +42,9 @@ export class MlDsa65KeyPair {
|
|
|
37
42
|
}
|
|
38
43
|
if (Symbol.dispose) MlDsa65KeyPair.prototype[Symbol.dispose] = MlDsa65KeyPair.prototype.free;
|
|
39
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Output of ML-KEM-768 decapsulation: the recovered shared secret.
|
|
47
|
+
*/
|
|
40
48
|
export class MlKem768DecapResult {
|
|
41
49
|
static __wrap(ptr) {
|
|
42
50
|
ptr = ptr >>> 0;
|
|
@@ -56,6 +64,7 @@ export class MlKem768DecapResult {
|
|
|
56
64
|
wasm.__wbg_mlkem768decapresult_free(ptr, 0);
|
|
57
65
|
}
|
|
58
66
|
/**
|
|
67
|
+
* Shared secret recovered from the ciphertext, 32 bytes.
|
|
59
68
|
* @returns {Uint8Array}
|
|
60
69
|
*/
|
|
61
70
|
get shared_secret() {
|
|
@@ -67,6 +76,9 @@ export class MlKem768DecapResult {
|
|
|
67
76
|
}
|
|
68
77
|
if (Symbol.dispose) MlKem768DecapResult.prototype[Symbol.dispose] = MlKem768DecapResult.prototype.free;
|
|
69
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Output of ML-KEM-768 encapsulation: ciphertext + shared secret.
|
|
81
|
+
*/
|
|
70
82
|
export class MlKem768EncapResult {
|
|
71
83
|
static __wrap(ptr) {
|
|
72
84
|
ptr = ptr >>> 0;
|
|
@@ -86,6 +98,7 @@ export class MlKem768EncapResult {
|
|
|
86
98
|
wasm.__wbg_mlkem768encapresult_free(ptr, 0);
|
|
87
99
|
}
|
|
88
100
|
/**
|
|
101
|
+
* Ciphertext to send to the decapsulator, 1088 bytes.
|
|
89
102
|
* @returns {Uint8Array}
|
|
90
103
|
*/
|
|
91
104
|
get ciphertext() {
|
|
@@ -95,6 +108,7 @@ export class MlKem768EncapResult {
|
|
|
95
108
|
return v1;
|
|
96
109
|
}
|
|
97
110
|
/**
|
|
111
|
+
* Shared secret derived from encapsulation, 32 bytes.
|
|
98
112
|
* @returns {Uint8Array}
|
|
99
113
|
*/
|
|
100
114
|
get shared_secret() {
|
|
@@ -106,6 +120,9 @@ export class MlKem768EncapResult {
|
|
|
106
120
|
}
|
|
107
121
|
if (Symbol.dispose) MlKem768EncapResult.prototype[Symbol.dispose] = MlKem768EncapResult.prototype.free;
|
|
108
122
|
|
|
123
|
+
/**
|
|
124
|
+
* ML-KEM-768 key pair (encapsulation + decapsulation key).
|
|
125
|
+
*/
|
|
109
126
|
export class MlKem768KeyPair {
|
|
110
127
|
static __wrap(ptr) {
|
|
111
128
|
ptr = ptr >>> 0;
|
|
@@ -125,6 +142,7 @@ export class MlKem768KeyPair {
|
|
|
125
142
|
wasm.__wbg_mlkem768keypair_free(ptr, 0);
|
|
126
143
|
}
|
|
127
144
|
/**
|
|
145
|
+
* Decapsulation (private) key, 2400 bytes.
|
|
128
146
|
* @returns {Uint8Array}
|
|
129
147
|
*/
|
|
130
148
|
get decapsulation_key() {
|
|
@@ -134,6 +152,7 @@ export class MlKem768KeyPair {
|
|
|
134
152
|
return v1;
|
|
135
153
|
}
|
|
136
154
|
/**
|
|
155
|
+
* Encapsulation (public) key, 1184 bytes.
|
|
137
156
|
* @returns {Uint8Array}
|
|
138
157
|
*/
|
|
139
158
|
get encapsulation_key() {
|
|
@@ -146,6 +165,7 @@ export class MlKem768KeyPair {
|
|
|
146
165
|
if (Symbol.dispose) MlKem768KeyPair.prototype[Symbol.dispose] = MlKem768KeyPair.prototype.free;
|
|
147
166
|
|
|
148
167
|
/**
|
|
168
|
+
* Generate a fresh ML-DSA-65 key pair from 32 random seed bytes.
|
|
149
169
|
* @returns {MlDsa65KeyPair}
|
|
150
170
|
*/
|
|
151
171
|
export function ml_dsa_65_generate() {
|
|
@@ -154,6 +174,7 @@ export function ml_dsa_65_generate() {
|
|
|
154
174
|
}
|
|
155
175
|
|
|
156
176
|
/**
|
|
177
|
+
* Sign `message` with a 32-byte ML-DSA-65 seed, returning a 3309-byte signature.
|
|
157
178
|
* @param {Uint8Array} sk_bytes
|
|
158
179
|
* @param {Uint8Array} message
|
|
159
180
|
* @returns {Uint8Array}
|
|
@@ -173,6 +194,7 @@ export function ml_dsa_65_sign(sk_bytes, message) {
|
|
|
173
194
|
}
|
|
174
195
|
|
|
175
196
|
/**
|
|
197
|
+
* Verify a 3309-byte ML-DSA-65 signature over `message` against a 1952-byte verifying key.
|
|
176
198
|
* @param {Uint8Array} vk_bytes
|
|
177
199
|
* @param {Uint8Array} message
|
|
178
200
|
* @param {Uint8Array} signature
|
|
@@ -193,6 +215,7 @@ export function ml_dsa_65_verify(vk_bytes, message, signature) {
|
|
|
193
215
|
}
|
|
194
216
|
|
|
195
217
|
/**
|
|
218
|
+
* Decapsulate a 1088-byte ciphertext with a 2400-byte decapsulation key.
|
|
196
219
|
* @param {Uint8Array} dk_bytes
|
|
197
220
|
* @param {Uint8Array} ct_bytes
|
|
198
221
|
* @returns {MlKem768DecapResult}
|
|
@@ -210,6 +233,7 @@ export function ml_kem_768_decapsulate(dk_bytes, ct_bytes) {
|
|
|
210
233
|
}
|
|
211
234
|
|
|
212
235
|
/**
|
|
236
|
+
* Encapsulate a fresh shared secret to a 1184-byte encapsulation key.
|
|
213
237
|
* @param {Uint8Array} ek_bytes
|
|
214
238
|
* @returns {MlKem768EncapResult}
|
|
215
239
|
*/
|
|
@@ -224,6 +248,7 @@ export function ml_kem_768_encapsulate(ek_bytes) {
|
|
|
224
248
|
}
|
|
225
249
|
|
|
226
250
|
/**
|
|
251
|
+
* Generate a fresh ML-KEM-768 key pair using OS randomness.
|
|
227
252
|
* @returns {MlKem768KeyPair}
|
|
228
253
|
*/
|
|
229
254
|
export function ml_kem_768_generate() {
|
|
Binary file
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_mldsa65keypair_free: (a: number, b: number) => void;
|
|
5
5
|
export const __wbg_mlkem768decapresult_free: (a: number, b: number) => void;
|
|
6
|
-
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
7
6
|
export const ml_dsa_65_generate: () => number;
|
|
8
7
|
export const ml_dsa_65_sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
8
|
export const ml_dsa_65_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
@@ -13,11 +12,12 @@ export const ml_kem_768_generate: () => number;
|
|
|
13
12
|
export const mldsa65keypair_signing_key: (a: number) => [number, number];
|
|
14
13
|
export const mldsa65keypair_verifying_key: (a: number) => [number, number];
|
|
15
14
|
export const mlkem768decapresult_shared_secret: (a: number) => [number, number];
|
|
15
|
+
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
16
|
+
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
16
17
|
export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
|
|
17
18
|
export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
|
|
18
|
-
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
19
|
-
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
20
19
|
export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
|
|
20
|
+
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
21
21
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
22
22
|
export const __externref_table_alloc: () => number;
|
|
23
23
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gefson Costa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/pkg-nodejs/README.md
CHANGED
|
@@ -84,7 +84,9 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
|
|
|
84
84
|
- **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
|
|
85
85
|
- **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
|
|
86
86
|
- **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
|
|
87
|
-
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
87
|
+
- **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
|
|
88
|
+
- **GHSA-h37v-hp6w-2pp8**: Off-by-two in `ml-dsa` `use_hint` when `r0 = 0` (FIPS 204 Alg. 40 deviation), patched in `>= 0.1.0-rc.5`.
|
|
89
|
+
- Cargo.toml tracks `ml-dsa = "0.1"` (stable 0.1.1); the FIPS 204 seed API and WASM stack-overflow fix that justified the former `=0.1.0-rc.8` pin shipped in 0.1.0. Signing uses ML-DSA's deterministic variant.
|
|
88
90
|
- **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
|
|
89
91
|
|
|
90
92
|
## License
|
package/pkg-nodejs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stenvault-pqc",
|
|
3
3
|
"description": "ML-KEM-768 + ML-DSA-65 WASM wrapper for StenVault",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"stenvault_pqc_bg.wasm",
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
],
|
|
11
11
|
"main": "stenvault_pqc.js",
|
|
12
12
|
"types": "stenvault_pqc.d.ts"
|
|
13
|
-
}
|
|
13
|
+
}
|
|
@@ -1,45 +1,96 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* ML-DSA-65 key pair (verifying key + 32-byte signing seed).
|
|
6
|
+
*/
|
|
4
7
|
export class MlDsa65KeyPair {
|
|
5
8
|
private constructor();
|
|
6
9
|
free(): void;
|
|
7
10
|
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Signing key as a 32-byte seed; expanded on demand during signing.
|
|
13
|
+
*/
|
|
8
14
|
readonly signing_key: Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Verifying (public) key, 1952 bytes.
|
|
17
|
+
*/
|
|
9
18
|
readonly verifying_key: Uint8Array;
|
|
10
19
|
}
|
|
11
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Output of ML-KEM-768 decapsulation: the recovered shared secret.
|
|
23
|
+
*/
|
|
12
24
|
export class MlKem768DecapResult {
|
|
13
25
|
private constructor();
|
|
14
26
|
free(): void;
|
|
15
27
|
[Symbol.dispose](): void;
|
|
28
|
+
/**
|
|
29
|
+
* Shared secret recovered from the ciphertext, 32 bytes.
|
|
30
|
+
*/
|
|
16
31
|
readonly shared_secret: Uint8Array;
|
|
17
32
|
}
|
|
18
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Output of ML-KEM-768 encapsulation: ciphertext + shared secret.
|
|
36
|
+
*/
|
|
19
37
|
export class MlKem768EncapResult {
|
|
20
38
|
private constructor();
|
|
21
39
|
free(): void;
|
|
22
40
|
[Symbol.dispose](): void;
|
|
41
|
+
/**
|
|
42
|
+
* Ciphertext to send to the decapsulator, 1088 bytes.
|
|
43
|
+
*/
|
|
23
44
|
readonly ciphertext: Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* Shared secret derived from encapsulation, 32 bytes.
|
|
47
|
+
*/
|
|
24
48
|
readonly shared_secret: Uint8Array;
|
|
25
49
|
}
|
|
26
50
|
|
|
51
|
+
/**
|
|
52
|
+
* ML-KEM-768 key pair (encapsulation + decapsulation key).
|
|
53
|
+
*/
|
|
27
54
|
export class MlKem768KeyPair {
|
|
28
55
|
private constructor();
|
|
29
56
|
free(): void;
|
|
30
57
|
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Decapsulation (private) key, 2400 bytes.
|
|
60
|
+
*/
|
|
31
61
|
readonly decapsulation_key: Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Encapsulation (public) key, 1184 bytes.
|
|
64
|
+
*/
|
|
32
65
|
readonly encapsulation_key: Uint8Array;
|
|
33
66
|
}
|
|
34
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Generate a fresh ML-DSA-65 key pair from 32 random seed bytes.
|
|
70
|
+
*/
|
|
35
71
|
export function ml_dsa_65_generate(): MlDsa65KeyPair;
|
|
36
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Sign `message` with a 32-byte ML-DSA-65 seed, returning a 3309-byte signature.
|
|
75
|
+
*/
|
|
37
76
|
export function ml_dsa_65_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8Array;
|
|
38
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Verify a 3309-byte ML-DSA-65 signature over `message` against a 1952-byte verifying key.
|
|
80
|
+
*/
|
|
39
81
|
export function ml_dsa_65_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
40
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Decapsulate a 1088-byte ciphertext with a 2400-byte decapsulation key.
|
|
85
|
+
*/
|
|
41
86
|
export function ml_kem_768_decapsulate(dk_bytes: Uint8Array, ct_bytes: Uint8Array): MlKem768DecapResult;
|
|
42
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Encapsulate a fresh shared secret to a 1184-byte encapsulation key.
|
|
90
|
+
*/
|
|
43
91
|
export function ml_kem_768_encapsulate(ek_bytes: Uint8Array): MlKem768EncapResult;
|
|
44
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Generate a fresh ML-KEM-768 key pair using OS randomness.
|
|
95
|
+
*/
|
|
45
96
|
export function ml_kem_768_generate(): MlKem768KeyPair;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/* @ts-self-types="./stenvault_pqc.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* ML-DSA-65 key pair (verifying key + 32-byte signing seed).
|
|
5
|
+
*/
|
|
3
6
|
class MlDsa65KeyPair {
|
|
4
7
|
static __wrap(ptr) {
|
|
5
8
|
ptr = ptr >>> 0;
|
|
@@ -19,6 +22,7 @@ class MlDsa65KeyPair {
|
|
|
19
22
|
wasm.__wbg_mldsa65keypair_free(ptr, 0);
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
25
|
+
* Signing key as a 32-byte seed; expanded on demand during signing.
|
|
22
26
|
* @returns {Uint8Array}
|
|
23
27
|
*/
|
|
24
28
|
get signing_key() {
|
|
@@ -28,6 +32,7 @@ class MlDsa65KeyPair {
|
|
|
28
32
|
return v1;
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
35
|
+
* Verifying (public) key, 1952 bytes.
|
|
31
36
|
* @returns {Uint8Array}
|
|
32
37
|
*/
|
|
33
38
|
get verifying_key() {
|
|
@@ -40,6 +45,9 @@ class MlDsa65KeyPair {
|
|
|
40
45
|
if (Symbol.dispose) MlDsa65KeyPair.prototype[Symbol.dispose] = MlDsa65KeyPair.prototype.free;
|
|
41
46
|
exports.MlDsa65KeyPair = MlDsa65KeyPair;
|
|
42
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Output of ML-KEM-768 decapsulation: the recovered shared secret.
|
|
50
|
+
*/
|
|
43
51
|
class MlKem768DecapResult {
|
|
44
52
|
static __wrap(ptr) {
|
|
45
53
|
ptr = ptr >>> 0;
|
|
@@ -59,6 +67,7 @@ class MlKem768DecapResult {
|
|
|
59
67
|
wasm.__wbg_mlkem768decapresult_free(ptr, 0);
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
70
|
+
* Shared secret recovered from the ciphertext, 32 bytes.
|
|
62
71
|
* @returns {Uint8Array}
|
|
63
72
|
*/
|
|
64
73
|
get shared_secret() {
|
|
@@ -71,6 +80,9 @@ class MlKem768DecapResult {
|
|
|
71
80
|
if (Symbol.dispose) MlKem768DecapResult.prototype[Symbol.dispose] = MlKem768DecapResult.prototype.free;
|
|
72
81
|
exports.MlKem768DecapResult = MlKem768DecapResult;
|
|
73
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Output of ML-KEM-768 encapsulation: ciphertext + shared secret.
|
|
85
|
+
*/
|
|
74
86
|
class MlKem768EncapResult {
|
|
75
87
|
static __wrap(ptr) {
|
|
76
88
|
ptr = ptr >>> 0;
|
|
@@ -90,6 +102,7 @@ class MlKem768EncapResult {
|
|
|
90
102
|
wasm.__wbg_mlkem768encapresult_free(ptr, 0);
|
|
91
103
|
}
|
|
92
104
|
/**
|
|
105
|
+
* Ciphertext to send to the decapsulator, 1088 bytes.
|
|
93
106
|
* @returns {Uint8Array}
|
|
94
107
|
*/
|
|
95
108
|
get ciphertext() {
|
|
@@ -99,6 +112,7 @@ class MlKem768EncapResult {
|
|
|
99
112
|
return v1;
|
|
100
113
|
}
|
|
101
114
|
/**
|
|
115
|
+
* Shared secret derived from encapsulation, 32 bytes.
|
|
102
116
|
* @returns {Uint8Array}
|
|
103
117
|
*/
|
|
104
118
|
get shared_secret() {
|
|
@@ -111,6 +125,9 @@ class MlKem768EncapResult {
|
|
|
111
125
|
if (Symbol.dispose) MlKem768EncapResult.prototype[Symbol.dispose] = MlKem768EncapResult.prototype.free;
|
|
112
126
|
exports.MlKem768EncapResult = MlKem768EncapResult;
|
|
113
127
|
|
|
128
|
+
/**
|
|
129
|
+
* ML-KEM-768 key pair (encapsulation + decapsulation key).
|
|
130
|
+
*/
|
|
114
131
|
class MlKem768KeyPair {
|
|
115
132
|
static __wrap(ptr) {
|
|
116
133
|
ptr = ptr >>> 0;
|
|
@@ -130,6 +147,7 @@ class MlKem768KeyPair {
|
|
|
130
147
|
wasm.__wbg_mlkem768keypair_free(ptr, 0);
|
|
131
148
|
}
|
|
132
149
|
/**
|
|
150
|
+
* Decapsulation (private) key, 2400 bytes.
|
|
133
151
|
* @returns {Uint8Array}
|
|
134
152
|
*/
|
|
135
153
|
get decapsulation_key() {
|
|
@@ -139,6 +157,7 @@ class MlKem768KeyPair {
|
|
|
139
157
|
return v1;
|
|
140
158
|
}
|
|
141
159
|
/**
|
|
160
|
+
* Encapsulation (public) key, 1184 bytes.
|
|
142
161
|
* @returns {Uint8Array}
|
|
143
162
|
*/
|
|
144
163
|
get encapsulation_key() {
|
|
@@ -152,6 +171,7 @@ if (Symbol.dispose) MlKem768KeyPair.prototype[Symbol.dispose] = MlKem768KeyPair.
|
|
|
152
171
|
exports.MlKem768KeyPair = MlKem768KeyPair;
|
|
153
172
|
|
|
154
173
|
/**
|
|
174
|
+
* Generate a fresh ML-DSA-65 key pair from 32 random seed bytes.
|
|
155
175
|
* @returns {MlDsa65KeyPair}
|
|
156
176
|
*/
|
|
157
177
|
function ml_dsa_65_generate() {
|
|
@@ -161,6 +181,7 @@ function ml_dsa_65_generate() {
|
|
|
161
181
|
exports.ml_dsa_65_generate = ml_dsa_65_generate;
|
|
162
182
|
|
|
163
183
|
/**
|
|
184
|
+
* Sign `message` with a 32-byte ML-DSA-65 seed, returning a 3309-byte signature.
|
|
164
185
|
* @param {Uint8Array} sk_bytes
|
|
165
186
|
* @param {Uint8Array} message
|
|
166
187
|
* @returns {Uint8Array}
|
|
@@ -181,6 +202,7 @@ function ml_dsa_65_sign(sk_bytes, message) {
|
|
|
181
202
|
exports.ml_dsa_65_sign = ml_dsa_65_sign;
|
|
182
203
|
|
|
183
204
|
/**
|
|
205
|
+
* Verify a 3309-byte ML-DSA-65 signature over `message` against a 1952-byte verifying key.
|
|
184
206
|
* @param {Uint8Array} vk_bytes
|
|
185
207
|
* @param {Uint8Array} message
|
|
186
208
|
* @param {Uint8Array} signature
|
|
@@ -202,6 +224,7 @@ function ml_dsa_65_verify(vk_bytes, message, signature) {
|
|
|
202
224
|
exports.ml_dsa_65_verify = ml_dsa_65_verify;
|
|
203
225
|
|
|
204
226
|
/**
|
|
227
|
+
* Decapsulate a 1088-byte ciphertext with a 2400-byte decapsulation key.
|
|
205
228
|
* @param {Uint8Array} dk_bytes
|
|
206
229
|
* @param {Uint8Array} ct_bytes
|
|
207
230
|
* @returns {MlKem768DecapResult}
|
|
@@ -220,6 +243,7 @@ function ml_kem_768_decapsulate(dk_bytes, ct_bytes) {
|
|
|
220
243
|
exports.ml_kem_768_decapsulate = ml_kem_768_decapsulate;
|
|
221
244
|
|
|
222
245
|
/**
|
|
246
|
+
* Encapsulate a fresh shared secret to a 1184-byte encapsulation key.
|
|
223
247
|
* @param {Uint8Array} ek_bytes
|
|
224
248
|
* @returns {MlKem768EncapResult}
|
|
225
249
|
*/
|
|
@@ -235,6 +259,7 @@ function ml_kem_768_encapsulate(ek_bytes) {
|
|
|
235
259
|
exports.ml_kem_768_encapsulate = ml_kem_768_encapsulate;
|
|
236
260
|
|
|
237
261
|
/**
|
|
262
|
+
* Generate a fresh ML-KEM-768 key pair using OS randomness.
|
|
238
263
|
* @returns {MlKem768KeyPair}
|
|
239
264
|
*/
|
|
240
265
|
function ml_kem_768_generate() {
|
|
Binary file
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_mldsa65keypair_free: (a: number, b: number) => void;
|
|
5
5
|
export const __wbg_mlkem768decapresult_free: (a: number, b: number) => void;
|
|
6
|
-
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
7
6
|
export const ml_dsa_65_generate: () => number;
|
|
8
7
|
export const ml_dsa_65_sign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
8
|
export const ml_dsa_65_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
@@ -13,11 +12,12 @@ export const ml_kem_768_generate: () => number;
|
|
|
13
12
|
export const mldsa65keypair_signing_key: (a: number) => [number, number];
|
|
14
13
|
export const mldsa65keypair_verifying_key: (a: number) => [number, number];
|
|
15
14
|
export const mlkem768decapresult_shared_secret: (a: number) => [number, number];
|
|
15
|
+
export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
|
|
16
|
+
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
16
17
|
export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
|
|
17
18
|
export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
|
|
18
|
-
export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
|
|
19
|
-
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
20
19
|
export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
|
|
20
|
+
export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
|
|
21
21
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
22
22
|
export const __externref_table_alloc: () => number;
|
|
23
23
|
export const __wbindgen_externrefs: WebAssembly.Table;
|