run402 4.42.0 → 4.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/command-manifest.mjs +6 -3
  2. package/lib/deploy-v2.mjs +27 -4
  3. package/lib/next-actions.mjs +5 -2
  4. package/lib/repos.mjs +571 -123
  5. package/lib/stats.mjs +57 -0
  6. package/package.json +1 -1
  7. package/sdk/dist/index.d.ts +10 -1
  8. package/sdk/dist/index.d.ts.map +1 -1
  9. package/sdk/dist/index.js +11 -0
  10. package/sdk/dist/index.js.map +1 -1
  11. package/sdk/dist/kernel.d.ts +31 -0
  12. package/sdk/dist/kernel.d.ts.map +1 -1
  13. package/sdk/dist/kernel.js +116 -3
  14. package/sdk/dist/kernel.js.map +1 -1
  15. package/sdk/dist/namespaces/gitvault.crypto.d.ts +178 -5
  16. package/sdk/dist/namespaces/gitvault.crypto.d.ts.map +1 -1
  17. package/sdk/dist/namespaces/gitvault.crypto.js +266 -7
  18. package/sdk/dist/namespaces/gitvault.crypto.js.map +1 -1
  19. package/sdk/dist/namespaces/gitvault.d.ts +103 -1
  20. package/sdk/dist/namespaces/gitvault.d.ts.map +1 -1
  21. package/sdk/dist/namespaces/gitvault.js +175 -7
  22. package/sdk/dist/namespaces/gitvault.js.map +1 -1
  23. package/sdk/dist/namespaces/gitvault.types.d.ts +184 -9
  24. package/sdk/dist/namespaces/gitvault.types.d.ts.map +1 -1
  25. package/sdk/dist/namespaces/gitvault.types.js +2 -1
  26. package/sdk/dist/namespaces/gitvault.types.js.map +1 -1
  27. package/sdk/dist/node/gitvault-apply.d.ts +8 -0
  28. package/sdk/dist/node/gitvault-apply.d.ts.map +1 -1
  29. package/sdk/dist/node/gitvault-apply.js +1 -0
  30. package/sdk/dist/node/gitvault-apply.js.map +1 -1
  31. package/sdk/dist/node/gitvault-deploy.d.ts +13 -0
  32. package/sdk/dist/node/gitvault-deploy.d.ts.map +1 -1
  33. package/sdk/dist/node/gitvault-deploy.js +28 -0
  34. package/sdk/dist/node/gitvault-deploy.js.map +1 -1
  35. package/sdk/dist/node/gitvault-keystore.d.ts +54 -4
  36. package/sdk/dist/node/gitvault-keystore.d.ts.map +1 -1
  37. package/sdk/dist/node/gitvault-keystore.js +20 -0
  38. package/sdk/dist/node/gitvault-keystore.js.map +1 -1
  39. package/sdk/dist/node/gitvault-publication.d.ts +328 -4
  40. package/sdk/dist/node/gitvault-publication.d.ts.map +1 -1
  41. package/sdk/dist/node/gitvault-publication.js +560 -14
  42. package/sdk/dist/node/gitvault-publication.js.map +1 -1
  43. package/sdk/dist/node/gitvault-snapshot.d.ts +40 -7
  44. package/sdk/dist/node/gitvault-snapshot.d.ts.map +1 -1
  45. package/sdk/dist/node/gitvault-snapshot.js +67 -19
  46. package/sdk/dist/node/gitvault-snapshot.js.map +1 -1
@@ -27,7 +27,7 @@
27
27
  */
28
28
  import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
29
29
  import { CipherSuite } from "@hpke/core";
30
- import type { GitvaultAllocation, GitvaultDigestLabel, GitvaultEncryptedObjectKind, GitvaultEncryptionKeypair, GitvaultEnvelopeAad, GitvaultFrameAad, GitvaultKeyEnvelope, GitvaultKeyEnvelopeReceipt, GitvaultObjectKind, GitvaultRecoveryReceipt, GitvaultSealedFrame, GitvaultSealedKeyEnvelope, GitvaultSignedObject, GitvaultSigningKeypair, GitvaultStrictParseReason, GitvaultVaultGenesis } from "./gitvault.types.js";
30
+ import type { GitvaultAllocation, GitvaultDigestLabel, GitvaultEncryptedObjectKind, GitvaultEncryptionKeypair, GitvaultEnvelopeAad, GitvaultFormat, GitvaultFrameAad, GitvaultKeyEnvelope, GitvaultKeyEnvelopeReceipt, GitvaultObjectKind, GitvaultRecoveryReceipt, GitvaultSealedFrame, GitvaultSealedKeyEnvelope, GitvaultSignedObject, GitvaultSigningKeypair, GitvaultStrictParseReason, GitvaultSuite, GitvaultVaultGenesis } from "./gitvault.types.js";
31
31
  /** Wire format tag (retained by decision D181 across the product rename). */
32
32
  export declare const GITVAULT_FORMAT: "r402s/v0";
33
33
  /** The one V0 cryptographic suite. */
@@ -125,6 +125,15 @@ export declare function gitvaultStrictParseReason(error: unknown): GitvaultStric
125
125
  export declare function storedBytes(object: GitvaultSignedObject): Uint8Array;
126
126
  /** SHA-256 over stored bytes — what every `*_sha256` naming a signed object means. */
127
127
  export declare function storedBytesSha256(object: GitvaultSignedObject): string;
