@bsv/dpp-core 0.3.0-beta.1

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 (86) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +95 -0
  3. package/dist/acceptance.d.ts +100 -0
  4. package/dist/acceptance.d.ts.map +1 -0
  5. package/dist/acceptance.js +202 -0
  6. package/dist/acceptance.js.map +1 -0
  7. package/dist/anchor.d.ts +66 -0
  8. package/dist/anchor.d.ts.map +1 -0
  9. package/dist/anchor.js +145 -0
  10. package/dist/anchor.js.map +1 -0
  11. package/dist/attestation.d.ts +40 -0
  12. package/dist/attestation.d.ts.map +1 -0
  13. package/dist/attestation.js +111 -0
  14. package/dist/attestation.js.map +1 -0
  15. package/dist/blob.d.ts +11 -0
  16. package/dist/blob.d.ts.map +1 -0
  17. package/dist/blob.js +16 -0
  18. package/dist/blob.js.map +1 -0
  19. package/dist/canonical.d.ts +32 -0
  20. package/dist/canonical.d.ts.map +1 -0
  21. package/dist/canonical.js +54 -0
  22. package/dist/canonical.js.map +1 -0
  23. package/dist/canonicalJson.d.ts +22 -0
  24. package/dist/canonicalJson.d.ts.map +1 -0
  25. package/dist/canonicalJson.js +60 -0
  26. package/dist/canonicalJson.js.map +1 -0
  27. package/dist/codec.d.ts +45 -0
  28. package/dist/codec.d.ts.map +1 -0
  29. package/dist/codec.js +459 -0
  30. package/dist/codec.js.map +1 -0
  31. package/dist/constants.d.ts +150 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/constants.js +179 -0
  34. package/dist/constants.js.map +1 -0
  35. package/dist/did.d.ts +37 -0
  36. package/dist/did.d.ts.map +1 -0
  37. package/dist/did.js +129 -0
  38. package/dist/did.js.map +1 -0
  39. package/dist/evidence.d.ts +224 -0
  40. package/dist/evidence.d.ts.map +1 -0
  41. package/dist/evidence.js +716 -0
  42. package/dist/evidence.js.map +1 -0
  43. package/dist/evidencePackage.d.ts +114 -0
  44. package/dist/evidencePackage.d.ts.map +1 -0
  45. package/dist/evidencePackage.js +164 -0
  46. package/dist/evidencePackage.js.map +1 -0
  47. package/dist/index.d.ts +31 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +31 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/owner.d.ts +135 -0
  52. package/dist/owner.d.ts.map +1 -0
  53. package/dist/owner.js +181 -0
  54. package/dist/owner.js.map +1 -0
  55. package/dist/publisherPolicy.d.ts +70 -0
  56. package/dist/publisherPolicy.d.ts.map +1 -0
  57. package/dist/publisherPolicy.js +186 -0
  58. package/dist/publisherPolicy.js.map +1 -0
  59. package/dist/signatures.d.ts +84 -0
  60. package/dist/signatures.d.ts.map +1 -0
  61. package/dist/signatures.js +137 -0
  62. package/dist/signatures.js.map +1 -0
  63. package/dist/transition.d.ts +29 -0
  64. package/dist/transition.d.ts.map +1 -0
  65. package/dist/transition.js +117 -0
  66. package/dist/transition.js.map +1 -0
  67. package/dist/types.d.ts +135 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +2 -0
  70. package/dist/types.js.map +1 -0
  71. package/dist/verifyChain.d.ts +152 -0
  72. package/dist/verifyChain.d.ts.map +1 -0
  73. package/dist/verifyChain.js +314 -0
  74. package/dist/verifyChain.js.map +1 -0
  75. package/package.json +46 -0
  76. package/schemas/capabilities.schema.json +129 -0
  77. package/schemas/epcis-import.schema.json +212 -0
  78. package/schemas/evidence-export.schema.json +67 -0
  79. package/schemas/evidence-package.schema.json +307 -0
  80. package/schemas/native-evidence-extension.schema.json +66 -0
  81. package/schemas/paginated-history.schema.json +32 -0
  82. package/schemas/passport-projection.schema.json +151 -0
  83. package/schemas/passport-source.schema.json +370 -0
  84. package/schemas/profile-evidence.schema.json +706 -0
  85. package/schemas/publisher-policy.schema.json +173 -0
  86. package/schemas/verification-report.schema.json +397 -0
