@shieldfive/crypto 1.0.0-alpha.5 → 1.0.0-alpha.7

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 CHANGED
@@ -5,6 +5,55 @@ All notable changes to `@shieldfive/crypto` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.0-alpha.7] — 2026-05
9
+
10
+ ### Dependencies
11
+
12
+ - Bump `@noble/post-quantum` from `^0.5.3` (resolved 0.5.4) to
13
+ `^0.6.0` (resolves to 0.6.1). The upstream maintainer self-audit
14
+ released alongside 0.6.1 (April 2026) covers the line ShieldFive
15
+ now ships; the 0.5.x line predates the self-audit. The pinned
16
+ `10_ml_kem_keypair_derivation` test vector in
17
+ `tests/vectors/vectors.json` is byte-identical under 0.6.1 and
18
+ 0.5.4 (both implement final FIPS 203 ML-KEM-1024), so no vector
19
+ refresh was required. Wire format and on-disk format are
20
+ byte-identical to prior alphas for the same plaintext, key, and
21
+ file_id inputs.
22
+
23
+ ### Documentation
24
+
25
+ - README dependency acknowledgement rewritten to accurately
26
+ describe the noble-post-quantum version (^0.6.0, resolving to
27
+ 0.6.1) and audit status (upstream self-audit April 2026; no
28
+ independent external audit of either the upstream library or
29
+ the ShieldFive PQ-hybrid construction on top of it). Closes the
30
+ audit punch-list item under `audit/launch/cho-deep-audit-2026-05-19`
31
+ § P0-7.
32
+
33
+ ## [1.0.0-alpha.6] — 2026-05
34
+
35
+ ### Added
36
+
37
+ - `./streams/pq-hybrid-v1` — `createPqHybridV1DecryptStream` now accepts
38
+ a pre-derived 32-byte combined key K via a new `combinedKey` option,
39
+ in lieu of the `recipientSecretKey` + `envelopeKey` pair. When present,
40
+ the stream skips ML-KEM decapsulation and uses K directly for header
41
+ MAC verification and per-chunk AEAD. The header MAC check still
42
+ cryptographically gates the rest of the stream, so a wrong K fails
43
+ fast. Unblocks Suite 0x03 share-link recipients: they unwrap K under
44
+ the share-link password and never touch ML-KEM material. The
45
+ `PqHybridV1DecryptStreamOptions` type is now a discriminated union
46
+ over the two key-input modes; existing callers that pass
47
+ `recipientSecretKey` + `envelopeKey` are unaffected.
48
+ - `./pq-hybrid-v1` (and `pqHybridV1` namespace on the umbrella entry) —
49
+ `decapsulateFromHeader`, `encapsulateForRecipient`, and the
50
+ `PQ_HYBRID_V1_SUITE_PAYLOAD_LENGTH` constant are now publicly
51
+ re-exported from the suite's public surface (`api.ts`). The previous
52
+ release exposed them only on the internal `index.js` path. Lets
53
+ callers that hold the parsed `suite_payload` + KEM material (e.g.,
54
+ share-link generators that need to derive K out-of-band) reach the
55
+ primitives without importing from a deep internal path.
56
+
8
57
  ## [1.0.0-alpha.5] — 2026-05
9
58
 
10
59
  ### Added
@@ -29,7 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
29
78
  principals" section enumerating share-link recipients, expanded
30
79
  metadata-leakage list, and a recovery-key-compromise paragraph
31
80
  under "Out of scope". See
