@shieldfive/crypto 1.0.0-rc.1 → 1.0.0-rc.2

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,25 @@ 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-rc.2 — 2026-08-02
9
+
10
+ No wire-format changes; every file written by a `1.0.0-*` release still decrypts
11
+ identically, and suite `0x03` is untouched. Adds a zero-knowledge inbound-intake
12
+ key exchange for the "Request documents" feature.
13
+
14
+ ### Added
15
+
16
+ - **Zero-knowledge inbound intake** (`inbound` module). An account-less sender
17
+ can encrypt a file to a recipient's published keys with no recipient secret,
18
+ and only the recipient can decrypt. The recipient publishes a static X25519
19
+ public key next to its ML-KEM-1024 key; the sender derives the suite-`0x03`
20
+ classical envelope key from an ephemeral-static X25519 ECDH, so the classical
21
+ share stays confidential under X25519 and the PQ share under ML-KEM — an
22
+ attacker must break both. Adds `deriveInboundStaticKeypair`,
23
+ `sealInboundEnvelopeKey`, and `openInboundEnvelopeKey`, plus two dedicated
24
+ HKDF labels. Integration tests cover the sender-to-recipient round trip and
25
+ that breaking either primitive alone fails closed.
26
+
8
27
  ## 1.0.0-rc.1 — 2026-07-14
9
28
 
