@stenvault/pqc-wasm 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @stenvault/pqc-wasm
2
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.
3
+ Post-quantum cryptography WASM wrapper for StenVault — ML-KEM-768 and ML-KEM-1024 (FIPS 203), ML-DSA-65 and ML-DSA-87 (FIPS 204), compiled from RustCrypto crates to WebAssembly.
4
4
 
5
5
  ## Why
6
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).
7
+ Replaces `@openforge-sh/liboqs`, an unofficial wrapper of the liboqs C library, with a self-maintained Rust→WASM build of the RustCrypto `ml-kem` and `ml-dsa` crates.
8
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.
9
+ RustCrypto writes these crates to run in constant time, with `ctutils` for selections and comparisons. Neither WebAssembly nor a JavaScript engine guarantees that compiled code keeps that property, and this package has not verified it on the final `.wasm`. `npm run test:timing` checks total running time statistically; see Security for what it does not cover.
10
10
 
11
11
  ## Build
12
12
 
@@ -25,10 +25,19 @@ wasm-pack build --target nodejs --release --out-dir pkg-nodejs
25
25
 
26
26
  ```bash
27
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)
28
+ npm test # copies of secrets in the JS layer (fake bindings), then interop, FIPS 203 input checks, Wycheproof vectors and memory wiping against the pkg-nodejs build
29
+ npm run test:fips203-scan # every single-byte change of one public key per ML-KEM parameter set, checked against noble
30
+ npm run test:timing # dudect-style timing test of decapsulation and signing, not part of npm test
30
31
  ```
31
32
 
33
+ The Kani proofs in `proofs/` (CI, on pull requests and `main`) check that the
34
+ key and ciphertext types have the sizes the wrapper converts into, that ML-DSA
35
+ verifying keys and signatures one byte short are rejected, and that two
36
+ 32-byte seed conversions cannot panic. They prove nothing about the
37
+ cryptography or its timing. Key and ciphertext decoding is fuzzed instead, by
38
+ the cargo-fuzz targets in `fuzz/` (ML-KEM-768 and ML-DSA-65). The global
39
+ allocator, the crate's only `unsafe` code, is tested under Miri in CI.
40
+
32
41
  The FIPS 203 tests draw their samples from a seed that is printed in the output.
33
42
  `FIPS203_SEED=<n> npm test` replays a run.
34
43
 
@@ -64,17 +73,41 @@ const signature = await sign(message, sigKp.secretKey)
64
73
  const valid = await verify(message, signature, sigKp.publicKey)
65
74
  ```
66
75
 
76
+ Every parameter set is also an object with the same methods, so moving to
77
+ another security level means passing another object. The top-level functions
78
+ above are ML-KEM-768 and ML-DSA-65.
79
+
80
+ ```typescript
81
+ import { mlKem768, mlKem1024, mlDsa65, mlDsa87, type Kem, type SignatureScheme } from '@stenvault/pqc-wasm'
82
+
83
+ const kem: Kem = mlKem1024
84
+ const kp = await kem.generateKeyPair()
85
+ const { ciphertext, sharedSecret } = await kem.encapsulate(kp.publicKey)
86
+ const decrypted = await kem.decapsulate(ciphertext, kp.secretKey)
87
+
88
+ const dsa: SignatureScheme = mlDsa87
89
+ const sigKp = await dsa.generateKeyPair()
90
+ const signature = await dsa.sign(message, sigKp.secretKey)
91
+ const valid = await dsa.verify(message, signature, sigKp.publicKey)
92
+ ```
93
+
94
+ A key belongs to one parameter set: an ML-KEM-768 key passed to `mlKem1024`
95
+ fails its length check, and the same holds for ML-DSA.
96
+
67
97
  ### ML-KEM input errors
68
98
 
69
- `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys:
99
+ `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys.
100
+ The lengths are those of the parameter set (see Key sizes); the messages below
101
+ are ML-KEM-768's.
70
102
 
71
103
  | Function | Message | Cause |
72
104
  |----------|---------|-------|
73
105
  | `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) |
106
+ | `encapsulate` | `encapsulation key is not canonical` | a 12-bit coefficient of the public key, all but its last 32 bytes, is ≥ 3329 (FIPS 203 §7.2) |
75
107
  | `decapsulate` | `invalid decapsulation key length: expected 2400 bytes` | wrong length |
