@stenvault/pqc-wasm 0.2.1 → 0.3.0

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/README.md CHANGED
@@ -21,6 +21,17 @@ wasm-pack build --target bundler --release --out-dir pkg-bundler
21
21
  wasm-pack build --target nodejs --release --out-dir pkg-nodejs
22
22
  ```
23
23
 
24
+ ## Test
25
+
26
+ ```bash
27
+ cargo test # Rust unit tests (native target)
28
+ npm test # interop, FIPS 203 input checks and Wycheproof vectors, against the pkg-nodejs build
29
+ npm run test:fips203-scan # every single-byte change of one public key, checked against noble (~2.5 min)
30
+ ```
31
+
32
+ The FIPS 203 tests draw their samples from a seed that is printed in the output.
33
+ `FIPS203_SEED=<n> npm test` replays a run.
34
+
24
35
  ## API
25
36
 
26
37
  ```typescript
@@ -53,6 +64,21 @@ const signature = await sign(message, sigKp.secretKey)
53
64
  const valid = await verify(message, signature, sigKp.publicKey)
54
65
  ```
55
66
 
67
+ ### ML-KEM input errors
68
+
69
+ `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys:
70
+
71
+ | Function | Message | Cause |
72
+ |----------|---------|-------|
73
+ | `encapsulate` | `invalid encapsulation key length: expected 1184 bytes` | wrong length |
74
+ | `encapsulate` | `encapsulation key is not canonical` | a 12-bit coefficient of `publicKey[0..1152]` is ≥ 3329 (FIPS 203 §7.2) |
75
+ | `decapsulate` | `invalid decapsulation key length: expected 2400 bytes` | wrong length |
76
+ | `decapsulate` | `invalid ciphertext length: expected 1088 bytes` | wrong length |
77
+ | `decapsulate` | `decapsulation key hash check failed` | SHA3-256 of the public key inside `secretKey` differs from the hash stored after it (FIPS 203 §7.3) |
78
+
79
+ A corrupted ciphertext does not throw. `decapsulate` returns ML-KEM's
80
+ implicit-rejection secret, which does not match the sender's.
81
+
56
82
  ## Architecture
57
83
 
58
84
  ```
@@ -82,11 +108,12 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
82
108
 
83
109
  - **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
84
110
  - **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
111
+ - **FIPS 203 input checks**: `encapsulate` runs the §7.2 modulus check and `decapsulate` the §7.3 hash check before calling `ml-kem`. `ml-kem` 0.2.x skips both: it reduces out-of-range key coefficients mod q and trusts the stored hash.
85
112
  - **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
86
113
  - **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
87
114
  - **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
88
115
  - **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 pins `= 0.1.0-rc.8` (FIPS 204 seed API + WASM stack-overflow fix via PRs #1259 + #1261).
116
+ - 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.
90
117
  - **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
91
118
 
92
119
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stenvault/pqc-wasm",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "ML-KEM-768 + ML-DSA-65 WASM wrapper — RustCrypto compiled to WebAssembly",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,9 +39,11 @@
39
39
  "postbuild:wasm": "rm -f pkg-bundler/.gitignore pkg-nodejs/.gitignore",
40
40
  "build:ts": "tsc",
41
41
  "build": "npm run build:wasm && npm run build:ts",
42
- "test": "npx tsx tests/interop.ts"
42
+ "test": "npx tsx tests/interop.ts && npx tsx tests/fips203.ts && npx tsx tests/wycheproof.ts",
43
+ "test:fips203-scan": "npx tsx tests/fips203.ts --full-scan"
43
44
  },
44
45
  "devDependencies": {
46
+ "@noble/post-quantum": "^0.6.1",
45
47
  "@openforge-sh/liboqs": "^0.14.3",
46
48
  "tsx": "^4.21.0",
47
49
  "typescript": "^5.7.0"
@@ -21,6 +21,17 @@ wasm-pack build --target bundler --release --out-dir pkg-bundler
21
21
  wasm-pack build --target nodejs --release --out-dir pkg-nodejs
22
22
  ```
23
23
 
24
+ ## Test
25
+
26
+ ```bash
27
+ cargo test # Rust unit tests (native target)
28
+ npm test # interop, FIPS 203 input checks and Wycheproof vectors, against the pkg-nodejs build
29
+ npm run test:fips203-scan # every single-byte change of one public key, checked against noble (~2.5 min)
30
+ ```
31
+
32
+ The FIPS 203 tests draw their samples from a seed that is printed in the output.
33
+ `FIPS203_SEED=<n> npm test` replays a run.
34
+
24
35
  ## API
25
36
 
26
37
  ```typescript
@@ -53,6 +64,21 @@ const signature = await sign(message, sigKp.secretKey)
53
64
  const valid = await verify(message, signature, sigKp.publicKey)
54
65
  ```
55
66
 
67
+ ### ML-KEM input errors
68
+
69
+ `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys:
70
+
71
+ | Function | Message | Cause |
72
+ |----------|---------|-------|
73
+ | `encapsulate` | `invalid encapsulation key length: expected 1184 bytes` | wrong length |
74
+ | `encapsulate` | `encapsulation key is not canonical` | a 12-bit coefficient of `publicKey[0..1152]` is ≥ 3329 (FIPS 203 §7.2) |
75
+ | `decapsulate` | `invalid decapsulation key length: expected 2400 bytes` | wrong length |
76
+ | `decapsulate` | `invalid ciphertext length: expected 1088 bytes` | wrong length |
77
+ | `decapsulate` | `decapsulation key hash check failed` | SHA3-256 of the public key inside `secretKey` differs from the hash stored after it (FIPS 203 §7.3) |
78
+
79
+ A corrupted ciphertext does not throw. `decapsulate` returns ML-KEM's
80
+ implicit-rejection secret, which does not match the sender's.
81
+
56
82
  ## Architecture
57
83
 
58
84
  ```
