@shieldfive/crypto 1.0.0-alpha.11 → 1.0.0-alpha.13

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,32 @@ 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.13 — 2026-06-09
9
+
10
+ ### Fixed
11
+
12
+ - `SHIELDFIVE_CRYPTO_VERSION` now reports the actual package version
13
+ (it was pinned at `1.0.0-alpha.11`). The constant is informational
14
+ only — it is never written into file output or any test vector.
15
+ - Corrected a backwards source comment in the `aes-gcm-v2` suite: the
16
+ cross-file nonce-prefix space *widens* from 2^32 to 2^64 (the comment
17
+ previously said "shrinks"). No behavior change — the README and
18
+ CHANGELOG already described it correctly as widening.
19
+
20
+ ## 1.0.0-alpha.12 — 2026-06-09
21
+
22
+ ### Documentation
23
+
24
+ - README: corrected the test-suite badge and prose from 171 to
25
+ **182** tests. The 11 additional tests are the offline single-file
26
+ decryptor example suite that landed after the badge was last
27
+ refreshed; `npm test` now reports 182/182.
28
+ - README: the cipher-suite table and the "four suites" wording now
29
+ match the package exports. Suite 0x04 `aes-gcm-v2` shipped in
30
+ alpha.11 but the README published with that release still listed
31
+ only three suites.
32
+ - No source changes in this release — documentation only.
33
+
8
34
  ## 1.0.0-alpha.11 — 2026-05-21
9
35
 