package/dist/owner.js ADDED
@@ -0,0 +1,181 @@
1
+ import { BigNumber, Curve, PublicKey, Utils, } from '@bsv/sdk';
2
+ import { OWNER_LINKAGE_HEX, OWNER_LINKAGE_KEY, OWNER_LINKAGE_REVELATION_PROTOCOL_ID, OWNER_PROTOCOL_ID, } from './constants.js';
3
+ /**
4
+ * Field 6 as `spec/record-model.md` §3 recommends: the wallet's root derived under
5
+ * OWNER_PROTOCOL_ID with keyID = passport_id and counterparty 'self'.
6
+ */
7
+ export async function ownerKeyFor(passportId, wallet) {
8
+ const { publicKey } = await wallet.getPublicKey({
9
+ protocolID: OWNER_PROTOCOL_ID,
10
+ keyID: passportId,
11
+ counterparty: 'self',
12
+ });
13
+ return publicKey;
14
+ }
15
+ /** The same key straight from a key deriver (server-side custodians, tests). */
16
+ export function ownerKeyFromDeriver(passportId, deriver) {
17
+ return deriver.derivePublicKey(OWNER_PROTOCOL_ID, passportId, 'self').toString();
18
+ }
19
+ /**
20
+ * The BRC-69 specific key linkage of the owner key, as 64 lower-case hex: the
21
+ * scalar `s` with `ownerKey = identityKey + s·G`. From a deriver, for the side
22
+ * that holds the root outright.
23
+ */
24
+ export function ownerLinkageFromDeriver(passportId, deriver) {
25
+ return Utils.toHex(deriver.revealSpecificSecret('self', OWNER_PROTOCOL_ID, passportId));
26
+ }
27
+ /**
28
+ * The BRC-100 path to the scalar: the owner's wallet reveals the linkage of its
29
+ * own owner key for this passport, encrypted to `verifierIdentityKey`. The
30
+ * counterparty is the wallet's own identity key, which is what 'self' means and
31
+ * is the spelling the BRC-100 wire accepts.
32
+ */
33
+ export async function revealOwnerLinkage(passportId, wallet, verifierIdentityKey) {
34
+ const { publicKey: identityKey } = await wallet.getPublicKey({ identityKey: true });
35
+ return await wallet.revealSpecificKeyLinkage({
36
+ counterparty: identityKey,
37
+ verifier: verifierIdentityKey,
38
+ protocolID: OWNER_PROTOCOL_ID,
39
+ keyID: passportId,
40
+ });
41
+ }
42
+ /**
43
+ * The verifier's side of `revealOwnerLinkage`: the scalar as 64 lower-case hex,
44
+ * ready to carry in event_data. The writing application does this once and then
45
+ * publishes the scalar in the clear, because on chain the verifier is everyone.
46
+ */
47
+ export async function decryptOwnerLinkage(revelation, wallet) {
48
+ const { plaintext } = await wallet.decrypt({
49
+ ciphertext: revelation.encryptedLinkage,
50
+ protocolID: OWNER_LINKAGE_REVELATION_PROTOCOL_ID,
51
+ keyID: revelation.keyID,
52
+ counterparty: revelation.prover,
53
+ });
54
+ if (plaintext.length !== 32) {
55
+ throw new Error(`owner linkage must decrypt to 32 bytes, got ${plaintext.length}`);
56
+ }
57
+ return Utils.toHex(plaintext);
58
+ }
59
+ /**
60
+ * `previousOwnerKey == actorIdentityKey + s·G`, mirroring PublicKey.deriveChild
61
+ * exactly: the scalar is the HMAC bytes read big-endian, and Point.mul reduces it
62
+ * modulo the curve order as derivation itself does. Pure, never throws: a key
63
+ * that does not parse is a false, not an exception, because the caller has a
64
+ * reason string to return and this function has none to add.
65
+ */
66
+ export function verifyOwnerLinkage(actorIdentityKeyHex, previousOwnerKeyHex, linkageHex) {
67
+ if (!OWNER_LINKAGE_HEX.test(linkageHex))
68
+ return false;
69
+ try {
70
+ const actor = PublicKey.fromString(actorIdentityKeyHex);
71
+ if (actor.toString() !== actorIdentityKeyHex)
72
+ return false;
73
+ const s = new BigNumber(Utils.toArray(linkageHex, 'hex'));
74
+ const child = new PublicKey(actor.add(new Curve().g.mul(s)));
75
+ return child.toString() === previousOwnerKeyHex;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
81
+ /** The three refusals of `spec/custody.md` §4, verbatim; fixtures pin these strings. */
82
+ export const OWNER_CONSENT_REFUSALS = {
83
+ noLinkage: 'TRANSFER actor is not the previous owner and event_data carries no owner_linkage',
84
+ malformedLinkage: 'owner_linkage must be 64 lower-case hex characters',
85
+ notLinked: 'owner_linkage does not link actor_identity_key to the previous owner_identity_key',
86
+ };
87
+ /** Absent (undefined) when event_data is empty, not JSON, not an object, or lacks the property. */
88
+ function readOwnerLinkage(eventData) {
89
+ if (eventData === '')
90
+ return undefined;
91
+ let parsed;
92
+ try {
93
+ parsed = JSON.parse(eventData);
94
+ }
95
+ catch {
96
+ return undefined;
97
+ }
98
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
99
+ return undefined;
100
+ if (!Object.hasOwn(parsed, OWNER_LINKAGE_KEY))
101
+ return undefined;
102
+ return parsed[OWNER_LINKAGE_KEY];
103
+ }
104
+ /**
105
+ * The owner-signed transfer (`spec/custody.md` §4). Returns null when the state
106
+ * passes or the predicate does not apply (not a TRANSFER), otherwise the reason
107
+ * a conforming reader reports. `authorities` are the profile's transfer
108
+ * authorities, already canonical (see `normaliseTransferAuthorities`).
109
+ */
110
+ export function checkOwnerConsent(prev, next, authorities = []) {
111
+ if (next.op !== 'TRANSFER')
112
+ return null;
113
+ if (next.actorIdentityKey === prev.ownerIdentityKey)
114
+ return null;
115
+ if (authorities.includes(next.actorIdentityKey))
116
+ return null;
117
+ const linkage = readOwnerLinkage(next.eventData);
118
+ if (linkage === undefined)
119
+ return OWNER_CONSENT_REFUSALS.noLinkage;
120
+ if (typeof linkage !== 'string' || !OWNER_LINKAGE_HEX.test(linkage)) {
121
+ return OWNER_CONSENT_REFUSALS.malformedLinkage;
122
+ }
123
+ if (!verifyOwnerLinkage(next.actorIdentityKey, prev.ownerIdentityKey, linkage)) {
124
+ return OWNER_CONSENT_REFUSALS.notLinked;
125
+ }
126
+ return null;
127
+ }
128
+ /**
129
+ * Transfer authorities as the predicate compares them: canonical compressed
130
+ * lower-case hex, the spelling fields 6 and 7 carry. Upper-case input is
131
+ * accepted and normalised; anything that is not a valid compressed key throws,
132
+ * because a misconfigured authority must fail at boot, not silently never match.
133
+ */
134
+ export function normaliseTransferAuthorities(keys) {
135
+ return keys.map((key) => {
136
+ let parsed;
137
+ try {
138
+ parsed = PublicKey.fromString(key);
139
+ }
140
+ catch {
141
+ throw new Error(`transfer authority is not a valid public key: ${key}`);
142
+ }
143
+ const canonical = parsed.toString();
144
+ if (canonical !== key.toLowerCase()) {
145
+ throw new Error(`transfer authority is not a canonical compressed public key: ${key}`);
146
+ }
147
+ return canonical;
148
+ });
149
+ }
150
+ /** The three refusals of `spec/record-model-v2.md` §6 (control), verbatim; fixtures pin these strings. */
151
+ export const CONTROL_REFUSALS = {
152
+ notProven: 'the actor is not the controller and control_linkage is empty',
153
+ redundantLinkage: 'control_linkage must be empty when the actor is the controller or a named authority',
154
+ notLinked: 'control_linkage does not link actor_identity_key to the previous controller_key',
155
+ };
156
+ /**
157
+ * The control proof of a version 2 UPDATE, TRANSFER or RETIRE
158
+ * (`spec/record-model-v2.md` §6): the actor is the previous controller by
159
+ * equality (field 7 equals the previous field 6), or a named authority, or
160
+ * proves it by linkage (field 14 is the scalar with previous field 6 equal to
161
+ * field 7 plus the scalar times G). Evaluated in that order, and the linkage
162
+ * field has one accepted state under each branch: empty under equality and
163
+ * under an authority, the scalar otherwise. Returns null when the state
164
+ * passes or the rule does not apply (an ISSUE), otherwise the reason.
165
+ */
166
+ export function checkControl(prev, next, authorities = []) {
167
+ if (next.op === 'ISSUE')
168
+ return null;
169
+ const controller = next.actorIdentityKey === prev.ownerIdentityKey;
170
+ const authority = !controller && authorities.includes(next.actorIdentityKey);
171
+ if (controller || authority) {
172
+ return next.controlLinkage === '' ? null : CONTROL_REFUSALS.redundantLinkage;
173
+ }
174
+ if (next.controlLinkage === '')
175
+ return CONTROL_REFUSALS.notProven;
176
+ if (!verifyOwnerLinkage(next.actorIdentityKey, prev.ownerIdentityKey, next.controlLinkage)) {
177
+ return CONTROL_REFUSALS.notLinked;
178
+ }
179
+ return null;
180
+ }
181
+ //# sourceMappingURL=owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner.js","sourceRoot":"","sources":["../src/owner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,GAIN,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oCAAoC,EACpC,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AAo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,CAAC,CAAC,CAAC,gBAAgB,CAAC,gBAAgB,CAAA;IAC9E,CAAC;IACD,IAAI,IAAI,CAAC,cAAc,KAAK,EAAE;QAAE,OAAO,gBAAgB,CAAC,SAAS,CAAA;IACjE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QAC3F,OAAO,gBAAgB,CAAC,SAAS,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,70 @@
1
+ export declare const PUBLISHER_POLICY_FORMAT = "dpp-publisher-policy@1";
2
+ export type PublisherRole = 'state-publisher' | 'anchor-publisher';
3
+ export type PolicyOperatorProfile = 'single-operator@1' | 'federated-operators@1';
4
+ export interface PublisherEntry {
5
+ /** Compressed public key, hex. */
6
+ key: string;
7
+ role: PublisherRole;
8
+ operator?: string;
9
+ activeFrom: string;
10
+ retiredAt?: string;
11
+ custody?: string;
12
+ }
13
+ export interface PolicyAuthorisation {
14
+ kind: 'genesis' | 'rotation' | 'handover';
15
+ signer: string;
16
+ suite: 'bsv-ecdsa-der';
17
+ value: string;
18
+ countersigner?: string;
19
+ countersignature?: string;
20
+ }
21
+ export interface PublisherPolicy {
22
+ policyFormat: typeof PUBLISHER_POLICY_FORMAT;
23
+ policyVersion: number;
24
+ scope: {
25
+ operatorProfile: PolicyOperatorProfile;
26
+ operators: string[];
27
+ topics?: string[];
28
+ };
29
+ issuedAt: string;
30
+ supersedes?: {
31
+ policyVersion: number;
32
+ sha256: string;
33
+ };
34
+ publishers: PublisherEntry[];
35
+ authorisation: PolicyAuthorisation;
36
+ notes?: string;
37
+ }
38
+ export type PolicyFailureReason = 'format' | 'version-order' | 'time-order' | 'entry-invalid' | 'supersedes-missing' | 'supersedes-mismatch' | 'genesis-signer-not-operator' | 'signer-not-active' | 'signature-invalid' | 'countersignature-missing' | 'countersignature-invalid' | 'countersigner-not-eligible' | 'scope-mismatch';
39
+ export interface PolicyFailure {
40
+ version: number;
41
+ reason: PolicyFailureReason;
42
+ detail: string;
43
+ }
44
+ export interface PolicyChainResult {
45
+ ok: boolean;
46
+ versions: number[];
47
+ failure?: PolicyFailure;
48
+ }
49
+ /** The bytes an authorisation signs: the policy without its signature values, in canonical JSON, UTF-8. */
50
+ export declare function policySigningPreimage(policy: PublisherPolicy): number[];
51
+ /** The digest a later version names in `supersedes.sha256`: the complete policy, signatures included, in canonical JSON. */
52
+ export declare function policyDigest(policy: PublisherPolicy): string;
53
+ /**
54
+ * Verify a chain of policy versions for one scope, oldest first. The result
55
+ * names the first version that fails and why; nothing after it is trusted.
56
+ *
57
+ * `operatorIdentityKeys` maps each operator identifier to its compressed
58
+ * identity key, from the reader's own configuration or a resolved DID
59
+ * document, never from the policy itself.
60
+ */
61
+ export declare function verifyPolicyChain(chain: PublisherPolicy[], operatorIdentityKeys: Record<string, string>): PolicyChainResult;
62
+ /** The policy version in force at an instant: the newest issued at or before it. */
63
+ export declare function policyInForceAt(chain: PublisherPolicy[], at: string | Date): PublisherPolicy | undefined;
64
+ /**
65
+ * The publisher keys a state or anchor of the given instant may be
66
+ * countersigned by, from a chain `verifyPolicyChain` has accepted. A key
67
+ * not yet active, or already retired, at that instant is not among them.
68
+ */
69
+ export declare function publisherKeysAt(chain: PublisherPolicy[], at: string | Date, role?: PublisherRole): string[];
70
+ //# sourceMappingURL=publisherPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherPolicy.d.ts","sourceRoot":"","sources":["../src/publisherPolicy.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,uBAAuB,2BAA2B,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClE,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,GAAG,uBAAuB,CAAA;AAEjF,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,GAAG,EAAE,MAAM,C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CAAE;AAC/F,MAAM,WAAW,iBAAiB;IAAG,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,aAAa,CAAA;CAAE;AAQ/F,2GAA2G;AAC3G,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE,CAGvE;AAED,4HAA4H;AAC5H,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAE5D;AAmDD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,iBAAiB,CA4C3H;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,eAAe,GAAG,SAAS,CAKxG;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAK3G"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * The publisher key policy (`spec/services.md` §1, `contracts/publisher-policy.schema.json`).
3
+ *
4
+ * The keys that countersign admitted states and anchors are a bounded,
5
+ * versioned set. Each version is a complete statement; a later version names
6
+ * the digest of the one it supersedes and carries an authorisation the
7
+ * superseded version's rules accept. A reader asks which keys were active at
8
+ * a state's time, so a retired key still authenticates what it signed while
9
+ * active and a new key authenticates nothing before its activation.
10
+ *
11
+ * `verifyPolicyChain` checks a chain once; `publisherKeysAt` then answers the
12
+ * time question from the verified chain. Neither trusts a list because a node
13
+ * served it: the chain's own signatures and digests are what is checked.
14
+ *
15
+ * A policy nests objects and arrays, so it uses the canonical JSON of
16
+ * canonicalJson.ts rather than the flat restricted form of native claims.
17
+ */
18
+ import { Hash, PublicKey, Signature, Utils } from '@bsv/sdk';
19
+ import { canonicalJson, CanonicalJsonError } from './canonicalJson.js';
20
+ export const PUBLISHER_POLICY_FORMAT = 'dpp-publisher-policy@1';
21
+ const KEY = /^0[23][0-9a-f]{64}$/;
22
+ const TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
23
+ const instant = (value) => Date.parse(value);
24
+ /** A well-formed instant that also exists: the grammar alone lets 2026-13-45T25:61:61Z through as NaN, and every NaN comparison is false. */
25
+ const realInstant = (value) => TIME.test(value) && Number.isFinite(Date.parse(value));
26
+ /** The bytes an authorisation signs: the policy without its signature values, in canonical JSON, UTF-8. */
27
+ export function policySigningPreimage(policy) {
28
+ const { value: _value, countersignature: _counter, ...authorisation } = policy.authorisation;
29
+ return Utils.toArray(canonicalJson({ ...policy, authorisation }), 'utf8');
30
+ }
31
+ /** The digest a later version names in `supersedes.sha256`: the complete policy, signatures included, in canonical JSON. */
32
+ export function policyDigest(policy) {
33
+ return Utils.toHex(Hash.sha256(Utils.toArray(canonicalJson(policy), 'utf8')));
34
+ }
35
+ function verifySignature(signer, preimage, der) {
36
+ try {
37
+ return PublicKey.fromString(signer).verify(preimage, Signature.fromDER(Utils.toArray(der, 'hex')));
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ function entryActiveAt(entry, at) {
44
+ return instant(entry.activeFrom) <= at && (entry.retiredAt == null || at < instant(entry.retiredAt));
45
+ }
46
+ /** Which operator a key speaks for under a policy: the operator whose identity key it is, else the operator its publisher entry names. */
47
+ function operatorOf(policy, key, identityKeys) {
48
+ const byIdentity = policy.scope.operators.find((op) => identityKeys[op] === key);
49
+ if (byIdentity != null)
50
+ return byIdentity;
51
+ const entry = policy.publishers.find((p) => p.key === key);
52
+ return entry?.operator ?? (policy.scope.operators.length === 1 ? policy.scope.operators[0] : undefined);
53
+ }
54
+ function shapeFailure(policy, previous) {
55
+ const version = policy.policyVersion;
56
+ if (policy.policyFormat !== PUBLISHER_POLICY_FORMAT)
57
+ return { version, reason: 'format', detail: `policyFormat is ${String(policy.policyFormat)}` };
58
+ if (!Number.isInteger(version) || version < 1)
59
+ return { version, reason: 'format', detail: 'policyVersion must be a positive integer' };
60
+ if (!realInstant(policy.issuedAt))
61
+ return { version, reason: 'format', detail: 'issuedAt must be a real instant in UTC' };
62
+ if (!Array.isArray(policy.scope?.operators) || policy.scope.operators.length === 0 || policy.scope.operators.length > 64 || new Set(policy.scope.operators).size !== policy.scope.operators.length)
63
+ return { version, reason: 'format', detail: 'scope.operators must name one to sixty-four distinct operators' };
64
+ if (policy.authorisation?.suite !== 'bsv-ecdsa-der' || !KEY.test(policy.authorisation.signer ?? ''))
65
+ return { version, reason: 'format', detail: 'authorisation needs the bsv-ecdsa-der suite and a compressed signer key' };
66
+ if (!Array.isArray(policy.publishers) || policy.publishers.length === 0 || policy.publishers.length > 256)
67
+ return { version, reason: 'entry-invalid', detail: 'publishers must hold one to 256 entries' };
68
+ for (const entry of policy.publishers) {
69
+ if (!KEY.test(entry.key))
70
+ return { version, reason: 'entry-invalid', detail: `publisher key ${String(entry.key)} is not a compressed key` };
71
+ if (entry.role !== 'state-publisher' && entry.role !== 'anchor-publisher')
72
+ return { version, reason: 'entry-invalid', detail: `publisher ${entry.key} has role ${String(entry.role)}` };
73
+ if (!realInstant(entry.activeFrom) || (entry.retiredAt != null && !realInstant(entry.retiredAt)))
74
+ return { version, reason: 'entry-invalid', detail: `publisher ${entry.key} has a malformed or unreal time` };
75
+ if (entry.retiredAt != null && instant(entry.retiredAt) <= instant(entry.activeFrom))
76
+ return { version, reason: 'entry-invalid', detail: `publisher ${entry.key} retires before it activates` };
77
+ if (entry.operator != null && !policy.scope.operators.includes(entry.operator))
78
+ return { version, reason: 'entry-invalid', detail: `publisher ${entry.key} names an operator outside the scope` };
79
+ if (policy.scope.operators.length > 1 && entry.operator == null)
80
+ return { version, reason: 'entry-invalid', detail: `publisher ${entry.key} must name its operator in a federated scope` };
81
+ }
82
+ if (previous == null) {
83
+ if (policy.authorisation.kind !== 'genesis')
84
+ return { version, reason: 'version-order', detail: 'the first version of a scope must be a genesis authorisation' };
85
+ if (policy.supersedes != null)
86
+ return { version, reason: 'supersedes-mismatch', detail: 'a genesis version supersedes nothing' };
87
+ }
88
+ else {
89
+ if (policy.authorisation.kind === 'genesis')
90
+ return { version, reason: 'version-order', detail: 'only the first version of a scope is a genesis' };
91
+ if (version <= previous.policyVersion)
92
+ return { version, reason: 'version-order', detail: `version ${version} does not follow ${previous.policyVersion}` };
93
+ if (instant(policy.issuedAt) <= instant(previous.issuedAt))
94
+ return { version, reason: 'time-order', detail: 'a later version must be issued after the one it supersedes' };
95
+ if (policy.supersedes == null)
96
+ return { version, reason: 'supersedes-missing', detail: 'a later version must name the version it supersedes and its digest' };
97
+ if (policy.supersedes.policyVersion !== previous.policyVersion || policy.supersedes.sha256 !== policyDigest(previous))
98
+ return { version, reason: 'supersedes-mismatch', detail: 'supersedes does not name the previous version and its digest' };
99
+ }
100
+ return undefined;
101
+ }
102
+ /**
103
+ * Verify a chain of policy versions for one scope, oldest first. The result
104
+ * names the first version that fails and why; nothing after it is trusted.
105
+ *
106
+ * `operatorIdentityKeys` maps each operator identifier to its compressed
107
+ * identity key, from the reader's own configuration or a resolved DID
108
+ * document, never from the policy itself.
109
+ */
110
+ export function verifyPolicyChain(chain, operatorIdentityKeys) {
111
+ const versions = [];
112
+ if (chain.length === 0)
113
+ return { ok: false, versions, failure: { version: 0, reason: 'format', detail: 'an empty chain authorises no key' } };
114
+ let previous;
115
+ for (const policy of chain) {
116
+ const failure = shapeFailure(policy, previous);
117
+ if (failure != null)
118
+ return { ok: false, versions, failure };
119
+ const version = policy.policyVersion;
120
+ let preimage;
121
+ try {
122
+ preimage = policySigningPreimage(policy);
123
+ }
124
+ catch (error) {
125
+ return { ok: false, versions, failure: { version, reason: 'format', detail: error instanceof CanonicalJsonError ? error.message : 'the policy has no canonical form' } };
126
+ }
127
+ const { signer, value, kind, countersigner, countersignature } = policy.authorisation;
128
+ if (!verifySignature(signer, preimage, value))
129
+ return { ok: false, versions, failure: { version, reason: 'signature-invalid', detail: `the authorisation does not verify under ${signer}` } };
130
+ if (previous == null) {
131
+ if (!policy.scope.operators.some((op) => operatorIdentityKeys[op] === signer)) {
132
+ return { ok: false, versions, failure: { version, reason: 'genesis-signer-not-operator', detail: 'a genesis is signed by the identity key of an operator in its scope' } };
133
+ }
134
+ }
135
+ else {
136
+ const issued = instant(policy.issuedAt);
137
+ const activeUnderPrevious = previous.publishers.some((p) => p.key === signer && entryActiveAt(p, issued)) || previous.scope.operators.some((op) => operatorIdentityKeys[op] === signer);
138
+ if (!activeUnderPrevious)
139
+ return { ok: false, versions, failure: { version, reason: 'signer-not-active', detail: 'the signer was not active under the superseded version at issue time' } };
140
+ const same = previous.scope.operators.length === policy.scope.operators.length && previous.scope.operators.every((op) => policy.scope.operators.includes(op));
141
+ if (kind === 'rotation' && !same)
142
+ return { ok: false, versions, failure: { version, reason: 'scope-mismatch', detail: 'a rotation keeps the operator set; a changed set is a handover' } };
143
+ if (kind === 'handover' && same)
144
+ return { ok: false, versions, failure: { version, reason: 'scope-mismatch', detail: 'a handover changes the operator set; an unchanged set is a rotation' } };
145
+ const signerOperator = operatorOf(previous, signer, operatorIdentityKeys);
146
+ const needsCounter = kind === 'handover' || previous.scope.operators.length > 1;
147
+ if (needsCounter) {
148
+ if (countersigner == null || countersignature == null)
149
+ return { ok: false, versions, failure: { version, reason: 'countersignature-missing', detail: kind === 'handover' ? 'a handover is countersigned by an incoming operator' : 'no operator of a federation authorises a key alone' } };
150
+ const incoming = policy.scope.operators.filter((op) => !previous.scope.operators.includes(op));
151
+ const eligible = kind === 'handover'
152
+ ? incoming.some((op) => operatorIdentityKeys[op] === countersigner)
153
+ : previous.scope.operators.some((op) => op !== signerOperator && operatorIdentityKeys[op] === countersigner);
154
+ if (!eligible)
155
+ return { ok: false, versions, failure: { version, reason: 'countersigner-not-eligible', detail: kind === 'handover' ? 'the countersigner is not the identity key of an incoming operator' : 'the countersigner is not another operator of the federation' } };
156
+ if (!verifySignature(countersigner, preimage, countersignature))
157
+ return { ok: false, versions, failure: { version, reason: 'countersignature-invalid', detail: `the countersignature does not verify under ${countersigner}` } };
158
+ }
159
+ }
160
+ versions.push(version);
161
+ previous = policy;
162
+ }
163
+ return { ok: true, versions };
164
+ }
165
+ /** The policy version in force at an instant: the newest issued at or before it. */
166
+ export function policyInForceAt(chain, at) {
167
+ const t = typeof at === 'string' ? instant(at) : at.getTime();
168
+ let inForce;
169
+ for (const policy of chain)
170
+ if (instant(policy.issuedAt) <= t && (inForce == null || policy.policyVersion > inForce.policyVersion))
171
+ inForce = policy;
172
+ return inForce;
173
+ }
174
+ /**
175
+ * The publisher keys a state or anchor of the given instant may be
176
+ * countersigned by, from a chain `verifyPolicyChain` has accepted. A key
177
+ * not yet active, or already retired, at that instant is not among them.
178
+ */
179
+ export function publisherKeysAt(chain, at, role) {
180
+ const policy = policyInForceAt(chain, at);
181
+ if (policy == null)
182
+ return [];
183
+ const t = typeof at === 'string' ? instant(at) : at.getTime();
184
+ return [...new Set(policy.publishers.filter((p) => (role == null || p.role === role) && entryActiveAt(p, t)).map((p) => p.key))];
185
+ }
186
+ //# sourceMappingURL=publisherPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherPolicy.js","sourceRoot":"","sources":["../src/publisherPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAA;AAoD/D,MAAM,GAAG,GAAG,qBAAqB,CAAA;AACjC,MAAM,IAAI,GAAG,gDAAgD,CAAA;AAC7D,MAAM,OA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AAa,GAAG,OAAO,CAAC,aAAa,CAAC;YAAE,OAAO,GAAG,MAAM,CAAA;IACpJ,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB,EAAE,EAAiB,EAAE,IAAoB;IAC/F,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACzC,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,EAAE,CAAA;IAC7B,MAAM,CAAC,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAA;IAC7D,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAClI,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { type WalletProtocol } from '@bsv/sdk';
2
+ import type { AnyDppStateData, DppState, DppStateData, DppStateDataV2 } from './types.js';
3
+ /**
4
+ * Canonical version 1 user-signature preimage (`spec/record-model.md` §5): the
5
+ * concatenated raw bytes of fields 1–12 in standard order - never a JSON
6
+ * serialization.
7
+ *
8
+ * Framing note: §5 mandates plain concatenation, so the preimage bytes alone
9
+ * do not bind field boundaries. Boundary uniqueness comes from field
10
+ * validation (op enum, ISO timestamp, fixed-width keys/hashes, JSON rules)
11
+ * plus the chain invariants (genesis must be ACTIVATE, spend linkage,
12
+ * passport_id immutability), which together block re-split states from
13
+ * verifying in any spec-sanctioned consumer. Version 2 replaces this with a
14
+ * framed, domain-tagged preimage (`actorPreimageV2`); version 1 keeps it
15
+ * because a published state keeps the contract it was signed under.
16
+ */
17
+ export declare function userPreimageV1(d: DppStateData): number[];
18
+ /** Canonical version 1 server-signature preimage: fields 1–13 (user preimage + user_signature). */
19
+ export declare function serverPreimageV1(d: DppStateData, userSignature: number[]): number[];
20
+ /**
21
+ * Length framing (`spec/record-model-v2.md` §5): each item as its Bitcoin
22
+ * VarInt byte length followed by its bytes, in order. The same framing the
23
+ * anchor rail uses (`spec/rules.md` §5), so one rule serves both.
24
+ */
25
+ export declare function frameFields(items: number[][]): number[];
26
+ /**
27
+ * The version 2 actor preimage: the actor tag, then fields 1–15, every item
28
+ * length-framed. Two field tuples that differ anywhere produce different
29
+ * bytes, and the tag keeps a signature made for the publisher role, or for
30
+ * version 1, from verifying here.
31
+ */
32
+ export declare function actorPreimageV2(d: DppStateDataV2): number[];
33
+ /** The version 2 publisher preimage: the publisher tag, fields 1–15 and the actor signature, every item length-framed. */
34
+ export declare function publisherPreimageV2(d: DppStateDataV2, actorSignature: number[]): number[];
35
+ /** The actor's preimage under the version the data declares: version 1 unframed, version 2 framed and tagged. */
36
+ export declare function userPreimage(d: AnyDppStateData): number[];
37
+ /** The publisher's preimage under the version the data declares. */
38
+ export declare function serverPreimage(d: AnyDppStateData, userSignature: number[]): number[];
39
+ /** The BRC-43 protocol both signatures of a state derive under: one per version, so keys never cross. */
40
+ export declare function protocolIdFor(d: object): WalletProtocol;
41
+ /**
42
+ * The signing capability dpp-core needs: satisfied by @bsv/sdk ProtoWallet
43
+ * (backend, holds a root key) and by a BRC-100 WalletClient (connected path).
44
+ * createSignature signs ECDSA over sha256(data) with the BRC-42 child key for
45
+ * (protocolID, keyID, counterparty).
46
+ */
47
+ export interface DataSigner {
48
+ createSignature: (args: {
49
+ data: number[];
50
+ protocolID: WalletProtocol;
51
+ keyID: string;
52
+ counterparty: string;
53
+ }) => Promise<{
54
+ signature: number[];
55
+ }>;
56
+ }
57
+ /**
58
+ * Create the actor signature (field 13 in version 1, field 16 in version 2):
59
+ * the actor signs the version's actor preimage with the child key for
60
+ * (the version's protocol, actor_keyID, counterparty 'anyone').
61
+ */
62
+ export declare function createUserSignature(d: AnyDppStateData, actorWallet: DataSigner): Promise<number[]>;
63
+ /**
64
+ * Create the publisher signature (field 14 in version 1, field 17 in version
65
+ * 2): the service signs the version's publisher preimage with the child key
66
+ * for (the version's protocol, keyID = passport_id, counterparty 'anyone').
67
+ * keyID is pinned to passport_id so verifiers can re-derive the service child
68
+ * key from on-chain data plus the published service identity key (§5).
69
+ */
70
+ export declare function createServerSignature(d: AnyDppStateData, userSignature: number[], serverWallet: DataSigner): Promise<number[]>;
71
+ /** Sign the actor and publisher preimages and assemble the complete state of the version the data declares. */
72
+ export declare function completeState(d: AnyDppStateData, actorWallet: DataSigner, serverWallet: DataSigner): Promise<DppState>;
73
+ /**
74
+ * Verify the actor signature against actor_identity_key + actor_keyID (§5;
75
+ * §8 check 1), under the version the state carries. Open verification: the
76
+ * key is derived with counterparty 'anyone', so no wallet or secret is needed.
77
+ */
78
+ export declare function verifyUserSignature(state: DppState): boolean;
79
+ /**
80
+ * Verify the publisher signature against a configured service identity key.
81
+ * Admission policy, not token validity (§5).
82
+ */
83
+ export declare function verifyServerSignature(state: DppState, serverIdentityKey: string): boolean;
84
+ //# sourceMappingURL=signatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../src/signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,UAAU,CAAA;AAUlF,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEzF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAExD;AAED,mGAAmG;AACnG,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,aAAa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