keyflower 0.0.0-stage → 0.3.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.
Files changed (156) hide show
  1. package/CRYPTO-INVENTORY.md +184 -0
  2. package/CRYPTO.md +636 -0
  3. package/ID-DESIGN.md +322 -0
  4. package/LICENSE +21 -0
  5. package/RATCHET-DESIGN.md +253 -0
  6. package/README.md +392 -2
  7. package/SKILL.md +118 -0
  8. package/WIRE-FORMAT.md +325 -0
  9. package/bench/README.md +36 -0
  10. package/bench/adversarial-policy.mjs +562 -0
  11. package/bench/agent-workload.mjs +247 -0
  12. package/bench/chaos-recovery.mjs +611 -0
  13. package/bench/crypto-overhead.mjs +454 -0
  14. package/bench/run.mjs +164 -0
  15. package/bench/stats.mjs +240 -0
  16. package/cli.mjs +3807 -0
  17. package/garden.mjs +1911 -0
  18. package/handshake.mjs +661 -0
  19. package/identity.mjs +2672 -0
  20. package/keyflower.mjs +761 -0
  21. package/keys/release.pub +1 -0
  22. package/living.mjs +220 -0
  23. package/migration.mjs +307 -0
  24. package/package.json +120 -4
  25. package/ratchet.mjs +519 -0
  26. package/relay/Dockerfile +19 -0
  27. package/relay/README.md +40 -0
  28. package/relay/fly.toml +35 -0
  29. package/scripts/fips-check.mjs +116 -0
  30. package/scripts/phone-serve.mjs +81 -0
  31. package/scripts/release.mjs +90 -0
  32. package/scripts/test-fips.mjs +28 -0
  33. package/session.mjs +263 -0
  34. package/site/BRAND-GUIDE.md +58 -0
  35. package/site/SKILL.md +118 -0
  36. package/site/bouquet.html +995 -0
  37. package/site/brand.css +421 -0
  38. package/site/favicon.svg +15 -0
  39. package/site/flowers/aster.html +398 -0
  40. package/site/flowers/babys-breath.html +382 -0
  41. package/site/flowers/bundle.html +161 -0
  42. package/site/flowers/calla-lily.html +392 -0
  43. package/site/flowers/carnation.html +411 -0
  44. package/site/flowers/chrysanthemum.html +402 -0
  45. package/site/flowers/cosmos.html +404 -0
  46. package/site/flowers/daisy.html +394 -0
  47. package/site/flowers/delphinium.html +399 -0
  48. package/site/flowers/gerbera.html +419 -0
  49. package/site/flowers/hydrangea.html +421 -0
  50. package/site/flowers/lib/aster.mjs +70 -0
  51. package/site/flowers/lib/babys-breath.mjs +81 -0
  52. package/site/flowers/lib/calla-lily.mjs +67 -0
  53. package/site/flowers/lib/carnation.mjs +88 -0
  54. package/site/flowers/lib/chrysanthemum.mjs +74 -0
  55. package/site/flowers/lib/cosmos.mjs +71 -0
  56. package/site/flowers/lib/daisy.mjs +70 -0
  57. package/site/flowers/lib/delphinium.mjs +87 -0
  58. package/site/flowers/lib/engine.mjs +380 -0
  59. package/site/flowers/lib/garden-view.mjs +231 -0
  60. package/site/flowers/lib/gerbera.mjs +91 -0
  61. package/site/flowers/lib/hydrangea.mjs +88 -0
  62. package/site/flowers/lib/lilies.mjs +91 -0
  63. package/site/flowers/lib/lily-of-the-valley.mjs +76 -0
  64. package/site/flowers/lib/lisianthus.mjs +76 -0
  65. package/site/flowers/lib/mimosa.mjs +84 -0
  66. package/site/flowers/lib/orchid.mjs +98 -0
  67. package/site/flowers/lib/peony.mjs +77 -0
  68. package/site/flowers/lib/periwinkle.mjs +83 -0
  69. package/site/flowers/lib/phenotype.mjs +221 -0
  70. package/site/flowers/lib/ranunculus.mjs +72 -0
  71. package/site/flowers/lib/rose.mjs +92 -0
  72. package/site/flowers/lib/scabiosa.mjs +100 -0
  73. package/site/flowers/lib/snapdragon.mjs +94 -0
  74. package/site/flowers/lib/sunflower.mjs +79 -0
  75. package/site/flowers/lib/tulips.mjs +75 -0
  76. package/site/flowers/lib/zinnia.mjs +89 -0
  77. package/site/flowers/lilies.html +412 -0
  78. package/site/flowers/lily-of-the-valley.html +380 -0
  79. package/site/flowers/lisianthus.html +434 -0
  80. package/site/flowers/mimosa.html +409 -0
  81. package/site/flowers/orchid.html +406 -0
  82. package/site/flowers/peony.html +435 -0
  83. package/site/flowers/periwinkle.html +402 -0
  84. package/site/flowers/ranunculus.html +400 -0
  85. package/site/flowers/rose.html +376 -0
  86. package/site/flowers/scabiosa.html +423 -0
  87. package/site/flowers/snapdragon.html +401 -0
  88. package/site/flowers/sunflower.html +307 -0
  89. package/site/flowers/tulips.html +400 -0
  90. package/site/flowers/zinnia.html +411 -0
  91. package/site/garden.html +1499 -0
  92. package/site/index.html +995 -0
  93. package/site/lib/LICENSE-jsQR +202 -0
  94. package/site/lib/TRANSPORTS.md +138 -0
  95. package/site/lib/VENDOR.md +44 -0
  96. package/site/lib/audio-transport.mjs +83 -0
  97. package/site/lib/fountain.mjs +278 -0
  98. package/site/lib/ggwave.js +21 -0
  99. package/site/lib/jsQR.js +10102 -0
  100. package/site/lib/qr-fountain.mjs +80 -0
  101. package/site/lib/qr-transport.mjs +86 -0
  102. package/site/lib/qrcode.mjs +2237 -0
  103. package/site/lib/sdp-qr.mjs +70 -0
  104. package/site/lib/webrtc-transport.mjs +138 -0
  105. package/site/lib/wire-codec.mjs +43 -0
  106. package/site/llms.txt +67 -0
  107. package/site/pollinate.html +1206 -0
  108. package/src/checkpoint.js +83 -0
  109. package/src/field.js +114 -0
  110. package/src/fs.mjs +34 -0
  111. package/src/genome.js +159 -0
  112. package/src/guard.mjs +14 -0
  113. package/src/hwkey.mjs +724 -0
  114. package/src/rng.js +34 -0
  115. package/src/runtime.mjs +38 -0
  116. package/src/suite.mjs +263 -0
  117. package/src/tunnel-session.mjs +445 -0
  118. package/src/world.js +735 -0
  119. package/storage.mjs +197 -0
  120. package/test/audio-transport.mjs +135 -0
  121. package/test/fixtures/mock-mcp-server.mjs +231 -0
  122. package/test/fixtures/v1-file.kf +0 -0
  123. package/test/fixtures/v1-file.txt +1 -0
  124. package/test/fixtures/v1.flower +1 -0
  125. package/test/fixtures/v1.pollen.json +694 -0
  126. package/test/fountain.mjs +177 -0
  127. package/test/fuzz-properties.mjs +693 -0
  128. package/test/hw-real.mjs +143 -0
  129. package/test/id-pinning.mjs +2547 -0
  130. package/test/kat.mjs +88 -0
  131. package/test/l5-render.mjs +527 -0
  132. package/test/l6-garden.mjs +432 -0
  133. package/test/l7-garden-tunnel.mjs +510 -0
  134. package/test/live-cli.mjs +338 -0
  135. package/test/m5-policy-lifecycle.mjs +661 -0
  136. package/test/mcp-ratchet.mjs +1121 -0
  137. package/test/net-transport.mjs +793 -0
  138. package/test/online-relay.mjs +561 -0
  139. package/test/qr-camera.mjs +168 -0
  140. package/test/qr-fountain.mjs +125 -0
  141. package/test/reliable-frame.mjs +443 -0
  142. package/test/run.mjs +704 -0
  143. package/test/site-browser.mjs +352 -0
  144. package/test/tunnel-session.mjs +285 -0
  145. package/test/webrtc-lan.mjs +136 -0
  146. package/tunnel/PRODUCTION-GATES.md +142 -0
  147. package/tunnel/README.md +85 -0
  148. package/tunnel/lifecycle.mjs +112 -0
  149. package/tunnel/mcp-bridge.mjs +1041 -0
  150. package/tunnel/mcp-policy.mjs +563 -0
  151. package/tunnel/net-transport.mjs +983 -0
  152. package/tunnel/padding.mjs +108 -0
  153. package/tunnel/relay-server.mjs +439 -0
  154. package/tunnel/relay-transport.mjs +740 -0
  155. package/tunnel/reliable-frame.mjs +827 -0
  156. package/tunnel/ws-frame.mjs +319 -0
