burnledger 0.8.1 → 0.9.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 (124) hide show
  1. package/README.md +139 -2
  2. package/dist/cjs/anchor.d.ts +5 -3
  3. package/dist/cjs/anchor.d.ts.map +1 -1
  4. package/dist/cjs/anchor.js +10 -4
  5. package/dist/cjs/anchor.js.map +1 -1
  6. package/dist/cjs/client.d.ts +95 -0
  7. package/dist/cjs/client.d.ts.map +1 -1
  8. package/dist/cjs/client.js +133 -2
  9. package/dist/cjs/client.js.map +1 -1
  10. package/dist/cjs/customer-keys.d.ts +73 -1
  11. package/dist/cjs/customer-keys.d.ts.map +1 -1
  12. package/dist/cjs/customer-keys.js +329 -3
  13. package/dist/cjs/customer-keys.js.map +1 -1
  14. package/dist/cjs/enclave-registration.d.ts +153 -0
  15. package/dist/cjs/enclave-registration.d.ts.map +1 -0
  16. package/dist/cjs/enclave-registration.js +275 -0
  17. package/dist/cjs/enclave-registration.js.map +1 -0
  18. package/dist/cjs/enclave-seal.d.ts +43 -0
  19. package/dist/cjs/enclave-seal.d.ts.map +1 -1
  20. package/dist/cjs/enclave-seal.js +62 -1
  21. package/dist/cjs/enclave-seal.js.map +1 -1
  22. package/dist/cjs/errors.d.ts +10 -0
  23. package/dist/cjs/errors.d.ts.map +1 -1
  24. package/dist/cjs/errors.js +11 -1
  25. package/dist/cjs/errors.js.map +1 -1
  26. package/dist/cjs/index.browser.d.ts +7 -3
  27. package/dist/cjs/index.browser.d.ts.map +1 -1
  28. package/dist/cjs/index.browser.js +6 -3
  29. package/dist/cjs/index.browser.js.map +1 -1
  30. package/dist/cjs/index.d.ts +22 -10
  31. package/dist/cjs/index.d.ts.map +1 -1
  32. package/dist/cjs/index.js +30 -6
  33. package/dist/cjs/index.js.map +1 -1
  34. package/dist/cjs/key-group.d.ts +80 -0
  35. package/dist/cjs/key-group.d.ts.map +1 -0
  36. package/dist/cjs/key-group.js +136 -0
  37. package/dist/cjs/key-group.js.map +1 -0
  38. package/dist/cjs/models.d.ts +60 -0
  39. package/dist/cjs/models.d.ts.map +1 -1
  40. package/dist/cjs/models.js +63 -0
  41. package/dist/cjs/models.js.map +1 -1
  42. package/dist/cjs/status-document.d.ts +25 -0
  43. package/dist/cjs/status-document.d.ts.map +1 -0
  44. package/dist/cjs/status-document.js +62 -0
  45. package/dist/cjs/status-document.js.map +1 -0
  46. package/dist/cjs/verify.d.ts +108 -3
  47. package/dist/cjs/verify.d.ts.map +1 -1
  48. package/dist/cjs/verify.js +389 -146
  49. package/dist/cjs/verify.js.map +1 -1
  50. package/dist/cjs/web-verifier.d.ts +23 -3
  51. package/dist/cjs/web-verifier.d.ts.map +1 -1
  52. package/dist/cjs/web-verifier.js +31 -5
  53. package/dist/cjs/web-verifier.js.map +1 -1
  54. package/dist/esm/anchor.d.ts +5 -3
  55. package/dist/esm/anchor.d.ts.map +1 -1
  56. package/dist/esm/anchor.js +10 -4
  57. package/dist/esm/anchor.js.map +1 -1
  58. package/dist/esm/cli.d.ts +13 -19
  59. package/dist/esm/cli.d.ts.map +1 -1
  60. package/dist/esm/cli.js +88 -81
  61. package/dist/esm/cli.js.map +1 -1
  62. package/dist/esm/client.d.ts +95 -0
  63. package/dist/esm/client.d.ts.map +1 -1
  64. package/dist/esm/client.js +133 -2
  65. package/dist/esm/client.js.map +1 -1
  66. package/dist/esm/customer-keys.d.ts +73 -1
  67. package/dist/esm/customer-keys.d.ts.map +1 -1
  68. package/dist/esm/customer-keys.js +323 -3
  69. package/dist/esm/customer-keys.js.map +1 -1
  70. package/dist/esm/enclave-registration.d.ts +153 -0
  71. package/dist/esm/enclave-registration.d.ts.map +1 -0
  72. package/dist/esm/enclave-registration.js +265 -0
  73. package/dist/esm/enclave-registration.js.map +1 -0
  74. package/dist/esm/enclave-seal.d.ts +43 -0
  75. package/dist/esm/enclave-seal.d.ts.map +1 -1
  76. package/dist/esm/enclave-seal.js +61 -1
  77. package/dist/esm/enclave-seal.js.map +1 -1
  78. package/dist/esm/errors.d.ts +10 -0
  79. package/dist/esm/errors.d.ts.map +1 -1
  80. package/dist/esm/errors.js +10 -0
  81. package/dist/esm/errors.js.map +1 -1
  82. package/dist/esm/index.browser.d.ts +7 -3
  83. package/dist/esm/index.browser.d.ts.map +1 -1
  84. package/dist/esm/index.browser.js +6 -3
  85. package/dist/esm/index.browser.js.map +1 -1
  86. package/dist/esm/index.d.ts +22 -10
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +18 -8
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/key-group.d.ts +80 -0
  91. package/dist/esm/key-group.d.ts.map +1 -0
  92. package/dist/esm/key-group.js +130 -0
  93. package/dist/esm/key-group.js.map +1 -0
  94. package/dist/esm/models.d.ts +60 -0
  95. package/dist/esm/models.d.ts.map +1 -1
  96. package/dist/esm/models.js +59 -0
  97. package/dist/esm/models.js.map +1 -1
  98. package/dist/esm/status-document.d.ts +25 -0
  99. package/dist/esm/status-document.d.ts.map +1 -0
  100. package/dist/esm/status-document.js +59 -0
  101. package/dist/esm/status-document.js.map +1 -0
  102. package/dist/esm/verify.d.ts +108 -3
  103. package/dist/esm/verify.d.ts.map +1 -1
  104. package/dist/esm/verify.js +386 -146
  105. package/dist/esm/verify.js.map +1 -1
  106. package/dist/esm/web-verifier.d.ts +23 -3
  107. package/dist/esm/web-verifier.d.ts.map +1 -1
  108. package/dist/esm/web-verifier.js +27 -5
  109. package/dist/esm/web-verifier.js.map +1 -1
  110. package/package.json +1 -1
  111. package/src/anchor.ts +10 -4
  112. package/src/cli.ts +96 -79
  113. package/src/client.ts +198 -6
  114. package/src/customer-keys.ts +373 -3
  115. package/src/enclave-registration.ts +390 -0
  116. package/src/enclave-seal.ts +108 -1
  117. package/src/errors.ts +11 -0
  118. package/src/index.browser.ts +9 -3
  119. package/src/index.ts +35 -6
  120. package/src/key-group.ts +181 -0
  121. package/src/models.ts +131 -0
  122. package/src/status-document.ts +59 -0
  123. package/src/verify.ts +499 -151
  124. package/src/web-verifier.ts +36 -3