76
108
  | `decapsulate` | `invalid ciphertext length: expected 1088 bytes` | wrong length |
77
109
  | `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) |
110
+ | `decapsulate` | `decapsulation key embeds a non-canonical encapsulation key` | the hash matches, but a 12-bit coefficient of the public key inside `secretKey` is ≥ 3329 (the §7.2 check, applied to that key); key generation never produces such a key |
78
111
 
79
112
  A corrupted ciphertext does not throw. `decapsulate` returns ML-KEM's
80
113
  implicit-rejection secret, which does not match the sender's.
@@ -86,11 +119,11 @@ Consumer (StenVault)
86
119
  ↓ imports from "@stenvault/pqc-wasm"
87
120
  index.browser.ts / index.node.ts ← ensurePqcInit() + re-export
88
121
  ↓
89
- core.ts ← free() in try/finally, param order normalization
122
+ core.ts ← free() in try/finally, param order normalization, each getter read once and returned as is
90
123
  ↓
91
124
  pkg-bundler/ or pkg-nodejs/ ← wasm-bindgen generated bindings
92
125
  ↓
93
- src/lib.rs ← 7 Rust functions, zeroize on Drop
126
+ src/lib.rs ← 12 exported Rust functions, memory wiped after each call
94
127
  ↓
95
128
  ml-kem + ml-dsa (RustCrypto) ← FIPS 203/204 implementations
96
129
  ```
@@ -102,19 +135,23 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
102
135
  | Algorithm | Public Key | Secret Key | Ciphertext | Signature | Shared Secret |
103
136
  |-----------|-----------|-----------|-----------|----------|--------------|
104
137
  | ML-KEM-768 | 1,184 B | 2,400 B | 1,088 B | — | 32 B |
138
+ | ML-KEM-1024 | 1,568 B | 3,168 B | 1,568 B | — | 32 B |
105
139
  | ML-DSA-65 | 1,952 B | 32 B (seed) | — | 3,309 B | — |
140
+ | ML-DSA-87 | 2,592 B | 32 B (seed) | — | 4,627 B | — |
106
141
 
107
142
  ## Security
108
143
 
109
- - **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
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.
112
- - **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
144
+ - **Constant time**: RustCrypto writes `ml-kem` and `ml-dsa` to run in constant time, with `ctutils`. Whether the compiled `.wasm` keeps that is not verified (see SECURITY.md, Known Limitations). `npm run test:timing` finds no timing difference between valid and invalid ciphertexts in decapsulation, or between seeds in signing, in Node 24.
145
+ - **Memory wiping**: every heap block is zeroed before it is freed, and each operation then overwrites the part of the stack it used, so no secret key, seed or shared secret is left in the module's memory after a call. `tests/memory.ts` scans the memory after every operation. Each secret leaves the module's memory once, as the `Uint8Array` returned to the caller, and the package keeps no other copy (`tests/core.ts`): that array is the one to overwrite with `fill(0)` when done. This keeps the copies down but is not a full guarantee: the JavaScript engine's garbage collector and JIT may copy the bytes where no code can reach them. In V8, for example, small arrays such as 32-byte secrets live inside the JavaScript heap, which the garbage collector moves.
146
+ - **FIPS 203 input checks**: `encapsulate` runs the §7.2 modulus check; `decapsulate` runs the §7.3 hash check, then the §7.2 check on the public key inside the secret key. `ml-kem` 0.3 runs the same checks; this package runs its own first, so the errors do not depend on the crate.
147
+ - **No audit**: Neither RustCrypto nor this wrapper have been independently audited.
113
148
  - **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
114
149
  - **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