10
36
  ### Added
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-155%2F155-brightgreen.svg)](tests/)
8
+ [![Tests](https://img.shields.io/badge/tests-182%2F182-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 155 passing tests including
20
+ reviewable. The implementation is covered by 182 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
@@ -165,7 +165,7 @@ The complete v1 wire format is documented in
165
165
 
166
166
  ```
167
167
  header := magic(5) = "SF5\x01\x00"
168
- || suite(1) = 0x01 | 0x02 | 0x03
168
+ || suite(1) = 0x01 | 0x02 | 0x03 | 0x04
169
169
  || flags(1) = 0x00 (reserved)
170
170
  || file_id(16) = random per-file
171
171
  || chunk_size(4) = uint32 BE
@@ -190,6 +190,13 @@ application-layer hashes.
190
190
  | 0x01 | `aes-256-gcm-v1` | | WebCrypto-only, hardware-accelerated |
191
191
  | 0x02 | `xchacha20-poly1305-v1` | | libsodium, 192-bit nonces |
192
192
  | 0x03 | `pq-hybrid-xchacha-mlkem1024-v1` | ✅ | XChaCha20-Poly1305 + ML-KEM-1024 hybrid |
193
+ | 0x04 | `aes-256-gcm-v2` | | WebCrypto-only, 8-byte nonce prefix |
194
+
195
+ Suite `0x04` is the current AES-GCM write path: identical to `0x01` except
196
+ the 12-byte GCM IV uses an 8-byte file-derived nonce prefix and a 4-byte
197
+ counter (rather than 4 + 8), widening the cross-file IV-collision margin.
198
+ `0x01` remains defined for reading files written before `0x04` existed.
199
+ See [`spec/format-v1.md`](spec/format-v1.md) for the per-suite derivations.
193
200
 
194
201
  ML-KEM-1024 is FIPS 203 (NIST PQC standard, security level 5). Files
195
202
  encrypted with suite 0x03 remain confidential against an adversary who
@@ -237,7 +244,7 @@ Requires Node 20+.
237
244
 
238
245
  **Alpha.** The wire format is frozen for the v1 release, but the public
239
246
  TypeScript API may make small adjustments before 1.0.0 stable. Test
240
- coverage is comprehensive (155 tests, all four suites, all architectural
247
+ coverage is comprehensive (182 tests, all four suites, all architectural
241
248
  guarantees verified). A formal third-party security audit is planned for
242
249
  the 1.0.0 stable milestone — until that audit lands, treat this library
243
250
  as a serious work-in-progress rather than a finished product.
@@ -250,7 +257,8 @@ crypto library; we chose it over MIT for that reason.
250
257
  ## Reporting vulnerabilities
251
258
 
252
259
  See [`SECURITY.md`](SECURITY.md). Coordinate with us at
253
- `security@shieldfive.com` (PGP key in SECURITY.md). 72-hour acknowledgement,
260
+ `security@shieldfive.com` (see SECURITY.md for the encrypted-channel
261
+ process). 72-hour acknowledgement,
254
262
  30-day target patch window for high-severity issues. Researchers acting
255
263
  in good faith are protected under the safe-harbor clause.
256
264
 
package/SECURITY.md CHANGED
@@ -127,4 +127,4 @@ with their consent.)
127
127
 
128
128
  ---
129
129
 
130
- Last updated: v1.0.0-alpha.7
130
+ Last updated: v1.0.0-alpha.13
package/dist/index.d.ts CHANGED
@@ -52,7 +52,7 @@ export interface AutoDecryptOptions {
52
52
  */
53
53
  export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
54
54
  /** Library version, also written into format documentation. */
55
- export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-alpha.11";
55
+ export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-alpha.13";
56
56
  /** Default cipher suite for new files when not specified by the caller. */
57
57
  export declare const DEFAULT_SUITE: 3;
58
58
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -140,7 +140,7 @@ export async function autoDecryptBlob(options) {
140
140
  }
141
141
  }
142
142
  /** Library version, also written into format documentation. */
143
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.11';
143
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.13';
144
144
  /** Default cipher suite for new files when not specified by the caller. */
145
145
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
146
146
  //# sourceMappingURL=index.js.map
@@ -4,12 +4,12 @@
4
4
  * Per-file content key. Per-chunk AEAD with file_id-bound AAD that
5
5
  * authenticates chunk index, total chunks, and the is-final flag. The
6
6
  * 12-byte GCM IV is split into an 8-byte file-derived prefix and a 4-byte
7
- * big-endian counter — a wider prefix than v1 (0x01) so the per-file
8
- * `(prefix, counter)` collision space across files sharing a content
9
- * key shrinks from 2^32 to 2^64. The per-file chunk ceiling drops from
10
- * 2^64 to 2^32 chunks, which is still well above any practical bound
11
- * the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and `chunkIndex` is a
12
- * safe JS integer).
7
+ * big-endian counter — a wider prefix than v1 (0x01) so the cross-file
8
+ * nonce-prefix space widens from 2^32 to 2^64, shrinking the chance of an
9
+ * IV collision across files that share a content key. The per-file chunk
10
+ * ceiling drops from 2^64 to 2^32 chunks, which is still well above any
11
+ * practical bound the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and
12
+ * `chunkIndex` is a safe JS integer).
13
13
  */
14
14
  import { type ParsedHeader } from '../../internal/types.js';
15
15
  export declare const AES_GCM_V2_TAG_BYTES = 16;
@@ -4,12 +4,12 @@
4
4
  * Per-file content key. Per-chunk AEAD with file_id-bound AAD that
5
5
  * authenticates chunk index, total chunks, and the is-final flag. The
6
6
  * 12-byte GCM IV is split into an 8-byte file-derived prefix and a 4-byte
7
- * big-endian counter — a wider prefix than v1 (0x01) so the per-file
8
- * `(prefix, counter)` collision space across files sharing a content
9
- * key shrinks from 2^32 to 2^64. The per-file chunk ceiling drops from
10
- * 2^64 to 2^32 chunks, which is still well above any practical bound
11
- * the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and `chunkIndex` is a
12
- * safe JS integer).
7
+ * big-endian counter — a wider prefix than v1 (0x01) so the cross-file
8
+ * nonce-prefix space widens from 2^32 to 2^64, shrinking the chance of an
9
+ * IV collision across files that share a content key. The per-file chunk
10
+ * ceiling drops from 2^64 to 2^32 chunks, which is still well above any
11
+ * practical bound the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and
12
+ * `chunkIndex` is a safe JS integer).
13
13
  */
14
14
  import { buildChunkAad } from '../../format/header.js';
15
15
  import { HKDF_INFO, HEADER_SIZES, } from '../../internal/types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shieldfive/crypto",
3
- "version": "1.0.0-alpha.11",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Client-side post-quantum hybrid encryption for cloud storage. The cryptographic core of ShieldFive.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -95,9 +95,11 @@
95
95
  "build": "tsc -p tsconfig.json",
96
96
  "clean": "rm -rf dist",
97
97
  "lint": "eslint src tests",
98
+ "pretest": "npm run build",
98
99
  "test": "node --experimental-vm-modules --test --import tsx tests/**/*.test.ts",
99
100
  "test:unit": "node --experimental-vm-modules --test --import tsx tests/unit/*.test.ts",
100
101
  "test:integration": "node --experimental-vm-modules --test --import tsx tests/integration/*.test.ts",
102
+ "test:vectors": "node --experimental-vm-modules --test --import tsx tests/vectors/vectors.test.ts",
101
103
  "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\""
102
104
  },
103
105
  "peerDependencies": {
package/spec/format-v1.md CHANGED
@@ -60,6 +60,7 @@ future minor-version bumps that remain backward-compatible.
60
60
  | `0x01` | `aes-256-gcm-v1` | required |
61
61
  | `0x02` | `xchacha20-poly1305-v1` | required |
62
62
  | `0x03` | `pq-hybrid-xchacha-mlkem1024-v1` | default |
63
+ | `0x04` | `aes-256-gcm-v2` | required |
63
64
  | `0x80` | (reserved, custom-suite range begins) | reserved |
64
65
 
65
66
  `flags` is reserved; readers MUST reject any header with a non-zero flags
@@ -93,8 +94,9 @@ header_mac_key := HKDF-SHA-256(
93
94
  ```
94
95
 
95
96
  For suites whose header MAC key is not derived from `suite_payload`
96
- (currently `0x01` aes-gcm-v1, `0x02` xchacha-v1), readers MUST verify
97
- `header_mac` before parsing `suite_payload` or any chunk. KEM suites
97
+ (currently `0x01` aes-gcm-v1, `0x02` xchacha-v1, `0x04` aes-gcm-v2),
98
+ readers MUST verify `header_mac` before parsing `suite_payload` or any
99
+ chunk. KEM suites
98
100
  (currently `0x03` pq-hybrid-v1) verify `header_mac` after decapsulation
99
101
  per their suite-specific decryption flow; see § "`0x03` — pq-hybrid"
100
102
  below for the required ordering and security argument. A header_mac
@@ -299,6 +301,51 @@ decapsulation) and therefore cannot be stored out-of-band. The full
299
301
  1664-byte `suite_payload` MUST be present inline in every PQ-hybrid
300
302
  file.
301
303
 
304
+ ### `0x04` — `aes-256-gcm-v2`
305
+
306
+ ```
307
+ suite_payload := wrapped_key (60 bytes) = AES-GCM-wrapped 32-byte content key
308
+ || wrap_iv (12 bytes) = AES-GCM IV used for wrapping
309
+ ```
310
+
311
+ `0x04` is a WebCrypto-only AEAD suite (no WASM dependency) that differs
312
+ from `0x01` in exactly one respect: the split of the 12-byte AES-GCM IV.
313
+ It is the suite new AES-GCM writes use; `0x01` remains defined so that
314
+ files written before `0x04` existed stay readable.
315
+
316
+ - `chunk_key(content_key, file_id)` =
317
+ `HKDF-SHA-256(ikm=content_key, salt=file_id, info="shieldfive/v1/aes-gcm/chunk-key", L=32)`
318
+
319
+ This is bit-for-bit identical to the `0x01` chunk-key derivation — same
320
+ HKDF `info` string (`shieldfive/v1/aes-gcm/chunk-key`), same inputs. A
321
+ `0x01` file and a `0x04` file sharing a `content_key` and `file_id`
322
+ derive the same chunk key. They never collide on AEAD inputs, because
323
+ the nonce-prefix derivation below uses a distinct `info` string, giving
324
+ the two suites disjoint `(prefix, counter)` spaces.
325
+
326
+ - `chunk_nonce(file_id, i)` =
327
+ `HKDF-SHA-256(ikm=file_id, salt=zeros(32), info="shieldfive/v1/aes-gcm-v2/nonce-prefix", L=8)`
328
+ `|| uint32_be(i)`
329
+
330
+ The 12-byte GCM IV is an 8-byte file-derived prefix followed by a 4-byte
331
+ big-endian chunk counter — the inverse of `0x01`'s split, which is a
332
+ 4-byte prefix and an 8-byte counter. Widening the prefix shrinks the
333
+ cross-file `(prefix, counter)` collision space (for two files that reuse
334
+ a `content_key` — which never happens under correct use, but defense in
335
+ depth) from 2^32 to 2^64. The trade is a per-file chunk ceiling of 2^32
336
+ chunks rather than 2^64; this is far above the format's
337
+ `MAX_TOTAL_CHUNKS` bound (1e9), so it is not a practical constraint.
338
+ Readers MUST reject a `0x04` file whose `total_chunks` exceeds 2^32. The
339
+ salt is the RFC 5869 absent-salt zero-fill (32 zero bytes), identical to
340
+ the `0x01` and `0x02` suites.
341
+
342
+ The wrapped-content-key field and the all-zero `suite_payload` convention
343
+ for out-of-band key storage are identical to `0x01`: the field is a fixed
344
+ 72 bytes (60-byte `wrapped_key` + 12-byte `wrap_iv`), zero-filled when the
345
+ wrapped key is stored out-of-band (e.g. in the ShieldFive vault database).
346
+ Readers MUST accept all-zero `suite_payload` bytes in that case and obtain
347
+ the wrapped key from the out-of-band channel.
348
+
302
349
  ## Signature block
303
350
 
304
351
  The signature block is an OPTIONAL trailing structure that carries a
@@ -91,9 +91,11 @@ chunk_key = HKDF(content_key, salt=file_id,
91
91
 
92
92
  nonce_prefix = HKDF(file_id,
93
93
  info="shieldfive/v1/<suite>/nonce-prefix",
94
- L = 4 (AES-GCM) or 16 (XChaCha))
94
+ L = 4 (aes-gcm-v1), 8 (aes-gcm-v2), or 16 (xchacha))
95
95
 
96
- iv / nonce_i = nonce_prefix || uint64_be(chunk_index)
96
+ iv / nonce_i = nonce_prefix || counter
97
+ (counter = uint32_be(chunk_index) for aes-gcm-v2's
98
+ 8-byte prefix; uint64_be(chunk_index) otherwise)
97
99
  ```
98
100
 
99
101
  For the PQ-hybrid suite, `content_key` is replaced by the combined key
@@ -118,6 +120,7 @@ application MUST NOT reuse any of them for unrelated purposes:
118
120
  shieldfive/v1/header-mac
119
121
  shieldfive/v1/aes-gcm/chunk-key
120
122
  shieldfive/v1/aes-gcm/nonce-prefix
123
+ shieldfive/v1/aes-gcm-v2/nonce-prefix
121
124
  shieldfive/v1/xchacha/chunk-key
122
125
  shieldfive/v1/xchacha/nonce-prefix
123
126
  shieldfive/v1/pq-hybrid/combine
@@ -63,9 +63,10 @@ v0 files have no chunk AAD, no `file_id` binding, and no truncation
63
63
  detection. Defense-in-depth for v0 files relies on the application's
64
64
  stored per-chunk SHA-1 hashes (`cipher_parts_sha1`), verified on
65
65
  download. Migration to v1 is required to gain the AEAD-bound integrity
66
- properties documented above. As of 2026-05-11, the v1 writer is
67
- enabled but most live data is still v0; migration policy and timeline
68
- are tracked separately.
66
+ properties documented above. As of 2026-05-17, the v1 PQ-hybrid
67
+ writer (Suite 0x03) is the production default for new uploads;
68
+ existing v0 files remain readable indefinitely and in-place migration
69
+ is tracked separately.
69
70
 
70
71
  ### A3 — Future quantum adversary
71
72
 
@@ -88,13 +89,10 @@ hybrid suite when migration is feasible.
88
89
 
89
90
  #### Current deployment status
90
91
 
91
- As of 2026-05-11, the production web client emits suite `0x01`
92
- (`aes-256-gcm-v1`) for new uploads. Suite `0x03`
93
- (`pq-hybrid-xchacha-mlkem1024-v1`) is implemented in the
94
- `@shieldfive/crypto` library but is not yet wired into the web worker;
95
- until Phase 3 ships, all newly-uploaded files are classical-only and
96
- are NOT protected against A3. This document will be updated when
97
- `0x03` becomes the default writer suite.
92
+ As of 2026-05-17, the production web client emits Suite `0x03`
93
+ (`pq-hybrid-xchacha-mlkem1024-v1`) for new uploads; files written
94
+ under the previous default (v0, Suite `0x01`) remain readable
95
+ indefinitely.
98
96
 
99
97
  ## Trust principals
100
98
 
@@ -111,14 +109,30 @@ by:
111
109
  expiry timestamp.
112
110
  - **No key reach.** The share endpoint never returns `rk`, parent
113
111
  folder keys, or other CSKs.
114
- - **Brute force.** Bcrypt-wrapped `share_password_hash` is rate
115
- limited per-share, per-IP, and per-burst; lockout state is tracked
116
- in `share_password_attempts` (Task 7).
112
+ - **Brute force.** Verification is rate limited per-share, per-IP, and
113
+ per-burst; lockout state is tracked in `share_password_attempts`
114
+ (Task 7). The brute-force defense wraps the verifier comparison the
115
+ same way it previously wrapped the bcrypt comparison.
117
116
 
118
117
  The recipient is a trusted third party for the single file shared; the
119
118
  system makes no confidentiality guarantee against that recipient.
120
- Confidentiality against A1 is unaffected (the server doesn't have the
121
- share password in cleartext; it has only the bcrypt hash).
119
+
120
+ New shares use a **client-derived blind verifier**: the client derives
121
+ `verifier = Argon2id(share password, share_verifier_salt)` and the
122
+ creator stores only `SHA-256(verifier)` (`share_verifier_hash`). At
123
+ download the recipient re-derives the verifier locally and sends it; the
124
+ server `SHA-256`s the received verifier and constant-time compares it to
125
+ `share_verifier_hash`. The share password is never transmitted to the
126
+ server, so the server never holds the cleartext password alongside
127
+ `csk_pw_wrapped` and cannot decrypt the shared file. The verifier salt
128
+ is independent of `csk_pw_salt`, and the key-wrapping path (`csk_pw_*`)
129
+ is unchanged. Confidentiality against A1 is therefore unaffected (the
130
+ server has only `share_verifier_hash`, never the password).
131
+
132
+ The legacy bcrypt path (`share_password_hash`) is retained only for
133
+ shares created before the blind verifier; those shares still send the
134
+ cleartext password for the server-side bcrypt compare. New shares are
135
+ always verifier mode.
122
136
 
123
137
  ## Out of scope
124
138
 
@@ -199,9 +213,10 @@ a security claim about which product is "best" — each makes different
199
213
  tradeoffs — but it documents the design positions ShieldFive v1 takes
200
214
  deliberately.
201
215
 
202
- † Suite `0x03` is available in the crypto library (1.0.0-alpha.3) and
203
- is the format-v1 spec default; the production web client has not yet
204
- been updated to emit it. See § "Current deployment status" under A3.
216
+ † As of 2026-05-17, the production web client emits Suite `0x03`
217
+ (`pq-hybrid-xchacha-mlkem1024-v1`) for new uploads; files written
218
+ under the previous default (v0, Suite `0x01`) remain readable
219
+ indefinitely. See § "Current deployment status" under A3.
205
220
 
206
221
  ## Known limitations of v1
207
222
 
@@ -236,7 +251,7 @@ These are intentional tradeoffs documented for transparency:
236
251
  ## Reporting
237
252
 
238
253
  Cryptographic vulnerabilities should be reported to
239
- `security@shieldfive.com` encrypted with the PGP key in `SECURITY.md`. We
240
- acknowledge within 72 hours and target a patch within 30 days for
241
- high-severity issues. Researchers acting in good faith are protected under
254
+ `security@shieldfive.com`; see `SECURITY.md` for the encrypted-channel
255
+ process. We acknowledge within 72 hours and target a patch within 30 days
256
+ for high-severity issues. Researchers acting in good faith are protected under
242
257
  the safe-harbor clause in `SECURITY.md`.
package/src/index.ts CHANGED
@@ -218,7 +218,7 @@ export async function autoDecryptBlob(
218
218
  }
219
219
 
220
220
  /** Library version, also written into format documentation. */
221
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.11'
221
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-alpha.13'
222
222
 
223
223
  /** Default cipher suite for new files when not specified by the caller. */
224
224
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1
@@ -4,12 +4,12 @@
4
4
  * Per-file content key. Per-chunk AEAD with file_id-bound AAD that
5
5
  * authenticates chunk index, total chunks, and the is-final flag. The
6
6
  * 12-byte GCM IV is split into an 8-byte file-derived prefix and a 4-byte
7
- * big-endian counter — a wider prefix than v1 (0x01) so the per-file
8
- * `(prefix, counter)` collision space across files sharing a content
9
- * key shrinks from 2^32 to 2^64. The per-file chunk ceiling drops from
10
- * 2^64 to 2^32 chunks, which is still well above any practical bound
11
- * the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and `chunkIndex` is a
12
- * safe JS integer).
7
+ * big-endian counter — a wider prefix than v1 (0x01) so the cross-file
8
+ * nonce-prefix space widens from 2^32 to 2^64, shrinking the chance of an
9
+ * IV collision across files that share a content key. The per-file chunk
10
+ * ceiling drops from 2^64 to 2^32 chunks, which is still well above any
11
+ * practical bound the format permits (`MAX_TOTAL_CHUNKS` is 1e9 and
12
+ * `chunkIndex` is a safe JS integer).
13
13
  */
14
14
 
15
15
  import { buildChunkAad } from '../../format/header.js'