128
+ /**
129
+ * Exported so the rotation producer (D195) can build the SAME
130
+ * signature-stripped shape `rotation_id`'s own derivation needs
131
+ * (`sha256(JCS(descriptor minus signature))`) without reaching into this
132
+ * module's private helper twice under two different names.
133
+ */
134
+ export declare function gitvaultWithoutSignature<T extends {
135
+ signature?: unknown;
136
+ }>(object: T): Omit<T, "signature">;
128
137
  /** Signature preimage = `"r402s/v0/" + object_kind + "\n" + JCS(object without its single top-level signature)`. */
129
138
  export declare function signaturePreimage(objectKind: GitvaultObjectKind, objectWithoutSignature: Record<string, unknown>): Uint8Array;
130
139
  export declare function ed25519PublicKey(seed: Uint8Array): Uint8Array;
@@ -166,6 +175,14 @@ export declare function deriveObjectKey(kRepo: Uint8Array, repoId: string, epoch
166
175
  /** `K_digest` info = lp("r402s/v0") ‖ lp("r402s-1") ‖ lp(repo_id) ‖ lp(epoch) ‖ lp("digest") ‖ lp(label) ‖ lp("L=32"). */
167
176
  export declare function digestKeyInfo(repoId: string, epoch: string, label: GitvaultDigestLabel): Uint8Array;
168
177
  export declare function deriveDigestKey(kRepo: Uint8Array, repoId: string, epoch: string, label: GitvaultDigestLabel): Uint8Array;
178
+ /**
179
+ * The general form `deriveDigestKey` is a fixed-`ikm=K_repo` specialization
180
+ * of (D195/D198/D200, rev 42): every rev-42 rotation label is keyed by the
181
+ * SAMPLED epoch key (`K_e` for a rotation, `K_1` for genesis) instead of
182
+ * `K_repo` — "the value being committed IS the key being distributed"
183
+ * (protocol-v0.md S1). Same HKDF info construction either way.
184
+ */
185
+ export declare function deriveDigestKeyFrom(ikm: Uint8Array, repoId: string, epoch: string, label: GitvaultDigestLabel): Uint8Array;
169
186
  /** Commitment = HMAC-SHA-256(K_digest(label), JCS(content)), lowercase hex. */
170
187
  export declare function keyedCommitment(kDigest: Uint8Array, content: unknown): string;
171
188
  /** The `"objectset"` content shape: `{oids:[sorted unique lowercase 40-hex]}`. */
@@ -231,8 +248,17 @@ export declare function openFrameWithAad(kObj: Uint8Array, frame: Uint8Array, aa
231
248
  export declare function gitvaultHpkeSuite(): CipherSuite;
232
249
  /** HPKE `info` (D188): lp("r402s/v0/envelope") ‖ lp("r402s-1") ‖ lp(lowerhex(SHA-256(recipient raw X25519 pubkey))) ‖ lp(created_by). */
233
250
  export declare function envelopeInfo(recipientPublicKeyRaw: Uint8Array, createdBy: string): Uint8Array;
234
- /** HPKE AAD (D188): JCS of exactly `{repo_id, epoch, recipient_kind:"principal", recipient_fingerprint}`. */
235
- export declare function envelopeAad(repoId: string, epoch: string, recipientFingerprint: string): GitvaultEnvelopeAad;
251
+ /**
252
+ * HPKE AAD (D188, discriminated by `rotation_id` presence — D203, rev 42):
253
+ * `rotation_id` ABSENT (genesis / ADD-workaround envelope) -> the rev-41
254
+ * four-field form, BYTE-IDENTICAL to every existing golden HPKE digest;
255
+ * `rotation_id` PRESENT (a rotation-attempt envelope) -> the new five-field
256
+ * form. Field ORDER in the returned object does not matter (JCS sorts
257
+ * object members), but `rotation_id` must never be included as an explicit
258
+ * `null` — the two shapes are genuinely different objects, not one object
259
+ * with an optional-null member (protocol-v0.md S2).
260
+ */
261
+ export declare function envelopeAad(repoId: string, epoch: string, recipientFingerprint: string, rotationId?: string | null): GitvaultEnvelopeAad;
236
262
  export interface GitvaultHpkeSealInput {
237
263
  recipient_public_key: Uint8Array;
238
264
  info: Uint8Array;
@@ -256,7 +282,7 @@ export interface GitvaultHpkeOpenInput {
256
282
  /** Single-shot HPKE open; any failure is `GITVAULT_HPKE_OPEN_FAILED` (never garbage plaintext). */
257
283
  export declare function hpkeOpen(input: GitvaultHpkeOpenInput): Promise<Uint8Array>;
258
284
  export interface GitvaultSealKeyEnvelopeInput {
259
- /** The raw 32-byte K_repothe ENTIRE plaintext. */
285
+ /** The raw 32-byte secret being distributed `K_repo`/`K_1` at genesis, `K_e` for a rotation. */
260
286
  k_repo: Uint8Array;
261
287
  repo_id: string;
262
288
  epoch: string;
@@ -265,6 +291,13 @@ export interface GitvaultSealKeyEnvelopeInput {
265
291
  /** The creator's signing keypair; its `vk_` fingerprint becomes `created_by`. */
266
292
  signer: GitvaultSigningKeypair;
267
293
  created_at: string;
294
+ /**
295
+ * PRESENT for a rotation-attempt envelope (D195/D196, rev 42): widens the
296
+ * path to `(repo_id, epoch, rotation_id, recipient_fingerprint)` and the
297
+ * HPKE AAD to the five-field form. ABSENT/omitted for a genesis/ADD-
298
+ * workaround envelope — byte-identical to rev 41.
299
+ */
300
+ rotation_id?: string | null;
268
301
  /** Vector determinism only. */
269
302
  ikm_e?: Uint8Array;
270
303
  }
@@ -280,7 +313,9 @@ export interface GitvaultOpenKeyEnvelopeInput {
280
313
  /**
281
314
  * Open a `key_envelope`: exact-scalar checks → signature (strict, domain
282
315
  * `key_envelope`) → path identity (recipient fingerprint = ours) → HPKE open
283
- * with the D188 info/AAD. Returns the raw 32-byte K_repo.
316
+ * with the D188 info/AAD (widened to the five-field form when the envelope
317
+ * itself carries `rotation_id` — D195/D203). Returns the raw 32-byte secret
318
+ * (`K_repo`/`K_1` at genesis, `K_e` for a rotation).
284
319
  */
285
320
  export declare function openKeyEnvelope(input: GitvaultOpenKeyEnvelopeInput): Promise<Uint8Array>;
286
321
  export interface GitvaultBuildGenesisInput {
@@ -344,5 +379,143 @@ export declare function checkAllocation(allocation: GitvaultAllocation, expected
344
379
  org_id?: string;
345
380
  project_id?: string;
346
381
  }, servicePublicKey?: Uint8Array | string): string[];
382
+ /** 16-hex epochs compare/increment as unsigned integers (chain.ts's `nextGeneration`, mirrored). */
383
+ export declare function epochValue(hex16: string): bigint;
384
+ export declare function nextEpoch(hex16: string): string;
385
+ export interface GitvaultIncludedPair {
386
+ principal_id: string;
387
+ ek_fingerprint: string;
388
+ }
389
+ /**
390
+ * D196: `target_partition_digest = SHA-256(JCS({recipient_state_version,
391
+ * recipient_revocation_version, pin_manifest_version, pin_manifest_sha256,
392
+ * included: [sorted {principal_id, ek_fingerprint}], excluded_keyless_principal_ids:
393
+ * [sorted], excluded_unconfirmed_principal_ids: [sorted]}))`. The producer
394
+ * calls this ONCE to build the value it embeds in both the descriptor
395
+ * (D195) and the payload (D196); the gateway recomputes the SAME formula
396
+ * twice server-side and refuses on any disagreement — so a bug here is a
397
+ * `RECIPIENT_SET_MISMATCH` at admission time, not a silent forgery.
398
+ */
399
+ export declare function computeTargetPartitionDigest(input: {
400
+ recipient_state_version: string;
401
+ recipient_revocation_version: string;
402
+ pin_manifest_version: string;
403
+ pin_manifest_sha256: string;
404
+ included: readonly GitvaultIncludedPair[];
405
+ excluded_keyless_principal_ids: readonly string[];
406
+ excluded_unconfirmed_principal_ids: readonly string[];
407
+ }): string;
408
+ /**
409
+ * D195: `rotation_id = lowerhex(SHA-256(JCS(the complete descriptor object,
410
+ * MINUS signature)))` — the full 64-hex digest, computed over the descriptor
411
+ * INCLUDING `attempt_key_commitment` (a field ON the descriptor). Callers
412
+ * pass the SIGNED descriptor (or the unsigned one — the signature member is
413
+ * stripped either way, matching the gateway's `computeRotationId`).
414
+ */
415
+ export declare function computeRotationId(descriptor: Record<string, unknown> & {
416
+ signature?: unknown;
417
+ }): string;
418
+ /**
419
+ * D195's `attempt_key_commitment` preimage: the descriptor's OWN fields
420
+ * minus `attempt_key_commitment` itself (and minus `signature`, which does
421
+ * not exist yet at this point in the build) — `rotation_id` is never a
422
+ * member of the descriptor object at all (it is the object's derived path
423
+ * key), so there is nothing to additionally strip for it. Noncircular by
424
+ * construction: `attempt_key_commitment` must exist before `rotation_id`
425
+ * can be computed FROM the complete descriptor.
426
+ */
427
+ export declare function attemptKeyCommitmentPreimage(descriptorFields: {
428
+ format: GitvaultFormat;
429
+ object_kind: "rotation_attempt_descriptor";
430
+ suite: GitvaultSuite;
431
+ repo_id: string;
432
+ base_head_sha256: string;
433
+ new_epoch: string;
434
+ recipient_state_version: string;
435
+ recipient_revocation_version: string;
436
+ pin_manifest_sha256: string;
437
+ target_partition_digest: string;
438
+ client_idempotency_key: string;
439
+ writer_key_id: string;
440
+ }): Record<string, unknown>;
441
+ /**
442
+ * D195/§1's `"epoch_rotation_attempt"` commitment: `HMAC-SHA-256(K_digest(
443
+ * "epoch_rotation_attempt", repo_id, new_epoch), JCS(the descriptor's own
444
+ * fields minus attempt_key_commitment), ikm=K_e)` — keyed by the SAMPLED
445
+ * epoch key being distributed, not `K_repo` (D195/D200/§1: "every one keyed
446
+ * by the SAMPLED epoch key... since the value being committed IS the key
447
+ * being distributed"). `K_digest`'s own `epoch` parameter is `new_epoch`
448
+ * (this rotation's OWN epoch) — the natural, and only internally-consistent,
449
+ * reading of §1's generic formula for a value that is a property of the new
450
+ * epoch's key; there is no gateway-side computation of this value to cross-
451
+ * check against (the gateway never sees `K_e`), so this is the SDK's own
452
+ * considered wire-shape decision, stated here rather than guessed silently.
453
+ */
454
+ export declare function attemptKeyCommitment(kE: Uint8Array, repoId: string, newEpoch: string, descriptorFields: Parameters<typeof attemptKeyCommitmentPreimage>[0]): string;
455
+ /**
456
+ * D200/§1's `"epoch_rotation"` commitment: `HMAC-SHA-256(K_digest(
457
+ * "epoch_rotation", repo_id, new_epoch), JCS({rotation_id, fingerprints:
458
+ * [sorted pairwise-distinct]}), ikm=K_e)`. Proves a PER-RECIPIENT self-check
459
+ * only (D200's narrowed claim) — never global set-coherence. A recipient
460
+ * who opens their own envelope recovers `K_e` + `epoch` (== `new_epoch`)
461
+ * directly from the envelope itself, so they can recompute this independent
462
+ * of the descriptor/payload — confirming `new_epoch` is the right `K_digest`
463
+ * epoch parameter (the same value both the producer and every recipient
464
+ * arrive at without coordination).
465
+ */
466
+ export declare function epochRotationKeyCommitment(kE: Uint8Array, repoId: string, newEpoch: string, rotationId: string, fingerprints: readonly string[]): string;
467
+ /**
468
+ * D198's genesis-specific `"vault_genesis_epoch_key"` commitment — the same
469
+ * per-recipient-self-check discipline applied to an N-recipient genesis,
470
+ * with its own noncircular preimage (no `rotation_id` exists at generation
471
+ * zero). Not built by this SDK's genesis path today (single-recipient
472
+ * genesis only); exported for vector generation / future N-recipient
473
+ * genesis support.
474
+ */
475
+ export declare function genesisEpochKeyCommitment(k1: Uint8Array, repoId: string, fingerprints: readonly string[]): string;
476
+ /**
477
+ * D195's producer obligation the round-3 review's own decisive witness
478
+ * forces: "a producer that cannot prove it is resuming its OWN prior
479
+ * in-flight attempt... MUST mint a fresh `client_idempotency_key`... before
480
+ * uploading any envelope." The corollary — and what actually PREVENTS the
481
+ * complementary-path mosaic client-side, before the descriptor's create-only
482
+ * CAS even gets a chance to catch it server-side — is that a fresh K_e must
483
+ * never equal any epoch key this client has ever locally held (constant-time
484
+ * comparison; a match is evidence of a broken CSPRNG or a reused seed, not a
485
+ * legitimate resume, since a genuine resume reuses the SAME
486
+ * client_idempotency_key AND therefore builds the identical descriptor, not
487
+ * merely the same K_e in isolation).
488
+ */
489
+ export declare function checkFreshEpochKeyAgainstPriorKeys(kE: Uint8Array, priorKeys: Iterable<Uint8Array>): void;
490
+ export type GitvaultHPartitionVerdict = {
491
+ ok: true;
492
+ } | {
493
+ ok: false;
494
+ detail: string;
495
+ };
496
+ /**
497
+ * D196's pair-level bijection, mirrored client-side as a PRE-SUBMIT
498
+ * self-check (the gateway's own recomputation under its live desired-state
499
+ * lock remains the authoritative check — this exists so a client-side
500
+ * partition bug surfaces as a clear local error instead of a round trip
501
+ * that ends in `RECIPIENT_SET_MISMATCH`).
502
+ */
503
+ export declare function checkHPartition(input: {
504
+ desiredPrincipalIds: ReadonlySet<string>;
505
+ keyedPrincipalIds: ReadonlySet<string>;
506
+ pinnedFingerprintOf: ReadonlyMap<string, string>;
507
+ included: readonly GitvaultIncludedPair[];
508
+ excludedKeylessPrincipalIds: readonly string[];
509
+ excludedUnconfirmedPrincipalIds: readonly string[];
510
+ }): GitvaultHPartitionVerdict;
511
+ /** D197's full-map conservation rule: `next_map = prior_map + receipt-authorized additions/replacements`, deletion-by-omission forbidden. */
512
+ export declare function checkPinManifestConservation(prior: readonly {
513
+ principal_id: string;
514
+ }[], next: readonly {
515
+ principal_id: string;
516
+ }[]): GitvaultHPartitionVerdict;
517
+ /** The synthetic ledger id a path-addressed `key_envelope` gets — mirrors the gateway's `keyEnvelopeLedgerId` exactly (drift here breaks receipt pairing at upload finalize). */
518
+ export declare function keyEnvelopeLedgerId(epoch: string, fingerprint: string, rotationId: string | null): string;
519
+ export declare function pinManifestLedgerId(pinManifestVersion: string): string;
347
520
  export { bytesToHex, hexToBytes };
348
521
  //# sourceMappingURL=gitvault.crypto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gitvault.crypto.d.ts","sourceRoot":"","sources":["../../src/namespaces/gitvault.crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAQH,OAAO,EAAE,UAAU,EAAE,UAAU,EAA4B,MAAM,wBAAwB,CAAC;AAG1F,OAAO,EAAE,WAAW,EAAqC,MAAM,YAAY,CAAC;AAG5E,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAI7B,6EAA6E;AAC7E,eAAO,MAAM,eAAe,EAAG,UAAmB,CAAC;AACnD,sCAAsC;AACtC,eAAO,MAAM,cAAc,EAAG,SAAkB,CAAC;AACjD,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,E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GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,mBAAmB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,2BAA2B,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,+BAA+B,EAAE,SAAS,MAAM,EAAE,CAAC;CACpD,GAAG,yBAAyB,CAuC5B;AAED,6IAA6I;AAC7I,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,SAAS;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,IAAI,EAAE,SAAS;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,yBAAyB,CAW7J;AAED,iLAAiL;AACjL,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEzG;AAED,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
@@ -275,6 +275,15 @@ function withoutSignature(object) {
275
275
  void _signature;
276
276
  return rest;
277
277
  }
278
+ /**
279
+ * Exported so the rotation producer (D195) can build the SAME
280
+ * signature-stripped shape `rotation_id`'s own derivation needs
281
+ * (`sha256(JCS(descriptor minus signature))`) without reaching into this
282
+ * module's private helper twice under two different names.
283
+ */
284
+ export function gitvaultWithoutSignature(object) {
285
+ return withoutSignature(object);
286
+ }
278
287
  /** Signature preimage = `"r402s/v0/" + object_kind + "\n" + JCS(object without its single top-level signature)`. */
279
288
  export function signaturePreimage(objectKind, objectWithoutSignature) {
280
289
  if ("signature" in objectWithoutSignature) {
@@ -372,7 +381,17 @@ export function digestKeyInfo(repoId, epoch, label) {
372
381
  return concatBytes(lp(GITVAULT_FORMAT), lp(GITVAULT_SUITE), lp(repoId), lp(epoch), lp("digest"), lp(label), lp("L=32"));
373
382
  }
374
383
  export function deriveDigestKey(kRepo, repoId, epoch, label) {
375
- return hkdf(sha256, kRepo, undefined, digestKeyInfo(repoId, epoch, label), 32);
384
+ return deriveDigestKeyFrom(kRepo, repoId, epoch, label);
385
+ }
386
+ /**
387
+ * The general form `deriveDigestKey` is a fixed-`ikm=K_repo` specialization
388
+ * of (D195/D198/D200, rev 42): every rev-42 rotation label is keyed by the
389
+ * SAMPLED epoch key (`K_e` for a rotation, `K_1` for genesis) instead of
390
+ * `K_repo` — "the value being committed IS the key being distributed"
391
+ * (protocol-v0.md S1). Same HKDF info construction either way.
392
+ */
393
+ export function deriveDigestKeyFrom(ikm, repoId, epoch, label) {
394
+ return hkdf(sha256, ikm, undefined, digestKeyInfo(repoId, epoch, label), 32);
376
395
  }
377
396
  /** Commitment = HMAC-SHA-256(K_digest(label), JCS(content)), lowercase hex. */
378
397
  export function keyedCommitment(kDigest, content) {
@@ -485,8 +504,20 @@ function toArrayBuffer(bytes) {
485
504
  export function envelopeInfo(recipientPublicKeyRaw, createdBy) {
486
505
  return concatBytes(lp(GITVAULT_ENVELOPE_INFO_LABEL), lp(GITVAULT_SUITE), lp(sha256Hex(recipientPublicKeyRaw)), lp(createdBy));
487
506
  }
488
- /** HPKE AAD (D188): JCS of exactly `{repo_id, epoch, recipient_kind:"principal", recipient_fingerprint}`. */
489
- export function envelopeAad(repoId, epoch, recipientFingerprint) {
507
+ /**
508
+ * HPKE AAD (D188, discriminated by `rotation_id` presence — D203, rev 42):
509
+ * `rotation_id` ABSENT (genesis / ADD-workaround envelope) -> the rev-41
510
+ * four-field form, BYTE-IDENTICAL to every existing golden HPKE digest;
511
+ * `rotation_id` PRESENT (a rotation-attempt envelope) -> the new five-field
512
+ * form. Field ORDER in the returned object does not matter (JCS sorts
513
+ * object members), but `rotation_id` must never be included as an explicit
514
+ * `null` — the two shapes are genuinely different objects, not one object
515
+ * with an optional-null member (protocol-v0.md S2).
516
+ */
517
+ export function envelopeAad(repoId, epoch, recipientFingerprint, rotationId) {
518
+ if (rotationId) {
519
+ return { repo_id: repoId, epoch, rotation_id: rotationId, recipient_kind: "principal", recipient_fingerprint: recipientFingerprint };
520
+ }
490
521
  return { repo_id: repoId, epoch, recipient_kind: "principal", recipient_fingerprint: recipientFingerprint };
491
522
  }
492
523
  /** Single-shot HPKE seal (Base mode) returning `{enc, ct}`. */
@@ -518,10 +549,11 @@ export async function sealKeyEnvelope(input) {
518
549
  fail("GITVAULT_BAD_TIMESTAMP", "created_at is not an RFC 3339 UTC ms timestamp", "sealing r402s/v0 key envelope");
519
550
  const createdBy = vkFingerprint(input.signer.public_key);
520
551
  const recipientFingerprint = ekFingerprint(input.recipient_public_key);
552
+ const rotationId = input.rotation_id ?? null;
521
553
  const { enc, ct } = await hpkeSeal({
522
554
  recipient_public_key: input.recipient_public_key,
523
555
  info: envelopeInfo(input.recipient_public_key, createdBy),
524
- aad: jcs(envelopeAad(input.repo_id, input.epoch, recipientFingerprint)),
556
+ aad: jcs(envelopeAad(input.repo_id, input.epoch, recipientFingerprint, rotationId)),
525
557
  plaintext: input.k_repo,
526
558
  ikm_e: input.ikm_e,
527
559
  });
@@ -537,6 +569,7 @@ export async function sealKeyEnvelope(input) {
537
569
  ct: toBase64url(ct),
538
570
  created_by: createdBy,
539
571
  created_at: input.created_at,
572
+ ...(rotationId ? { rotation_id: rotationId } : {}),
540
573
  };
541
574
  const envelope = signGitvaultObject(unsigned, input.signer.seed);
542
575
  const bytes = storedBytes(envelope);
@@ -546,13 +579,22 @@ export async function sealKeyEnvelope(input) {
546
579
  stored_bytes: bytes,
547
580
  stored_bytes_sha256: hash,
548
581
  size_bytes: String(bytes.length),
549
- receipt: { object_kind: "key_envelope", epoch: input.epoch, recipient_fingerprint: recipientFingerprint, stored_bytes_sha256: hash, size_bytes: String(bytes.length) },
582
+ receipt: {
583
+ object_kind: "key_envelope",
584
+ epoch: input.epoch,
585
+ recipient_fingerprint: recipientFingerprint,
586
+ stored_bytes_sha256: hash,
587
+ size_bytes: String(bytes.length),
588
+ ...(rotationId ? { rotation_id: rotationId } : {}),
589
+ },
550
590
  };
551
591
  }
552
592
  /**
553
593
  * Open a `key_envelope`: exact-scalar checks → signature (strict, domain
554
594
  * `key_envelope`) → path identity (recipient fingerprint = ours) → HPKE open
555
- * with the D188 info/AAD. Returns the raw 32-byte K_repo.
595
+ * with the D188 info/AAD (widened to the five-field form when the envelope
596
+ * itself carries `rotation_id` — D195/D203). Returns the raw 32-byte secret
597
+ * (`K_repo`/`K_1` at genesis, `K_e` for a rotation).
556
598
  */
557
599
  export async function openKeyEnvelope(input) {
558
600
  const env = input.envelope;
@@ -568,7 +610,7 @@ export async function openKeyEnvelope(input) {
568
610
  recipient_private_key: input.recipient.private_key,
569
611
  enc: fromBase64url(env.enc, "enc"),
570
612
  info: envelopeInfo(input.recipient.public_key, env.created_by),
571
- aad: jcs(envelopeAad(env.repo_id, env.epoch, env.recipient_fingerprint)),
613
+ aad: jcs(envelopeAad(env.repo_id, env.epoch, env.recipient_fingerprint, env.rotation_id ?? null)),
572
614
  ct: fromBase64url(env.ct, "ct"),
573
615
  });
574
616
  if (kRepo.length !== 32)
@@ -715,5 +757,222 @@ export function checkAllocation(allocation, expected, servicePublicKey) {
715
757
  problems.push("signature");
716
758
  return problems;
717
759
  }
760
+ // ─── Epoch rotation (D193-D203, rev 42, change gitvault-human-envelopes) ───
761
+ //
762
+ // Pure, isomorphic math shared by the producer (Node-only, gitvault-
763
+ // publication.ts's `rotateEpoch`, which has the live desired-recipient
764
+ // state + local keystore this module cannot see) and by vector generation.
765
+ // Every formula here MIRRORS the gateway's own pure functions in
766
+ // `packages/gateway/src/services/gitvault/epoch-rotation.ts` byte-for-byte
767
+ // (same field order is irrelevant — JCS sorts — but the SAME field SET and
768
+ // the SAME preimage construction is load-bearing: a drift here would build
769
+ // a descriptor/payload the gateway's own re-derivation refuses).
770
+ /** 16-hex epochs compare/increment as unsigned integers (chain.ts's `nextGeneration`, mirrored). */
771
+ export function epochValue(hex16) {
772
+ return BigInt("0x" + hex16);
773
+ }
774
+ export function nextEpoch(hex16) {
775
+ return (epochValue(hex16) + 1n).toString(16).padStart(16, "0");
776
+ }
777
+ function sortedDistinct(xs) {
778
+ return [...new Set(xs)].sort();
779
+ }
780
+ /**
781
+ * D196: `target_partition_digest = SHA-256(JCS({recipient_state_version,
782
+ * recipient_revocation_version, pin_manifest_version, pin_manifest_sha256,
783
+ * included: [sorted {principal_id, ek_fingerprint}], excluded_keyless_principal_ids:
784
+ * [sorted], excluded_unconfirmed_principal_ids: [sorted]}))`. The producer
785
+ * calls this ONCE to build the value it embeds in both the descriptor
786
+ * (D195) and the payload (D196); the gateway recomputes the SAME formula
787
+ * twice server-side and refuses on any disagreement — so a bug here is a
788
+ * `RECIPIENT_SET_MISMATCH` at admission time, not a silent forgery.
789
+ */
790
+ export function computeTargetPartitionDigest(input) {
791
+ const includedSorted = [...input.included].sort((a, b) => (a.principal_id < b.principal_id ? -1 : a.principal_id > b.principal_id ? 1 : 0));
792
+ const body = {
793
+ recipient_state_version: input.recipient_state_version,
794
+ recipient_revocation_version: input.recipient_revocation_version,
795
+ pin_manifest_version: input.pin_manifest_version,
796
+ pin_manifest_sha256: input.pin_manifest_sha256,
797
+ included: includedSorted.map((p) => ({ principal_id: p.principal_id, ek_fingerprint: p.ek_fingerprint })),
798
+ excluded_keyless_principal_ids: sortedDistinct(input.excluded_keyless_principal_ids),
799
+ excluded_unconfirmed_principal_ids: sortedDistinct(input.excluded_unconfirmed_principal_ids),
800
+ };
801
+ return sha256Hex(jcs(body));
802
+ }
803
+ /**
804
+ * D195: `rotation_id = lowerhex(SHA-256(JCS(the complete descriptor object,
805
+ * MINUS signature)))` — the full 64-hex digest, computed over the descriptor
806
+ * INCLUDING `attempt_key_commitment` (a field ON the descriptor). Callers
807
+ * pass the SIGNED descriptor (or the unsigned one — the signature member is
808
+ * stripped either way, matching the gateway's `computeRotationId`).
809
+ */
810
+ export function computeRotationId(descriptor) {
811
+ return sha256Hex(jcs(gitvaultWithoutSignature(descriptor)));
812
+ }
813
+ /**
814
+ * D195's `attempt_key_commitment` preimage: the descriptor's OWN fields
815
+ * minus `attempt_key_commitment` itself (and minus `signature`, which does
816
+ * not exist yet at this point in the build) — `rotation_id` is never a
817
+ * member of the descriptor object at all (it is the object's derived path
818
+ * key), so there is nothing to additionally strip for it. Noncircular by
819
+ * construction: `attempt_key_commitment` must exist before `rotation_id`
820
+ * can be computed FROM the complete descriptor.
821
+ */
822
+ export function attemptKeyCommitmentPreimage(descriptorFields) {
823
+ return { ...descriptorFields };
824
+ }
825
+ /**
826
+ * D195/§1's `"epoch_rotation_attempt"` commitment: `HMAC-SHA-256(K_digest(
827
+ * "epoch_rotation_attempt", repo_id, new_epoch), JCS(the descriptor's own
828
+ * fields minus attempt_key_commitment), ikm=K_e)` — keyed by the SAMPLED
829
+ * epoch key being distributed, not `K_repo` (D195/D200/§1: "every one keyed
830
+ * by the SAMPLED epoch key... since the value being committed IS the key
831
+ * being distributed"). `K_digest`'s own `epoch` parameter is `new_epoch`
832
+ * (this rotation's OWN epoch) — the natural, and only internally-consistent,
833
+ * reading of §1's generic formula for a value that is a property of the new
834
+ * epoch's key; there is no gateway-side computation of this value to cross-
835
+ * check against (the gateway never sees `K_e`), so this is the SDK's own
836
+ * considered wire-shape decision, stated here rather than guessed silently.
837
+ */
838
+ export function attemptKeyCommitment(kE, repoId, newEpoch, descriptorFields) {
839
+ const kDigest = deriveDigestKeyFrom(kE, repoId, newEpoch, "epoch_rotation_attempt");
840
+ return keyedCommitment(kDigest, attemptKeyCommitmentPreimage(descriptorFields));
841
+ }
842
+ /**
843
+ * D200/§1's `"epoch_rotation"` commitment: `HMAC-SHA-256(K_digest(
844
+ * "epoch_rotation", repo_id, new_epoch), JCS({rotation_id, fingerprints:
845
+ * [sorted pairwise-distinct]}), ikm=K_e)`. Proves a PER-RECIPIENT self-check
846
+ * only (D200's narrowed claim) — never global set-coherence. A recipient
847
+ * who opens their own envelope recovers `K_e` + `epoch` (== `new_epoch`)
848
+ * directly from the envelope itself, so they can recompute this independent
849
+ * of the descriptor/payload — confirming `new_epoch` is the right `K_digest`
850
+ * epoch parameter (the same value both the producer and every recipient
851
+ * arrive at without coordination).
852
+ */
853
+ export function epochRotationKeyCommitment(kE, repoId, newEpoch, rotationId, fingerprints) {
854
+ const kDigest = deriveDigestKeyFrom(kE, repoId, newEpoch, "epoch_rotation");
855
+ return keyedCommitment(kDigest, { rotation_id: rotationId, fingerprints: sortedDistinct(fingerprints) });
856
+ }
857
+ /**
858
+ * D198's genesis-specific `"vault_genesis_epoch_key"` commitment — the same
859
+ * per-recipient-self-check discipline applied to an N-recipient genesis,
860
+ * with its own noncircular preimage (no `rotation_id` exists at generation
861
+ * zero). Not built by this SDK's genesis path today (single-recipient
862
+ * genesis only); exported for vector generation / future N-recipient
863
+ * genesis support.
864
+ */
865
+ export function genesisEpochKeyCommitment(k1, repoId, fingerprints) {
866
+ const kDigest = deriveDigestKeyFrom(k1, repoId, GITVAULT_GENESIS_EPOCH, "vault_genesis_epoch_key");
867
+ return keyedCommitment(kDigest, { repo_id: repoId, generation: GITVAULT_GENESIS_GENERATION, epoch: GITVAULT_GENESIS_EPOCH, fingerprints: sortedDistinct(fingerprints) });
868
+ }
869
+ /**
870
+ * D195's producer obligation the round-3 review's own decisive witness
871
+ * forces: "a producer that cannot prove it is resuming its OWN prior
872
+ * in-flight attempt... MUST mint a fresh `client_idempotency_key`... before
873
+ * uploading any envelope." The corollary — and what actually PREVENTS the
874
+ * complementary-path mosaic client-side, before the descriptor's create-only
875
+ * CAS even gets a chance to catch it server-side — is that a fresh K_e must
876
+ * never equal any epoch key this client has ever locally held (constant-time
877
+ * comparison; a match is evidence of a broken CSPRNG or a reused seed, not a
878
+ * legitimate resume, since a genuine resume reuses the SAME
879
+ * client_idempotency_key AND therefore builds the identical descriptor, not
880
+ * merely the same K_e in isolation).
881
+ */
882
+ export function checkFreshEpochKeyAgainstPriorKeys(kE, priorKeys) {
883
+ if (kE.length !== 32)
884
+ fail("GITVAULT_BAD_KEY", "a freshly sampled K_e must be 32 bytes", "sampling a fresh epoch key");
885
+ const fresh = bytesToHex(kE);
886
+ for (const prior of priorKeys) {
887
+ if (bytesToHex(prior) === fresh) {
888
+ fail("GITVAULT_EPOCH_KEY_NOT_FRESH", "the freshly sampled K_e equals a prior epoch key already held locally — refusing to seal under it", "sampling a fresh epoch key");
889
+ }
890
+ }
891
+ }
892
+ /**
893
+ * D196's pair-level bijection, mirrored client-side as a PRE-SUBMIT
894
+ * self-check (the gateway's own recomputation under its live desired-state
895
+ * lock remains the authoritative check — this exists so a client-side
896
+ * partition bug surfaces as a clear local error instead of a round trip
897
+ * that ends in `RECIPIENT_SET_MISMATCH`).
898
+ */
899
+ export function checkHPartition(input) {
900
+ const includedIds = input.included.map((p) => p.principal_id);
901
+ const includedFps = input.included.map((p) => p.ek_fingerprint);
902
+ if (new Set(includedIds).size !== includedIds.length)
903
+ return { ok: false, detail: "envelopes[].principal_id are not pairwise-distinct" };
904
+ if (new Set(includedFps).size !== includedFps.length)
905
+ return { ok: false, detail: "envelopes[].envelope.recipient_fingerprint are not pairwise-distinct" };
906
+ if (new Set(input.excludedKeylessPrincipalIds).size !== input.excludedKeylessPrincipalIds.length)
907
+ return { ok: false, detail: "excluded_keyless_principal_ids are not pairwise-distinct" };
908
+ if (new Set(input.excludedUnconfirmedPrincipalIds).size !== input.excludedUnconfirmedPrincipalIds.length)
909
+ return { ok: false, detail: "excluded_unconfirmed_principal_ids are not pairwise-distinct" };
910
+ const partition = new Map();
911
+ for (const id of includedIds) {
912
+ if (partition.has(id))
913
+ return { ok: false, detail: `principal ${id} appears more than once across the partition` };
914
+ partition.set(id, "included");
915
+ }
916
+ for (const id of input.excludedKeylessPrincipalIds) {
917
+ if (partition.has(id))
918
+ return { ok: false, detail: `principal ${id} appears more than once across the partition` };
919
+ partition.set(id, "keyless");
920
+ }
921
+ for (const id of input.excludedUnconfirmedPrincipalIds) {
922
+ if (partition.has(id))
923
+ return { ok: false, detail: `principal ${id} appears more than once across the partition` };
924
+ partition.set(id, "unconfirmed");
925
+ }
926
+ if (partition.size !== input.desiredPrincipalIds.size)
927
+ return { ok: false, detail: `partition covers ${partition.size} principals; H has ${input.desiredPrincipalIds.size}` };
928
+ for (const id of partition.keys())
929
+ if (!input.desiredPrincipalIds.has(id))
930
+ return { ok: false, detail: `principal ${id} is not in the current desired-recipient set H` };
931
+ for (const id of input.desiredPrincipalIds)
932
+ if (!partition.has(id))
933
+ return { ok: false, detail: `principal ${id} in H is named by neither envelopes[] nor either exclusion array` };
934
+ for (const pair of input.included) {
935
+ if (!input.keyedPrincipalIds.has(pair.principal_id))
936
+ return { ok: false, detail: `included principal ${pair.principal_id} has no enrolled key` };
937
+ const pinned = input.pinnedFingerprintOf.get(pair.principal_id);
938
+ if (pinned === undefined)
939
+ return { ok: false, detail: `included principal ${pair.principal_id} has no live pin-manifest entry` };
940
+ if (pinned !== pair.ek_fingerprint)
941
+ return { ok: false, detail: `included principal ${pair.principal_id}'s envelope fingerprint does not match the effective pin manifest's binding` };
942
+ }
943
+ for (const id of input.excludedKeylessPrincipalIds) {
944
+ if (input.keyedPrincipalIds.has(id))
945
+ return { ok: false, detail: `excluded-keyless principal ${id} actually has an enrolled key` };
946
+ }
947
+ for (const id of input.excludedUnconfirmedPrincipalIds) {
948
+ if (!input.keyedPrincipalIds.has(id))
949
+ return { ok: false, detail: `excluded-unconfirmed principal ${id} is keyless, not unconfirmed` };
950
+ if (input.pinnedFingerprintOf.has(id))
951
+ return { ok: false, detail: `excluded-unconfirmed principal ${id} actually has a live pin-manifest entry` };
952
+ }
953
+ return { ok: true };
954
+ }
955
+ /** D197's full-map conservation rule: `next_map = prior_map + receipt-authorized additions/replacements`, deletion-by-omission forbidden. */
956
+ export function checkPinManifestConservation(prior, next) {
957
+ const nextIds = new Set(next.map((p) => p.principal_id));
958
+ for (const p of prior) {
959
+ if (!nextIds.has(p.principal_id))
960
+ return { ok: false, detail: `principal ${p.principal_id} present in the predecessor manifest is missing from the successor — deletion by omission is forbidden in V0` };
961
+ }
962
+ const seen = new Set();
963
+ for (const p of next) {
964
+ if (seen.has(p.principal_id))
965
+ return { ok: false, detail: `principal ${p.principal_id} appears more than once in the manifest` };
966
+ seen.add(p.principal_id);
967
+ }
968
+ return { ok: true };
969
+ }
970
+ /** The synthetic ledger id a path-addressed `key_envelope` gets — mirrors the gateway's `keyEnvelopeLedgerId` exactly (drift here breaks receipt pairing at upload finalize). */
971
+ export function keyEnvelopeLedgerId(epoch, fingerprint, rotationId) {
972
+ return rotationId ? `key_envelope:${epoch}:${rotationId}:${fingerprint}` : `key_envelope:${epoch}:${fingerprint}`;
973
+ }
974
+ export function pinManifestLedgerId(pinManifestVersion) {
975
+ return `recipient_pin_manifest:${pinManifestVersion}`;
976
+ }
718
977
  export { bytesToHex, hexToBytes };
719
978
  //# sourceMappingURL=gitvault.crypto.js.map