115
150
  - **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`.
116
151
  - **RUSTSEC-2026-0385**: Non-constant-time mask generation and `u128` comparisons in `ctutils`, which `ml-dsa` uses for constant-time selection, patched in `ctutils >= 0.4.4` (this package: 0.3.1).
117
- - Cargo.toml requires `ml-dsa >= 0.1.2`, the first release that pulls a patched `ctutils`. Signing uses ML-DSA's deterministic variant.
152
+ - Cargo.toml requires `ml-dsa >= 0.1.2`, the first release that pulls a patched `ctutils`.
153
+ - Cargo.toml requires `ml-kem >= 0.3.4`, which removed a secret-indexed table lookup from noise sampling and made the conditional subtraction mod q constant-time.
154
+ - **Hedged signing**: `sign` uses FIPS 204's default, hedged variant: each signature mixes in 32 fresh bytes from `crypto.getRandomValues`, so two signatures of the same message differ. That keeps a fault or a side channel from being lined up across repeated signings. With those bytes pinned to zero it gives the deterministic variant, which the tests use to compare against known-answer vectors. If no randomness is available, `sign` throws instead of signing.
118
155
  - **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
119
156
 
120
157
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stenvault/pqc-wasm",
3
- "version": "0.3.1",
4
- "description": "ML-KEM-768 + ML-DSA-65 WASM wrapper — RustCrypto compiled to WebAssembly",
3
+ "version": "0.4.1",
4
+ "description": "ML-KEM-768/1024 + ML-DSA-65/87 WASM wrapper — RustCrypto compiled to WebAssembly",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -39,8 +39,9 @@
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 && npx tsx tests/fips203.ts && npx tsx tests/wycheproof.ts",
43
- "test:fips203-scan": "npx tsx tests/fips203.ts --full-scan"
42
+ "test": "npx tsx tests/core.ts && npx tsx tests/interop.ts && npx tsx tests/fips203.ts && npx tsx tests/wycheproof.ts && npx tsx tests/memory.ts",
43
+ "test:fips203-scan": "npx tsx tests/fips203.ts --full-scan",
44
+ "test:timing": "npx tsx tests/timing.ts"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@noble/post-quantum": "^0.6.1",
@@ -1,12 +1,12 @@
1
1
  # @stenvault/pqc-wasm
2
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.
3
+ Post-quantum cryptography WASM wrapper for StenVault — ML-KEM-768 and ML-KEM-1024 (FIPS 203), ML-DSA-65 and ML-DSA-87 (FIPS 204), compiled from RustCrypto crates to WebAssembly.
4
4
 
5
5
  ## Why
6
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).
7
+ Replaces `@openforge-sh/liboqs`, an unofficial wrapper of the liboqs C library, with a self-maintained Rust→WASM build of the RustCrypto `ml-kem` and `ml-dsa` crates.
8
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.
9
+ RustCrypto writes these crates to run in constant time, with `ctutils` for selections and comparisons. Neither WebAssembly nor a JavaScript engine guarantees that compiled code keeps that property, and this package has not verified it on the final `.wasm`. `npm run test:timing` checks total running time statistically; see Security for what it does not cover.
10
10
 
11
11
  ## Build
12
12
 
@@ -25,10 +25,19 @@ wasm-pack build --target nodejs --release --out-dir pkg-nodejs
25
25
 
26
26
  ```bash
27
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)
28
+ npm test # copies of secrets in the JS layer (fake bindings), then interop, FIPS 203 input checks, Wycheproof vectors and memory wiping against the pkg-nodejs build
29
+ npm run test:fips203-scan # every single-byte change of one public key per ML-KEM parameter set, checked against noble
30
+ npm run test:timing # dudect-style timing test of decapsulation and signing, not part of npm test
30
31
  ```
31
32
 
33
+ The Kani proofs in `proofs/` (CI, on pull requests and `main`) check that the
34
+ key and ciphertext types have the sizes the wrapper converts into, that ML-DSA
35
+ verifying keys and signatures one byte short are rejected, and that two
36
+ 32-byte seed conversions cannot panic. They prove nothing about the
37
+ cryptography or its timing. Key and ciphertext decoding is fuzzed instead, by
38
+ the cargo-fuzz targets in `fuzz/` (ML-KEM-768 and ML-DSA-65). The global
39
+ allocator, the crate's only `unsafe` code, is tested under Miri in CI.
40
+
32
41
  The FIPS 203 tests draw their samples from a seed that is printed in the output.
33
42
  `FIPS203_SEED=<n> npm test` replays a run.
34
43
 
@@ -64,17 +73,41 @@ const signature = await sign(message, sigKp.secretKey)
64
73
  const valid = await verify(message, signature, sigKp.publicKey)
65
74
  ```
66
75
 
