burnledger 0.8.0 → 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 +146 -0
  11. package/dist/cjs/customer-keys.d.ts.map +1 -0
  12. package/dist/cjs/customer-keys.js +465 -0
  13. package/dist/cjs/customer-keys.js.map +1 -0
  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 +23 -9
  31. package/dist/cjs/index.d.ts.map +1 -1
  32. package/dist/cjs/index.js +40 -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 +112 -3
  47. package/dist/cjs/verify.d.ts.map +1 -1
  48. package/dist/cjs/verify.js +393 -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 +109 -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 +146 -0
  67. package/dist/esm/customer-keys.d.ts.map +1 -0
  68. package/dist/esm/customer-keys.js +450 -0
  69. package/dist/esm/customer-keys.js.map +1 -0
  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 +23 -9
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +18 -7
  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 +112 -3
  103. package/dist/esm/verify.d.ts.map +1 -1
  104. package/dist/esm/verify.js +390 -147
  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 +122 -79
  113. package/src/client.ts +198 -6
  114. package/src/customer-keys.ts +550 -0
  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 +48 -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 +503 -152
  124. package/src/web-verifier.ts +36 -3
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Customer key groups (ADR-025 §2), computed on the customer's own machine.
3
+ *
4
+ * WHY THIS IS CLIENT-SIDE AND NOT AN API CALL. The private halves never leave
5
+ * the customer's machines -- that is the entire point of the mechanism. What a
6
+ * customer needs from us is not a service that computes their key id, but the
7
+ * ability to compute it themselves and compare it against the id the enclave
8
+ * signed. An id returned over HTTP would be an id the parent could choose, and
9
+ * the one comparison this design rests on would be checking our answer against
10
+ * our answer.
11
+ *
12
+ * WHY IT MUST MATCH GO EXACTLY. `customer_key_id` is derived independently by
13
+ * the enclave and by the customer. If the two derivations disagree by so much
14
+ * as a JSON separator, enrollment SUCCEEDS, the enclave signs a statement
15
+ * naming an id, and the customer's comparison fails -- indistinguishable, from
16
+ * where they are standing, from a parent having substituted their key. Every
17
+ * expectation in tests/customer-key-parity.test.ts comes from a corpus the Go
18
+ * generator writes by calling core itself.
19
+ */
20
+ import type { CryptoOps } from "./crypto.js";
21
+ /**
22
+ * Mirrors core.CustomerKeyIDPrefix. It distinguishes a customer's key id from
23
+ * an issuer key id, which are otherwise the same shape and would be confusable
24
+ * in a log line at exactly the wrong moment.
25
+ */
26
+ export declare const CUSTOMER_KEY_ID_PREFIX = "cust_k_";
27
+ /**
28
+ * Mirrors core.PayloadTypeKeyRotationRequest. v2 carries not_after, which bounds
29
+ * the request itself; a protocol-12 enclave refuses v1.
30
+ */
31
+ export declare const PAYLOAD_TYPE_KEY_ROTATION_REQUEST = "burnledger.key_rotation_request.v2";
32
+ /** Mirrors core.MaxCustomerKeyGroupMembers. */
33
+ export declare const MAX_CUSTOMER_KEY_GROUP_MEMBERS = 16;
34
+ /** A group that cannot be enrolled, for a reason stated in the message. */
35
+ export declare class InvalidKeyGroupError extends Error {
36
+ constructor(message: string);
37
+ }
38
+ export interface CustomerKeyGroup {
39
+ /** How many distinct members must sign. 1 <= threshold <= members.length. */
40
+ threshold: number;
41
+ /**
42
+ * The enrolled public keys. Order is not significant: the id sorts the
43
+ * fingerprints, so two customers who list the same keys in a different order
44
+ * enrol the same group rather than two indistinguishable ones.
45
+ */
46
+ members: Uint8Array[];
47
+ }
48
+ /** hex(SHA-256(public key)) -- a member's identity inside a group. */
49
+ export declare function memberFingerprint(crypto: CryptoOps, publicKey: Uint8Array): Promise<string>;
50
+ /** Throws InvalidKeyGroupError unless this group could ever be used. */
51
+ export declare function validateKeyGroup(crypto: CryptoOps, group: CustomerKeyGroup): Promise<void>;
52
+ /** The members' fingerprints, sorted, so the id does not depend on order. */
53
+ export declare function memberFingerprints(crypto: CryptoOps, group: CustomerKeyGroup): Promise<string[]>;
54
+ /**
55
+ * The id the enclave will compute for this group.
56
+ *
57
+ * Throws rather than returning an id for a group that could never be enrolled:
58
+ * an id for an unusable group is a value a caller would go on to compare
59
+ * against, and it would never match anything.
60
+ */
61
+ export declare function customerKeyId(crypto: CryptoOps, group: CustomerKeyGroup): Promise<string>;
62
+ /**
63
+ * A request's `not_after` as Go signs it (core.KeyTimeFormat): UTC, whole
64
+ * seconds, the fraction truncated as Go's Format truncates it.
65
+ */
66
+ export declare function keyTime(value: Date): string;
67
+ /**
68
+ * The canonical bytes the OUTGOING group's members sign to authorise a rotation.
69
+ *
70
+ * This is the only payload in the scheme signed by the customer rather than by
71
+ * the enclave, so it is the only one where a signature captured elsewhere could
72
+ * be replayed into the mechanism -- hence its own payload type.
73
+ *
74
+ * Both ids are bound, not just the successor: a statement naming only the
75
+ * incoming key could be lifted onto a different predecessor, re-presenting the
76
+ * same signatures as though another group had approved it.
77
+ */
78
+ export declare function buildKeyRotationRequestPayload(request: {
79
+ assertedTeamId: string;
80
+ prevKeyId: string;
81
+ nextKeyId: string;
82
+ /**
83
+ * Bounds the request: the enclave ends the successor's window no later than
84
+ * this and refuses the request once it has passed, so a replay cannot renew
85
+ * the window. Signed as whole seconds, UTC.
86
+ */
87
+ notAfter: Date;
88
+ }): Uint8Array;
89
+ /** Mirrors core.PayloadTypeKeyEnrollmentRequest. */
90
+ export declare const PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST = "burnledger.key_enrollment_request.v1";
91
+ /** Mirrors core.PayloadTypeSystemRegistrationRequest. */
92
+ export declare const PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST = "burnledger.system_registration_request.v1";
93
+ /**
94
+ * The canonical bytes EVERY member of a group signs to enrol it for a team.
95
+ *
96
+ * Port of core.BuildKeyEnrollmentRequestPayload. Without these signatures
97
+ * whoever relays the request could enrol public keys it does not hold — the
98
+ * customer's included — so the enclave demands one from each member, not a
99
+ * threshold: the statement it signs vouches for every key. `notAfter` is the
100
+ * latest the resulting authorization may end, and when the request itself stops
101
+ * being usable: the enclave cannot recognize a replay, so this is what keeps a
102
+ * relayed copy from renewing the window.
103
+ */
104
+ export declare function buildKeyEnrollmentRequestPayload(request: {
105
+ assertedTeamId: string;
106
+ customerKeyId: string;
107
+ notAfter: Date;
108
+ }): Uint8Array;
109
+ /**
110
+ * The canonical bytes an enrolled group signs, at its threshold, to register one
111
+ * system under it.
112
+ *
113
+ * Port of core.BuildSystemRegistrationRequestPayload. Both digests are over bytes
114
+ * the CUSTOMER holds: `configDigest` is SHA-256 of the exact config bytes
115
+ * submitted when the system was created (the plaintext that was sealed), and
116
+ * `queryTemplateSha256` is SHA-256 of the template exactly as it will be sent —
117
+ * raw, not normalized. The enclave recomputes both from what it decrypted and
118
+ * was given, so a relay that substitutes either changes the bytes and the
119
+ * signatures fail.
120
+ */
121
+ export declare function buildSystemRegistrationRequestPayload(request: {
122
+ assertedTeamId: string;
123
+ systemId: string;
124
+ configDigest: Uint8Array;
125
+ queryTemplateSha256: Uint8Array;
126
+ connectorType: string;
127
+ customerKeyId: string;
128
+ }): Uint8Array;
129
+ /**
130
+ * Verify the enclave's signature on a key enrolment statement (the `enrollment`
131
+ * object ENROLL_KEY and ROTATE_KEY return). Also refuses a statement whose
132
+ * `customer_key_id` is not the id its own group derives, as Go's payload
133
+ * builder does -- so a statement that verifies names exactly its members and
134
+ * threshold, and comparing its key id with yours compares those too.
135
+ */
136
+ export declare function verifyKeyEnrollmentStatement(crypto: CryptoOps, statement: unknown, enclaveKey: Uint8Array): Promise<void>;
137
+ /**
138
+ * Verify the enclave's signature on a team authorization (the `authorization`
139
+ * object ENROLL_KEY and ROTATE_KEY return). The signature only: whether it is
140
+ * in force now is a separate question, as in Go.
141
+ */
142
+ export declare function verifyTeamAuthorization(crypto: CryptoOps, certificate: unknown, enclaveKey: Uint8Array): Promise<void>;
143
+ /** Verify the enclave's signature on a system registration (the
144
+ * `registration` object REGISTER_SYSTEM returns). */
145
+ export declare function verifySystemRegistration(crypto: CryptoOps, certificate: unknown, enclaveKey: Uint8Array): Promise<void>;
146
+ //# sourceMappingURL=customer-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-keys.d.ts","sourceRoot":"","sources":["../../src/customer-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAShD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,uCAAuC,CAAC;AAEtF,+CAA+C;AAC/C,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAIjD,2EAA2E;AAC3E,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAMD,sEAAsE;AACtE,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wEAAwE;AACxE,wBAAsB,gBAAgB,C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AsB,4BAA4B,CAChD,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,OAAO,EACpB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED;qDACqD;AACrD,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,OAAO,EACpB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,465 @@
1
+ "use strict";
2
+ /**
3
+ * Customer key groups (ADR-025 §2), computed on the customer's own machine.
4
+ *
5
+ * WHY THIS IS CLIENT-SIDE AND NOT AN API CALL. The private halves never leave
6
+ * the customer's machines -- that is the entire point of the mechanism. What a
7
+ * customer needs from us is not a service that computes their key id, but the
8
+ * ability to compute it themselves and compare it against the id the enclave
9
+ * signed. An id returned over HTTP would be an id the parent could choose, and
10
+ * the one comparison this design rests on would be checking our answer against
11
+ * our answer.
12
+ *
13
+ * WHY IT MUST MATCH GO EXACTLY. `customer_key_id` is derived independently by
14
+ * the enclave and by the customer. If the two derivations disagree by so much
15
+ * as a JSON separator, enrollment SUCCEEDS, the enclave signs a statement
16
+ * naming an id, and the customer's comparison fails -- indistinguishable, from
17
+ * where they are standing, from a parent having substituted their key. Every
18
+ * expectation in tests/customer-key-parity.test.ts comes from a corpus the Go
19
+ * generator writes by calling core itself.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST = exports.PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST = exports.InvalidKeyGroupError = exports.MAX_CUSTOMER_KEY_GROUP_MEMBERS = exports.PAYLOAD_TYPE_KEY_ROTATION_REQUEST = exports.CUSTOMER_KEY_ID_PREFIX = void 0;
23
+ exports.memberFingerprint = memberFingerprint;
24
+ exports.validateKeyGroup = validateKeyGroup;
25
+ exports.memberFingerprints = memberFingerprints;
26
+ exports.customerKeyId = customerKeyId;
27
+ exports.keyTime = keyTime;
28
+ exports.buildKeyRotationRequestPayload = buildKeyRotationRequestPayload;
29
+ exports.buildKeyEnrollmentRequestPayload = buildKeyEnrollmentRequestPayload;
30
+ exports.buildSystemRegistrationRequestPayload = buildSystemRegistrationRequestPayload;
31
+ exports.verifyKeyEnrollmentStatement = verifyKeyEnrollmentStatement;
32
+ exports.verifyTeamAuthorization = verifyTeamAuthorization;
33
+ exports.verifySystemRegistration = verifySystemRegistration;
34
+ const verify_js_1 = require("./verify.js");
35
+ const errors_js_1 = require("./errors.js");
36
+ /**
37
+ * Mirrors core.CustomerKeyIDPrefix. It distinguishes a customer's key id from
38
+ * an issuer key id, which are otherwise the same shape and would be confusable
39
+ * in a log line at exactly the wrong moment.
40
+ */
41
+ exports.CUSTOMER_KEY_ID_PREFIX = "cust_k_";
42
+ /**
43
+ * Mirrors core.payloadTypeCustomerKeyGroup. Unexported in Go because it is
44
+ * never signed or transmitted -- only hashed -- but it IS inside the hash, so a
45
+ * reimplementation that omits it computes a different id for every group.
46
+ */
47
+ const PAYLOAD_TYPE_CUSTOMER_KEY_GROUP = "burnledger.customer_key_group.v1";
48
+ /**
49
+ * Mirrors core.PayloadTypeKeyRotationRequest. v2 carries not_after, which bounds
50
+ * the request itself; a protocol-12 enclave refuses v1.
51
+ */
52
+ exports.PAYLOAD_TYPE_KEY_ROTATION_REQUEST = "burnledger.key_rotation_request.v2";
53
+ /** Mirrors core.MaxCustomerKeyGroupMembers. */
54
+ exports.MAX_CUSTOMER_KEY_GROUP_MEMBERS = 16;
55
+ const ED25519_PUBLIC_KEY_SIZE = 32;
56
+ /** A group that cannot be enrolled, for a reason stated in the message. */
57
+ class InvalidKeyGroupError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = "InvalidKeyGroupError";
61
+ }
62
+ }
63
+ exports.InvalidKeyGroupError = InvalidKeyGroupError;
64
+ function toHex(bytes) {
65
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
66
+ }
67
+ /** hex(SHA-256(public key)) -- a member's identity inside a group. */
68
+ async function memberFingerprint(crypto, publicKey) {
69
+ return toHex(await crypto.sha256(publicKey));
70
+ }
71
+ /** Throws InvalidKeyGroupError unless this group could ever be used. */
72
+ async function validateKeyGroup(crypto, group) {
73
+ if (group.members.length === 0) {
74
+ throw new InvalidKeyGroupError("a customer key group needs at least one member");
75
+ }
76
+ if (group.members.length > exports.MAX_CUSTOMER_KEY_GROUP_MEMBERS) {
77
+ throw new InvalidKeyGroupError(`a customer key group may have at most ${exports.MAX_CUSTOMER_KEY_GROUP_MEMBERS} members, ` +
78
+ `got ${group.members.length}`);
79
+ }
80
+ if (!Number.isInteger(group.threshold) ||
81
+ group.threshold < 1 ||
82
+ group.threshold > group.members.length) {
83
+ throw new InvalidKeyGroupError(`threshold ${group.threshold} is not between 1 and the ${group.members.length} members`);
84
+ }
85
+ const seen = new Set();
86
+ for (const member of group.members) {
87
+ if (member.length !== ED25519_PUBLIC_KEY_SIZE) {
88
+ throw new InvalidKeyGroupError(`every member must be a ${ED25519_PUBLIC_KEY_SIZE}-byte Ed25519 key`);
89
+ }
90
+ if (!isNotSmallOrder(member)) {
91
+ // A small-order key is held by nobody: with the identity point as the
92
+ // public key, R = identity and S = 0 verify over ANY message, so it
93
+ // would pass proof of possession and count toward a threshold for free.
94
+ throw new InvalidKeyGroupError("every member must be an Ed25519 public key on the curve and not of small order " +
95
+ "(small-order and off-curve keys are refused)");
96
+ }
97
+ const fingerprint = await memberFingerprint(crypto, member);
98
+ if (seen.has(fingerprint)) {
99
+ // A repeated member would let one holder satisfy a threshold meant to
100
+ // require several, which is the entire point of one.
101
+ throw new InvalidKeyGroupError("the same member key is listed twice");
102
+ }
103
+ seen.add(fingerprint);
104
+ }
105
+ }
106
+ /** The members' fingerprints, sorted, so the id does not depend on order. */
107
+ async function memberFingerprints(crypto, group) {
108
+ const out = [];
109
+ for (const member of group.members) {
110
+ out.push(await memberFingerprint(crypto, member));
111
+ }
112
+ return out.sort();
113
+ }
114
+ /**
115
+ * The id the enclave will compute for this group.
116
+ *
117
+ * Throws rather than returning an id for a group that could never be enrolled:
118
+ * an id for an unusable group is a value a caller would go on to compare
119
+ * against, and it would never match anything.
120
+ */
121
+ async function customerKeyId(crypto, group) {
122
+ await validateKeyGroup(crypto, group);
123
+ const document = {
124
+ member_key_ids: await memberFingerprints(crypto, group),
125
+ payload_type: PAYLOAD_TYPE_CUSTOMER_KEY_GROUP,
126
+ threshold: group.threshold,
127
+ };
128
+ return exports.CUSTOMER_KEY_ID_PREFIX + toHex(await crypto.sha256((0, verify_js_1.canonicalJson)(document)));
129
+ }
130
+ /**
131
+ * A request's `not_after` as Go signs it (core.KeyTimeFormat): UTC, whole
132
+ * seconds, the fraction truncated as Go's Format truncates it.
133
+ */
134
+ function keyTime(value) {
135
+ if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
136
+ throw new Error("not_after is required");
137
+ }
138
+ return value.toISOString().slice(0, 19) + "Z";
139
+ }
140
+ /**
141
+ * The canonical bytes the OUTGOING group's members sign to authorise a rotation.
142
+ *
143
+ * This is the only payload in the scheme signed by the customer rather than by
144
+ * the enclave, so it is the only one where a signature captured elsewhere could
145
+ * be replayed into the mechanism -- hence its own payload type.
146
+ *
147
+ * Both ids are bound, not just the successor: a statement naming only the
148
+ * incoming key could be lifted onto a different predecessor, re-presenting the
149
+ * same signatures as though another group had approved it.
150
+ */
151
+ function buildKeyRotationRequestPayload(request) {
152
+ if (!request.prevKeyId || !request.nextKeyId) {
153
+ throw new Error("a rotation request names both the key being replaced and its replacement");
154
+ }
155
+ if (!(request.notAfter instanceof Date) || Number.isNaN(request.notAfter.getTime())) {
156
+ throw new Error("not_after is required");
157
+ }
158
+ if (request.prevKeyId === request.nextKeyId) {
159
+ // A self-rotation is a cycle in the chain the enclave walks, and it walks
160
+ // without a visited set.
161
+ throw new Error("a rotation request cannot name the same key as both predecessor and successor");
162
+ }
163
+ return (0, verify_js_1.canonicalJson)({
164
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
165
+ next_key_id: request.nextKeyId,
166
+ not_after: keyTime(request.notAfter),
167
+ payload_type: exports.PAYLOAD_TYPE_KEY_ROTATION_REQUEST,
168
+ prev_key_id: request.prevKeyId,
169
+ });
170
+ }
171
+ // Ed25519 arithmetic for one question only: is a member key a curve point
172
+ // outside the small-order subgroup? It mirrors the decoding Go's
173
+ // filippo.io/edwards25519 performs in core.CustomerKeyGroup.Validate, so both
174
+ // sides refuse exactly the same keys: bit 255 of y is ignored and y is reduced
175
+ // mod p (non-canonical encodings are accepted), a y with no matching x is
176
+ // refused, and the sign bit selects the negative root even when x = 0.
177
+ const FIELD_P = 2n ** 255n - 19n;
178
+ const fieldMod = (a) => ((a % FIELD_P) + FIELD_P) % FIELD_P;
179
+ function fieldPow(base, exp) {
180
+ let result = 1n;
181
+ let b = fieldMod(base);
182
+ for (let e = exp; e > 0n; e >>= 1n) {
183
+ if (e & 1n)
184
+ result = (result * b) % FIELD_P;
185
+ b = (b * b) % FIELD_P;
186
+ }
187
+ return result;
188
+ }
189
+ const fieldInv = (a) => fieldPow(a, FIELD_P - 2n);
190
+ const CURVE_D = fieldMod(-121665n * fieldInv(121666n));
191
+ const SQRT_MINUS_ONE = fieldPow(2n, (FIELD_P - 1n) / 4n);
192
+ function decodePoint(bytes) {
193
+ // validateKeyGroup has already required exactly 32 bytes.
194
+ const top = bytes[31] ?? 0;
195
+ let y = 0n;
196
+ for (let i = 31; i >= 0; i--) {
197
+ y = (y << 8n) | BigInt(i === 31 ? top & 0x7f : (bytes[i] ?? 0));
198
+ }
199
+ y = fieldMod(y);
200
+ const u = fieldMod(y * y - 1n);
201
+ const v = fieldMod(CURVE_D * y * y + 1n);
202
+ let x = fieldMod(u * fieldPow(v, 3n) * fieldPow(u * fieldPow(v, 7n), (FIELD_P - 5n) / 8n));
203
+ const vx2 = fieldMod(v * x * x);
204
+ if (vx2 === fieldMod(-u)) {
205
+ x = fieldMod(x * SQRT_MINUS_ONE);
206
+ }
207
+ else if (vx2 !== u) {
208
+ return null;
209
+ }
210
+ if (Number(x & 1n) !== top >> 7)
211
+ x = fieldMod(-x);
212
+ return [x, y];
213
+ }
214
+ // The complete twisted-Edwards addition law (a = -1); its denominators are
215
+ // never zero because d is not a square.
216
+ function addPoints(p, q) {
217
+ const t = fieldMod(CURVE_D * p[0] * q[0] * p[1] * q[1]);
218
+ return [
219
+ fieldMod((p[0] * q[1] + p[1] * q[0]) * fieldInv(1n + t)),
220
+ fieldMod((p[1] * q[1] + p[0] * q[0]) * fieldInv(fieldMod(1n - t))),
221
+ ];
222
+ }
223
+ /**
224
+ * Whether key decodes to a curve point that is not of small order (8·P ≠ identity).
225
+ * Not a prime-order check: a mixed-order key passes, as it does in Go.
226
+ */
227
+ function isNotSmallOrder(key) {
228
+ let point = decodePoint(key);
229
+ if (point === null)
230
+ return false;
231
+ for (let i = 0; i < 3; i++)
232
+ point = addPoints(point, point);
233
+ return !(point[0] === 0n && point[1] === 1n);
234
+ }
235
+ /** Mirrors core.PayloadTypeKeyEnrollmentRequest. */
236
+ exports.PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST = "burnledger.key_enrollment_request.v1";
237
+ /** Mirrors core.PayloadTypeSystemRegistrationRequest. */
238
+ exports.PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST = "burnledger.system_registration_request.v1";
239
+ 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}$/;
240
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
241
+ /**
242
+ * A UUID in the one form Go prints it (uuid.UUID.String()): lowercase and
243
+ * hyphenated. The enclave rebuilds every customer-signed payload from the
244
+ * uuid.UUID it parsed, so a team id signed as the caller happened to type it —
245
+ * uppercase, say — would be different bytes, and the refusal would be a 401 with
246
+ * nothing in it to say why.
247
+ */
248
+ function canonicalUuid(value, field) {
249
+ if (typeof value !== "string" || !UUID_RE.test(value)) {
250
+ throw new Error(`${field} must be a UUID, got ${JSON.stringify(value)}`);
251
+ }
252
+ return value.toLowerCase();
253
+ }
254
+ function requireSha256(value, field) {
255
+ if (!(value instanceof Uint8Array) || value.length !== 32) {
256
+ throw new Error(`${field} must be a 32-byte SHA-256 digest`);
257
+ }
258
+ return toHex(value);
259
+ }
260
+ /**
261
+ * The canonical bytes EVERY member of a group signs to enrol it for a team.
262
+ *
263
+ * Port of core.BuildKeyEnrollmentRequestPayload. Without these signatures
264
+ * whoever relays the request could enrol public keys it does not hold — the
265
+ * customer's included — so the enclave demands one from each member, not a
266
+ * threshold: the statement it signs vouches for every key. `notAfter` is the
267
+ * latest the resulting authorization may end, and when the request itself stops
268
+ * being usable: the enclave cannot recognize a replay, so this is what keeps a
269
+ * relayed copy from renewing the window.
270
+ */
271
+ function buildKeyEnrollmentRequestPayload(request) {
272
+ if (!request.customerKeyId)
273
+ throw new Error("customer_key_id is required");
274
+ return (0, verify_js_1.canonicalJson)({
275
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
276
+ customer_key_id: request.customerKeyId,
277
+ not_after: keyTime(request.notAfter),
278
+ payload_type: exports.PAYLOAD_TYPE_KEY_ENROLLMENT_REQUEST,
279
+ });
280
+ }
281
+ /**
282
+ * The canonical bytes an enrolled group signs, at its threshold, to register one
283
+ * system under it.
284
+ *
285
+ * Port of core.BuildSystemRegistrationRequestPayload. Both digests are over bytes
286
+ * the CUSTOMER holds: `configDigest` is SHA-256 of the exact config bytes
287
+ * submitted when the system was created (the plaintext that was sealed), and
288
+ * `queryTemplateSha256` is SHA-256 of the template exactly as it will be sent —
289
+ * raw, not normalized. The enclave recomputes both from what it decrypted and
290
+ * was given, so a relay that substitutes either changes the bytes and the
291
+ * signatures fail.
292
+ */
293
+ function buildSystemRegistrationRequestPayload(request) {
294
+ if (!request.customerKeyId)
295
+ throw new Error("customer_key_id is required");
296
+ const systemId = canonicalUuid(request.systemId, "systemId");
297
+ if (systemId === NIL_UUID)
298
+ throw new Error("system_id is required");
299
+ return (0, verify_js_1.canonicalJson)({
300
+ asserted_team_id: canonicalUuid(request.assertedTeamId, "assertedTeamId"),
301
+ config_digest: requireSha256(request.configDigest, "configDigest"),
302
+ connector_type: request.connectorType,
303
+ customer_key_id: request.customerKeyId,
304
+ payload_type: exports.PAYLOAD_TYPE_SYSTEM_REGISTRATION_REQUEST,
305
+ query_template_sha256: requireSha256(request.queryTemplateSha256, "queryTemplateSha256"),
306
+ system_id: systemId,
307
+ });
308
+ }
309
+ // --- The documents the ENCLAVE signs -----------------------------------------
310
+ //
311
+ // Ports of core.VerifyKeyEnrollment, core.VerifyTeamAuthorization and
312
+ // core.VerifySystemRegistration. Each takes the key rather than finding one, as
313
+ // Go's do: a document that names the key vouching for it proves only that its
314
+ // author holds that key. The key to pass is the signing key of an enclave you
315
+ // attested against your pinned PCR0 (EnclaveIdentity.signingKey) -- the client's
316
+ // enrol, rotate and register calls use exactly that. Each reads the document as
317
+ // the API returns it, because the signed bytes are rebuilt from the wire
318
+ // strings (whole-second UTC timestamps, lowercase UUIDs), and throws
319
+ // VerificationError on anything that does not verify.
320
+ // v2 from wire protocol 12, and v2 is the only version a protocol-12 enclave
321
+ // issues or honors: a v1 document could have been minted by an earlier image
322
+ // without the customer's signature.
323
+ const PAYLOAD_TYPE_KEY_ENROLLMENT = "burnledger.key_enrollment.v2";
324
+ const PAYLOAD_TYPE_TEAM_AUTHORIZATION = "burnledger.team_authorization.v2";
325
+ const PAYLOAD_TYPE_SYSTEM_REGISTRATION = "burnledger.system_registration.v2";
326
+ function docObject(value, what) {
327
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
328
+ throw new errors_js_1.VerificationError(`${what} is not an object`);
329
+ }
330
+ return value;
331
+ }
332
+ function docString(doc, what, field) {
333
+ const value = doc[field];
334
+ if (typeof value !== "string")
335
+ throw new errors_js_1.VerificationError(`${what}.${field} is not a string`);
336
+ return value;
337
+ }
338
+ function docKeyId(doc, what) {
339
+ const value = docString(doc, what, "customer_key_id");
340
+ if (value === "")
341
+ throw new errors_js_1.VerificationError(`${what}.customer_key_id is empty`);
342
+ return value;
343
+ }
344
+ function docUuid(doc, what, field) {
345
+ const value = docString(doc, what, field);
346
+ if (!UUID_RE.test(value))
347
+ throw new errors_js_1.VerificationError(`${what}.${field} is not a UUID`);
348
+ return value.toLowerCase();
349
+ }
350
+ /** Go encodes [N]byte as an array of numbers. */
351
+ function docBytes(doc, what, field, length) {
352
+ const value = doc[field];
353
+ if (!Array.isArray(value) ||
354
+ value.length !== length ||
355
+ !value.every((b) => Number.isInteger(b) && b >= 0 && b <= 255)) {
356
+ throw new errors_js_1.VerificationError(`${what}.${field} is not ${length} bytes`);
357
+ }
358
+ return new Uint8Array(value);
359
+ }
360
+ /** Go encodes []byte as padded standard base64. */
361
+ function base64Bytes(value, what) {
362
+ if (typeof value !== "string" || value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value)) {
363
+ throw new errors_js_1.VerificationError(`${what} is not base64`);
364
+ }
365
+ const bin = atob(value);
366
+ const out = new Uint8Array(bin.length);
367
+ for (let i = 0; i < bin.length; i++)
368
+ out[i] = bin.charCodeAt(i);
369
+ return out;
370
+ }
371
+ async function requireEnclaveSignature(crypto, enclaveKey, payload, signature, what) {
372
+ if (!(enclaveKey instanceof Uint8Array) || enclaveKey.length !== ED25519_PUBLIC_KEY_SIZE) {
373
+ throw new TypeError(`enclaveKey must be a ${ED25519_PUBLIC_KEY_SIZE}-byte Ed25519 public key`);
374
+ }
375
+ if (!(await crypto.ed25519Verify(enclaveKey, payload, signature))) {
376
+ const keyId = "dp_k_" + toHex(await crypto.sha256(enclaveKey));
377
+ throw new errors_js_1.VerificationError(`the ${what} is not signed by enclave key ${keyId}. Do not use it: a relay that ` +
378
+ "forged or altered one would produce exactly this.");
379
+ }
380
+ }
381
+ /**
382
+ * Verify the enclave's signature on a key enrolment statement (the `enrollment`
383
+ * object ENROLL_KEY and ROTATE_KEY return). Also refuses a statement whose
384
+ * `customer_key_id` is not the id its own group derives, as Go's payload
385
+ * builder does -- so a statement that verifies names exactly its members and
386
+ * threshold, and comparing its key id with yours compares those too.
387
+ */
388
+ async function verifyKeyEnrollmentStatement(crypto, statement, enclaveKey) {
389
+ const what = "enrollment";
390
+ const doc = docObject(statement, what);
391
+ const rawGroup = docObject(doc.group, `${what}.group`);
392
+ if (!Array.isArray(rawGroup.members))
393
+ throw new errors_js_1.VerificationError(`${what}.group.members is not an array`);
394
+ const group = {
395
+ threshold: rawGroup.threshold,
396
+ members: rawGroup.members.map((m, i) => base64Bytes(m, `${what}.group.members[${i}]`)),
397
+ };
398
+ let derived;
399
+ try {
400
+ derived = await customerKeyId(crypto, group);
401
+ }
402
+ catch (err) {
403
+ if (err instanceof InvalidKeyGroupError)
404
+ throw new errors_js_1.VerificationError(`${what}.group: ${err.message}`);
405
+ throw err;
406
+ }
407
+ const keyId = docKeyId(doc, what);
408
+ if (keyId !== derived) {
409
+ throw new errors_js_1.VerificationError(`${what}.customer_key_id ${keyId} is not the id its own group derives (${derived})`);
410
+ }
411
+ const payload = (0, verify_js_1.canonicalJson)({
412
+ asserted_team_id: docUuid(doc, what, "asserted_team_id"),
413
+ customer_key_id: keyId,
414
+ enclave_pcr0: docString(doc, what, "enclave_pcr0"),
415
+ enrolled_at: (0, verify_js_1.formatTimestamp)(doc.enrolled_at, `${what}.enrolled_at`),
416
+ member_key_ids: await memberFingerprints(crypto, group),
417
+ payload_type: PAYLOAD_TYPE_KEY_ENROLLMENT,
418
+ threshold: group.threshold,
419
+ });
420
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "enrollment statement");
421
+ }
422
+ /**
423
+ * Verify the enclave's signature on a team authorization (the `authorization`
424
+ * object ENROLL_KEY and ROTATE_KEY return). The signature only: whether it is
425
+ * in force now is a separate question, as in Go.
426
+ */
427
+ async function verifyTeamAuthorization(crypto, certificate, enclaveKey) {
428
+ const what = "authorization";
429
+ const doc = docObject(certificate, what);
430
+ const notBefore = (0, verify_js_1.formatTimestamp)(doc.not_before, `${what}.not_before`);
431
+ const notAfter = (0, verify_js_1.formatTimestamp)(doc.not_after, `${what}.not_after`);
432
+ // Go compares at full precision; the whole-second strings disagree with it
433
+ // only for a window shorter than a second, which no enclave issues.
434
+ if (notAfter <= notBefore)
435
+ throw new errors_js_1.VerificationError(`${what}.not_after is not after not_before`);
436
+ // prev_key_id is omitempty in Go: absent on a first enrolment, and absent
437
+ // from the signed payload too.
438
+ const prevKeyId = doc.prev_key_id == null ? "" : docString(doc, what, "prev_key_id");
439
+ const payload = (0, verify_js_1.canonicalJson)({
440
+ asserted_team_id: docUuid(doc, what, "asserted_team_id"),
441
+ customer_key_id: docKeyId(doc, what),
442
+ not_after: notAfter,
443
+ not_before: notBefore,
444
+ payload_type: PAYLOAD_TYPE_TEAM_AUTHORIZATION,
445
+ ...(prevKeyId === "" ? {} : { prev_key_id: prevKeyId }),
446
+ });
447
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "team authorization");
448
+ }
449
+ /** Verify the enclave's signature on a system registration (the
450
+ * `registration` object REGISTER_SYSTEM returns). */
451
+ async function verifySystemRegistration(crypto, certificate, enclaveKey) {
452
+ const what = "registration";
453
+ const doc = docObject(certificate, what);
454
+ const payload = (0, verify_js_1.canonicalJson)({
455
+ config_digest: toHex(docBytes(doc, what, "config_digest", 32)),
456
+ connector_type: docString(doc, what, "connector_type"),
457
+ customer_key_id: docKeyId(doc, what),
458
+ payload_type: PAYLOAD_TYPE_SYSTEM_REGISTRATION,
459
+ query_template_hash: toHex(docBytes(doc, what, "query_template_hash", 32)),
460
+ registered_at: (0, verify_js_1.formatTimestamp)(doc.registered_at, `${what}.registered_at`),
461
+ system_id: docUuid(doc, what, "system_id"),
462
+ });
463
+ await requireEnclaveSignature(crypto, enclaveKey, payload, docBytes(doc, what, "signature", 64), "system registration");
464
+ }
465
+ //# sourceMappingURL=customer-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-keys.js","sourceRoot":"","sources":["../../src/customer-keys.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;AAEH,2CAA6D;AAE7D,2CAAgD;AAEhD;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;GAIG;AACH,MAAM,+BAA+B,GAAG,kCAAkC,CAAC;AAE3E;;;GAGG;AACU,QAAA,iCAAiC,GAAG,oCAAoC,CAAC;AAEtF,+CAA+C;AAClC,QAAA,8BAA8B,GAAG,EAAE,CAAC;AAEjD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,2EAA2E;AAC3E,0BAAkC,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;;AAaD,SAAS,KAAK,CAAC,KAAiB;IAC9B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,sEAAsE;AAC/D,KAAK,4BACV,MAAiB,EACjB,SAAqB;IAErB,OAAO,KAAK,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,wEAAwE;AACjE,KAAK,2BACV,MAAiB,EACjB,KAAuB;IAEvB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK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