@@ -17,7 +17,8 @@
17
17
  * expectation in tests/customer-key-parity.test.ts comes from a corpus the Go
18
18
  * generator writes by calling core itself.
19
19
  */
20
- import { canonicalJson } from "./verify.js";
20
+ import { canonicalJson, formatTimestamp } from "./verify.js";
21
+ import { VerificationError } from "./errors.js";
21
22
  /**
22
23
  * Mirrors core.CustomerKeyIDPrefix. It distinguishes a customer's key id from
23
24
  * an issuer key id, which are otherwise the same shape and would be confusable
@@ -30,7 +31,11 @@ export const CUSTOMER_KEY_ID_PREFIX = "cust_k_";
30
31
  * reimplementation that omits it computes a different id for every group.
31
32
  */
32
33
  const PAYLOAD_TYPE_CUSTOMER_KEY_GROUP = "burnledger.customer_key_group.v1";
33
- export const PAYLOAD_TYPE_KEY_ROTATION_REQUEST = "burnledger.key_rotation_request.v1";
34
+ /**
35
+ * Mirrors core.PayloadTypeKeyRotationRequest. v2 carries not_after, which bounds
36
+ * the request itself; a protocol-12 enclave refuses v1.
37
+ */
38
+ export const PAYLOAD_TYPE_KEY_ROTATION_REQUEST = "burnledger.key_rotation_request.v2";
34
39
  /** Mirrors core.MaxCustomerKeyGroupMembers. */
35
40
  export const MAX_CUSTOMER_KEY_GROUP_MEMBERS = 16;
36
41
  const ED25519_PUBLIC_KEY_SIZE = 32;