76
+ Every parameter set is also an object with the same methods, so moving to
77
+ another security level means passing another object. The top-level functions
78
+ above are ML-KEM-768 and ML-DSA-65.
79
+
80
+ ```typescript
81
+ import { mlKem768, mlKem1024, mlDsa65, mlDsa87, type Kem, type SignatureScheme } from '@stenvault/pqc-wasm'
82
+
83
+ const kem: Kem = mlKem1024
84
+ const kp = await kem.generateKeyPair()
85
+ const { ciphertext, sharedSecret } = await kem.encapsulate(kp.publicKey)
86
+ const decrypted = await kem.decapsulate(ciphertext, kp.secretKey)
87
+
88
+ const dsa: SignatureScheme = mlDsa87
89
+ const sigKp = await dsa.generateKeyPair()
90
+ const signature = await dsa.sign(message, sigKp.secretKey)
91
+ const valid = await dsa.verify(message, signature, sigKp.publicKey)
92
+ ```
93
+
94
+ A key belongs to one parameter set: an ML-KEM-768 key passed to `mlKem1024`
95
+ fails its length check, and the same holds for ML-DSA.
96
+
67
97
  ### ML-KEM input errors
68
98
 
69
- `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys:
99
+ `encapsulate` and `decapsulate` reject (the promise throws) on malformed keys.
100
+ The lengths are those of the parameter set (see Key sizes); the messages below
101
+ are ML-KEM-768's.
70
102
 
71
103
  | Function | Message | Cause |
72
104
  |----------|---------|-------|
73
105
  | `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) |
106
+ | `encapsulate` | `encapsulation key is not canonical` | a 12-bit coefficient of the public key, all but its last 32 bytes, is ≥ 3329 (FIPS 203 §7.2) |
75
107
  | `decapsulate` | `invalid decapsulation key length: expected 2400 bytes` | wrong length |
76
108
  | `decapsulate` | `invalid ciphertext length: expected 1088 bytes` | wrong length |
77
109
  | `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) |
110
+ | `decapsulate` | `decapsulation key embeds a non-canonical encapsulation key` | the hash matches, but a 12-bit coefficient of the public key inside `secretKey` is ≥ 3329 (the §7.2 check, applied to that key); key generation never produces such a key |
78
111
 
79
112
  A corrupted ciphertext does not throw. `decapsulate` returns ML-KEM's
80
113
  implicit-rejection secret, which does not match the sender's.
@@ -86,11 +119,11 @@ Consumer (StenVault)
86
119
  ↓ imports from "@stenvault/pqc-wasm"
87
120
  index.browser.ts / index.node.ts ← ensurePqcInit() + re-export
88
121
  ↓
89
- core.ts ← free() in try/finally, param order normalization
122
+ core.ts ← free() in try/finally, param order normalization, each getter read once and returned as is
90
123
  ↓
91
124
  pkg-bundler/ or pkg-nodejs/ ← wasm-bindgen generated bindings
92
125
  ↓
93
- src/lib.rs ← 7 Rust functions, zeroize on Drop
126
+ src/lib.rs ← 12 exported Rust functions, memory wiped after each call
94
127
  ↓
95
128
  ml-kem + ml-dsa (RustCrypto) ← FIPS 203/204 implementations
96
129
  ```
@@ -102,19 +135,23 @@ The consumer never calls `free()`, never calls `init()`, and never imports from
102
135
  | Algorithm | Public Key | Secret Key | Ciphertext | Signature | Shared Secret |
103
136
  |-----------|-----------|-----------|-----------|----------|--------------|
104
137
  | ML-KEM-768 | 1,184 B | 2,400 B | 1,088 B | — | 32 B |
138
+ | ML-KEM-1024 | 1,568 B | 3,168 B | 1,568 B | — | 32 B |
105
139
  | ML-DSA-65 | 1,952 B | 32 B (seed) | — | 3,309 B | — |
140
+ | ML-DSA-87 | 2,592 B | 32 B (seed) | — | 4,627 B | — |
106
141
 
107
142
  ## Security
108
143
 