@@ -82,11 +108,12 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
82
108
 
83
109
  - **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
84
110
  - **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
111
+ - **FIPS 203 input checks**: `encapsulate` runs the §7.2 modulus check and `decapsulate` the §7.3 hash check before calling `ml-kem`. `ml-kem` 0.2.x skips both: it reduces out-of-range key coefficients mod q and trusts the stored hash.
85
112
  - **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
86
113
  - **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
87
114
  - **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
88
115
  - **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 pins `= 0.1.0-rc.8` (FIPS 204 seed API + WASM stack-overflow fix via PRs #1259 + #1261).
116
+ - 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.
90
117
  - **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
91
118
 
92
119
  ## License
@@ -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.0",
5
+ "version": "0.3.0",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "stenvault_pqc_bg.wasm",
Binary file
@@ -14,10 +14,10 @@ export const mldsa65keypair_verifying_key: (a: number) => [number, number];
14
14
  export const mlkem768decapresult_shared_secret: (a: number) => [number, number];
15
15
  export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
16
16
  export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
17
- export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
18
- export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
19
- export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
20
17
  export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
18
+ export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
19
+ export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
20
+ export const mlkem768encapresult_ciphertext: (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;
@@ -21,6 +21,17 @@ wasm-pack build --target bundler --release --out-dir pkg-bundler
21
21
  wasm-pack build --target nodejs --release --out-dir pkg-nodejs
22
22
  ```
23
23
 
24
+ ## Test
25
+
26
+ ```bash
27
+ cargo test # Rust unit tests (native target)
28
+ npm test # interop, FIPS 203 input checks and Wycheproof vectors, against the pkg-nodejs build
29
+ npm run test:fips203-scan # every single-byte change of one public key, checked against noble (~2.5 min)
30
+ ```
31
+
32
+ The FIPS 203 tests draw their samples from a seed that is printed in the output.
33
+ `FIPS203_SEED=<n> npm test` replays a run.
34
+
24
35
  ## API
25
36
 
26
37
  ```typescript
@@ -53,6 +64,21 @@ const signature = await sign(message, sigKp.secretKey)
53
64
  const valid = await verify(message, signature, sigKp.publicKey)
54
65
  ```
55
66
 
67
+ ### ML-KEM input errors
68
+
69
+ `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys:
70
+
71
+ | Function | Message | Cause |
72
+ |----------|---------|-------|
73
+ | `encapsulate` | `invalid encapsulation key length: expected 1184 bytes` | wrong length |
74
+ | `encapsulate` | `encapsulation key is not canonical` | a 12-bit coefficient of `publicKey[0..1152]` is ≥ 3329 (FIPS 203 §7.2) |
75
+ | `decapsulate` | `invalid decapsulation key length: expected 2400 bytes` | wrong length |
76
+ | `decapsulate` | `invalid ciphertext length: expected 1088 bytes` | wrong length |
77
+ | `decapsulate` | `decapsulation key hash check failed` | SHA3-256 of the public key inside `secretKey` differs from the hash stored after it (FIPS 203 §7.3) |
78
+
79
+ A corrupted ciphertext does not throw. `decapsulate` returns ML-KEM's
80
+ implicit-rejection secret, which does not match the sender's.
81
+
56
82
  ## Architecture
57
83
 
58
84
  ```
@@ -82,11 +108,12 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
82
108
 
83
109
  - **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
84
110
  - **Memory zeroing**: `zeroize` crate with `#[derive(ZeroizeOnDrop)]` on all secret-holding structs
111
+ - **FIPS 203 input checks**: `encapsulate` runs the §7.2 modulus check and `decapsulate` the §7.3 hash check before calling `ml-kem`. `ml-kem` 0.2.x skips both: it reduces out-of-range key coefficients mod q and trusts the stored hash.
85
112
  - **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
86
113
  - **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
87
114
  - **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
88
115
  - **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 pins `= 0.1.0-rc.8` (FIPS 204 seed API + WASM stack-overflow fix via PRs #1259 + #1261).
116
+ - 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.
90
117
  - **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
91
118
 
92
119
  ## License
@@ -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.0",
4
+ "version": "0.3.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "stenvault_pqc_bg.wasm",
Binary file
@@ -14,10 +14,10 @@ export const mldsa65keypair_verifying_key: (a: number) => [number, number];
14
14
  export const mlkem768decapresult_shared_secret: (a: number) => [number, number];
15
15
  export const __wbg_mlkem768encapresult_free: (a: number, b: number) => void;
16
16
  export const __wbg_mlkem768keypair_free: (a: number, b: number) => void;
17
- export const mlkem768encapresult_ciphertext: (a: number) => [number, number];
18
- export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
19
- export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
20
17
  export const mlkem768keypair_encapsulation_key: (a: number) => [number, number];
18
+ export const mlkem768keypair_decapsulation_key: (a: number) => [number, number];
19
+ export const mlkem768encapresult_shared_secret: (a: number) => [number, number];
20
+ export const mlkem768encapresult_ciphertext: (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;