@@ -0,0 +1,184 @@
1
+ # CRYPTO-INVENTORY.md — KEYflower
2
+
3
+ Every cryptographic primitive KEYflower uses, where it is isolated, every HKDF
4
+ and signature domain-separation prefix, every on-disk and wire artifact, and
5
+ current FIPS / CNSA 2.0 readiness.
6
+
7
+ - **Scope:** Full codebase through **CNSA 2.0 (M0–M5)**, **Tunnel/MCP (M0–M5)**,
8
+ **Living/Garden (L1–L7)**, and **Peer Identity & Pinning (ID0–ID5)**.
9
+ - **Runtime verified:** Node `24.23.0`, OpenSSL `3.5.9`.
10
+ - **Single-file agility invariant:** Every algorithm name and every `node:crypto`
11
+ primitive call lives exclusively in `src/suite.mjs` (plus runtime key-type
12
+ probing in `src/runtime.mjs`). `test/run.mjs §0` enforces this across all
13
+ library, CLI, tunnel, and script modules.
14
+ - **Companion references:** `CRYPTO.md` (threat model & KAT vectors),
15
+ `WIRE-FORMAT.md` (unified binary/envelope/JSON wire layouts),
16
+ `RATCHET-DESIGN.md` (KEM double ratchet design & caveats), `ID-DESIGN.md`
17
+ (ID0–ID5 peer identity spec), and `tunnel/PRODUCTION-GATES.md` (external gates).
18
+
19
+ ---
20
+
21
+ ## 1. Suite v2 Primitives (Current Default, CNSA 2.0 Aligned)
22
+
23
+ All new flowers, files, sessions, gardens, tunnels, and identity artifacts use
24
+ suite **v2**. Requirements column references the
25
+ [NSA CNSA 2.0 FAQ](https://media.defense.gov/2022/Sep/07/2003071836/-1/-1/1/CSI_CNSA_2.0_FAQ_.PDF).
26
+
27
+ | Primitive | Parameters | Used For | Isolated In | CNSA 2.0 Status |
28
+ |---|---|---|---|---|
29
+ | **AES-256-GCM** | 256-bit key, 96-bit nonce (enforced by `assertNonce`), 128-bit tag | Message/file AEAD (`KFLW`), pressed flowers (`kf2:`), sessions (`kf2sess:`), migration prekeys (`kf2pre:`), garden links (`kf2edge:`), fast checkpoints (`kf2ckpt:`), ratchet frames, L2 storage sealing, L4 hardware KEK wrapping | `src/suite.mjs` (`seal`, `open`) | Compliant algorithm (module FIPS 140-3 validation pending Gate 2) |
30
+ | **SHA-384** | 384-bit digest (FIPS 180-4) | Genome digests, pollen digests, public key fingerprints (first 16 bytes = 128 bits grouped hex), release tarball digests, ID3 detached artifact digests (`createHasher` / `digest`) | `src/suite.mjs` (`digest`, `createHasher`, `fingerprint`) | Compliant algorithm |
31
+ | **HKDF-SHA384** | RFC 5869 over SHA-384 | Root ratcheting (`grow`), per-message keys, pollination shared root, ratchet root/chain/AEAD/export keys, L1 living epoch views/keys, L2 per-file & shared storage keys, M3 rekey epoch roots, L7 garden tunnel roots | `src/suite.mjs` (`hkdf`) | Compliant (uses SHA-384) |
32
+ | **PBKDF2-HMAC-SHA384** | 600,000 default iterations (`>= 100,000` enforced, bounded `<= 10M` / `<= 20M` on parse), 32-byte salt, 32-byte key (NIST SP 800-132) | Passphrase wrapping for `kf2:` flower backups, `kf2sess:`, `kf2pre:`, `kf2edge:`, and `kf2ckpt:` wrapping-key headers | `src/suite.mjs` (`stretch`) | NIST-approved KDF with SHA-384 |
33
+ | **ML-KEM-1024** | FIPS 203 (Category 5), SPKI/PKCS#8 DER wire | Double ratchet root steps (`ratchet.mjs`), prekey bundles, L3 `migration.mjs`, L6/L7 garden links, M1–M5 tunnels | `src/suite.mjs` (`kemKeypair`, `kemEncapsulate`, `kemDecapsulate`) | Compliant (FIPS 203 Category 5) |
34
+ | **ML-DSA-87** | FIPS 204 (Category 5), SPKI/PKCS#8 DER wire | Pollen signatures, ratchet prekey bundles, M3 rekey envelopes, L3 migrants, release tarball signatures, ID1 cards, ID3 detached signatures, ID4 proofs of possession, ID5 revocations & dual-signed rotations | `src/suite.mjs` (`sigKeypair`, `identityKeypair`, `signWire`, `verifyWire`) | Compliant (FIPS 204 Category 5) |
35
+ | **CSPRNG** | `crypto.randomBytes` (OpenSSL DRBG) | Plant entropy, `grow` taps, AEAD nonces, salts, storage key IDs/keys, checkpoint `wrapKey`, ID4 32-byte challenge nonces, rekey salts/challenges, L4 KEKs | `src/suite.mjs` (`randomBytes`) | Compliant when backed by a FIPS-validated module (Gate 2) |
36
+
37
+ ### Opt-In / Auxiliary Primitives (Non-Default or Hardware-Local)
38
+
39
+ | Primitive | Parameters | Used For | Isolated In | CNSA 2.0 Notes |
40
+ |---|---|---|---|---|
41
+ | **X25519** *(opt-in `--hybrid` only)* | RFC 7748, SPKI/PKCS#8 DER wire | Optional classical defense-in-depth leg in ratchet root steps (`ikm = ml_kem_1024_ss \|\| x25519_ss`, negotiated inside ML-DSA-87-signed prekey/rekey envelopes) | `src/suite.mjs` (`HYBRID_DH`, `dhKeypair`, `dhDerive`) | **Not a CNSA 2.0 algorithm.** Off by default; pure ML-KEM-1024 is the default. Adding X25519 via concatenation never weakens PQ security. |
42
+ | **TPM 2.0 Parent Profiles** *(L4 `kf bind` only)* | Ordered preference: `sha384` + `ecc384:aes256cfb`, `rsa2048:aes256cfb`, `ecc256:aes256cfb`; fallback `sha256` (`ecc256` / `rsa2048`) when not in CNSA-only mode | Local TPM 2.0 storage primary parent for sealing a random 256-bit KEK (`TPM2_Create`/`TPM2_Load`/`TPM2_Unseal` via `tpm2-tools`) | `src/suite.mjs` (`TPM_PARENT_PROFILES`), orchestrated in `src/hwkey.mjs` | Child private blobs are symmetrically wrapped by the TPM parent's internal `seedValue` (AES-256-CFB + HMAC), not asymmetric encryption. CNSA-only mode restricts parent hashes to `sha384`. |
43
+ | **CRC-32 (IEEE 802.3)** *(non-cryptographic)* | 32-bit polynomial `0xedb88320` | Browser pollination LT fountain codec reassembly/stop guard (`site/lib/fountain.mjs`) | `site/lib/fountain.mjs` | Not used for security. End-to-end authenticity of pollen grains is enforced by ML-DSA-87 signatures + out-of-band SHA-384 fingerprint confirmation. |
44
+
45
+ ---
46
+
47
+ ## 2. Legacy Suite v1 Primitives (Read / Migrate Only)
48
+
49
+ Suite **v1** is retained solely to open legacy flowers/files and run `kf migrate`
50
+ / `kf reseal`, and to preserve the pinned `CRYPTO.md §6` KAT vectors. In FIPS
51
+ mode or with `KEYFLOWER_REQUIRE_CNSA2=1`, suite **v1** is **refused everywhere**.
52
+
53
+ | Primitive (v1) | Parameters | Legacy Role | CNSA 2.0 Gap | Remediation |
54
+ |---|---|---|---|---|
55
+ | **AES-256-GCM** | 256-bit key, 96-bit nonce, 128-bit tag | Message, file (`KFLW\x01`), backup, ratchet AEAD | None (algorithm OK) | Carried into v2 with authenticated headers |
56
+ | **HKDF-SHA256 / SHA-256** | 256-bit digest | Root/message KDFs, genome/pollen digests | SHA-384/512 required | Replaced by SHA-384 / HKDF-SHA384 in v2 |
57
+ | **scrypt** | `N=2^15`, `r=8`, `p=1`, 16-byte salt, 32-byte key | Passphrase wrapping for v1 backups | Not a NIST-approved KDF | Replaced by PBKDF2-HMAC-SHA384 in v2 |
58
+ | **ML-KEM-768** | FIPS 203 Category 3 | Legacy ratchet root step | ML-KEM-1024 required | Replaced by ML-KEM-1024 in v2 |
59
+ | **Signatures** | None | Legacy pollen & prekeys unsigned | ML-DSA-87 required | Added ML-DSA-87 in v2 |
60
+
61
+ ---
62
+
63
+ ## 3. Complete Domain-Separation Registry
64
+
65
+ ### 3.1 Signature Domains (ML-DSA-87, Suite v2)
66
+
67
+ Every ML-DSA-87 signature signs `UTF-8("<prefix>\n" + <payload>)`. No prefix can
68
+ collide with another.
69
+
70
+ | Prefix | Payload | Module | Feature |
71
+ |---|---|---|---|
72
+ | `keyflower/v2/pollen\n` | `canonical(body)` | `keyflower.mjs` | Signed pollen grain |
73
+ | `keyflower/v2/migrant\n` | `canonical(body)` | `migration.mjs` | L3 periodic migration envelope |
74
+ | `keyflower/v2/release\n` | `<sha384-hex>` | `scripts/release.mjs` | Signed release tarball (`.sig`) |
75
+ | `keyflower/ratchet/v2/prekey\n` | `canonical(body)` | `ratchet.mjs` | Signed ML-KEM (+ optional X25519) prekey bundle |
76
+ | `keyflower/ratchet/v2/rekey\n` | `canonical(body)` | `tunnel/reliable-frame.mjs` | M3 3-way `rekey` (`request`/`offer`/`confirm`) |
77
+ | `keyflower/v2/id-card\n` | `canonical(body)` | `identity.mjs` | ID1 public identity card (`*.id.json`) |
78
+ | `keyflower/v2/id-sign\n` | `canonical(body)` | `identity.mjs` | ID3 detached artifact signature (`*.kfsig`) |
79
+ | `keyflower/v2/id-proof\n` | `canonical(body)` | `identity.mjs` | ID4 challenge-response proof (`*.proof.json`) |
80
+ | `keyflower/v2/id-revoke\n` | `canonical(body)` | `identity.mjs` | ID5 revocation certificate (`*.revoke.json`) |
81
+ | `keyflower/v2/id-rotate-old\n` | `canonical(body)` | `identity.mjs` | ID5 outgoing key signature (`*.rotate.json`) |
82
+ | `keyflower/v2/id-rotate-new\n` | `canonical(body)` | `identity.mjs` | ID5 incoming key signature (`*.rotate.json`) |
83
+
84
+ ### 3.2 HKDF Info & Salt Domains
85
+
86
+ `hkdf(s, ikm, salt, info, len, domain)` passes `Buffer.from("${domain}/${info}")`
87
+ as the HKDF `info` parameter (`s.domain` = `keyflower/v2` or `keyflower/v1`;
88
+ `s.ratchetDomain` = `keyflower/ratchet/v2` or `keyflower/ratchet/v1`).
89
+
90
+ | HKDF `info` String | Salt | Output Len | Module | Purpose |
91
+ |---|---|---|---|---|
92
+ | `<domain>/root` | `genomeDigest` | 32 B | `keyflower.mjs` | Initial flower root from `plant()` entropy |
93
+ | `<domain>/ratchet/<gen>` | `genomeDigest` | 32 B | `keyflower.mjs` | Symmetric root advance in `grow()` |
94
+ | `<domain>/msgkey` | 12 B nonce | 32 B | `keyflower.mjs` | Per-message / `--epoch` file AEAD key |
95
+ | `<domain>/shared-root` | `<domain>/pair` | 32 B | `keyflower.mjs` | Pollination shared root from sorted pollen digests |
96
+ | `<domain>/living/epoch/view` | `u64be(epoch)` | 16 B | `keyflower.mjs`, `living.mjs` | Public visual tag for current epoch (L1/L5) |
97
+ | `<domain>/living/epoch/<purpose>` | `u64be(epoch)` | caller `len` | `living.mjs` | Ephemeral epoch-scoped derived key (L1) |
98
+ | `<domain>/storage/pair/id` | empty | 8 B | `storage.mjs` | Deterministic shared storage key ID post-pollination (L2) |
99
+ | `<domain>/storage/pair/key` | empty | 32 B | `storage.mjs` | Deterministic shared storage key post-pollination (L2) |
100
+ | `<domain>/storage/file/<keyId>` | 32 B `fileSalt` | 32 B | `storage.mjs` | Unique per-file AEAD key (L2) |
101
+ | `<domain>/edge:<edgeId>` | `keyflower/garden-tunnel/v1` | 32 B | `garden.mjs` | Garden-backed `kf tunnel`/`kf mcp` root key (L7) |
102
+ | `<ratchetDomain>/root` | `rootKey` | 64 B | `ratchet.mjs` | Next `(rootKey \|\| chainKey)` from ML-KEM (or `ML-KEM \|\| X25519`) secret |
103
+ | `<ratchetDomain>/msg` | empty | 32 B | `ratchet.mjs` | Per-message chain key output |
104
+ | `<ratchetDomain>/chain` | empty | 32 B | `ratchet.mjs` | Next symmetric chain key |
105
+ | `<ratchetDomain>/aead` | empty | 44 B | `ratchet.mjs` | Per-message `(32 B AES key \|\| 12 B GCM nonce)` |
106
+ | `<ratchetDomain>/export/<label>` | empty | caller `len` | `ratchet.mjs` | Session key exporter (e.g. `"living"` in L3 migration) |
107
+ | `<ratchetDomain>/rekey/epoch/<epoch>` | 32 B random `salt` | 32 B | `tunnel/reliable-frame.mjs` | Fresh epoch root during M3 authenticated rekey |
108
+
109
+ ### 3.3 Dedicated AAD Prefixes
110
+
111
+ | AAD Format | Module | Bound Data |
112
+ |---|---|---|
113
+ | `keyflower/v<v>/hw\n` + `canonical({v,label,seed,generation,pub,provider,handle})` | `keyflower.mjs` | L4 hardware-wrapped inner secrets (`rootKey`, `identity.priv`, `storage`) |
114
+ | `u16be(hlen) \|\| headerJSON` | `keyflower.mjs`, `session.mjs`, `src/tunnel-session.mjs` | Suite ID, KDF parameters, and checkpoint `wrapKey` metadata |
115
+ | `"KFLW" \|\| version(1) \|\| u32be(hlen) \|\| headerJSON` | `cli.mjs` | Sealed v2 `.kf` file header (`suite`, optional `keyId`, `label`, `generation`) |
116
+ | `canonical(header)` | `ratchet.mjs` | Ratchet frame header (`v`, `pub`, `ct`, `pn`, `n`, optional `dh`) |
117
+
118
+ ---
119
+
120
+ ## 4. Data-at-Rest & Wire Artifact Inventory
121
+
122
+ See `WIRE-FORMAT.md` for full byte-level layouts and size ceilings.
123
+
124
+ | Artifact | Marker / Kind | Primitives Used | Permissions | Sensitivity |
125
+ |---|---|---|---|---|
126
+ | Flower file (`*.flower`, v2) | `kf2:` | PBKDF2-HMAC-SHA384 + AES-256-GCM (+ optional L4 TPM KEK inner AEAD) | `0600` (atomic) | **Secret** (live root, ML-DSA-87 priv, L2 storage keyring) |
127
+ | Flower file (`*.flower`, v1 legacy) | raw base64 | scrypt + AES-256-GCM | `0600` (atomic) | **Secret** (`kf migrate` upgrades to v2) |
128
+ | Sealed file (`*.kf`, v2 L2 default) | `KFLW\x02` + `keyId` | HKDF-SHA384 (`fileSalt`) + AES-256-GCM (AAD = prefix) | `0644` / caller | Ciphertext (survives `kf grow`) |
129
+ | Sealed file (`*.kf`, v2 `--epoch` / v1) | `KFLW\x02` (no `keyId`) / `KFLW\x01` | HKDF root `msgkey` + AES-256-GCM | `0644` / caller | Ciphertext (locked out by `kf grow`) |
130
+ | Pollen grain (`*.pollen.json`) | `{ v:2, genome, identity, [prekey], sig }` | SHA-384 + ML-DSA-87 | `0600` | **Secret** (derives shared root; delete after pollination) |
131
+ | Signed prekey invite (`*.invite.json`) | `{ v:2, prekey, identity, [hybrid, dhPrekey], sig }` | ML-KEM-1024 (+ optional X25519) + ML-DSA-87 | `0644` | Public (must pin with `--expect`) |
132
+ | Chat / tunnel session (`*.session`) | `kf2sess:` | PBKDF2-HMAC-SHA384 + AES-256-GCM | `0600` (atomic) | **Secret** (live ratchet keys & skipped-key cache) |
133
+ | Tunnel checkpoint (`*.session.ckpt`) | `kf2ckpt:` | PBKDF2-wrapped 32 B `wrapKey` + per-save AES-256-GCM | `0600` (atomic) | **Secret** (live ratchet + unacked **ciphertext** only) |
134
+ | Migration prekey (`*.prekey`) | `kf2pre:` | PBKDF2-HMAC-SHA384 + AES-256-GCM | `0600` (atomic) | **Secret** (responder ML-KEM private key) |
135
+ | Garden link (`edges/*.link`) | `kf2edge:` | PBKDF2-HMAC-SHA384 + AES-256-GCM | `0600` (atomic) | **Secret** (pairwise `sharedRoot` + prekeys + pinned bundles) |
136
+ | Garden manifest (`garden.json`) | JSON topology & plot metadata | SHA-384 fingerprints only (no private keys) | `0600` / `0644` | Metadata (integrity-sensitive) |
137
+ | MCP policy (`policy.json`) | JSON peer allowlist | Keyed by verified ML-DSA-87 fingerprint | `0444` / `0600` | Integrity-critical (no secrets) |
138
+ | Public identity card (`*.id.json`) | `keyflower/id/v1` | ML-DSA-87 (`id-card`) | `0644` | **Public, zero-secret** |
139
+ | Detached signature (`*.kfsig`) | `keyflower/sig/v1` | SHA-384 + ML-DSA-87 (`id-sign`) | `0644` | **Public** |
140
+ | Auth challenge / proof | `keyflower/id-challenge/v1`, `keyflower/id-proof/v1` | CSPRNG 32 B nonce + ML-DSA-87 (`id-proof`) | `0644` / transient | **Public / transient** |
141
+ | Revocation cert (`*.revoke.json`) | `keyflower/id-revoke/v1` | ML-DSA-87 (`id-revoke`) | `0600` (`--prepare`) / `0644` (published) | Sensitive while held offline; public once published |
142
+ | Rotation cert (`*.rotate.json`) | `keyflower/id-rotate/v1` | Dual ML-DSA-87 (`id-rotate-old` + `id-rotate-new`) | `0644` | **Public** |
143
+ | Local trust store (`trusted.json`) | `keyflower/trusted-peers/v1` | Pinned SPKI keys & SHA-384 fingerprints | `0600` (atomic) | Integrity-critical local trust anchor |
144
+ | Local CRL (`revoked.json`) | `keyflower/revoked-peers/v1` | Self-authenticating ML-DSA-87 tombstones (re-verified on load) | `0600` (atomic) | Integrity-critical local revocation state |
145
+ | Release signature (`*.tgz.sig`) | `{ suite:2, digest, sig }` | SHA-384 + ML-DSA-87 (`release`) | `0644` | **Public** (`keys/release.pub`) |
146
+
147
+ ---
148
+
149
+ ## 5. Runtime Requirements & FIPS Mode (M6 / Gate 2)
150
+
151
+ Node `>= 24` (OpenSSL 3.5+) is required for native ML-KEM-1024 and ML-DSA-87,
152
+ enforced by `package.json` `"engines"` and `src/runtime.mjs` / `src/guard.mjs`.
153
+
154
+ The M6 readiness checklist is executable via `npm run fips:check`
155
+ (`scripts/fips-check.mjs`) and `npm run test:fips` (`scripts/test-fips.mjs`),
156
+ and guarded against regressions by `test/run.mjs §11`.
157
+
158
+ - **Default Node 24 binaries cannot enter FIPS mode:** official builds
159
+ statically link OpenSSL 3.5.9 without a FIPS provider (`crypto.getFips() === 0`).
160
+ `npm run test:fips` detects this and exits 0 with a clear `SKIPPED` line; on a
161
+ FIPS-capable Node host it runs the entire test gate under `--force-fips`.
162
+ - **Automatic CNSA-only policy:** under FIPS mode (or when
163
+ `KEYFLOWER_REQUIRE_CNSA2=1` is set), `src/suite.mjs` refuses suite v1
164
+ everywhere and restricts TPM parent profile selection to `sha384`. CI runs both
165
+ default and `KEYFLOWER_REQUIRE_CNSA2=1` gates on every push and PR.
166
+ - **Open checks requiring a real FIPS 140-3 host (Gate 2):**
167
+ 1. Confirm `npm run fips:check` Check 0 reports `--force-fips` active.
168
+ 2. Confirm Check 1 passes ML-KEM-1024 and ML-DSA-87 round-trips **and**
169
+ manually verify the OpenSSL FIPS provider's CMVP certificate includes
170
+ FIPS 203 and FIPS 204 inside its validated boundary.
171
+ 3. Confirm Check 2 resolves the FIPS 140-3 IG C.H / SP 800-38D external
172
+ AES-GCM IV question (switch `src/suite.mjs` `seal()` to provider-generated
173
+ IVs if the target FIPS provider rejects caller-supplied 96-bit nonces).
174
+ 4. Run `npm run test:fips` and record the host, OpenSSL FIPS provider version,
175
+ and CMVP certificate number here.
176
+
177
+ **Latest host check (2026-12-06, Node `24.23.0`, OpenSSL `3.5.9`, non-FIPS build):**
178
+ - Check 0: process not in FIPS mode; no OpenSSL FIPS provider linked.
179
+ - Check 1: `ml-kem-1024` and `ml-dsa-87` round-trips PASS (default provider).
180
+ - Check 2: `aes-256-gcm` external-IV round-trip PASS (default provider; must be
181
+ re-verified on a FIPS host).
182
+ - Verdict: primitives usable; FIPS boundary validation still pending a real FIPS
183
+ 140-3 host. Validation belongs to the crypto module vendor (OpenSSL), not to
184
+ KEYflower.