109
- - **Constant-time**: `subtle` crate in Rust, preserved through WASM compilation
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.
112
- - **No audit**: Neither RustCrypto nor this wrapper have been independently audited. RustCrypto is honest about this.
144
+ - **Constant time**: RustCrypto writes `ml-kem` and `ml-dsa` to run in constant time, with `ctutils`. Whether the compiled `.wasm` keeps that is not verified (see SECURITY.md, Known Limitations). `npm run test:timing` finds no timing difference between valid and invalid ciphertexts in decapsulation, or between seeds in signing, in Node 24.
145
+ - **Memory wiping**: every heap block is zeroed before it is freed, and each operation then overwrites the part of the stack it used, so no secret key, seed or shared secret is left in the module's memory after a call. `tests/memory.ts` scans the memory after every operation. Each secret leaves the module's memory once, as the `Uint8Array` returned to the caller, and the package keeps no other copy (`tests/core.ts`): that array is the one to overwrite with `fill(0)` when done. This keeps the copies down but is not a full guarantee: the JavaScript engine's garbage collector and JIT may copy the bytes where no code can reach them. In V8, for example, small arrays such as 32-byte secrets live inside the JavaScript heap, which the garbage collector moves.
146
+ - **FIPS 203 input checks**: `encapsulate` runs the §7.2 modulus check; `decapsulate` runs the §7.3 hash check, then the §7.2 check on the public key inside the secret key. `ml-kem` 0.3 runs the same checks; this package runs its own first, so the errors do not depend on the crate.
147
+ - **No audit**: Neither RustCrypto nor this wrapper have been independently audited.
113
148
  - **CVE-2026-22705**: Timing side-channel in `ml-dsa` Decompose function, patched in `>= 0.1.0-rc.3` (Barrett reduction).
114
149
  - **CVE-2026-24850**: Signature malleability via duplicate hint indices in `ml-dsa`, patched in `>= 0.1.0-rc.4`.
