kxco-post-quantum 1.1.12 → 1.2.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/CHANGELOG.md +32 -0
- package/README.md +25 -4
- package/SECURITY.md +2 -1
- package/package.json +10 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/ml-dsa.d.ts +1 -1
- package/src/ml-dsa.js +3 -3
- package/src/ml-kem.d.ts +1 -1
- package/src/ml-kem.js +1 -1
- package/src/slh-dsa.d.ts +46 -0
- package/src/slh-dsa.js +88 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0 — 2026-07-22
|
|
4
|
+
|
|
5
|
+
Adds SLH-DSA (FIPS 205) and modernises the underlying primitive engine to
|
|
6
|
+
`@noble/post-quantum@0.6.1`. **No breaking changes for consumers** — the
|
|
7
|
+
public API and all previously pinned outputs are byte-for-byte identical.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`slhDsa` — SLH-DSA-SHA2-192s (NIST FIPS 205)**, exported both from the
|
|
11
|
+
package root and the `kxco-post-quantum/slh-dsa` subpath. Hash-based,
|
|
12
|
+
stateless signatures at Security Category 3 (matching ML-DSA-65), whose
|
|
13
|
+
security rests only on SHA-2 — the conservative hedge alongside the
|
|
14
|
+
lattice-based ML-DSA-65. Deterministic `keypairFromMaster(master, info?)`
|
|
15
|
+
via the same HKDF-SHA-512 derivation, plus `sign` / `verify`. Public key
|
|
16
|
+
48 bytes, secret key 96 bytes, signature 16224 bytes.
|
|
17
|
+
- Test vectors extended to pin SLH-DSA keypairs and round-trip (39 checks,
|
|
18
|
+
up from 29).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- **`@noble/post-quantum` bumped `^0.2.1` → `^0.6.1`** — the FIPS 203/204/205
|
|
22
|
+
final reference implementation. The engine's public API changed argument
|
|
23
|
+
order for signature `sign`/`verify` and requires `.js` in subpath imports;
|
|
24
|
+
both are absorbed inside this package's wrappers, so no downstream package
|
|
25
|
+
or caller is affected.
|
|
26
|
+
- Description and keywords updated to reflect SLH-DSA / FIPS 205 coverage.
|
|
27
|
+
|
|
28
|
+
### Verification
|
|
29
|
+
- 11 node tests pass, 7 browser-smoke tests pass, 39 pinned vectors pass.
|
|
30
|
+
- **Compatibility gate:** every ML-DSA-65, ML-KEM-768, HKDF, fingerprint and
|
|
31
|
+
webhook vector pinned under `@noble/post-quantum@0.2.1` still matches
|
|
32
|
+
bit-for-bit under `0.6.1`. Deterministic keys derived from existing KXCO
|
|
33
|
+
master secrets — including Armature L1 identities — are unchanged.
|
|
34
|
+
|
|
3
35
|
## 1.1.6 — 2026-05-24
|
|
4
36
|
|
|
5
37
|
Maintenance release. No breaking changes.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Post-quantum cryptography primitives for the KXCO stack.
|
|
|
6
6
|
[](https://github.com/JackKXCO/kxco-post-quantum/actions/workflows/ci.yml)
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
|
|
9
|
-
ML-DSA-65 (FIPS 204) signatures
|
|
9
|
+
ML-DSA-65 (FIPS 204) and SLH-DSA-SHA2-192s (FIPS 205) signatures, ML-KEM-768 (FIPS 203) key encapsulation, and key fingerprinting utilities. Wraps [`@noble/post-quantum`](https://github.com/paulmillr/noble-post-quantum) — the NIST reference implementation. All other `kxco-pq-*` packages depend on this one.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -23,13 +23,18 @@ Requires Node.js 20.19+. ESM-only.
|
|
|
23
23
|
## Quick start
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
import { mlDsa, mlKem, fingerprint, kidEquals } from 'kxco-post-quantum'
|
|
26
|
+
import { mlDsa, mlKem, slhDsa, fingerprint, kidEquals } from 'kxco-post-quantum'
|
|
27
27
|
|
|
28
28
|
// ML-DSA-65 — sign and verify
|
|
29
29
|
const { publicKey, secretKey } = mlDsa.keypairFromMaster(masterSecret, 'signing-v1')
|
|
30
30
|
const sig = mlDsa.sign(secretKey, 'hello')
|
|
31
31
|
const ok = mlDsa.verify(publicKey, 'hello', sig) // true
|
|
32
32
|
|
|
33
|
+
// SLH-DSA-SHA2-192s — hash-based signatures (same API shape as mlDsa)
|
|
34
|
+
const slh = slhDsa.keypairFromMaster(masterSecret, 'signing-v1')
|
|
35
|
+
const slhSig = slhDsa.sign(slh.secretKey, 'hello')
|
|
36
|
+
const slhOk = slhDsa.verify(slh.publicKey, 'hello', slhSig) // true
|
|
37
|
+
|
|
33
38
|
// Key fingerprint
|
|
34
39
|
const kid = fingerprint(publicKey) // e.g. '4a7c9e2f1b3d5680'
|
|
35
40
|
kidEquals(kid, kid) // true (constant-time)
|
|
@@ -58,6 +63,19 @@ const recovered = mlKem.decapsulate(ciphertext, kemKeys.secretKey)
|
|
|
58
63
|
|
|
59
64
|
`publicKey` is 1952 bytes. `secretKey` is 4032 bytes. `message` accepts `Buffer`, `Uint8Array`, or `string`.
|
|
60
65
|
|
|
66
|
+
### `slhDsa` — SLH-DSA-SHA2-192s (NIST FIPS 205)
|
|
67
|
+
|
|
68
|
+
Hash-based, stateless signatures. Security Category 3 (matching ML-DSA-65), but security rests only on the SHA-2 hash function — no lattice or number-theoretic assumptions. Use this as a conservative hedge alongside `mlDsa`. Tradeoff: signatures are ~5× larger (16224 vs 3309 bytes) and signing is slower.
|
|
69
|
+
|
|
70
|
+
| Export | Signature | Description |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `keypairFromMaster` | `(master, info?) → { publicKey, secretKey }` | Deterministic keypair via HKDF-SHA-512. `info` defaults to `'slh-dsa-sha2-192s-v1'`. |
|
|
73
|
+
| `sign` | `(secretKey, message) → string` | Signs a message. Returns a hex-encoded signature (32448 chars). |
|
|
74
|
+
| `verify` | `(publicKey, message, sigHex) → boolean` | Verifies a hex-encoded signature. Returns `false` on any failure. |
|
|
75
|
+
| `slh_dsa_sha2_192s` | raw primitive | The underlying `@noble/post-quantum` primitive, re-exported. |
|
|
76
|
+
|
|
77
|
+
`publicKey` is 48 bytes. `secretKey` is 96 bytes. `message` accepts `Buffer`, `Uint8Array`, or `string`.
|
|
78
|
+
|
|
61
79
|
### `mlKem` — ML-KEM-768 (NIST FIPS 203)
|
|
62
80
|
|
|
63
81
|
| Export | Signature | Description |
|
|
@@ -81,12 +99,15 @@ Constant-time comparison of two kid strings. Use this when comparing user-suppli
|
|
|
81
99
|
|
|
82
100
|
HKDF-SHA-512 derivation. `master` must be at least 16 bytes. `info` is a required domain-separation string. Returns `length` bytes.
|
|
83
101
|
|
|
102
|
+
### `webhook` — hybrid HMAC + ML-DSA-65 delivery signing
|
|
103
|
+
|
|
104
|
+
Low-level helpers for the KXCO hybrid webhook pattern: `envelope`, `hmacHex`, `verifyHmac`, `pqSign`, `verifyPq`, `signDelivery`, `verifyDelivery`. HMAC-SHA-256 gives symmetric verification with no library dependency; ML-DSA-65 adds non-repudiation over the same `${timestamp}.${body}` envelope. The full identity/credential surface lives in `kxco-pq-sdk`.
|
|
105
|
+
|
|
84
106
|
---
|
|
85
107
|
|
|
86
108
|
## What this does NOT do
|
|
87
109
|
|
|
88
|
-
- No identity credentials or verifiable claims
|
|
89
|
-
- No webhook signing or HMAC utilities (those are in `kxco-pq-sdk`)
|
|
110
|
+
- No identity credentials or verifiable claims (those are in `kxco-pq-sdk`)
|
|
90
111
|
- No relay, transport, or network layer
|
|
91
112
|
- No key storage or KMS integration
|
|
92
113
|
- No FIPS 140-3 module validation (the algorithms are FIPS-standardised; the module is not validated)
|
package/SECURITY.md
CHANGED
|
@@ -14,11 +14,12 @@ In scope:
|
|
|
14
14
|
- Kid fingerprint collision behaviour
|
|
15
15
|
|
|
16
16
|
Out of scope (report upstream to https://github.com/paulmillr/noble-post-quantum):
|
|
17
|
-
- Bugs in the underlying ML-DSA-65, ML-KEM-768, or HKDF primitives
|
|
17
|
+
- Bugs in the underlying ML-DSA-65, ML-KEM-768, SLH-DSA-SHA2-192s, or HKDF primitives
|
|
18
18
|
|
|
19
19
|
## Algorithms used
|
|
20
20
|
- ML-DSA-65 — NIST FIPS 204 (lattice signatures)
|
|
21
21
|
- ML-KEM-768 — NIST FIPS 203 (key encapsulation)
|
|
22
|
+
- SLH-DSA-SHA2-192s — NIST FIPS 205 (hash-based signatures)
|
|
22
23
|
- HMAC-SHA-256
|
|
23
24
|
- HKDF-SHA-512 (RFC 5869)
|
|
24
25
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kxco-post-quantum",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "ML-DSA-65
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "ML-DSA-65, ML-KEM-768 and SLH-DSA-SHA2-192s primitives with key fingerprinting. The base layer for all kxco-pq-* packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"post-quantum",
|
|
7
7
|
"pqc",
|
|
8
8
|
"ml-dsa",
|
|
9
9
|
"ml-kem",
|
|
10
|
+
"slh-dsa",
|
|
11
|
+
"sphincs",
|
|
10
12
|
"dilithium",
|
|
11
13
|
"kyber",
|
|
12
14
|
"nist",
|
|
13
15
|
"fips-203",
|
|
14
16
|
"fips-204",
|
|
17
|
+
"fips-205",
|
|
15
18
|
"webhook-signing",
|
|
16
19
|
"quantum-resistant",
|
|
17
20
|
"armature",
|
|
@@ -60,6 +63,10 @@
|
|
|
60
63
|
"types": "./src/ml-kem.d.ts",
|
|
61
64
|
"import": "./src/ml-kem.js"
|
|
62
65
|
},
|
|
66
|
+
"./slh-dsa": {
|
|
67
|
+
"types": "./src/slh-dsa.d.ts",
|
|
68
|
+
"import": "./src/slh-dsa.js"
|
|
69
|
+
},
|
|
63
70
|
"./derive": {
|
|
64
71
|
"types": "./src/derive.d.ts",
|
|
65
72
|
"import": "./src/derive.js"
|
|
@@ -85,7 +92,7 @@
|
|
|
85
92
|
},
|
|
86
93
|
"dependencies": {
|
|
87
94
|
"@noble/hashes": "^2.2.0",
|
|
88
|
-
"@noble/post-quantum": "^0.
|
|
95
|
+
"@noble/post-quantum": "^0.6.1"
|
|
89
96
|
},
|
|
90
97
|
"scripts": {
|
|
91
98
|
"test": "node --test test/basic.test.js && node --test test/browser-smoke.test.js && node test/run-vectors.js",
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/ml-dsa.d.ts
CHANGED
|
@@ -42,4 +42,4 @@ export function verify(
|
|
|
42
42
|
* who want the lower-level API. The wrapper functions above are
|
|
43
43
|
* recommended for production use.
|
|
44
44
|
*/
|
|
45
|
-
export const ml_dsa65: typeof import('@noble/post-quantum/ml-dsa').ml_dsa65
|
|
45
|
+
export const ml_dsa65: typeof import('@noble/post-quantum/ml-dsa.js').ml_dsa65
|
package/src/ml-dsa.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Isomorphic: works in Node and modern browsers. Returns Buffer on Node
|
|
7
7
|
// (backwards compatible), Uint8Array in browsers.
|
|
8
8
|
|
|
9
|
-
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa'
|
|
9
|
+
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js'
|
|
10
10
|
import { deriveSeed } from './derive.js'
|
|
11
11
|
|
|
12
12
|
const HAS_BUFFER = typeof Buffer !== 'undefined'
|
|
@@ -55,7 +55,7 @@ export function keypairFromMaster(master, info = 'ml-dsa-65-v1') {
|
|
|
55
55
|
* @returns {string} hex-encoded signature (6618 chars)
|
|
56
56
|
*/
|
|
57
57
|
export function sign(secretKey, message) {
|
|
58
|
-
const sig = ml_dsa65.sign(
|
|
58
|
+
const sig = ml_dsa65.sign(toBytes(message), secretKey)
|
|
59
59
|
return bytesToHex(sig)
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -69,7 +69,7 @@ export function sign(secretKey, message) {
|
|
|
69
69
|
*/
|
|
70
70
|
export function verify(publicKey, message, sigHex) {
|
|
71
71
|
try {
|
|
72
|
-
return ml_dsa65.verify(
|
|
72
|
+
return ml_dsa65.verify(hexToBytes(sigHex), toBytes(message), publicKey)
|
|
73
73
|
} catch {
|
|
74
74
|
return false
|
|
75
75
|
}
|
package/src/ml-kem.d.ts
CHANGED
|
@@ -46,4 +46,4 @@ export function decapsulate(
|
|
|
46
46
|
/**
|
|
47
47
|
* Raw `@noble/post-quantum` ML-KEM-768 primitive, re-exported.
|
|
48
48
|
*/
|
|
49
|
-
export const ml_kem768: typeof import('@noble/post-quantum/ml-kem').ml_kem768
|
|
49
|
+
export const ml_kem768: typeof import('@noble/post-quantum/ml-kem.js').ml_kem768
|
package/src/ml-kem.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Isomorphic: works in Node and modern browsers. Returns Buffer on Node
|
|
8
8
|
// (backwards compatible), Uint8Array in browsers.
|
|
9
9
|
|
|
10
|
-
import { ml_kem768 } from '@noble/post-quantum/ml-kem'
|
|
10
|
+
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js'
|
|
11
11
|
import { deriveSeed } from './derive.js'
|
|
12
12
|
|
|
13
13
|
const HAS_BUFFER = typeof Buffer !== 'undefined'
|
package/src/slh-dsa.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
export interface SlhDsaKeypair {
|
|
4
|
+
/** 48-byte public key */
|
|
5
|
+
publicKey: Buffer
|
|
6
|
+
/** 96-byte secret key */
|
|
7
|
+
secretKey: Buffer
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate an SLH-DSA-SHA2-192s (NIST FIPS 205) keypair deterministically
|
|
12
|
+
* from a master + domain-separation info string.
|
|
13
|
+
*
|
|
14
|
+
* Same inputs always produce the same keypair — no state, no DB row.
|
|
15
|
+
* Security Category 3, matching ML-DSA-65.
|
|
16
|
+
*/
|
|
17
|
+
export function keypairFromMaster(
|
|
18
|
+
master: Buffer | Uint8Array,
|
|
19
|
+
info?: string,
|
|
20
|
+
): SlhDsaKeypair
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sign a message under an SLH-DSA-SHA2-192s secret key. Returns the signature
|
|
24
|
+
* as a hex string (16224 bytes = 32448 hex characters).
|
|
25
|
+
*/
|
|
26
|
+
export function sign(
|
|
27
|
+
secretKey: Buffer | Uint8Array,
|
|
28
|
+
message: Buffer | string,
|
|
29
|
+
): string
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Verify a hex-encoded SLH-DSA-SHA2-192s signature against a public key +
|
|
33
|
+
* message. Returns `false` on any error (invalid hex, wrong length, mismatch).
|
|
34
|
+
*/
|
|
35
|
+
export function verify(
|
|
36
|
+
publicKey: Buffer | Uint8Array,
|
|
37
|
+
message: Buffer | string,
|
|
38
|
+
sigHex: string,
|
|
39
|
+
): boolean
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Raw `@noble/post-quantum` SLH-DSA-SHA2-192s primitive, re-exported for
|
|
43
|
+
* callers who want the lower-level API. The wrapper functions above are
|
|
44
|
+
* recommended for production use.
|
|
45
|
+
*/
|
|
46
|
+
export const slh_dsa_sha2_192s: typeof import('@noble/post-quantum/slh-dsa.js').slh_dsa_sha2_192s
|
package/src/slh-dsa.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// SLH-DSA-SHA2-192s helpers (NIST FIPS 205, SPHINCS+).
|
|
2
|
+
//
|
|
3
|
+
// Stateless hash-based signatures. Security Category 3 (≈ AES-192), matching
|
|
4
|
+
// ML-DSA-65's security level. Public key 48 bytes, secret key 96 bytes,
|
|
5
|
+
// signature 16224 bytes. Security rests only on the SHA-2 hash function — no
|
|
6
|
+
// lattice or number-theoretic assumptions — which makes it the conservative
|
|
7
|
+
// hedge alongside ML-DSA-65.
|
|
8
|
+
//
|
|
9
|
+
// Tradeoff: signatures are ~5x larger than ML-DSA-65 (16224 vs 3309 bytes) and
|
|
10
|
+
// signing is slower. Use ML-DSA-65 as the default; reach for SLH-DSA when you
|
|
11
|
+
// want a signature whose security does not depend on lattice hardness.
|
|
12
|
+
//
|
|
13
|
+
// Isomorphic: works in Node and modern browsers. Returns Buffer on Node
|
|
14
|
+
// (consistent with ml-dsa.js), Uint8Array in browsers.
|
|
15
|
+
|
|
16
|
+
import { slh_dsa_sha2_192s } from '@noble/post-quantum/slh-dsa.js'
|
|
17
|
+
import { deriveSeed } from './derive.js'
|
|
18
|
+
|
|
19
|
+
const HAS_BUFFER = typeof Buffer !== 'undefined'
|
|
20
|
+
const enc = new TextEncoder()
|
|
21
|
+
|
|
22
|
+
function toBytes(input) {
|
|
23
|
+
if (input instanceof Uint8Array) return input
|
|
24
|
+
if (typeof input === 'string') return enc.encode(input)
|
|
25
|
+
throw new Error('expected Uint8Array or string')
|
|
26
|
+
}
|
|
27
|
+
function hexToBytes(hex) {
|
|
28
|
+
if (typeof hex !== 'string' || hex.length % 2) throw new Error('invalid hex')
|
|
29
|
+
const b = new Uint8Array(hex.length / 2)
|
|
30
|
+
for (let i = 0; i < b.length; i++) b[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16)
|
|
31
|
+
return b
|
|
32
|
+
}
|
|
33
|
+
function bytesToHex(bytes) {
|
|
34
|
+
let s = ''
|
|
35
|
+
for (let i = 0; i < bytes.length; i++) s += bytes[i].toString(16).padStart(2, '0')
|
|
36
|
+
return s
|
|
37
|
+
}
|
|
38
|
+
function wrap(bytes) {
|
|
39
|
+
return HAS_BUFFER ? Buffer.from(bytes) : bytes
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Seed length for SLH-DSA-SHA2-192s keygen (FIPS 205: SK.seed || SK.prf || PK.seed).
|
|
43
|
+
const SEED_BYTES = slh_dsa_sha2_192s.lengths.seed
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Generate an SLH-DSA-SHA2-192s keypair from a master + domain-separation info.
|
|
47
|
+
*
|
|
48
|
+
* @returns {{ publicKey: Buffer|Uint8Array, secretKey: Buffer|Uint8Array }}
|
|
49
|
+
*/
|
|
50
|
+
export function keypairFromMaster(master, info = 'slh-dsa-sha2-192s-v1') {
|
|
51
|
+
const seed = deriveSeed(master, info, SEED_BYTES)
|
|
52
|
+
const seedU8 = seed instanceof Uint8Array ? seed : new Uint8Array(seed)
|
|
53
|
+
const k = slh_dsa_sha2_192s.keygen(seedU8)
|
|
54
|
+
return {
|
|
55
|
+
publicKey: wrap(k.publicKey),
|
|
56
|
+
secretKey: wrap(k.secretKey),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sign a message. Returns the signature as a hex string.
|
|
62
|
+
*
|
|
63
|
+
* @param {Buffer|Uint8Array} secretKey
|
|
64
|
+
* @param {Buffer|Uint8Array|string} message
|
|
65
|
+
* @returns {string} hex-encoded signature (32448 chars)
|
|
66
|
+
*/
|
|
67
|
+
export function sign(secretKey, message) {
|
|
68
|
+
const sig = slh_dsa_sha2_192s.sign(toBytes(message), secretKey)
|
|
69
|
+
return bytesToHex(sig)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Verify a hex-encoded signature.
|
|
74
|
+
*
|
|
75
|
+
* @param {Buffer|Uint8Array} publicKey
|
|
76
|
+
* @param {Buffer|Uint8Array|string} message
|
|
77
|
+
* @param {string} sigHex
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
export function verify(publicKey, message, sigHex) {
|
|
81
|
+
try {
|
|
82
|
+
return slh_dsa_sha2_192s.verify(hexToBytes(sigHex), toBytes(message), publicKey)
|
|
83
|
+
} catch {
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { slh_dsa_sha2_192s }
|