32
- [crypto#4](https://github.com/shieldfive/crypto/pull/4) for the
81
+ [crypto#4](https://github.com/shieldfive/crypto/commit/bb967cb) for the
33
82
  detailed diff. Docs-only; no wire-format or code changes.
34
83
 
35
84
  ## [1.0.0-alpha.3] — 2026-05
@@ -116,4 +165,6 @@ The first public release.
116
165
  [1.0.0-alpha.3]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.2...v1.0.0-alpha.3
117
166
  [1.0.0-alpha.4]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.3...v1.0.0-alpha.4
118
167
  [1.0.0-alpha.5]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.4...v1.0.0-alpha.5
119
- [Unreleased]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.5...HEAD
168
+ [1.0.0-alpha.6]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.5...v1.0.0-alpha.6
169
+ [1.0.0-alpha.7]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.6...v1.0.0-alpha.7
170
+ [Unreleased]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.7...HEAD
package/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2026 ShieldFive Labs
189
+ Copyright 2026 ShieldFive
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > [ShieldFive](https://shieldfive.com), released as a standalone library.
6
6
 
7
7
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
- [![Tests](https://img.shields.io/badge/tests-126%2F126-brightgreen.svg)](tests/)
8
+ [![Tests](https://img.shields.io/badge/tests-155%2F155-brightgreen.svg)](tests/)
9
9
  [![Status](https://img.shields.io/badge/status-alpha-orange.svg)](#status)
10
10
 
11
11
  ## Status & honest scope
@@ -17,7 +17,7 @@ treat this library as a serious work-in-progress rather than a finished
17
17
  product.
18
18
 
19
19
  The design choices documented in [`spec/`](spec/) are deliberate and
20
- reviewable. The implementation is covered by 126 passing tests including
20
+ reviewable. The implementation is covered by 155 passing tests including
21
21
  truncation, reordering, splice, and tampering detection across all four
22
22
  suites. That is enough for internal dogfooding. It is **not** enough to
23
23
  claim "most secure crypto library" — that claim requires external review
@@ -32,7 +32,7 @@ spec section that documents the choice.
32
32
 
33
33
  | Property | This library | Proton OpenPGP.js | Internxt SDK | MEGA SDK |
34
34
  | ------------------------------------------ | :----------: | :---------------: | :----------: | :------: |
35
- | Post-quantum hybrid by default | ✅ | ❌ | ⚠️ | ❌ |
35
+ | Post-quantum hybrid by default | ✅ | ⚠️ | ⚠️ | ❌ |
36
36
  | ML-KEM-1024 (NIST PQC level 5) | ✅ | ❌ | ❌ (Kyber-512) | ❌ |
37
37
  | Self-describing on-disk file format | ✅ | ✅ | ⚠️ | ⚠️ |
38
38
  | Cipher-suite agile (one byte selects) | ✅ | ⚠️ | ❌ | ❌ |
@@ -43,7 +43,12 @@ spec section that documents the choice.
43
43
  | Apache 2.0 (patent grant) | ✅ | ⚠️ (LGPL) | ⚠️ | ⚠️ |
44
44
 
45
45
  ⚠️ = partial or feature-flagged. See [`spec/threat-model.md`](spec/threat-model.md)
46
- for the comparison methodology and source citations.
46
+ for the comparison methodology and source citations. Proton OpenPGP.js
47
+ added optional post-quantum (ML-KEM + ECC hybrid) support via OpenPGP v6
48
+ in May 2026 (proton.me/blog/introducing-post-quantum-encryption); it is
49
+ opt-in, not default — hence ⚠️ rather than ✅ in the table. Comparison
50
+ cells reflect publicly available specifications and audit reports as of
51
+ 2026-05-18 and will be updated as upstreams change.
47
52
 
48
53
  ## Quick start
49
54
 
@@ -134,6 +139,25 @@ const plaintext = await decryptV0({
134
139
 
135
140
  There is no `encryptV0`. New writes must use a v1 suite.
136
141
 
142
+ ### Decrypting an exported ShieldFive backup
143
+
144
+ A ShieldFive user can export their account at any time and
145
+ decrypt the resulting bundle offline using this library plus the
146
+ small Node script that ships at
147
+ [shieldfive.com/export](https://shieldfive.com/export). The
148
+ recipe walks the key hierarchy (master password → user key →
149
+ root key → folder keys → per-file content keys), re-derives the
150
+ ML-KEM-1024 secret for Suite 0x03 files deterministically from
151
+ the root key (per `spec/key-derivation.md`), and feeds each blob
152
+ into `autoDecryptBlob` here.
153
+
154
+ The recipe and the script live in the web repository so that the
155
+ documented version stays in lock-step with the API surface; this
156
+ library is the decryption primitive the script depends on. If
157
+ you want to reproduce the path from first principles (with no
158
+ ShieldFive code in the loop), `spec/format-v1.md` and
159
+ `spec/key-derivation.md` together describe everything needed.
160
+
137
161
  ## File format
138
162
 
139
163
  The complete v1 wire format is documented in
@@ -213,7 +237,7 @@ Requires Node 20+.
213
237
 
214
238
  **Alpha.** The wire format is frozen for the v1 release, but the public
215
239
  TypeScript API may make small adjustments before 1.0.0 stable. Test
216
- coverage is comprehensive (64 tests, all four suites, all architectural
240
+ coverage is comprehensive (155 tests, all four suites, all architectural
217
241
  guarantees verified). A formal third-party security audit is planned for
218
242
  the 1.0.0 stable milestone — until that audit lands, treat this library
219
243
  as a serious work-in-progress rather than a finished product.
@@ -233,9 +257,19 @@ in good faith are protected under the safe-harbor clause.
233
257
  ## Acknowledgements
234
258
 
235
259
  - [@noble/post-quantum](https://github.com/paulmillr/noble-post-quantum)
236
- by Paul Miller — clean, audited ML-KEM-1024 implementation.
260
+ by Paul Miller — clean, minimal ML-KEM-1024 (FIPS 203)
261
+ implementation. ShieldFive pins `^0.6.0`, which resolves to the 0.6.1
262
+ release. Upstream completed a maintainer self-audit at 0.6.1 in
263
+ April 2026 (see the
264
+ ["Security"](https://github.com/paulmillr/noble-post-quantum#security)
265
+ section of the upstream README) and has **not** been independently
266
+ audited by an external firm. ShieldFive's PQ-hybrid construction on
267
+ top of the library — the HKDF-SHA-256 combiner that mixes the
268
+ classical and ML-KEM shares — has also not received an independent
269
+ external audit. A third-party audit of the ShieldFive layer is
270
+ planned for the v1.0.0 stable milestone.
237
271
  - [libsodium](https://github.com/jedisct1/libsodium) — XChaCha20-Poly1305
238
272
  and XSalsa20-Poly1305 secretbox.
239
273
  - The NIST PQC competition and FIPS 203 authors.
240
274
 
241
- — *ShieldFive Labs*
275
+ — Cho Garcia, maintainer
package/SECURITY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Security Policy
2
2
 
3
- ShieldFive Labs takes the security of `@shieldfive/crypto` seriously. This
3
+ ShieldFive takes the security of `@shieldfive/crypto` seriously. This
4
4
  document describes how to report a vulnerability, what we commit to, and
5
5
  the safe-harbor terms for security researchers.
6
6
 
@@ -10,8 +10,11 @@ the safe-harbor terms for security researchers.
10
10
  us directly:
11
11
 
12
12
  - **Email:** `security@shieldfive.com`
13
- - **PGP key fingerprint:** *(to be published at v1.0.0 stable release)*
14
- - **Public PGP key:** `https://shieldfive.com/.well-known/security/pgp-key.txt`
13
+ - **PGP key:** Not yet published. Encrypt with a temporary key on
14
+ request, or send in plaintext — we'd rather know about the issue
15
+ than have it sit in your inbox. The permanent PGP key fingerprint
16
+ will be published at v1.0.0 stable release alongside the URL
17
+ `https://shieldfive.com/.well-known/security/pgp-key.txt`.
15
18
 
16
19
  If you cannot encrypt the report, send it in plaintext anyway — we would
17
20
  rather hear about a vulnerability in plaintext than not at all. We will
@@ -120,4 +123,4 @@ with their consent.)
120
123
 
121
124
  ---
122
125
 
123
- Last updated: v1.0.0-alpha.1
126
+ Last updated: v1.0.0-alpha.7
package/dist/index.d.ts CHANGED
@@ -46,7 +46,7 @@ export interface AutoDecryptOptions {
46
46
  */
47
47
  export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
48
48
  /** Library version, also written into format documentation. */
49
- export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-alpha.3";
49
+ export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-alpha.6";
50
50
  /** Default cipher suite for new files when not specified by the caller. */
51
51
  export declare const DEFAULT_SUITE: 3;
52
52
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ export async function autoDecryptBlob(options) {
118
118
  }
119
119
  }
120
120
  /** Library version, also written into format documentation. */
121
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.3';
121
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.6';
122
122
  /** Default cipher suite for new files when not specified by the caller. */
123
123
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
124
124
  //# sourceMappingURL=index.js.map
@@ -33,6 +33,14 @@ export interface PqHybridV1EncryptStreamOptions {
33
33
  /**
34
34
  * Combined content key from `encapsulateForRecipient`. 32 bytes. Used
35
35
  * both for header MAC and for chunk AEAD.
36
+ *
37
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
38
+ * capability for any file whose header was produced with it. Treat
39
+ * as cryptographic secret material: hold only in memory for the
40
+ * duration of the operation, do not persist to disk or storage, do
41
+ * not log, do not transmit. The only safe way to reproduce it on
42
+ * another machine is to re-encapsulate via the recipient's ML-KEM
43
+ * public key.
36
44
  */
37
45
  combinedKey: Uint8Array;
38
46
  /** 16-byte file_id used as HKDF salt in encapsulation and key derivation. */
@@ -47,7 +55,17 @@ export interface PqHybridV1EncryptStreamOptions {
47
55
  export interface PqHybridV1EncryptStreamResult {
48
56
  /** TransformStream<Uint8Array, Uint8Array> emitting the v1 wire format. */
49
57
  stream: TransformStream<Uint8Array, Uint8Array>;
50
- /** The combined key used (echoed back for caller convenience). */
58
+ /**
59
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
60
+ * capability for any file whose header was produced with it. Treat
61
+ * as cryptographic secret material: hold only in memory for the
62
+ * duration of the operation, do not persist to disk or storage, do
63
+ * not log, do not transmit. The only safe way to reproduce it on
64
+ * another machine is to re-encapsulate via the recipient's ML-KEM
65
+ * public key.
66
+ *
67
+ * Echoed back for caller convenience.
68
+ */
51
69
  combinedKey: Uint8Array;
52
70
  /** The file_id used (echoed back for caller convenience). */
53
71
  fileId: Uint8Array;
@@ -69,21 +87,58 @@ export interface PqHybridV1EncryptStreamResult {
69
87
  * public key directly.
70
88
  */
71
89
  export declare function createPqHybridV1EncryptStream(options: PqHybridV1EncryptStreamOptions): PqHybridV1EncryptStreamResult;
72
- export interface PqHybridV1DecryptStreamOptions {
73
- /** Recipient's ML-KEM-1024 secret key (3168 bytes) */
90
+ /**
91
+ * Inputs for {@link createPqHybridV1DecryptStream}. Either provide the
92
+ * KEM material (`recipientSecretKey` + `envelopeKey`) so the stream can
93
+ * derive the combined key itself, OR provide the already-derived
94
+ * `combinedKey` directly. The latter is what share-link recipients use:
95
+ * they hold a 32-byte K (wrapped under the share-link password) and
96
+ * never see the ML-KEM secret key.
97
+ *
98
+ * Mixing both modes is not supported — `combinedKey` always wins. The
99
+ * caller is responsible for picking one path.
100
+ */
101
+ export type PqHybridV1DecryptStreamOptions = {
102
+ /** Recipient's ML-KEM-1024 secret key (3168 bytes). */
74
103
  recipientSecretKey: Uint8Array;
75
- /** Classical envelope key (32 bytes) */
104
+ /** Classical envelope key (32 bytes). */
76
105
  envelopeKey: Uint8Array;
77
- }
106
+ combinedKey?: undefined;
107
+ } | {
108
+ /**
109
+ * Pre-derived 32-byte combined key K. When provided, the stream
110
+ * skips ML-KEM decapsulation entirely and uses K for header MAC
111
+ * verification + per-chunk AEAD. Header MAC validation still
112
+ * cryptographically gates the rest of the stream, so a wrong K
113
+ * fails fast.
114
+ *
115
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
116
+ * capability for any file whose header was produced with it. Treat
117
+ * as cryptographic secret material: hold only in memory for the
118
+ * duration of the operation, do not persist to disk or storage, do
119
+ * not log, do not transmit. The only safe way to reproduce it on
120
+ * another machine is to re-encapsulate via the recipient's ML-KEM
121
+ * public key.
122
+ */
123
+ combinedKey: Uint8Array;
124
+ recipientSecretKey?: undefined;
125
+ envelopeKey?: undefined;
126
+ };
78
127
  /**
79
128
  * Build a TransformStream that decrypts a v1 ciphertext stream produced
80
129
  * under suite 0x03 into plaintext. Unlike the whole-blob decryptor, this
81
130
  * version processes input incrementally — useful for very large files or
82
131
  * when ciphertext arrives chunked over the network.
83
132
  *
84
- * PQ decapsulation runs once, the moment the header has been buffered,
85
- * before any chunk is processed. After that the stream behaves
86
- * identically to the AES-GCM-v1 decrypt stream.
133
+ * Two key-input modes:
134
+ * - KEM mode (`recipientSecretKey` + `envelopeKey`): the stream runs
135
+ * ML-KEM decapsulation once, the moment the header has been
136
+ * buffered, then proceeds identically to the AES-GCM-v1 decrypt
137
+ * stream.
138
+ * - Combined-key mode (`combinedKey`): skips decapsulation entirely
139
+ * and uses the supplied K for header MAC verification + chunk AEAD.
140
+ * Intended for share-link recipients who hold a wrapped K but no
141
+ * ML-KEM secret.
87
142
  */
88
143
  export declare function createPqHybridV1DecryptStream(options: PqHybridV1DecryptStreamOptions): TransformStream<Uint8Array, Uint8Array>;
89
144
  export interface EncryptStreamPqHybridV1Options {
@@ -100,11 +155,22 @@ export interface EncryptStreamPqHybridV1Options {
100
155
  }
101
156
  /**
102
157
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 encrypt
103
- * transform and return the resulting ReadableStream + the materials the
104
- * caller will need to store alongside the file (file_id) or share back
105
- * to the sender's records (combined key, suite payload).
158
+ * transform and return the resulting ReadableStream alongside the
159
+ * derived material the caller will need: the 16-byte file_id (safe
160
+ * to persist with the ciphertext), the suite payload (safe to
161
+ * persist with the ciphertext; required for later decapsulation),
162
+ * and the 32-byte combined key.
163
+ *
164
+ * SECURITY: The returned `combinedKey` grants permanent decryption
165
+ * capability for any file whose header was produced with it. Treat
166
+ * as cryptographic secret material: hold only in memory for the
167
+ * duration of the operation, do not persist to disk or storage, do
168
+ * not log, do not transmit. The only safe way to reproduce it on
169
+ * another machine is to re-encapsulate via the recipient's ML-KEM
170
+ * public key.
106
171
  *
107
- * This helper is async because PQ encapsulation requires libsodium init.
172
+ * This helper is async because PQ encapsulation requires libsodium
173
+ * init.
108
174
  */
109
175
  export declare function encryptStreamPqHybridV1(source: ReadableStream<Uint8Array>, options: EncryptStreamPqHybridV1Options): Promise<{
110
176
  ciphertext: ReadableStream<Uint8Array>;
@@ -114,7 +180,9 @@ export declare function encryptStreamPqHybridV1(source: ReadableStream<Uint8Arra
114
180
  }>;
115
181
  /**
116
182
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 decrypt
117
- * transform and return the resulting plaintext ReadableStream.
183
+ * transform and return the resulting plaintext ReadableStream. See
184
+ * {@link PqHybridV1DecryptStreamOptions} for the two key-input modes
185
+ * (KEM secret + envelope vs. pre-derived combined key K).
118
186
  */
119
187
  export declare function decryptStreamPqHybridV1(source: ReadableStream<Uint8Array>, options: PqHybridV1DecryptStreamOptions): ReadableStream<Uint8Array>;
120
188
  //# sourceMappingURL=pq-hybrid-v1.d.ts.map
@@ -1 +1 @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AC9B,yCAAyC;IACzC,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,CAAC,EAAE,SAAS,CAAA;CACxB,GACD;IACE;;;;;;;;;;;;;;OAcG;IACH,WAAW,EAAE,UAAU,CAAA;IACvB,kBAAkB,CAAC,EAAE,SAAS,CAAA;IAC9B,WAAW,CAAC,EAAE,SAAS,CAAA;CACxB,CAAA;AAEL;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAyMzC;AAMD,MAAM,WAAW,8BAA8B;IAC7C,sDAAsD;IACtD,kBAAkB,EAAE,UAAU,CAAA;IAC9B,wCAAwC;IACxC,WAAW,EAAE,UAAU,CAAA;IACvB,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAA;IACrB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC;IACT,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACtC,WAAW,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,UAAU,CAAA;IAClB,YAAY,EAAE,UAAU,CAAA;CACzB,CAAC,CA8BD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,8BAA8B,GACtC,cAAc,CAAC,UAAU,CAAC,CAE5B"}
@@ -161,16 +161,34 @@ export function createPqHybridV1EncryptStream(options) {
161
161
  * version processes input incrementally — useful for very large files or
162
162
  * when ciphertext arrives chunked over the network.
163
163
  *
164
- * PQ decapsulation runs once, the moment the header has been buffered,
165
- * before any chunk is processed. After that the stream behaves
166
- * identically to the AES-GCM-v1 decrypt stream.
164
+ * Two key-input modes:
165
+ * - KEM mode (`recipientSecretKey` + `envelopeKey`): the stream runs
166
+ * ML-KEM decapsulation once, the moment the header has been
167
+ * buffered, then proceeds identically to the AES-GCM-v1 decrypt
168
+ * stream.
169
+ * - Combined-key mode (`combinedKey`): skips decapsulation entirely
170
+ * and uses the supplied K for header MAC verification + chunk AEAD.
171
+ * Intended for share-link recipients who hold a wrapped K but no
172
+ * ML-KEM secret.
167
173
  */
168
174
  export function createPqHybridV1DecryptStream(options) {
169
- const { recipientSecretKey, envelopeKey } = options;
170
- if (envelopeKey.length !== 32) {
171
- throw new RangeError('decrypt stream: envelopeKey must be 32 bytes');
175
+ const combinedKeyOverride = options.combinedKey;
176
+ const recipientSecretKey = options.recipientSecretKey;
177
+ const envelopeKey = options.envelopeKey;
178
+ if (combinedKeyOverride) {
179
+ if (combinedKeyOverride.length !== 32) {
180
+ throw new RangeError('decrypt stream: combinedKey must be 32 bytes');
181
+ }
182
+ }
183
+ else {
184
+ if (!recipientSecretKey || !envelopeKey) {
185
+ throw new RangeError('decrypt stream: provide either combinedKey or recipientSecretKey + envelopeKey');
186
+ }
187
+ if (envelopeKey.length !== 32) {
188
+ throw new RangeError('decrypt stream: envelopeKey must be 32 bytes');
189
+ }
190
+ // Length of recipientSecretKey is checked inside decapsulateFromHeader.
172
191
  }
173
- // Length of recipientSecretKey is checked inside decapsulateFromHeader.
174
192
  // Phases:
175
193
  // 0 = waiting for header bytes
176
194
  // 1 = streaming chunks: alternating length-prefix + ciphertext
@@ -226,15 +244,24 @@ export function createPqHybridV1DecryptStream(options) {
226
244
  if (parsedHeader.suite !== SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1) {
227
245
  throw new HeaderError(`decrypt stream: this stream only supports pq-hybrid-xchacha-mlkem1024-v1; got suite 0x${parsedHeader.suite.toString(16)}`);
228
246
  }
229
- // Recover the combined key — this is where PQ decapsulation happens.
230
- // The header MAC implicitly verifies that the right combined key was
231
- // recovered (i.e., the PQ secret + envelope key match the file).
232
- const { combinedKey } = await decapsulateFromHeader({
233
- suitePayload: parsedHeader.suitePayload,
234
- recipientSecretKey,
235
- envelopeKey,
236
- fileId: parsedHeader.fileId,
237
- });
247
+ // Recover the combined key. Two paths:
248
+ // - KEM mode: run ML-KEM decapsulation now.
249
+ // - Combined-key mode: trust the supplied K. The header MAC check
250
+ // below still cryptographically gates the rest of the stream, so
251
+ // a wrong K fails fast.
252
+ let combinedKey;
253
+ if (combinedKeyOverride) {
254
+ combinedKey = combinedKeyOverride;
255
+ }
256
+ else {
257
+ ;
258
+ ({ combinedKey } = await decapsulateFromHeader({
259
+ suitePayload: parsedHeader.suitePayload,
260
+ recipientSecretKey: recipientSecretKey,
261
+ envelopeKey: envelopeKey,
262
+ fileId: parsedHeader.fileId,
263
+ }));
264
+ }
238
265
  const { verifyHeaderMac } = await import('../format/header.js');
239
266
  await verifyHeaderMac(parsedHeader, combinedKey);
240
267
  contextPromise = createChunkContext(combinedKey, parsedHeader.fileId, parsedHeader.totalChunks);
@@ -324,11 +351,22 @@ export function createPqHybridV1DecryptStream(options) {
324
351
  }
325
352
  /**
326
353
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 encrypt
327
- * transform and return the resulting ReadableStream + the materials the
328
- * caller will need to store alongside the file (file_id) or share back
329
- * to the sender's records (combined key, suite payload).
354
+ * transform and return the resulting ReadableStream alongside the
355
+ * derived material the caller will need: the 16-byte file_id (safe
356
+ * to persist with the ciphertext), the suite payload (safe to
357
+ * persist with the ciphertext; required for later decapsulation),
358
+ * and the 32-byte combined key.
359
+ *
360
+ * SECURITY: The returned `combinedKey` grants permanent decryption
361
+ * capability for any file whose header was produced with it. Treat
362
+ * as cryptographic secret material: hold only in memory for the
363
+ * duration of the operation, do not persist to disk or storage, do
364
+ * not log, do not transmit. The only safe way to reproduce it on
365
+ * another machine is to re-encapsulate via the recipient's ML-KEM
366
+ * public key.
330
367
  *
331
- * This helper is async because PQ encapsulation requires libsodium init.
368
+ * This helper is async because PQ encapsulation requires libsodium
369
+ * init.
332
370
  */
333
371
  export async function encryptStreamPqHybridV1(source, options) {
334
372
  const { recipientPublicKey, envelopeKey } = options;
@@ -360,7 +398,9 @@ export async function encryptStreamPqHybridV1(source, options) {
360
398
  }
361
399
  /**
362
400
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 decrypt
363
- * transform and return the resulting plaintext ReadableStream.
401
+ * transform and return the resulting plaintext ReadableStream. See
402
+ * {@link PqHybridV1DecryptStreamOptions} for the two key-input modes
403
+ * (KEM secret + envelope vs. pre-derived combined key K).
364
404
  */
365
405
  export function decryptStreamPqHybridV1(source, options) {
366
406
  return source.pipeThrough(createPqHybridV1DecryptStream(options));
@@ -1 +1 @@
1
- {"version":3,"file":"pq-hybrid-v1.js","sourceRoot":"","sources":["../../src/streams/pq-hybrid-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,uBAAuB,EACvB,YAAY,GACb,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,KAAK,GACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAmC7B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAuC;IAEvC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAA;IACzD,IAAI,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A;IACD,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACpC,aAAa,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IAC7C,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,6BAA6B,CAAC,aAAa,CAAC,CAAA;IAE/D,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;QACtC,WAAW;QACX,MAAM;QACN,YAAY;KACb,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAkC,EAClC,OAAuC;IAEvC,OAAO,MAAM,CAAC,WAAW,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAA;AACnE,CAAC"}
@@ -11,6 +11,7 @@
11
11
  * recovered correctly.
12
12
  */
13
13
  import { type EncryptedFile, type ProgressCallback } from '../../internal/types.js';
14
+ export { decapsulateFromHeader, encapsulateForRecipient, PQ_HYBRID_V1_SUITE_PAYLOAD_LENGTH, } from './index.js';
14
15
  export interface PqHybridEncryptOptions {
15
16
  blob: Blob;
16
17
  /** Recipient's ML-KEM-1024 public key (1568 bytes) */
@@ -21,6 +22,19 @@ export interface PqHybridEncryptOptions {
21
22
  chunkSize?: number;
22
23
  onProgress?: ProgressCallback;
23
24
  }
25
+ /**
26
+ * Encrypt a Blob under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
27
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
28
+ * content key used to produce it.
29
+ *
30
+ * SECURITY: The returned `combinedKey` grants permanent decryption
31
+ * capability for any file whose header was produced with it. Treat
32
+ * as cryptographic secret material: hold only in memory for the
33
+ * duration of the operation, do not persist to disk or storage, do
34
+ * not log, do not transmit. The only safe way to reproduce it on
35
+ * another machine is to re-encapsulate via the recipient's ML-KEM
36
+ * public key.
37
+ */
24
38
  export declare function encryptBlob(options: PqHybridEncryptOptions): Promise<EncryptedFile & {
25
39
  combinedKey: Uint8Array;
26
40
  }>;
@@ -33,6 +47,19 @@ export interface PqHybridDecryptOptions {
33
47
  onProgress?: ProgressCallback;
34
48
  }
35
49
  export declare function decryptBlob(options: PqHybridDecryptOptions): Promise<Blob>;
50
+ /**
51
+ * Encrypt a Uint8Array under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
52
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
53
+ * content key used to produce it.
54
+ *
55
+ * SECURITY: The returned `combinedKey` grants permanent decryption
56
+ * capability for any file whose header was produced with it. Treat
57
+ * as cryptographic secret material: hold only in memory for the
58
+ * duration of the operation, do not persist to disk or storage, do
59
+ * not log, do not transmit. The only safe way to reproduce it on
60
+ * another machine is to re-encapsulate via the recipient's ML-KEM
61
+ * public key.
62
+ */
36
63
  export declare function encryptBytes(bytes: Uint8Array, options: Omit<PqHybridEncryptOptions, 'blob'>): Promise<EncryptedFile & {
37
64
  combinedKey: Uint8Array;
38
65
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/suites/pq-hybrid-v1/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiBH,OAAO,EAEL,KAAK,aAAa,EAGlB,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAA;AAUhC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,IAAI,CAAA;IACV,sDAAsD;IACtD,kBAAkB,EAAE,UAAU,CAAA;IAC9B,wEAAwE;IACxE,WAAW,EAAE,UAAU,CAAA;IACvB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,aAAa,GAAG;IAAE,WAAW,EAAE,UAAU,CAAA;CAAE,CAAC,CAsEtD;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,IAAI,CAAA;I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ACV,sDAAsD;IACtD,kBAAkB,EAAE,UAAU,CAAA;IAC9B,6BAA6B;IAC7B,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAsGf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,GAC5C,OAAO,CAAC,aAAa,GAAG;IAAE,WAAW,EAAE,UAAU,CAAA;CAAE,CAAC,CAGtD;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAGrB"}
@@ -15,7 +15,27 @@ import { PQ_HYBRID_V1_SUITE_PAYLOAD_LENGTH, PQ_HYBRID_V1_TAG_BYTES, createChunkC
15
15
  import { DEFAULT_CHUNK_SIZE, HEADER_SIZES, MAX_TOTAL_CHUNKS, SUITE, } from '../../internal/types.js';
16
16
  import { asBlobPart, readUint32BE, uint32BE, } from '../../internal/encoding.js';
17
17
  import { randomBytes } from '../../internal/runtime.js';
18
+ // Re-exports of suite primitives that are useful to callers outside the
19
+ // streaming/whole-blob API surfaces. `decapsulateFromHeader` lets a
20
+ // caller that already has the parsed suite_payload + KEM material
21
+ // recover the combined key K out-of-band (e.g., a share-link generator
22
+ // that wraps K under a separate password for recipients who never see
23
+ // ML-KEM secrets).
24
+ export { decapsulateFromHeader, encapsulateForRecipient, PQ_HYBRID_V1_SUITE_PAYLOAD_LENGTH, } from './index.js';
18
25
  const LENGTH_PREFIX_BYTES = 4;
26
+ /**
27
+ * Encrypt a Blob under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
28
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
29
+ * content key used to produce it.
30
+ *
31
+ * SECURITY: The returned `combinedKey` grants permanent decryption
32
+ * capability for any file whose header was produced with it. Treat
33
+ * as cryptographic secret material: hold only in memory for the
34
+ * duration of the operation, do not persist to disk or storage, do
35
+ * not log, do not transmit. The only safe way to reproduce it on
36
+ * another machine is to re-encapsulate via the recipient's ML-KEM
37
+ * public key.
38
+ */
19
39
  export async function encryptBlob(options) {
20
40
  const { blob, recipientPublicKey, envelopeKey, onProgress } = options;
21
41
  if (!(blob instanceof Blob)) {
@@ -146,6 +166,19 @@ export async function decryptBlob(options) {
146
166
  onProgress?.(1);
147
167
  return new Blob(plaintextParts, { type: 'application/octet-stream' });
148
168
  }
169
+ /**
170
+ * Encrypt a Uint8Array under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
171
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
172
+ * content key used to produce it.
173
+ *
174
+ * SECURITY: The returned `combinedKey` grants permanent decryption
175
+ * capability for any file whose header was produced with it. Treat
176
+ * as cryptographic secret material: hold only in memory for the
177
+ * duration of the operation, do not persist to disk or storage, do
178
+ * not log, do not transmit. The only safe way to reproduce it on
179
+ * another machine is to re-encapsulate via the recipient's ML-KEM
180
+ * public key.
181
+ */
149
182
  export async function encryptBytes(bytes, options) {
150
183
  const blob = new Blob([asBlobPart(bytes)]);
151
184
  return encryptBlob({ blob, ...options });
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/suites/pq-hybrid-v1/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,uBAAuB,EACvB,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,kBAAkB,EAElB,YAAY,EACZ,gBAAgB,EAEhB,KAAK,GACN,MAAM,yBAAyB,CAAA;AAChC,OA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AK,UAAU,cAAc,CAClC,OAA+B;IAE/B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,CAAA;IACvC,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;AACjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shieldfive/crypto",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "Open, audited-ready, post-quantum-hybrid client-side encryption for cloud storage. The cryptographic core of ShieldFive.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  "webcrypto",
26
26
  "cloud-storage"
27
27
  ],
28
- "author": "ShieldFive Labs <security@shieldfive.com>",
28
+ "author": "Cho Garcia <security@shieldfive.com>",
29
29
  "exports": {
30
30
  ".": {
31
31
  "types": "./dist/index.d.ts",
@@ -105,7 +105,7 @@
105
105
  }
106
106
  },
107
107
  "dependencies": {
108
- "@noble/post-quantum": "^0.5.3"
108
+ "@noble/post-quantum": "^0.6.0"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@types/node": "^22.10.0",
@@ -50,7 +50,7 @@ A2 cannot:
50
50
  [`format-v1.md` § "Suite payloads"](./format-v1.md#suite-payloads)
51
51
  for each suite's derivations. file_id is NOT in chunk AAD; the
52
52
  binding is structural — see
53
- [crypto PR #1](https://github.com/shieldfive/crypto/pull/1) for the
53
+ [crypto PR #1](https://github.com/shieldfive/crypto/commit/f3f52ba) for the
54
54
  test vector pinning this behavior).
55
55
 
56
56
  #### Legacy v0 data
@@ -183,17 +183,21 @@ backup obtains the same access as the user.
183
183
 
184
184
  | Product | File AEAD | PQ | Truncation detection | Format self-describing |
185
185
  | -------------------------------- | ------------------------------------------- | ----------------------------- | ----------------------------------------------- | ---------------------- |
186
- | Proton Drive | AES-256-GCM (chunked) | None (as of audit dates) | Application layer only | No (DB-side metadata) |
186
+ | Proton Drive | AES-256-GCM (chunked) | Proton Mail (sibling product) added optional PQ via OpenPGP v6 in May 2026; Proton Drive's on-disk format had not adopted PQ as of 2026-05-18 | Application layer only | No (DB-side metadata) |
187
187
  | Internxt | AES-256-CTR + Kyber-512 hybrid | Kyber-512 (≈AES-128 PQ) | N/A (CTR is unauthenticated; integrity layered) | Partial |
188
188
  | MEGA | AES-128-CCM, Ed25519 sigs | None | Application layer | Partial |
189
189
  | Tresorit | AES-256-GCM, ECC | None (as of public docs) | Application layer | Proprietary |
190
190
  | **ShieldFive (v1, suite 0x03)†** | **XChaCha20-Poly1305 + ML-KEM-1024 hybrid** | **ML-KEM-1024 (≈AES-256 PQ)** | **AEAD-bound** | **Yes** |
191
191
 
192
192
  This table reflects publicly available specifications and audit reports as
193
- of the v1 specification date. It is updated when those specifications
194
- change. This is not a security claim about which product is "best" — each
195
- makes different tradeoffs — but it documents the design positions ShieldFive
196
- v1 takes deliberately.
193
+ of 2026-05-18 (last access date). It is updated when those specifications
194
+ change — for example, Proton Mail (sibling product to Proton Drive)
195
+ launched optional post-quantum encryption via OpenPGP v6 in May 2026
196
+ (proton.me/blog/introducing-post-quantum-encryption); the Proton Drive
197
+ on-disk wire format had not adopted PQ as of the access date. This is not
198
+ a security claim about which product is "best" — each makes different
199
+ tradeoffs — but it documents the design positions ShieldFive v1 takes
200
+ deliberately.
197
201
 
198
202
  † Suite `0x03` is available in the crypto library (1.0.0-alpha.3) and
199
203
  is the format-v1 spec default; the production web client has not yet
package/src/index.ts CHANGED
@@ -191,7 +191,7 @@ export async function autoDecryptBlob(
191
191
  }
192
192
 
193
193
  /** Library version, also written into format documentation. */
194
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.3'
194
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.6'
195
195
 
196
196
  /** Default cipher suite for new files when not specified by the caller. */
197
197
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1
@@ -63,6 +63,14 @@ export interface PqHybridV1EncryptStreamOptions {
63
63
  /**
64
64
  * Combined content key from `encapsulateForRecipient`. 32 bytes. Used
65
65
  * both for header MAC and for chunk AEAD.
66
+ *
67
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
68
+ * capability for any file whose header was produced with it. Treat
69
+ * as cryptographic secret material: hold only in memory for the
70
+ * duration of the operation, do not persist to disk or storage, do
71
+ * not log, do not transmit. The only safe way to reproduce it on
72
+ * another machine is to re-encapsulate via the recipient's ML-KEM
73
+ * public key.
66
74
  */
67
75
  combinedKey: Uint8Array
68
76
  /** 16-byte file_id used as HKDF salt in encapsulation and key derivation. */
@@ -78,7 +86,17 @@ export interface PqHybridV1EncryptStreamOptions {
78
86
  export interface PqHybridV1EncryptStreamResult {
79
87
  /** TransformStream<Uint8Array, Uint8Array> emitting the v1 wire format. */
80
88
  stream: TransformStream<Uint8Array, Uint8Array>
81
- /** The combined key used (echoed back for caller convenience). */
89
+ /**
90
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
91
+ * capability for any file whose header was produced with it. Treat
92
+ * as cryptographic secret material: hold only in memory for the
93
+ * duration of the operation, do not persist to disk or storage, do
94
+ * not log, do not transmit. The only safe way to reproduce it on
95
+ * another machine is to re-encapsulate via the recipient's ML-KEM
96
+ * public key.
97
+ *
98
+ * Echoed back for caller convenience.
99
+ */
82
100
  combinedKey: Uint8Array
83
101
  /** The file_id used (echoed back for caller convenience). */
84
102
  fileId: Uint8Array
@@ -243,12 +261,45 @@ export function createPqHybridV1EncryptStream(
243
261
  // Decrypting transform
244
262
  // ─────────────────────────────────────────────────────────────────────
245
263
 
246
- export interface PqHybridV1DecryptStreamOptions {
247
- /** Recipient's ML-KEM-1024 secret key (3168 bytes) */
248
- recipientSecretKey: Uint8Array
249
- /** Classical envelope key (32 bytes) */
250
- envelopeKey: Uint8Array
251
- }
264
+ /**
265
+ * Inputs for {@link createPqHybridV1DecryptStream}. Either provide the
266
+ * KEM material (`recipientSecretKey` + `envelopeKey`) so the stream can
267
+ * derive the combined key itself, OR provide the already-derived
268
+ * `combinedKey` directly. The latter is what share-link recipients use:
269
+ * they hold a 32-byte K (wrapped under the share-link password) and
270
+ * never see the ML-KEM secret key.
271
+ *
272
+ * Mixing both modes is not supported — `combinedKey` always wins. The
273
+ * caller is responsible for picking one path.
274
+ */
275
+ export type PqHybridV1DecryptStreamOptions =
276
+ | {
277
+ /** Recipient's ML-KEM-1024 secret key (3168 bytes). */
278
+ recipientSecretKey: Uint8Array
279
+ /** Classical envelope key (32 bytes). */
280
+ envelopeKey: Uint8Array
281
+ combinedKey?: undefined
282
+ }
283
+ | {
284
+ /**
285
+ * Pre-derived 32-byte combined key K. When provided, the stream
286
+ * skips ML-KEM decapsulation entirely and uses K for header MAC
287
+ * verification + per-chunk AEAD. Header MAC validation still
288
+ * cryptographically gates the rest of the stream, so a wrong K
289
+ * fails fast.
290
+ *
291
+ * SECURITY: Possession of `combinedKey` grants permanent decryption
292
+ * capability for any file whose header was produced with it. Treat
293
+ * as cryptographic secret material: hold only in memory for the
294
+ * duration of the operation, do not persist to disk or storage, do
295
+ * not log, do not transmit. The only safe way to reproduce it on
296
+ * another machine is to re-encapsulate via the recipient's ML-KEM
297
+ * public key.
298
+ */
299
+ combinedKey: Uint8Array
300
+ recipientSecretKey?: undefined
301
+ envelopeKey?: undefined
302
+ }
252
303
 
253
304
  /**
254
305
  * Build a TransformStream that decrypts a v1 ciphertext stream produced
@@ -256,18 +307,38 @@ export interface PqHybridV1DecryptStreamOptions {
256
307
  * version processes input incrementally — useful for very large files or
257
308
  * when ciphertext arrives chunked over the network.
258
309
  *
259
- * PQ decapsulation runs once, the moment the header has been buffered,
260
- * before any chunk is processed. After that the stream behaves
261
- * identically to the AES-GCM-v1 decrypt stream.
310
+ * Two key-input modes:
311
+ * - KEM mode (`recipientSecretKey` + `envelopeKey`): the stream runs
312
+ * ML-KEM decapsulation once, the moment the header has been
313
+ * buffered, then proceeds identically to the AES-GCM-v1 decrypt
314
+ * stream.
315
+ * - Combined-key mode (`combinedKey`): skips decapsulation entirely
316
+ * and uses the supplied K for header MAC verification + chunk AEAD.
317
+ * Intended for share-link recipients who hold a wrapped K but no
318
+ * ML-KEM secret.
262
319
  */
263
320
  export function createPqHybridV1DecryptStream(
264
321
  options: PqHybridV1DecryptStreamOptions,
265
322
  ): TransformStream<Uint8Array, Uint8Array> {
266
- const { recipientSecretKey, envelopeKey } = options
267
- if (envelopeKey.length !== 32) {
268
- throw new RangeError('decrypt stream: envelopeKey must be 32 bytes')
323
+ const combinedKeyOverride = options.combinedKey
324
+ const recipientSecretKey = options.recipientSecretKey
325
+ const envelopeKey = options.envelopeKey
326
+
327
+ if (combinedKeyOverride) {
328
+ if (combinedKeyOverride.length !== 32) {
329
+ throw new RangeError('decrypt stream: combinedKey must be 32 bytes')
330
+ }
331
+ } else {
332
+ if (!recipientSecretKey || !envelopeKey) {
333
+ throw new RangeError(
334
+ 'decrypt stream: provide either combinedKey or recipientSecretKey + envelopeKey',
335
+ )
336
+ }
337
+ if (envelopeKey.length !== 32) {
338
+ throw new RangeError('decrypt stream: envelopeKey must be 32 bytes')
339
+ }
340
+ // Length of recipientSecretKey is checked inside decapsulateFromHeader.
269
341
  }
270
- // Length of recipientSecretKey is checked inside decapsulateFromHeader.
271
342
 
272
343
  // Phases:
273
344
  // 0 = waiting for header bytes
@@ -336,15 +407,22 @@ export function createPqHybridV1DecryptStream(
336
407
  )
337
408
  }
338
409
 
339
- // Recover the combined key — this is where PQ decapsulation happens.
340
- // The header MAC implicitly verifies that the right combined key was
341
- // recovered (i.e., the PQ secret + envelope key match the file).
342
- const { combinedKey } = await decapsulateFromHeader({
343
- suitePayload: parsedHeader.suitePayload,
344
- recipientSecretKey,
345
- envelopeKey,
346
- fileId: parsedHeader.fileId,
347
- })
410
+ // Recover the combined key. Two paths:
411
+ // - KEM mode: run ML-KEM decapsulation now.
412
+ // - Combined-key mode: trust the supplied K. The header MAC check
413
+ // below still cryptographically gates the rest of the stream, so
414
+ // a wrong K fails fast.
415
+ let combinedKey: Uint8Array
416
+ if (combinedKeyOverride) {
417
+ combinedKey = combinedKeyOverride
418
+ } else {
419
+ ;({ combinedKey } = await decapsulateFromHeader({
420
+ suitePayload: parsedHeader.suitePayload,
421
+ recipientSecretKey: recipientSecretKey!,
422
+ envelopeKey: envelopeKey!,
423
+ fileId: parsedHeader.fileId,
424
+ }))
425
+ }
348
426
 
349
427
  const { verifyHeaderMac } = await import('../format/header.js')
350
428
  await verifyHeaderMac(parsedHeader, combinedKey)
@@ -463,11 +541,22 @@ export interface EncryptStreamPqHybridV1Options {
463
541
 
464
542
  /**
465
543
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 encrypt
466
- * transform and return the resulting ReadableStream + the materials the
467
- * caller will need to store alongside the file (file_id) or share back
468
- * to the sender's records (combined key, suite payload).
544
+ * transform and return the resulting ReadableStream alongside the
545
+ * derived material the caller will need: the 16-byte file_id (safe
546
+ * to persist with the ciphertext), the suite payload (safe to
547
+ * persist with the ciphertext; required for later decapsulation),
548
+ * and the 32-byte combined key.
549
+ *
550
+ * SECURITY: The returned `combinedKey` grants permanent decryption
551
+ * capability for any file whose header was produced with it. Treat
552
+ * as cryptographic secret material: hold only in memory for the
553
+ * duration of the operation, do not persist to disk or storage, do
554
+ * not log, do not transmit. The only safe way to reproduce it on
555
+ * another machine is to re-encapsulate via the recipient's ML-KEM
556
+ * public key.
469
557
  *
470
- * This helper is async because PQ encapsulation requires libsodium init.
558
+ * This helper is async because PQ encapsulation requires libsodium
559
+ * init.
471
560
  */
472
561
  export async function encryptStreamPqHybridV1(
473
562
  source: ReadableStream<Uint8Array>,
@@ -511,7 +600,9 @@ export async function encryptStreamPqHybridV1(
511
600
 
512
601
  /**
513
602
  * Pipe a ReadableStream<Uint8Array> through the PQ-hybrid-v1 decrypt
514
- * transform and return the resulting plaintext ReadableStream.
603
+ * transform and return the resulting plaintext ReadableStream. See
604
+ * {@link PqHybridV1DecryptStreamOptions} for the two key-input modes
605
+ * (KEM secret + envelope vs. pre-derived combined key K).
515
606
  */
516
607
  export function decryptStreamPqHybridV1(
517
608
  source: ReadableStream<Uint8Array>,
@@ -41,6 +41,18 @@ import {
41
41
  } from '../../internal/encoding.js'
42
42
  import { randomBytes } from '../../internal/runtime.js'
43
43
 
44
+ // Re-exports of suite primitives that are useful to callers outside the
45
+ // streaming/whole-blob API surfaces. `decapsulateFromHeader` lets a
46
+ // caller that already has the parsed suite_payload + KEM material
47
+ // recover the combined key K out-of-band (e.g., a share-link generator
48
+ // that wraps K under a separate password for recipients who never see
49
+ // ML-KEM secrets).
50
+ export {
51
+ decapsulateFromHeader,
52
+ encapsulateForRecipient,
53
+ PQ_HYBRID_V1_SUITE_PAYLOAD_LENGTH,
54
+ } from './index.js'
55
+
44
56
  const LENGTH_PREFIX_BYTES = 4
45
57
 
46
58
  export interface PqHybridEncryptOptions {
@@ -54,6 +66,19 @@ export interface PqHybridEncryptOptions {
54
66
  onProgress?: ProgressCallback
55
67
  }
56
68
 
69
+ /**
70
+ * Encrypt a Blob under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
71
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
72
+ * content key used to produce it.
73
+ *
74
+ * SECURITY: The returned `combinedKey` grants permanent decryption
75
+ * capability for any file whose header was produced with it. Treat
76
+ * as cryptographic secret material: hold only in memory for the
77
+ * duration of the operation, do not persist to disk or storage, do
78
+ * not log, do not transmit. The only safe way to reproduce it on
79
+ * another machine is to re-encapsulate via the recipient's ML-KEM
80
+ * public key.
81
+ */
57
82
  export async function encryptBlob(
58
83
  options: PqHybridEncryptOptions,
59
84
  ): Promise<EncryptedFile & { combinedKey: Uint8Array }> {
@@ -243,6 +268,19 @@ export async function decryptBlob(
243
268
  return new Blob(plaintextParts, { type: 'application/octet-stream' })
244
269
  }
245
270
 
271
+ /**
272
+ * Encrypt a Uint8Array under suite 0x03 (PQ-hybrid XChaCha20-Poly1305 +
273
+ * ML-KEM-1024). Returns the encrypted file alongside the combined
274
+ * content key used to produce it.
275
+ *
276
+ * SECURITY: The returned `combinedKey` grants permanent decryption
277
+ * capability for any file whose header was produced with it. Treat
278
+ * as cryptographic secret material: hold only in memory for the
279
+ * duration of the operation, do not persist to disk or storage, do
280
+ * not log, do not transmit. The only safe way to reproduce it on
281
+ * another machine is to re-encapsulate via the recipient's ML-KEM
282
+ * public key.
283
+ */
246
284
  export async function encryptBytes(
247
285
  bytes: Uint8Array,
248
286
  options: Omit<PqHybridEncryptOptions, 'blob'>,