10
29
  Release candidate for `1.0.0`. The v1 wire format and the public TypeScript API
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Zero-knowledge inbound intake.
3
+ *
4
+ * The PQ-hybrid suite (0x03) derives a file's content key from BOTH an ML-KEM
5
+ * encapsulated share AND a classical share that is secret-box-wrapped under a
6
+ * caller-supplied 32-byte `envelopeKey`. To decrypt, a recipient needs the
7
+ * ML-KEM secret key AND that envelope key — the KEM does not deliver the
8
+ * envelope key.
9
+ *
10
+ * For OUTBOUND files the owner is the recipient and already holds the envelope
11
+ * key (it is the file's own content key). An INBOUND, account-less sender has
12
+ * no firm secret, so it cannot produce an envelope key the firm can later
13
+ * recover. Using a public constant would make the classical share public and
14
+ * collapse the scheme to ML-KEM-only.
15
+ *
16
+ * This module closes that gap WITHOUT touching the frozen suite: the firm
17
+ * publishes a static X25519 public key alongside its ML-KEM public key, and the
18
+ * sender derives the envelope key from an ephemeral↔static X25519 ECDH. The
19
+ * classical share is then confidential under X25519 while the PQ share is
20
+ * confidential under ML-KEM, so an attacker must break BOTH primitives — a
21
+ * genuine hybrid, with the bulk file still produced by the existing
22
+ * `encryptStreamPqHybridV1` / `encryptBlob` path.
23
+ *
24
+ * Trust note: the recipient's published keys are only as trustworthy as the
25
+ * channel that serves them. Browser-delivered code "trusts the served code each
26
+ * load"; pair this with an out-of-band key fingerprint for the strong claim.
27
+ * This module does the cryptography; it does not establish key authenticity.
28
+ */
29
+ /** X25519 public key length (Curve25519 u-coordinate). */
30
+ export declare const X25519_PUBLIC_KEY_LENGTH = 32;
31
+ /** X25519 secret scalar length. */
32
+ export declare const X25519_SECRET_KEY_LENGTH = 32;
33
+ export interface InboundStaticKeypair {
34
+ /** Static X25519 public key (32 bytes) — publish next to the ML-KEM public key. */
35
+ x25519PublicKey: Uint8Array;
36
+ /** Static X25519 secret scalar (32 bytes) — treat as highly sensitive. */
37
+ x25519SecretKey: Uint8Array;
38
+ }
39
+ /**
40
+ * Deterministically derive the firm's static X25519 keypair from its master
41
+ * secret, mirroring how the ML-KEM keypair is derived. The same master secret
42
+ * always yields the same keypair across devices, so losing a device does not
43
+ * orphan received files (as long as the master secret is recoverable).
44
+ */
45
+ export declare function deriveInboundStaticKeypair(masterSecret: Uint8Array): Promise<InboundStaticKeypair>;
46
+ /**
47
+ * Sender side (account-less, in the browser). Given the firm's published static
48
+ * X25519 public key and the file_id used for the upload, produce the classical
49
+ * `envelopeKey` to pass to `encryptStreamPqHybridV1` / `encryptBlob`, plus the
50
+ * ephemeral public key to store alongside the ciphertext so the firm can
51
+ * recover the same envelope key. No firm secret is required.
52
+ */
53
+ export declare function sealInboundEnvelopeKey(options: {
54
+ recipientX25519PublicKey: Uint8Array;
55
+ fileId: Uint8Array;
56
+ }): Promise<{
57
+ envelopeKey: Uint8Array;
58
+ ephemeralPublicKey: Uint8Array;
59
+ }>;
60
+ /**
61
+ * Recipient side (the firm). Recover the same `envelopeKey` from its static
62
+ * X25519 secret key and the sender's ephemeral public key, then feed it (with
63
+ * the ML-KEM secret key) to the standard KEM-mode decrypt path.
64
+ */
65
+ export declare function openInboundEnvelopeKey(options: {
66
+ x25519SecretKey: Uint8Array;
67
+ ephemeralPublicKey: Uint8Array;
68
+ fileId: Uint8Array;
69
+ }): Promise<{
70
+ envelopeKey: Uint8Array;
71
+ }>;
72
+ //# sourceMappingURL=inbound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AASH,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAC1C,mCAAmC;AACnC,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAI1C,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,eAAe,EAAE,UAAU,CAAA;IAC3B,0EAA0E;IAC1E,eAAe,EAAE,UAAU,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AA0BD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,wBAAwB,EAAE,UAAU,CAAA;IACpC,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,UAAU,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,CAAC,CA0BvE;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,eAAe,EAAE,UAAU,CAAA;IAC3B,kBAAkB,EAAE,UAAU,CAAA;IAC9B,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,UAAU,CAAA;CAAE,CAAC,CA4BvC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Zero-knowledge inbound intake.
3
+ *
4
+ * The PQ-hybrid suite (0x03) derives a file's content key from BOTH an ML-KEM
5
+ * encapsulated share AND a classical share that is secret-box-wrapped under a
6
+ * caller-supplied 32-byte `envelopeKey`. To decrypt, a recipient needs the
7
+ * ML-KEM secret key AND that envelope key — the KEM does not deliver the
8
+ * envelope key.
9
+ *
10
+ * For OUTBOUND files the owner is the recipient and already holds the envelope
11
+ * key (it is the file's own content key). An INBOUND, account-less sender has
12
+ * no firm secret, so it cannot produce an envelope key the firm can later
13
+ * recover. Using a public constant would make the classical share public and
14
+ * collapse the scheme to ML-KEM-only.
15
+ *
16
+ * This module closes that gap WITHOUT touching the frozen suite: the firm
17
+ * publishes a static X25519 public key alongside its ML-KEM public key, and the
18
+ * sender derives the envelope key from an ephemeral↔static X25519 ECDH. The
19
+ * classical share is then confidential under X25519 while the PQ share is
20
+ * confidential under ML-KEM, so an attacker must break BOTH primitives — a
21
+ * genuine hybrid, with the bulk file still produced by the existing
22
+ * `encryptStreamPqHybridV1` / `encryptBlob` path.
23
+ *
24
+ * Trust note: the recipient's published keys are only as trustworthy as the
25
+ * channel that serves them. Browser-delivered code "trusts the served code each
26
+ * load"; pair this with an out-of-band key fingerprint for the strong claim.
27
+ * This module does the cryptography; it does not establish key authenticity.
28
+ */
29
+ import { x25519 } from '@noble/curves/ed25519.js';
30
+ import { concatBytes } from '../internal/encoding.js';
31
+ import { hkdfSha256 } from '../internal/hkdf.js';
32
+ import { randomBytes } from '../internal/runtime.js';
33
+ import { HEADER_SIZES, HKDF_INFO } from '../internal/types.js';
34
+ /** X25519 public key length (Curve25519 u-coordinate). */
35
+ export const X25519_PUBLIC_KEY_LENGTH = 32;
36
+ /** X25519 secret scalar length. */
37
+ export const X25519_SECRET_KEY_LENGTH = 32;
38
+ const INBOUND_ENVELOPE_KEY_BYTES = 32;
39
+ /**
40
+ * Deterministically derive the firm's static X25519 keypair from its master
41
+ * secret, mirroring how the ML-KEM keypair is derived. The same master secret
42
+ * always yields the same keypair across devices, so losing a device does not
43
+ * orphan received files (as long as the master secret is recoverable).
44
+ */
45
+ export async function deriveInboundStaticKeypair(masterSecret) {
46
+ if (masterSecret.length < 16) {
47
+ throw new RangeError('deriveInboundStaticKeypair: masterSecret must be at least 16 bytes');
48
+ }
49
+ const seed = await hkdfSha256({
50
+ ikm: masterSecret,
51
+ info: HKDF_INFO.INBOUND_X25519_STATIC_SEED,
52
+ length: X25519_SECRET_KEY_LENGTH,
53
+ });
54
+ const x25519PublicKey = x25519.getPublicKey(seed);
55
+ return { x25519PublicKey, x25519SecretKey: seed };
56
+ }
57
+ /**
58
+ * Derive the per-file envelope key from a shared secret. The full ECDH
59
+ * transcript (shared secret, ephemeral public key, recipient static public key)
60
+ * is bound into the HKDF input and the file_id into the salt, so a captured
61
+ * ephemeral key cannot be replayed against a different recipient or file.
62
+ */
63
+ async function deriveEnvelopeKey(sharedSecret, ephemeralPublicKey, recipientStaticPublicKey, fileId) {
64
+ return hkdfSha256({
65
+ ikm: concatBytes([
66
+ sharedSecret,
67
+ ephemeralPublicKey,
68
+ recipientStaticPublicKey,
69
+ ]),
70
+ salt: fileId,
71
+ info: HKDF_INFO.INBOUND_ENVELOPE,
72
+ length: INBOUND_ENVELOPE_KEY_BYTES,
73
+ });
74
+ }
75
+ /**
76
+ * Sender side (account-less, in the browser). Given the firm's published static
77
+ * X25519 public key and the file_id used for the upload, produce the classical
78
+ * `envelopeKey` to pass to `encryptStreamPqHybridV1` / `encryptBlob`, plus the
79
+ * ephemeral public key to store alongside the ciphertext so the firm can
80
+ * recover the same envelope key. No firm secret is required.
81
+ */
82
+ export async function sealInboundEnvelopeKey(options) {
83
+ const { recipientX25519PublicKey, fileId } = options;
84
+ if (recipientX25519PublicKey.length !== X25519_PUBLIC_KEY_LENGTH) {
85
+ throw new RangeError(`sealInboundEnvelopeKey: recipientX25519PublicKey must be ${X25519_PUBLIC_KEY_LENGTH} bytes`);
86
+ }
87
+ if (fileId.length !== HEADER_SIZES.FILE_ID) {
88
+ throw new RangeError(`sealInboundEnvelopeKey: fileId must be ${HEADER_SIZES.FILE_ID} bytes`);
89
+ }
90
+ const ephemeralSecret = randomBytes(X25519_SECRET_KEY_LENGTH);
91
+ const ephemeralPublicKey = x25519.getPublicKey(ephemeralSecret);
92
+ // Throws on a low-order / all-zero shared secret (contributory behaviour).
93
+ const sharedSecret = x25519.getSharedSecret(ephemeralSecret, recipientX25519PublicKey);
94
+ const envelopeKey = await deriveEnvelopeKey(sharedSecret, ephemeralPublicKey, recipientX25519PublicKey, fileId);
95
+ return { envelopeKey, ephemeralPublicKey };
96
+ }
97
+ /**
98
+ * Recipient side (the firm). Recover the same `envelopeKey` from its static
99
+ * X25519 secret key and the sender's ephemeral public key, then feed it (with
100
+ * the ML-KEM secret key) to the standard KEM-mode decrypt path.
101
+ */
102
+ export async function openInboundEnvelopeKey(options) {
103
+ const { x25519SecretKey, ephemeralPublicKey, fileId } = options;
104
+ if (x25519SecretKey.length !== X25519_SECRET_KEY_LENGTH) {
105
+ throw new RangeError(`openInboundEnvelopeKey: x25519SecretKey must be ${X25519_SECRET_KEY_LENGTH} bytes`);
106
+ }
107
+ if (ephemeralPublicKey.length !== X25519_PUBLIC_KEY_LENGTH) {
108
+ throw new RangeError(`openInboundEnvelopeKey: ephemeralPublicKey must be ${X25519_PUBLIC_KEY_LENGTH} bytes`);
109
+ }
110
+ if (fileId.length !== HEADER_SIZES.FILE_ID) {
111
+ throw new RangeError(`openInboundEnvelopeKey: fileId must be ${HEADER_SIZES.FILE_ID} bytes`);
112
+ }
113
+ // Recompute the static public key from the secret so the transcript binding
114
+ // matches the sender's byte-for-byte.
115
+ const recipientStaticPublicKey = x25519.getPublicKey(x25519SecretKey);
116
+ const sharedSecret = x25519.getSharedSecret(x25519SecretKey, ephemeralPublicKey);
117
+ const envelopeKey = await deriveEnvelopeKey(sharedSecret, ephemeralPublicKey, recipientStaticPublicKey, fileId);
118
+ return { envelopeKey };
119
+ }
120
+ //# sourceMappingURL=inbound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAE9D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,mCAAmC;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,0BAA0B,GAAG,EAAE,CAAA;AASrC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,YAAwB;IAExB,IAAI,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,UAAU,CAClB,oEAAoE,CACrE,CAAA;IACH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC;QAC5B,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,SAAS,CAAC,0BAA0B;QAC1C,MAAM,EAAE,wBAAwB;KACjC,CAAC,CAAA;IACF,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACjD,OAAO,EAAE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,CAAC,OAI5C;IACC,MAAM,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC/D,IAAI,eAAe,CAAC,MAAM,KAAK,wBAAwB,EAAE,CAAC;QACxD,MAAM,IAAI,UAAU,CAClB,mDAAmD,wBAAwB,QAAQ,CACpF,CAAA;IACH,CAAC;IACD,IAAI,kBAAkB,CAAC,MAAM,KAAK,wBAAwB,EAAE,CAAC;QAC3D,MAAM,IAAI,UAAU,CAClB,sDAAsD,wBAAwB,QAAQ,CACvF,CAAA;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC;QAC3C,MAAM,IAAI,UAAU,CAClB,0CAA0C,YAAY,CAAC,OAAO,QAAQ,CACvE,CAAA;IACH,CAAC;IACD,4EAA4E;IAC5E,sCAAsC;IACtC,MAAM,wBAAwB,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,CAAA;IACrE,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAA;IAChF,MAAM,WAAW,GAAG,MAAM,iBAAiB,CACzC,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,MAAM,CACP,CAAA;IACD,OAAO,EAAE,WAAW,EAAE,CAAA;AACxB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export * as legacyV0 from './suites/aes-gcm-v0/api.js';
32
32
  export * as streamsAesGcmV1 from './streams/aes-gcm-v1.js';
33
33
  export * as kdfArgon2id from './kdf/argon2id.js';
34
34
  export * as identity from './identity/index.js';
35
+ export * as inbound from './identity/inbound.js';
35
36
  export * as migrationV0 from './migration/v0-bridge.js';
36
37
  import { type ProgressCallback } from './internal/types.js';
37
38
  export interface AutoDecryptOptions {
@@ -53,7 +54,7 @@ export interface AutoDecryptOptions {
53
54
  */
54
55
  export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
55
56
  /** Library version, also written into format documentation. */
56
- export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.1";
57
+ export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.2";
57
58
  /** Default cipher suite for new files when not specified by the caller. */
58
59
  export declare const DEFAULT_SUITE: 3;
59
60
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,SAAS,GACV,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAK/B,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,OAAO,GACR,MAAM,uBAAuB,CAAA;AAU9B,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,cAAc,IAAI,sBAAsB,EACzC,MAAM,4BAA4B,CAAA;AACnC,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AACD,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;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AM,aAAa,GAAuC,CAAA"}
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ export * as legacyV0 from './suites/aes-gcm-v0/api.js';
51
51
  export * as streamsAesGcmV1 from './streams/aes-gcm-v1.js';
52
52
  export * as kdfArgon2id from './kdf/argon2id.js';
53
53
  export * as identity from './identity/index.js';
54
+ export * as inbound from './identity/inbound.js';
54
55
  export * as migrationV0 from './migration/v0-bridge.js';
55
56
  // ──────────────────────────────────────────────────────────────────────
56
57
  // Auto-routing decryptor
@@ -140,7 +141,7 @@ export async function autoDecryptBlob(options) {
140
141
  }
141
142
  }
142
143
  /** Library version, also written into format documentation. */
143
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.1';
144
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.2';
144
145
  /** Default cipher suite for new files when not specified by the caller. */
145
146
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
146
147
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,yEAAyE;AACzE,oBAAoB;AACpB,yEAAyE;AACzE,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAE3B,yEAAyE;AACzE,iCAAiC;AACjC,yEAAyE;AACzE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAS5B,yEAAyE;AACzE,gDAAgD;AAChD,yEAAyE;AACzE,OAAO,EACL,aAAa,EACb,aAAa,EACb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AC,WAAW,CAAC;gBAC1B,IAAI;gBACJ,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;gBAC9C,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAI,WAAW,CACnB,oCAAqC,KAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CACrE,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAA;AAErD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,8BAA8B,CAAA"}
@@ -56,6 +56,8 @@ export declare const HKDF_INFO: Readonly<{
56
56
  PQ_HYBRID_COMBINE: "shieldfive/v1/pq-hybrid/combine";
57
57
  ML_KEM_1024_SEED: "shieldfive/v1/pq-hybrid/ml-kem-1024-seed";
58
58
  SHARE_TRANSPORT: "shieldfive/v1/share-transport";
59
+ INBOUND_X25519_STATIC_SEED: "shieldfive/v1/inbound/x25519-static-seed";
60
+ INBOUND_ENVELOPE: "shieldfive/v1/inbound/envelope-key";
59
61
  ARGON2ID_SALT_COMPRESSION: "shieldfive/v1/argon2id/salt-compression";
60
62
  }>;
61
63
  /** AAD domain string mixed into every chunk's authenticator */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;CACxD,CAAA;AAED,MAAM,MAAM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AAE7C,gFAAgF;AAChF,eAAO,MAAM,SAAS;;;;;;;;;;;;;EAwBpB,CAAA;AAEF,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,wBAAwB,CAAA;AACrD,eAAO,MAAM,gBAAgB,QAAsC,CAAA;AAEnE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,UAAU,CAAA;IACxB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA"}
@@ -67,6 +67,15 @@ export const HKDF_INFO = Object.freeze({
67
67
  // label above, so a share transport key is never equal to a file's
68
68
  // combined key for the same (recipient, envelope, file_id).
69
69
  SHARE_TRANSPORT: 'shieldfive/v1/share-transport',
70
+ // Zero-knowledge inbound intake. An account-less sender derives the classical
71
+ // envelope key (the 32-byte input suite 0x03 already expects) from an
72
+ // ephemeral↔static X25519 ECDH against the recipient's published static key,
73
+ // so the classical share stays confidential under X25519 while the PQ share
74
+ // stays confidential under ML-KEM — a genuine break-both hybrid with no change
75
+ // to the frozen suite. These two labels are dedicated to that path and reused
76
+ // nowhere else.
77
+ INBOUND_X25519_STATIC_SEED: 'shieldfive/v1/inbound/x25519-static-seed',
78
+ INBOUND_ENVELOPE: 'shieldfive/v1/inbound/envelope-key',
70
79
  ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
71
80
  });
72
81
  /** AAD domain string mixed into every chunk's authenticator */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,cAAc,EAAE,IAAI;IACpB,qBAAqB,EAAE,IAAI;IAC3B,8BAA8B,EAAE,IAAI;IACpC,cAAc,EAAE,IAAI;CACZ,CAAA;AAUV,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,gBAAgB;IACxC,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,uBAAuB;IACtD,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE,gCAAgC;IACxE,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,gBAAgB;CACzC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAe,IAAI,UAAU,CAAC;IACrD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAC7B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAEpC,iDAAiD;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,CAAC;IACf,cAAc,EAAE,CAAC;IACjB,iBAAiB,EAAE,CAAC;IACpB,UAAU,EAAE,EAAE;CACf,CAAC,CAAA;AAEF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GACrC,YAAY,CAAC,KAAK;IAClB,YAAY,CAAC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AAA;AAE7C,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,0BAA0B;IACtC,iBAAiB,EAAE,iCAAiC;IACpD,oBAAoB,EAAE,oCAAoC;IAC1D,uBAAuB,EAAE,uCAAuC;IAChE,iBAAiB,EAAE,iCAAiC;IACpD,oBAAoB,EAAE,oCAAoC;IAC1D,iBAAiB,EAAE,iCAAiC;IACpD,gBAAgB,EAAE,0CAA0C;IAC5D,4EAA4E;IAC5E,yEAAyE;IACzE,mEAAmE;IACnE,4DAA4D;IAC5D,eAAe,EAAE,+BAA+B;IAChD,8EAA8E;IAC9E,sEAAsE;IACtE,6EAA6E;IAC7E,4EAA4E;IAC5E,+EAA+E;IAC/E,8EAA8E;IAC9E,gBAAgB;IAChB,0BAA0B,EAAE,0CAA0C;IACtE,gBAAgB,EAAE,oCAAoC;IACtD,yBAAyB,EAAE,yCAAyC;CACrE,CAAC,CAAA;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAA;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shieldfive/crypto",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
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",
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Zero-knowledge inbound intake.
3
+ *
4
+ * The PQ-hybrid suite (0x03) derives a file's content key from BOTH an ML-KEM
5
+ * encapsulated share AND a classical share that is secret-box-wrapped under a
6
+ * caller-supplied 32-byte `envelopeKey`. To decrypt, a recipient needs the
7
+ * ML-KEM secret key AND that envelope key — the KEM does not deliver the
8
+ * envelope key.
9
+ *
10
+ * For OUTBOUND files the owner is the recipient and already holds the envelope
11
+ * key (it is the file's own content key). An INBOUND, account-less sender has
12
+ * no firm secret, so it cannot produce an envelope key the firm can later
13
+ * recover. Using a public constant would make the classical share public and
14
+ * collapse the scheme to ML-KEM-only.
15
+ *
16
+ * This module closes that gap WITHOUT touching the frozen suite: the firm
17
+ * publishes a static X25519 public key alongside its ML-KEM public key, and the
18
+ * sender derives the envelope key from an ephemeral↔static X25519 ECDH. The
19
+ * classical share is then confidential under X25519 while the PQ share is
20
+ * confidential under ML-KEM, so an attacker must break BOTH primitives — a
21
+ * genuine hybrid, with the bulk file still produced by the existing
22
+ * `encryptStreamPqHybridV1` / `encryptBlob` path.
23
+ *
24
+ * Trust note: the recipient's published keys are only as trustworthy as the
25
+ * channel that serves them. Browser-delivered code "trusts the served code each
26
+ * load"; pair this with an out-of-band key fingerprint for the strong claim.
27
+ * This module does the cryptography; it does not establish key authenticity.
28
+ */
29
+
30
+ import { x25519 } from '@noble/curves/ed25519.js'
31
+
32
+ import { concatBytes } from '../internal/encoding.js'
33
+ import { hkdfSha256 } from '../internal/hkdf.js'
34
+ import { randomBytes } from '../internal/runtime.js'
35
+ import { HEADER_SIZES, HKDF_INFO } from '../internal/types.js'
36
+
37
+ /** X25519 public key length (Curve25519 u-coordinate). */
38
+ export const X25519_PUBLIC_KEY_LENGTH = 32
39
+ /** X25519 secret scalar length. */
40
+ export const X25519_SECRET_KEY_LENGTH = 32
41
+
42
+ const INBOUND_ENVELOPE_KEY_BYTES = 32
43
+
44
+ export interface InboundStaticKeypair {
45
+ /** Static X25519 public key (32 bytes) — publish next to the ML-KEM public key. */
46
+ x25519PublicKey: Uint8Array
47
+ /** Static X25519 secret scalar (32 bytes) — treat as highly sensitive. */
48
+ x25519SecretKey: Uint8Array
49
+ }
50
+
51
+ /**
52
+ * Deterministically derive the firm's static X25519 keypair from its master
53
+ * secret, mirroring how the ML-KEM keypair is derived. The same master secret
54
+ * always yields the same keypair across devices, so losing a device does not
55
+ * orphan received files (as long as the master secret is recoverable).
56
+ */
57
+ export async function deriveInboundStaticKeypair(
58
+ masterSecret: Uint8Array,
59
+ ): Promise<InboundStaticKeypair> {
60
+ if (masterSecret.length < 16) {
61
+ throw new RangeError(
62
+ 'deriveInboundStaticKeypair: masterSecret must be at least 16 bytes',
63
+ )
64
+ }
65
+ const seed = await hkdfSha256({
66
+ ikm: masterSecret,
67
+ info: HKDF_INFO.INBOUND_X25519_STATIC_SEED,
68
+ length: X25519_SECRET_KEY_LENGTH,
69
+ })
70
+ const x25519PublicKey = x25519.getPublicKey(seed)
71
+ return { x25519PublicKey, x25519SecretKey: seed }
72
+ }
73
+
74
+ /**
75
+ * Derive the per-file envelope key from a shared secret. The full ECDH
76
+ * transcript (shared secret, ephemeral public key, recipient static public key)
77
+ * is bound into the HKDF input and the file_id into the salt, so a captured
78
+ * ephemeral key cannot be replayed against a different recipient or file.
79
+ */
80
+ async function deriveEnvelopeKey(
81
+ sharedSecret: Uint8Array,
82
+ ephemeralPublicKey: Uint8Array,
83
+ recipientStaticPublicKey: Uint8Array,
84
+ fileId: Uint8Array,
85
+ ): Promise<Uint8Array> {
86
+ return hkdfSha256({
87
+ ikm: concatBytes([
88
+ sharedSecret,
89
+ ephemeralPublicKey,
90
+ recipientStaticPublicKey,
91
+ ]),
92
+ salt: fileId,
93
+ info: HKDF_INFO.INBOUND_ENVELOPE,
94
+ length: INBOUND_ENVELOPE_KEY_BYTES,
95
+ })
96
+ }
97
+
98
+ /**
99
+ * Sender side (account-less, in the browser). Given the firm's published static
100
+ * X25519 public key and the file_id used for the upload, produce the classical
101
+ * `envelopeKey` to pass to `encryptStreamPqHybridV1` / `encryptBlob`, plus the
102
+ * ephemeral public key to store alongside the ciphertext so the firm can
103
+ * recover the same envelope key. No firm secret is required.
104
+ */
105
+ export async function sealInboundEnvelopeKey(options: {
106
+ recipientX25519PublicKey: Uint8Array
107
+ fileId: Uint8Array
108
+ }): Promise<{ envelopeKey: Uint8Array; ephemeralPublicKey: Uint8Array }> {
109
+ const { recipientX25519PublicKey, fileId } = options
110
+ if (recipientX25519PublicKey.length !== X25519_PUBLIC_KEY_LENGTH) {
111
+ throw new RangeError(
112
+ `sealInboundEnvelopeKey: recipientX25519PublicKey must be ${X25519_PUBLIC_KEY_LENGTH} bytes`,
113
+ )
114
+ }
115
+ if (fileId.length !== HEADER_SIZES.FILE_ID) {
116
+ throw new RangeError(
117
+ `sealInboundEnvelopeKey: fileId must be ${HEADER_SIZES.FILE_ID} bytes`,
118
+ )
119
+ }
120
+ const ephemeralSecret = randomBytes(X25519_SECRET_KEY_LENGTH)
121
+ const ephemeralPublicKey = x25519.getPublicKey(ephemeralSecret)
122
+ // Throws on a low-order / all-zero shared secret (contributory behaviour).
123
+ const sharedSecret = x25519.getSharedSecret(
124
+ ephemeralSecret,
125
+ recipientX25519PublicKey,
126
+ )
127
+ const envelopeKey = await deriveEnvelopeKey(
128
+ sharedSecret,
129
+ ephemeralPublicKey,
130
+ recipientX25519PublicKey,
131
+ fileId,
132
+ )
133
+ return { envelopeKey, ephemeralPublicKey }
134
+ }
135
+
136
+ /**
137
+ * Recipient side (the firm). Recover the same `envelopeKey` from its static
138
+ * X25519 secret key and the sender's ephemeral public key, then feed it (with
139
+ * the ML-KEM secret key) to the standard KEM-mode decrypt path.
140
+ */
141
+ export async function openInboundEnvelopeKey(options: {
142
+ x25519SecretKey: Uint8Array
143
+ ephemeralPublicKey: Uint8Array
144
+ fileId: Uint8Array
145
+ }): Promise<{ envelopeKey: Uint8Array }> {
146
+ const { x25519SecretKey, ephemeralPublicKey, fileId } = options
147
+ if (x25519SecretKey.length !== X25519_SECRET_KEY_LENGTH) {
148
+ throw new RangeError(
149
+ `openInboundEnvelopeKey: x25519SecretKey must be ${X25519_SECRET_KEY_LENGTH} bytes`,
150
+ )
151
+ }
152
+ if (ephemeralPublicKey.length !== X25519_PUBLIC_KEY_LENGTH) {
153
+ throw new RangeError(
154
+ `openInboundEnvelopeKey: ephemeralPublicKey must be ${X25519_PUBLIC_KEY_LENGTH} bytes`,
155
+ )
156
+ }
157
+ if (fileId.length !== HEADER_SIZES.FILE_ID) {
158
+ throw new RangeError(
159
+ `openInboundEnvelopeKey: fileId must be ${HEADER_SIZES.FILE_ID} bytes`,
160
+ )
161
+ }
162
+ // Recompute the static public key from the secret so the transcript binding
163
+ // matches the sender's byte-for-byte.
164
+ const recipientStaticPublicKey = x25519.getPublicKey(x25519SecretKey)
165
+ const sharedSecret = x25519.getSharedSecret(x25519SecretKey, ephemeralPublicKey)
166
+ const envelopeKey = await deriveEnvelopeKey(
167
+ sharedSecret,
168
+ ephemeralPublicKey,
169
+ recipientStaticPublicKey,
170
+ fileId,
171
+ )
172
+ return { envelopeKey }
173
+ }
package/src/index.ts CHANGED
@@ -97,6 +97,7 @@ export * as legacyV0 from './suites/aes-gcm-v0/api.js'
97
97
  export * as streamsAesGcmV1 from './streams/aes-gcm-v1.js'
98
98
  export * as kdfArgon2id from './kdf/argon2id.js'
99
99
  export * as identity from './identity/index.js'
100
+ export * as inbound from './identity/inbound.js'
100
101
  export * as migrationV0 from './migration/v0-bridge.js'
101
102
 
102
103
  // ──────────────────────────────────────────────────────────────────────
@@ -218,7 +219,7 @@ export async function autoDecryptBlob(
218
219
  }
219
220
 
220
221
  /** Library version, also written into format documentation. */
221
- export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.1'
222
+ export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.2'
222
223
 
223
224
  /** Default cipher suite for new files when not specified by the caller. */
224
225
  export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1
@@ -93,6 +93,15 @@ export const HKDF_INFO = Object.freeze({
93
93
  // label above, so a share transport key is never equal to a file's
94
94
  // combined key for the same (recipient, envelope, file_id).
95
95
  SHARE_TRANSPORT: 'shieldfive/v1/share-transport',
96
+ // Zero-knowledge inbound intake. An account-less sender derives the classical
97
+ // envelope key (the 32-byte input suite 0x03 already expects) from an
98
+ // ephemeral↔static X25519 ECDH against the recipient's published static key,
99
+ // so the classical share stays confidential under X25519 while the PQ share
100
+ // stays confidential under ML-KEM — a genuine break-both hybrid with no change
101
+ // to the frozen suite. These two labels are dedicated to that path and reused
102
+ // nowhere else.
103
+ INBOUND_X25519_STATIC_SEED: 'shieldfive/v1/inbound/x25519-static-seed',
104
+ INBOUND_ENVELOPE: 'shieldfive/v1/inbound/envelope-key',
96
105
  ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
97
106
  })
98
107