@@ -67,6 +72,13 @@ export async function validateKeyGroup(crypto, group) {
67
72
  if (member.length !== ED25519_PUBLIC_KEY_SIZE) {
68
73
  throw new InvalidKeyGroupError(`every member must be a ${ED25519_PUBLIC_KEY_SIZE}-byte Ed25519 key`);
69
74
  }
75
+ if (!isNotSmallOrder(member)) {
76
+ // A small-order key is held by nobody: with the identity point as the
77
+ // public key, R = identity and S = 0 verify over ANY message, so it
78
+ // would pass proof of possession and count toward a threshold for free.
79
+ throw new InvalidKeyGroupError("every member must be an Ed25519 public key on the curve and not of small order " +
80
+ "(small-order and off-curve keys are refused)");
81
+ }
70
82
  const fingerprint = await memberFingerprint(crypto, member);
71
83
  if (seen.has(fingerprint)) {
72
84
  // A repeated member would let one holder satisfy a threshold meant to
@@ -100,6 +112,16 @@ export async function customerKeyId(crypto, group) {
100
112
  };
101
113
  return CUSTOMER_KEY_ID_PREFIX + toHex(await crypto.sha256(canonicalJson(document)));
102
114
  }
115
+ /**
116
+ * A request's `not_after` as Go signs it (core.KeyTimeFormat): UTC, whole
117
+ * seconds, the fraction truncated as Go's Format truncates it.
118
+ */
119
+ export function keyTime(value) {
120
+ if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
121
+ throw new Error("not_after is required");
122
+ }
123
+ return value.toISOString().slice(0, 19) + "Z";
124
+ }
103
125
  /**
104
126
  * The canonical bytes the OUTGOING group's members sign to authorise a rotation.
105
127
  *
@@ -115,16 +137,314 @@ export function buildKeyRotationRequestPayload(request) {
115
137
  if (!request.prevKeyId || !request.nextKeyId) {
116
138
  throw new Error("a rotation request names both the key being replaced and its replacement");
117
139
  }
140
+ if (!(request.notAfter instanceof Date) || Number.isNaN(request.notAfter.getTime())) {
141
+ throw new Error("not_after is required");
142
+ }
118
143
  if (request.prevKeyId === request.nextKeyId) {
119
144
  // A self-rotation is a cycle in the chain the enclave walks, and it walks
120
145
  // without a visited set.
121
146
  throw new Error("a rotation request cannot name the same key as both predecessor and successor");
122
147
  }
123
148
  return canonicalJson({
124
- asserted_team_id: request.assertedTeamId,
149
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
125
150
  next_key_id: request.nextKeyId,
151
+ not_after: keyTime(request.notAfter),
126
152
  payload_type: PAYLOAD_TYPE_KEY_ROTATION_REQUEST,
127
153
  prev_key_id: request.prevKeyId,
128
154
  });
129
155
  }
156
+ // Ed25519 arithmetic for one question only: is a member key a curve point
157
+ // outside the small-order subgroup? It mirrors the decoding Go's
158
+ // filippo.io/edwards25519 performs in core.CustomerKeyGroup.Validate, so both
159
+ // sides refuse exactly the same keys: bit 255 of y is ignored and y is reduced
160
+ // mod p (non-canonical encodings are accepted), a y with no matching x is
161
+ // refused, and the sign bit selects the negative root even when x = 0.
162
+ const FIELD_P = 2n ** 255n - 19n;
163
+ const fieldMod = (a) => ((a % FIELD_P) + FIELD_P) % FIELD_P;
164
+ function fieldPow(base, exp) {
165
+ let result = 1n;
166
+ let b = fieldMod(base);
167
+ for (let e = exp; e > 0n; e >>= 1n) {
168
+ if (e & 1n)
169
+ result = (result * b) % FIELD_P;
170
+ b = (b * b) % FIELD_P;
171
+ }
172
+ return result;
173
+ }
174
+ const fieldInv = (a) => fieldPow(a, FIELD_P - 2n);
175
+ const CURVE_D = fieldMod(-121665n * fieldInv(121666n));
176
+ const SQRT_MINUS_ONE = fieldPow(2n, (FIELD_P - 1n) / 4n);
177
+ function decodePoint(bytes) {
178
+ // validateKeyGroup has already required exactly 32 bytes.
179
+ const top = bytes[31] ?? 0;
180
+ let y = 0n;
181
+ for (let i = 31; i >= 0; i--) {
182
+ y = (y << 8n) | BigInt(i === 31 ? top & 0x7f : (bytes[i] ?? 0));
183
+ }
184
+ y = fieldMod(y);
185
+ const u = fieldMod(y * y - 1n);
186
+ const v = fieldMod(CURVE_D * y * y + 1n);
187
+ let x = fieldMod(u * fieldPow(v, 3n) * fieldPow(u * fieldPow(v, 7n), (FIELD_P - 5n) / 8n));
188
+ const vx2 = fieldMod(v * x * x);
189
+ if (vx2 === fieldMod(-u)) {
190
+ x = fieldMod(x * SQRT_MINUS_ONE);
191
+ }
192
+ else if (vx2 !== u) {
193
+ return null;
194
+ }
195
+ if (Number(x & 1n) !== top >> 7)
196
+ x = fieldMod(-x);
197
+ return [x, y];
198
+ }
199
+ // The complete twisted-Edwards addition law (a = -1); its denominators are
200
+ // never zero because d is not a square.
201
+ function addPoints(p, q) {
202
+ const t = fieldMod(CURVE_D * p[0] * q[0] * p[1] * q[1]);
203
+ return [
204
+ fieldMod((p[0] * q[1] + p[1] * q[0]) * fieldInv(1n + t)),
205
+ fieldMod((p[1] * q[1] + p[0] * q[0]) * fieldInv(fieldMod(1n - t))),
206
+ ];
207
+ }
208
+ /**
209
+ * Whether key decodes to a curve point that is not of small order (8·P ≠ identity).
210
+ * Not a prime-order check: a mixed-order key passes, as it does in Go.
211
+ */
212
+ function isNotSmallOrder(key) {
213
+ let point = decodePoint(key);
214
+ if (point === null)
215
+ return false;
216
+ for (let i = 0; i < 3; i++)
217
+ point = addPoints(point, point);
218
+ return !(point[0] === 0n && point[1] === 1n);
219
+ }
220
+ /** Mirrors core.PayloadTypeKeyEnrollmentRequest. */
221
+ export const PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST = "burnledger.key_enrollment_request.v1";
222
+ /** Mirrors core.PayloadTypeSystemRegistrationRequest. */
223
+ export const PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST = "burnledger.system_registration_request.v1";
224
+ const UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
225
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
226
+ /**
227
+ * A UUID in the one form Go prints it (uuid.UUID.String()): lowercase and
228
+ * hyphenated. The enclave rebuilds every customer-signed payload from the
229
+ * uuid.UUID it parsed, so a team id signed as the caller happened to type it —
230
+ * uppercase, say — would be different bytes, and the refusal would be a 401 with
231
+ * nothing in it to say why.
232
+ */
233
+ function canonicalUuid(value, field) {
234
+ if (typeof value !== "string" || !UUID_RE.test(value)) {
235
+ throw new Error(`${field} must be a UUID, got ${JSON.stringify(value)}`);
236
+ }
237
+ return value.toLowerCase();
238
+ }
239
+ function requireSha256(value, field) {
240
+ if (!(value instanceof Uint8Array) || value.length !== 32) {
241
+ throw new Error(`${field} must be a 32-byte SHA-256 digest`);
242
+ }
243
+ return toHex(value);
244
+ }
245
+ /**
246
+ * The canonical bytes EVERY member of a group signs to enrol it for a team.
247
+ *
248
+ * Port of core.BuildKeyEnrollmentRequestPayload. Without these signatures
249
+ * whoever relays the request could enrol public keys it does not hold — the
250
+ * customer's included — so the enclave demands one from each member, not a
251
+ * threshold: the statement it signs vouches for every key. `notAfter` is the
252
+ * latest the resulting authorization may end, and when the request itself stops
253
+ * being usable: the enclave cannot recognize a replay, so this is what keeps a
254
+ * relayed copy from renewing the window.
255
+ */
256
+ export function buildKeyEnrollmentRequestPayload(request) {
257
+ if (!request.customerKeyId)
258
+ throw new Error("customer_key_id is required");
259
+ return canonicalJson({
260
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
261
+ customer_key_id: request.customerKeyId,
262
+ not_after: keyTime(request.notAfter),
263
+ payload_type: PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST,
264
+ });
265
+ }
266
+ /**
267
+ * The canonical bytes an enrolled group signs, at its threshold, to register one
268
+ * system under it.
269
+ *
270
+ * Port of core.BuildSystemRegistrationRequestPayload. Both digests are over bytes
271
+ * the CUSTOMER holds: `configDigest` is SHA-256 of the exact config bytes
272
+ * submitted when the system was created (the plaintext that was sealed), and
273
+ * `queryTemplateSha256` is SHA-256 of the template exactly as it will be sent —
274
+ * raw, not normalized. The enclave recomputes both from what it decrypted and
275
+ * was given, so a relay that substitutes either changes the bytes and the
276
+ * signatures fail.
277
+ */
278
+ export function buildSystemRegistrationRequestPayload(request) {
279
+ if (!request.customerKeyId)
280
+ throw new Error("customer_key_id is required");
281
+ const systemId = canonicalUuid(request.systemId, "systemId");
282
+ if (systemId === NIL_UUID)
283
+ throw new Error("system_id is required");
284
+ return canonicalJson({
285
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
286
+ config_digest: requireSha256(request.configDigest, "configDigest"),
287
+ connector_type: request.connectorType,
288
+ customer_key_id: request.customerKeyId,
289
+ payload_type: PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST,
290
+ query_template_sha256: requireSha256(request.queryTemplateSha256, "queryTemplateSha256"),
291
+ system_id: systemId,
292
+ });
293
+ }
294
+ // --- The documents the ENCLAVE signs -----------------------------------------
295
+ //
296
+ // Ports of core.VerifyKeyEnrollment, core.VerifyTeamAuthorization and
297
+ // core.VerifySystemRegistration. Each takes the key rather than finding one, as
298
+ // Go's do: a document that names the key vouching for it proves only that its
299
+ // author holds that key. The key to pass is the signing key of an enclave you
300
+ // attested against your pinned PCR0 (EnclaveIdentity.signingKey) -- the client's
301
+ // enrol, rotate and register calls use exactly that. Each reads the document as
302
+ // the API returns it, because the signed bytes are rebuilt from the wire
303
+ // strings (whole-second UTC timestamps, lowercase UUIDs), and throws
304
+ // VerificationError on anything that does not verify.
305
+ // v2 from wire protocol 12, and v2 is the only version a protocol-12 enclave
306
+ // issues or honors: a v1 document could have been minted by an earlier image
307
+ // without the customer's signature.
308
+ const PAYLOAD_TYPE_KEY_ENROLLMENT = "burnledger.key_enrollment.v2";
309
+ const PAYLOAD_TYPE_TEAM_AUTHORIZATION = "burnledger.team_authorization.v2";
310
+ const PAYLOAD_TYPE_SYSTEM_REGISTRATION = "burnledger.system_registration.v2";
311
+ function docObject(value, what) {
312
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
313
+ throw new VerificationError(`${what} is not an object`);
314
+ }
315
+ return value;
316
+ }
317
+ function docString(doc, what, field) {
318
+ const value = doc[field];
319
+ if (typeof value !== "string")
320
+ throw new VerificationError(`${what}.${field} is not a string`);
321
+ return value;
322
+ }
323
+ function docKeyId(doc, what) {
324
+ const value = docString(doc, what, "customer_key_id");
325
+ if (value === "")
326
+ throw new VerificationError(`${what}.customer_key_id is empty`);
327
+ return value;
328
+ }
329
+ function docUuid(doc, what, field) {
330
+ const value = docString(doc, what, field);
331
+ if (!UUID_RE.test(value))
332
+ throw new VerificationError(`${what}.${field} is not a UUID`);
333
+ return value.toLowerCase();
334
+ }
335
+ /** Go encodes [N]byte as an array of numbers. */
336
+ function docBytes(doc, what, field, length) {
337
+ const value = doc[field];
338
+ if (!Array.isArray(value) ||
339
+ value.length !== length ||
340
+ !value.every((b) => Number.isInteger(b) && b >= 0 && b <= 255)) {
341
+ throw new VerificationError(`${what}.${field} is not ${length} bytes`);
342
+ }
343
+ return new Uint8Array(value);
344
+ }
345
+ /** Go encodes []byte as padded standard base64. */
346
+ function base64Bytes(value, what) {
347
+ if (typeof value !== "string" || value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value)) {
348
+ throw new VerificationError(`${what} is not base64`);
349
+ }
350
+ const bin = atob(value);
351
+ const out = new Uint8Array(bin.length);
352
+ for (let i = 0; i < bin.length; i++)
353
+ out[i] = bin.charCodeAt(i);
354
+ return out;
355
+ }
356
+ async function requireEnclaveSignature(crypto, enclaveKey, payload, signature, what) {
357
+ if (!(enclaveKey instanceof Uint8Array) || enclaveKey.length !== ED25519_PUBLIC_KEY_SIZE) {
358
+ throw new TypeError(`enclaveKey must be a ${ED25519_PUBLIC_KEY_SIZE}-byte Ed25519 public key`);
359
+ }
360
+ if (!(await crypto.ed25519Verify(enclaveKey, payload, signature))) {
361
+ const keyId = "dp_k_" + toHex(await crypto.sha256(enclaveKey));
362
+ throw new VerificationError(`the ${what} is not signed by enclave key ${keyId}. Do not use it: a relay that ` +
363
+ "forged or altered one would produce exactly this.");
364
+ }
365
+ }
366
+ /**
367
+ * Verify the enclave's signature on a key enrolment statement (the `enrollment`
368
+ * object ENROLL_KEY and ROTATE_KEY return). Also refuses a statement whose
369
+ * `customer_key_id` is not the id its own group derives, as Go's payload
370
+ * builder does -- so a statement that verifies names exactly its members and
371
+ * threshold, and comparing its key id with yours compares those too.
372
+ */
373
+ export async function verifyKeyEnrollmentStatement(crypto, statement, enclaveKey) {
374
+ const what = "enrollment";
375
+ const doc = docObject(statement, what);
376
+ const rawGroup = docObject(doc.group, `${what}.group`);
377
+ if (!Array.isArray(rawGroup.members))
378
+ throw new VerificationError(`${what}.group.members is not an array`);
379
+ const group = {
380
+ threshold: rawGroup.threshold,
381
+ members: rawGroup.members.map((m, i) => base64Bytes(m, `${what}.group.members[${i}]`)),
382
+ };
383
+ let derived;
384
+ try {
385
+ derived = await customerKeyId(crypto, group);
386
+ }
387
+ catch (err) {
388
+ if (err instanceof InvalidKeyGroupError)
389
+ throw new VerificationError(`${what}.group: ${err.message}`);
390
+ throw err;
391
+ }
392
+ const keyId = docKeyId(doc, what);
393
+ if (keyId !== derived) {
394
+ throw new VerificationError(`${what}.customer_key_id ${keyId} is not the id its own group derives (${derived})`);
395
+ }
396
+ const payload = canonicalJson({
397
+ asserted_team_id: docUuid(doc, what, "asserted_team_id"),
398
+ customer_key_id: keyId,
399
+ enclave_pcr0: docString(doc, what, "enclave_pcr0"),
400
+ enrolled_at: formatTimestamp(doc.enrolled_at, `${what}.enrolled_at`),
401
+ member_key_ids: await memberFingerprints(crypto, group),
402
+ payload_type: PAYLOAD_TYPE_KEY_ENROLLMENT,
403
+ threshold: group.threshold,
404
+ });
405
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "enrollment statement");
406
+ }
407
+ /**
408
+ * Verify the enclave's signature on a team authorization (the `authorization`
409
+ * object ENROLL_KEY and ROTATE_KEY return). The signature only: whether it is
410
+ * in force now is a separate question, as in Go.
411
+ */
412
+ export async function verifyTeamAuthorization(crypto, certificate, enclaveKey) {
413
+ const what = "authorization";
414
+ const doc = docObject(certificate, what);
415
+ const notBefore = formatTimestamp(doc.not_before, `${what}.not_before`);
416
+ const notAfter = formatTimestamp(doc.not_after, `${what}.not_after`);
417
+ // Go compares at full precision; the whole-second strings disagree with it
418
+ // only for a window shorter than a second, which no enclave issues.
419
+ if (notAfter <= notBefore)
420
+ throw new VerificationError(`${what}.not_after is not after not_before`);
421
+ // prev_key_id is omitempty in Go: absent on a first enrolment, and absent
422
+ // from the signed payload too.
423
+ const prevKeyId = doc.prev_key_id == null ? "" : docString(doc, what, "prev_key_id");
424
+ const payload = canonicalJson({
425
+ asserted_team_id: docUuid(doc, what, "asserted_team_id"),
426
+ customer_key_id: docKeyId(doc, what),
427
+ not_after: notAfter,
428
+ not_before: notBefore,
429
+ payload_type: PAYLOAD_TYPE_TEAM_AUTHORIZATION,
430
+ ...(prevKeyId === "" ? {} : { prev_key_id: prevKeyId }),
431
+ });
432
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "team authorization");
433
+ }
434
+ /** Verify the enclave's signature on a system registration (the
435
+ * `registration` object REGISTER_SYSTEM returns). */
436
+ export async function verifySystemRegistration(crypto, certificate, enclaveKey) {
437
+ const what = "registration";
438
+ const doc = docObject(certificate, what);
439
+ const payload = canonicalJson({
440
+ config_digest: toHex(docBytes(doc, what, "config_digest", 32)),
441
+ connector_type: docString(doc, what, "connector_type"),
442
+ customer_key_id: docKeyId(doc, what),
443
+ payload_type: PAYLOAD_TYPE_SYSTEM_REGISTRATION,
444
+ query_template_hash: toHex(docBytes(doc, what, "query_template_hash", 32)),
445
+ registered_at: formatTimestamp(doc.registered_at, `${what}.registered_at`),
446
+ system_id: docUuid(doc, what, "system_id"),
447
+ });
448
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "system registration");
449
+ }
130
450
  //# sourceMappingURL=customer-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customer-keys.js","sourceRoot":"","sources":["../../src/customer-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;GAIG;AACH,MAAM,+BAA+B,GAAG,kCAAkC,CAAC;AAE3E,MAAM,CAAC,MAAM,iCAAiC,GAAG,oCAAoC,CAAC;AAEtF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAEjD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,2EAA2E;AAC3E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CA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AAa,EAAE,eAAe,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,IAAI,gBAAgB,CAAC;QAC1E,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC;KAC3C,CAAC,CAAC;IACH,MAAM,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAC1H,CAAC"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The customer's side of ADR-025: verify the enclave, enrol a key group, rotate