115
150
  - **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`.
116
151
  - **RUSTSEC-2026-0385**: Non-constant-time mask generation and `u128` comparisons in `ctutils`, which `ml-dsa` uses for constant-time selection, patched in `ctutils >= 0.4.4` (this package: 0.3.1).
117
- - Cargo.toml requires `ml-dsa >= 0.1.2`, the first release that pulls a patched `ctutils`. Signing uses ML-DSA's deterministic variant.
152
+ - Cargo.toml requires `ml-dsa >= 0.1.2`, the first release that pulls a patched `ctutils`.
153
+ - Cargo.toml requires `ml-kem >= 0.3.4`, which removed a secret-indexed table lookup from noise sampling and made the conditional subtraction mod q constant-time.
154
+ - **Hedged signing**: `sign` uses FIPS 204's default, hedged variant: each signature mixes in 32 fresh bytes from `crypto.getRandomValues`, so two signatures of the same message differ. That keeps a fault or a side channel from being lined up across repeated signings. With those bytes pinned to zero it gives the deterministic variant, which the tests use to compare against known-answer vectors. If no randomness is available, `sign` throws instead of signing.
118
155
  - **Supply chain**: `Cargo.lock` committed, CI runs `cargo audit` before every build.
119
156
 
120
157
  ## License
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "stenvault-pqc",
3
3
  "type": "module",
4
- "description": "ML-KEM-768 + ML-DSA-65 WASM wrapper for StenVault",
5
- "version": "0.3.1",
4
+ "description": "ML-KEM-768/1024 + ML-DSA-65/87 WASM wrapper for StenVault",
5
+ "version": "0.4.1",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "stenvault_pqc_bg.wasm",
@@ -18,6 +18,70 @@ export class MlDsa65KeyPair {
18
18
  readonly verifying_key: Uint8Array;
19
19
  }
20
20
 
21
+ /**
22
+ * ML-DSA-87 key pair (verifying key + 32-byte signing seed).
23
+ */
24
+ export class MlDsa87KeyPair {
25
+ private constructor();
26
+ free(): void;
27
+ [Symbol.dispose](): void;
28
+ /**
29
+ * Signing key as a 32-byte seed; expanded on demand during signing.
30
+ */
31
+ readonly signing_key: Uint8Array;
32
+ /**
33
+ * Verifying (public) key, 2592 bytes.
34
+ */
35
+ readonly verifying_key: Uint8Array;
36
+ }
37
+
38
+ /**
39
+ * Output of ML-KEM-1024 decapsulation: the recovered shared secret.
40
+ */
41
+ export class MlKem1024DecapResult {
42
+ private constructor();
43
+ free(): void;
44
+ [Symbol.dispose](): void;
45
+ /**
46
+ * Shared secret recovered from the ciphertext, 32 bytes.
47
+ */
48
+ readonly shared_secret: Uint8Array;
49
+ }
50
+
51
+ /**
52
+ * Output of ML-KEM-1024 encapsulation: ciphertext + shared secret.
53
+ */
54
+ export class MlKem1024EncapResult {
55
+ private constructor();
56
+ free(): void;
57
+ [Symbol.dispose](): void;
58
+ /**
59
+ * Ciphertext to send to the decapsulator, 1568 bytes.
60
+ */
61
+ readonly ciphertext: Uint8Array;
62
+ /**
63
+ * Shared secret derived from encapsulation, 32 bytes.
64
+ */
65
+ readonly shared_secret: Uint8Array;
66
+ }
67
+
68
+ /**
69
+ * ML-KEM-1024 key pair (encapsulation + decapsulation key).
70
+ */
71
+ export class MlKem1024KeyPair {
72
+ private constructor();
73
+ free(): void;
74
+ [Symbol.dispose](): void;
75
+ /**
76
+ * Decapsulation (private) key, 3168 bytes.
77
+ */
78
+ readonly decapsulation_key: Uint8Array;
79
+ /**
80
+ * Encapsulation (public) key, 1568 bytes.
81
+ */
82
+ readonly encapsulation_key: Uint8Array;
83
+ }
84
+
21
85
  /**
22
86
  * Output of ML-KEM-768 decapsulation: the recovered shared secret.
23
87
  */
@@ -80,6 +144,36 @@ export function ml_dsa_65_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8
80
144
  */
81
145
  export function ml_dsa_65_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
82
146
 
147
+ /**
148
+ * Generate a fresh ML-DSA-87 key pair from 32 random seed bytes.
149
+ */
150
+ export function ml_dsa_87_generate(): MlDsa87KeyPair;
151
+
152
+ /**
153
+ * Sign `message` with a 32-byte ML-DSA-87 seed, returning a 4627-byte signature.
154
+ */
155
+ export function ml_dsa_87_sign(sk_bytes: Uint8Array, message: Uint8Array): Uint8Array;
156
+
157
+ /**
158
+ * Verify a 4627-byte ML-DSA-87 signature over `message` against a 2592-byte verifying key.
159
+ */
160
+ export function ml_dsa_87_verify(vk_bytes: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
161
+
162
+ /**
163
+ * Decapsulate a 1568-byte ciphertext with a 3168-byte decapsulation key.
164
+ */
165
+ export function ml_kem_1024_decapsulate(dk_bytes: Uint8Array, ct_bytes: Uint8Array): MlKem1024DecapResult;
166
+
167
+ /**
168
+ * Encapsulate a fresh shared secret to a 1568-byte encapsulation key.
169
+ */
170
+ export function ml_kem_1024_encapsulate(ek_bytes: Uint8Array): MlKem1024EncapResult;
171
+
172
+ /**
173
+ * Generate a fresh ML-KEM-1024 key pair using OS randomness.
174
+ */
175
+ export function ml_kem_1024_generate(): MlKem1024KeyPair;
176
+
83
177
  /**
84
178
  * Decapsulate a 1088-byte ciphertext with a 2400-byte decapsulation key.
85
179
  */
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./stenvault_pqc_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- MlDsa65KeyPair, MlKem768DecapResult, 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
8
+ MlDsa65KeyPair, MlDsa87KeyPair, MlKem1024DecapResult, MlKem1024EncapResult, MlKem1024KeyPair, MlKem768DecapResult, MlKem768EncapResult, MlKem768KeyPair, ml_dsa_65_generate, ml_dsa_65_sign, ml_dsa_65_verify, ml_dsa_87_generate, ml_dsa_87_sign, ml_dsa_87_verify, ml_kem_1024_decapsulate, ml_kem_1024_encapsulate, ml_kem_1024_generate, ml_kem_768_decapsulate, ml_kem_768_encapsulate, ml_kem_768_generate
9
9
  } from "./stenvault_pqc_bg.js";