@shieldfive/crypto 1.0.0-rc.2 → 1.0.0-rc.3
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 +18 -0
- package/dist/identity/inbound.d.ts +35 -0
- package/dist/identity/inbound.d.ts.map +1 -1
- package/dist/identity/inbound.js +71 -1
- package/dist/identity/inbound.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/types.d.ts +1 -0
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/internal/types.js +3 -0
- package/dist/internal/types.js.map +1 -1
- package/package.json +1 -1
- package/src/identity/inbound.ts +118 -1
- package/src/index.ts +1 -1
- package/src/internal/types.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ 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.3 — 2026-08-03
|
|
9
|
+
|
|
10
|
+
No wire-format changes; suite `0x03` and the identity bundle are untouched. Adds
|
|
11
|
+
firm key-bundle signing for the inbound-intake "Request documents" feature.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Firm key-bundle signing** in the `inbound` module. `deriveInboundSigningKeypair`
|
|
16
|
+
derives a deterministic Ed25519 identity keypair from the master secret;
|
|
17
|
+
`signInboundKeyBundle` signs the domain-separated, length-framed
|
|
18
|
+
`(ml_kem || x25519)` public-key bundle, and `verifyInboundKeyBundle` checks it.
|
|
19
|
+
This lets a guest detect a swapped firm key (the signature must verify against
|
|
20
|
+
the firm's out-of-band-trusted signing key) — it does not defeat a server that
|
|
21
|
+
also serves malicious verifying code (the honest-claim ceiling). Reuses the
|
|
22
|
+
audited Ed25519 primitives from `sign.ts`. Integration tests cover the
|
|
23
|
+
round trip and detection of a swapped ml_kem/x25519 key, a wrong signer, and a
|
|
24
|
+
tampered signature.
|
|
25
|
+
|
|
8
26
|
## 1.0.0-rc.2 — 2026-08-02
|
|
9
27
|
|
|
10
28
|
No wire-format changes; every file written by a `1.0.0-*` release still decrypts
|
|
@@ -69,4 +69,39 @@ export declare function openInboundEnvelopeKey(options: {
|
|
|
69
69
|
}): Promise<{
|
|
70
70
|
envelopeKey: Uint8Array;
|
|
71
71
|
}>;
|
|
72
|
+
/** Ed25519 signing public key length (bytes). */
|
|
73
|
+
export declare const INBOUND_SIGNING_PUBLIC_KEY_LENGTH = 32;
|
|
74
|
+
/** Ed25519 key-bundle signature length (bytes). */
|
|
75
|
+
export declare const INBOUND_KEY_BUNDLE_SIGNATURE_LENGTH = 64;
|
|
76
|
+
export interface InboundSigningKeypair {
|
|
77
|
+
/** Ed25519 public key (32 bytes) — publish so guests can verify the bundle. */
|
|
78
|
+
ed25519PublicKey: Uint8Array;
|
|
79
|
+
/** Ed25519 secret seed (32 bytes) — treat as highly sensitive. */
|
|
80
|
+
ed25519SecretKey: Uint8Array;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Deterministically derive the firm's Ed25519 signing keypair from its master
|
|
84
|
+
* secret, mirroring the ML-KEM / X25519 derivations. Stable across devices.
|
|
85
|
+
*/
|
|
86
|
+
export declare function deriveInboundSigningKeypair(masterSecret: Uint8Array): Promise<InboundSigningKeypair>;
|
|
87
|
+
/**
|
|
88
|
+
* Sign the firm's published (ml_kem || x25519) bundle with its Ed25519 signing
|
|
89
|
+
* secret. Returns a raw 64-byte signature to store next to the keys.
|
|
90
|
+
*/
|
|
91
|
+
export declare function signInboundKeyBundle(options: {
|
|
92
|
+
ed25519SecretKey: Uint8Array;
|
|
93
|
+
mlKemPublicKey: Uint8Array;
|
|
94
|
+
x25519PublicKey: Uint8Array;
|
|
95
|
+
}): Uint8Array;
|
|
96
|
+
/**
|
|
97
|
+
* Guest side: verify a firm key-bundle signature. Returns false on any failure
|
|
98
|
+
* (never throws). The guest must additionally trust the signing public key via
|
|
99
|
+
* an out-of-band fingerprint.
|
|
100
|
+
*/
|
|
101
|
+
export declare function verifyInboundKeyBundle(options: {
|
|
102
|
+
ed25519PublicKey: Uint8Array;
|
|
103
|
+
mlKemPublicKey: Uint8Array;
|
|
104
|
+
x25519PublicKey: Uint8Array;
|
|
105
|
+
signature: Uint8Array;
|
|
106
|
+
}): boolean;
|
|
72
107
|
//# sourceMappingURL=inbound.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAkBH,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;AAYD,iDAAiD;AACjD,eAAO,MAAM,iCAAiC,KAA4B,CAAA;AAC1E,mDAAmD;AACnD,eAAO,MAAM,mCAAmC,KAA2B,CAAA;AAM3E,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,gBAAgB,EAAE,UAAU,CAAA;IAC5B,kEAAkE;IAClE,gBAAgB,EAAE,UAAU,CAAA;CAC7B;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAahC;AAsBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,gBAAgB,EAAE,UAAU,CAAA;IAC5B,cAAc,EAAE,UAAU,CAAA;IAC1B,eAAe,EAAE,UAAU,CAAA;CAC5B,GAAG,UAAU,CASb;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,gBAAgB,EAAE,UAAU,CAAA;IAC5B,cAAc,EAAE,UAAU,CAAA;IAC1B,eAAe,EAAE,UAAU,CAAA;IAC3B,SAAS,EAAE,UAAU,CAAA;CACtB,GAAG,OAAO,CAUV"}
|
package/dist/identity/inbound.js
CHANGED
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
* This module does the cryptography; it does not establish key authenticity.
|
|
28
28
|
*/
|
|
29
29
|
import { x25519 } from '@noble/curves/ed25519.js';
|
|
30
|
-
import {
|
|
30
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
31
|
+
import { deriveEd25519PublicKey, ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, signSenderTranscript, verifySenderTranscript, } from './sign.js';
|
|
32
|
+
import { concatBytes, uint32BE } from '../internal/encoding.js';
|
|
31
33
|
import { hkdfSha256 } from '../internal/hkdf.js';
|
|
32
34
|
import { randomBytes } from '../internal/runtime.js';
|
|
33
35
|
import { HEADER_SIZES, HKDF_INFO } from '../internal/types.js';
|
|
@@ -117,4 +119,72 @@ export async function openInboundEnvelopeKey(options) {
|
|
|
117
119
|
const envelopeKey = await deriveEnvelopeKey(sharedSecret, ephemeralPublicKey, recipientStaticPublicKey, fileId);
|
|
118
120
|
return { envelopeKey };
|
|
119
121
|
}
|
|
122
|
+
// ── Firm key-bundle signing ──────────────────────────────────────────────────
|
|
123
|
+
//
|
|
124
|
+
// The guest fetches the firm's ml_kem + x25519 public keys from a server it does
|
|
125
|
+
// not trust. To detect a swapped key, the firm signs its published key bundle
|
|
126
|
+
// with a long-lived Ed25519 identity key derived from the same master secret,
|
|
127
|
+
// and the guest verifies the signature against the firm's published signing key
|
|
128
|
+
// (whose fingerprint the firm communicates out of band). This raises the bar to
|
|
129
|
+
// a firm-key forgery; it does not defeat a server that also serves malicious
|
|
130
|
+
// verifying code (the honest-claim ceiling).
|
|
131
|
+
/** Ed25519 signing public key length (bytes). */
|
|
132
|
+
export const INBOUND_SIGNING_PUBLIC_KEY_LENGTH = ED25519_PUBLIC_KEY_LENGTH;
|
|
133
|
+
/** Ed25519 key-bundle signature length (bytes). */
|
|
134
|
+
export const INBOUND_KEY_BUNDLE_SIGNATURE_LENGTH = ED25519_SIGNATURE_LENGTH;
|
|
135
|
+
const INBOUND_KEY_BUNDLE_DOMAIN = new TextEncoder().encode('shieldfive/v1/inbound/key-bundle');
|
|
136
|
+
/**
|
|
137
|
+
* Deterministically derive the firm's Ed25519 signing keypair from its master
|
|
138
|
+
* secret, mirroring the ML-KEM / X25519 derivations. Stable across devices.
|
|
139
|
+
*/
|
|
140
|
+
export async function deriveInboundSigningKeypair(masterSecret) {
|
|
141
|
+
if (masterSecret.length < 16) {
|
|
142
|
+
throw new RangeError('deriveInboundSigningKeypair: masterSecret must be at least 16 bytes');
|
|
143
|
+
}
|
|
144
|
+
const seed = await hkdfSha256({
|
|
145
|
+
ikm: masterSecret,
|
|
146
|
+
info: HKDF_INFO.INBOUND_SIGNING_SEED,
|
|
147
|
+
length: ED25519_SECRET_KEY_LENGTH,
|
|
148
|
+
});
|
|
149
|
+
const ed25519PublicKey = deriveEd25519PublicKey(seed);
|
|
150
|
+
return { ed25519PublicKey, ed25519SecretKey: seed };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Domain-separated, length-framed digest over the published key bundle. Framing
|
|
154
|
+
* the lengths prevents a (ml_kem, x25519) split from colliding with a different
|
|
155
|
+
* pairing.
|
|
156
|
+
*/
|
|
157
|
+
function inboundKeyBundleDigest(mlKemPublicKey, x25519PublicKey) {
|
|
158
|
+
return sha256(concatBytes([
|
|
159
|
+
INBOUND_KEY_BUNDLE_DOMAIN,
|
|
160
|
+
uint32BE(mlKemPublicKey.length),
|
|
161
|
+
mlKemPublicKey,
|
|
162
|
+
uint32BE(x25519PublicKey.length),
|
|
163
|
+
x25519PublicKey,
|
|
164
|
+
]));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Sign the firm's published (ml_kem || x25519) bundle with its Ed25519 signing
|
|
168
|
+
* secret. Returns a raw 64-byte signature to store next to the keys.
|
|
169
|
+
*/
|
|
170
|
+
export function signInboundKeyBundle(options) {
|
|
171
|
+
const digest = inboundKeyBundleDigest(options.mlKemPublicKey, options.x25519PublicKey);
|
|
172
|
+
return signSenderTranscript({
|
|
173
|
+
ed25519SecretKey: options.ed25519SecretKey,
|
|
174
|
+
transcriptDigest: digest,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Guest side: verify a firm key-bundle signature. Returns false on any failure
|
|
179
|
+
* (never throws). The guest must additionally trust the signing public key via
|
|
180
|
+
* an out-of-band fingerprint.
|
|
181
|
+
*/
|
|
182
|
+
export function verifyInboundKeyBundle(options) {
|
|
183
|
+
const digest = inboundKeyBundleDigest(options.mlKemPublicKey, options.x25519PublicKey);
|
|
184
|
+
return verifySenderTranscript({
|
|
185
|
+
ed25519PublicKey: options.ed25519PublicKey,
|
|
186
|
+
transcriptDigest: digest,
|
|
187
|
+
signature: options.signature,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
120
190
|
//# sourceMappingURL=inbound.js.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAC/D,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,0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,EAAE,OAAO,CAAC,gBAAgB;QAC1C,gBAAgB,EAAE,MAAM;KACzB,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAKtC;IACC,MAAM,MAAM,GAAG,sBAAsB,CACnC,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,eAAe,CACxB,CAAA;IACD,OAAO,sBAAsB,CAAC;QAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,gBAAgB,EAAE,MAAM;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface AutoDecryptOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
|
|
56
56
|
/** Library version, also written into format documentation. */
|
|
57
|
-
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.
|
|
57
|
+
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.3";
|
|
58
58
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
59
59
|
export declare const DEFAULT_SUITE: 3;
|
|
60
60
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -141,7 +141,7 @@ export async function autoDecryptBlob(options) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
/** Library version, also written into format documentation. */
|
|
144
|
-
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.
|
|
144
|
+
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.3';
|
|
145
145
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
146
146
|
export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
|
|
147
147
|
//# sourceMappingURL=index.js.map
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare const HKDF_INFO: Readonly<{
|
|
|
58
58
|
SHARE_TRANSPORT: "shieldfive/v1/share-transport";
|
|
59
59
|
INBOUND_X25519_STATIC_SEED: "shieldfive/v1/inbound/x25519-static-seed";
|
|
60
60
|
INBOUND_ENVELOPE: "shieldfive/v1/inbound/envelope-key";
|
|
61
|
+
INBOUND_SIGNING_SEED: "shieldfive/v1/inbound/ed25519-signing-seed";
|
|
61
62
|
ARGON2ID_SALT_COMPRESSION: "shieldfive/v1/argon2id/salt-compression";
|
|
62
63
|
}>;
|
|
63
64
|
/** 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,YAAY,GAAG,UAAU,CAAC,YAAY,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;CAKR,CAAA;AAEV,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAExD,MAAM,MAAM,SAAS,GACjB,gBAAgB,GAChB,uBAAuB,GACvB,gCAAgC,GAChC,gBAAgB,CAAA;AAEpB,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAKlD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,UAEzB,CAAA;AAEF,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC,iDAAiD;AACjD,eAAO,MAAM,YAAY;;;;;;;;;;EAUvB,CAAA;AAEF,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,QAQP,CAAA;AAEhC,gEAAgE;AAChE,eAAO,MAAM,kBAA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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"}
|
package/dist/internal/types.js
CHANGED
|
@@ -76,6 +76,9 @@ export const HKDF_INFO = Object.freeze({
|
|
|
76
76
|
// nowhere else.
|
|
77
77
|
INBOUND_X25519_STATIC_SEED: 'shieldfive/v1/inbound/x25519-static-seed',
|
|
78
78
|
INBOUND_ENVELOPE: 'shieldfive/v1/inbound/envelope-key',
|
|
79
|
+
// Ed25519 identity signing key for inbound intake. The firm signs its
|
|
80
|
+
// published (ml_kem || x25519) bundle so a guest can detect a key swap.
|
|
81
|
+
INBOUND_SIGNING_SEED: 'shieldfive/v1/inbound/ed25519-signing-seed',
|
|
79
82
|
ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
|
|
80
83
|
});
|
|
81
84
|
/** AAD domain string mixed into every chunk's authenticator */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRo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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,sEAAsE;IACtE,wEAAwE;IACxE,oBAAoB,EAAE,4CAA4C;IAClE,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
package/src/identity/inbound.ts
CHANGED
|
@@ -28,8 +28,17 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
import { x25519 } from '@noble/curves/ed25519.js'
|
|
31
|
+
import { sha256 } from '@noble/hashes/sha2.js'
|
|
31
32
|
|
|
32
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
deriveEd25519PublicKey,
|
|
35
|
+
ED25519_PUBLIC_KEY_LENGTH,
|
|
36
|
+
ED25519_SECRET_KEY_LENGTH,
|
|
37
|
+
ED25519_SIGNATURE_LENGTH,
|
|
38
|
+
signSenderTranscript,
|
|
39
|
+
verifySenderTranscript,
|
|
40
|
+
} from './sign.js'
|
|
41
|
+
import { concatBytes, uint32BE } from '../internal/encoding.js'
|
|
33
42
|
import { hkdfSha256 } from '../internal/hkdf.js'
|
|
34
43
|
import { randomBytes } from '../internal/runtime.js'
|
|
35
44
|
import { HEADER_SIZES, HKDF_INFO } from '../internal/types.js'
|
|
@@ -171,3 +180,111 @@ export async function openInboundEnvelopeKey(options: {
|
|
|
171
180
|
)
|
|
172
181
|
return { envelopeKey }
|
|
173
182
|
}
|
|
183
|
+
|
|
184
|
+
// ── Firm key-bundle signing ──────────────────────────────────────────────────
|
|
185
|
+
//
|
|
186
|
+
// The guest fetches the firm's ml_kem + x25519 public keys from a server it does
|
|
187
|
+
// not trust. To detect a swapped key, the firm signs its published key bundle
|
|
188
|
+
// with a long-lived Ed25519 identity key derived from the same master secret,
|
|
189
|
+
// and the guest verifies the signature against the firm's published signing key
|
|
190
|
+
// (whose fingerprint the firm communicates out of band). This raises the bar to
|
|
191
|
+
// a firm-key forgery; it does not defeat a server that also serves malicious
|
|
192
|
+
// verifying code (the honest-claim ceiling).
|
|
193
|
+
|
|
194
|
+
/** Ed25519 signing public key length (bytes). */
|
|
195
|
+
export const INBOUND_SIGNING_PUBLIC_KEY_LENGTH = ED25519_PUBLIC_KEY_LENGTH
|
|
196
|
+
/** Ed25519 key-bundle signature length (bytes). */
|
|
197
|
+
export const INBOUND_KEY_BUNDLE_SIGNATURE_LENGTH = ED25519_SIGNATURE_LENGTH
|
|
198
|
+
|
|
199
|
+
const INBOUND_KEY_BUNDLE_DOMAIN = new TextEncoder().encode(
|
|
200
|
+
'shieldfive/v1/inbound/key-bundle',
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
export interface InboundSigningKeypair {
|
|
204
|
+
/** Ed25519 public key (32 bytes) — publish so guests can verify the bundle. */
|
|
205
|
+
ed25519PublicKey: Uint8Array
|
|
206
|
+
/** Ed25519 secret seed (32 bytes) — treat as highly sensitive. */
|
|
207
|
+
ed25519SecretKey: Uint8Array
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Deterministically derive the firm's Ed25519 signing keypair from its master
|
|
212
|
+
* secret, mirroring the ML-KEM / X25519 derivations. Stable across devices.
|
|
213
|
+
*/
|
|
214
|
+
export async function deriveInboundSigningKeypair(
|
|
215
|
+
masterSecret: Uint8Array,
|
|
216
|
+
): Promise<InboundSigningKeypair> {
|
|
217
|
+
if (masterSecret.length < 16) {
|
|
218
|
+
throw new RangeError(
|
|
219
|
+
'deriveInboundSigningKeypair: masterSecret must be at least 16 bytes',
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
const seed = await hkdfSha256({
|
|
223
|
+
ikm: masterSecret,
|
|
224
|
+
info: HKDF_INFO.INBOUND_SIGNING_SEED,
|
|
225
|
+
length: ED25519_SECRET_KEY_LENGTH,
|
|
226
|
+
})
|
|
227
|
+
const ed25519PublicKey = deriveEd25519PublicKey(seed)
|
|
228
|
+
return { ed25519PublicKey, ed25519SecretKey: seed }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Domain-separated, length-framed digest over the published key bundle. Framing
|
|
233
|
+
* the lengths prevents a (ml_kem, x25519) split from colliding with a different
|
|
234
|
+
* pairing.
|
|
235
|
+
*/
|
|
236
|
+
function inboundKeyBundleDigest(
|
|
237
|
+
mlKemPublicKey: Uint8Array,
|
|
238
|
+
x25519PublicKey: Uint8Array,
|
|
239
|
+
): Uint8Array {
|
|
240
|
+
return sha256(
|
|
241
|
+
concatBytes([
|
|
242
|
+
INBOUND_KEY_BUNDLE_DOMAIN,
|
|
243
|
+
uint32BE(mlKemPublicKey.length),
|
|
244
|
+
mlKemPublicKey,
|
|
245
|
+
uint32BE(x25519PublicKey.length),
|
|
246
|
+
x25519PublicKey,
|
|
247
|
+
]),
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Sign the firm's published (ml_kem || x25519) bundle with its Ed25519 signing
|
|
253
|
+
* secret. Returns a raw 64-byte signature to store next to the keys.
|
|
254
|
+
*/
|
|
255
|
+
export function signInboundKeyBundle(options: {
|
|
256
|
+
ed25519SecretKey: Uint8Array
|
|
257
|
+
mlKemPublicKey: Uint8Array
|
|
258
|
+
x25519PublicKey: Uint8Array
|
|
259
|
+
}): Uint8Array {
|
|
260
|
+
const digest = inboundKeyBundleDigest(
|
|
261
|
+
options.mlKemPublicKey,
|
|
262
|
+
options.x25519PublicKey,
|
|
263
|
+
)
|
|
264
|
+
return signSenderTranscript({
|
|
265
|
+
ed25519SecretKey: options.ed25519SecretKey,
|
|
266
|
+
transcriptDigest: digest,
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Guest side: verify a firm key-bundle signature. Returns false on any failure
|
|
272
|
+
* (never throws). The guest must additionally trust the signing public key via
|
|
273
|
+
* an out-of-band fingerprint.
|
|
274
|
+
*/
|
|
275
|
+
export function verifyInboundKeyBundle(options: {
|
|
276
|
+
ed25519PublicKey: Uint8Array
|
|
277
|
+
mlKemPublicKey: Uint8Array
|
|
278
|
+
x25519PublicKey: Uint8Array
|
|
279
|
+
signature: Uint8Array
|
|
280
|
+
}): boolean {
|
|
281
|
+
const digest = inboundKeyBundleDigest(
|
|
282
|
+
options.mlKemPublicKey,
|
|
283
|
+
options.x25519PublicKey,
|
|
284
|
+
)
|
|
285
|
+
return verifySenderTranscript({
|
|
286
|
+
ed25519PublicKey: options.ed25519PublicKey,
|
|
287
|
+
transcriptDigest: digest,
|
|
288
|
+
signature: options.signature,
|
|
289
|
+
})
|
|
290
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -219,7 +219,7 @@ export async function autoDecryptBlob(
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/** Library version, also written into format documentation. */
|
|
222
|
-
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.
|
|
222
|
+
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.3'
|
|
223
223
|
|
|
224
224
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
225
225
|
export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1
|
package/src/internal/types.ts
CHANGED
|
@@ -102,6 +102,9 @@ export const HKDF_INFO = Object.freeze({
|
|
|
102
102
|
// nowhere else.
|
|
103
103
|
INBOUND_X25519_STATIC_SEED: 'shieldfive/v1/inbound/x25519-static-seed',
|
|
104
104
|
INBOUND_ENVELOPE: 'shieldfive/v1/inbound/envelope-key',
|
|
105
|
+
// Ed25519 identity signing key for inbound intake. The firm signs its
|
|
106
|
+
// published (ml_kem || x25519) bundle so a guest can detect a key swap.
|
|
107
|
+
INBOUND_SIGNING_SEED: 'shieldfive/v1/inbound/ed25519-signing-seed',
|
|
105
108
|
ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
|
|
106
109
|
})
|
|
107
110
|
|