3
+ * it, register a system under it.
4
+ *
5
+ * Request-building and response-checking for the BurnLedger client's methods of
6
+ * the same names, kept in a Node-only module the client imports lazily — the
7
+ * client is also the browser entry's, and these need node:crypto. Nothing here
8
+ * holds a private key: every signature comes from a {@link KeyGroupSigner} (see
9
+ * key-group.ts for why, and for what losing a key costs).
10
+ *
11
+ * WHAT THE CHECKS ON EACH RESPONSE ARE FOR. The API relays every byte, so the
12
+ * documents it returns are only worth what the client checks, and it checks two
13
+ * things. First, that the enclave signed them — under the signing key of an
14
+ * enclave the caller attested against its own pinned PCR0. Without that, a relay
15
+ * could hand the customer a forged enrolment and they would believe themselves
16
+ * registered when nothing was. The key set at /.well-known/burnledger-keys is not
17
+ * the anchor for this: the same API serves it, so a relay that forged a document
18
+ * could publish the forging key beside it. Second, that they are about what the
19
+ * caller asked for. ADR-025 §2 names the load-bearing comparison: the enrolment
20
+ * statement must name the key group the customer generated. A relay that enrolled
21
+ * its own group instead would hand back a genuine, enclave-signed statement
22
+ * naming a key the customer does not hold; this comparison is where that stops
23
+ * being invisible. The enrolment and the authorization must also be for the team
24
+ * the customer named, and the authorization must end exactly at the `not_after`
25
+ * the customer signed and not start in the future: a relay that replayed an
26
+ * older genuine answer, or another team's, would otherwise have the caller
27
+ * believe a fresh window exists. The registration must name this key, this
28
+ * system, this config digest and this connector, or it registered something
29
+ * else.
30
+ */
31
+ import { type CustomerKeyGroup } from "./customer-keys.js";
32
+ import { type EnclaveIdentity, type SealOptions } from "./enclave-seal.js";
33
+ import { type KeyGroupSigner } from "./key-group.js";
34
+ import { type KeyEnrollmentResult, type System, type SystemRegistrationCertificate } from "./models.js";
35
+ type Raw = Record<string, unknown>;
36
+ /** How to check the enclave: the PCR0 you pinned out of band, and optionally
37
+ * your own challenge (otherwise 32 bytes are drawn from the OS CSPRNG). */
38
+ export interface EnclavePinOptions extends SealOptions {
39
+ nonce?: Uint8Array;
40
+ }
41
+ /** What `createRegisteredSystem` did, in order. */
42
+ export interface RegisteredSystem {
43
+ /** The system, created with its config sealed so the API never read it. */
44
+ readonly system: System;
45
+ /** The enclave's registration of that system under your key group. */
46
+ readonly registration: SystemRegistrationCertificate;
47
+ }
48
+ /**
49
+ * The challenge and the query string that carries it. A nonce the checked party
50
+ * chose — including one the API suggested — proves nothing about when the
51
+ * document was produced, so it is drawn here unless the caller brings its own.
52
+ */
53
+ export declare function attestationParams(nonce?: Uint8Array): {
54
+ nonce: Uint8Array;
55
+ params: Record<string, string>;
56
+ };
57
+ /**
58
+ * Verify the document the API returned against this caller's own challenge. The
59
+ * `nonce` the API echoes beside the document is ignored: nothing signs it. The
60
+ * check is against the nonce inside the document, under AWS's signature.
61
+ */
62
+ export declare function identityFromResponse(data: unknown, options: SealOptions & {
63
+ nonce: Uint8Array;
64
+ }): Promise<EnclaveIdentity>;
65
+ /**
66
+ * The ENROLL_KEY request, the key id it enrols and the `not_after` it signs.
67
+ * EVERY member signs.
68
+ */
69
+ export declare function enrollBody(opts: {
70
+ teamId: string;
71
+ group: CustomerKeyGroup;
72
+ signers: readonly KeyGroupSigner[];
73
+ notAfter?: Date;
74
+ }): Promise<{
75
+ body: Raw;
76
+ keyId: string;
77
+ notAfter: string;
78
+ }>;
79
+ /**
80
+ * The ROTATE_KEY request. Both groups sign the same key_rotation_request.v2: the
81
+ * OUTGOING group at its threshold, to spend its authority, and EVERY incoming
82
+ * member, to prove it holds its key.
83
+ */
84
+ export declare function rotateBody(opts: {
85
+ teamId: string;
86
+ previousGroup: CustomerKeyGroup;
87
+ previousSigners: readonly KeyGroupSigner[];
88
+ nextGroup: CustomerKeyGroup;
89
+ nextSigners: readonly KeyGroupSigner[];
90
+ notAfter?: Date;
91
+ }): Promise<{
92
+ body: Raw;
93
+ prevKeyId: string;
94
+ nextKeyId: string;
95
+ notAfter: string;
96
+ }>;
97
+ /**
98
+ * Verify both documents ENROLL_KEY and ROTATE_KEY return under the attested
99
+ * enclave's signing key, then refuse them unless they name the group this caller
100
+ * holds and the team it asked for, link to the predecessor it expects, end
101
+ * exactly at the `notAfter` (whole-second UTC) it signed, and do not start in
102
+ * the future. `teamId` is the team the request asserted; the SDK always asserts
103
+ * one, so there is no request this check has no team for.
104
+ *
105
+ * The end must be EXACT. A protocol-12 enclave ends the grant at the signed
106
+ * bound, to the second, so any other end answers some other request -- which is
107
+ * what a relay replaying an older genuine response, or dropping a renewal,
108
+ * hands back.
109
+ */
110
+ export declare function checkEnrollment(data: unknown, opts: {
111
+ enclave: EnclaveIdentity;
112
+ keyId: string;
113
+ prevKeyId: string | undefined;
114
+ teamId: string;
115
+ notAfter: string;
116
+ /** The time to judge `not_before` against. Defaults to this machine's clock. */
117
+ now?: Date;
118
+ }): Promise<KeyEnrollmentResult>;
119
+ /** The exact bytes sealed, and therefore the bytes `config_digest` is over. */
120
+ export declare function configBytes(config: Record<string, unknown>): Uint8Array;
121
+ /**
122
+ * The REGISTER_SYSTEM request, its key id and the config digest it signs.
123
+ *
124
+ * `config` must be the EXACT bytes submitted when the system was created — the
125
+ * plaintext that was sealed, or the `connection_config` JSON text as sent. An
126
+ * object is refused: re-serializing it produces bytes that may differ by one
127
+ * space from what the enclave decrypts, and the refusal would be a 401 with no
128
+ * way to see why.
129
+ */
130
+ export declare function registrationBody(opts: {
131
+ teamId: string;
132
+ group: CustomerKeyGroup;
133
+ signers: readonly KeyGroupSigner[];
134
+ systemId: string;
135
+ config: Uint8Array | string;
136
+ queryTemplate: string;
137
+ connectorType: string;
138
+ }): Promise<{
139
+ body: Raw;
140
+ keyId: string;
141
+ configDigest: Uint8Array;
142
+ }>;
143
+ /** Verify the registration under the attested enclave's signing key, then
144
+ * refuse it unless it binds what this caller signed. */
145
+ export declare function checkRegistration(data: unknown, opts: {
146
+ enclave: EnclaveIdentity;
147
+ keyId: string;
148
+ systemId: string;
149
+ configDigest: Uint8Array;
150
+ connectorType: string;
151
+ }): Promise<SystemRegistrationCertificate>;
152
+ export {};
153
+ //# sourceMappingURL=enclave-registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enclave-registration.d.ts","sourceRoot":"","sources":["../../src/enclave-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EASL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,6BAA6B,EACnC,MAAM,aAAa,CAAC;AAGrB,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC;2EAC2E;AAC3E,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,YAAY,EAAE,6BAA6B,CAAC;CACtD;AAyBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG;IACrD,KAAK,EAAE,UAAU,CA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