@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
@@ -0,0 +1,179 @@
1
+ /**
2
+ * DPP Token Standard v1 - constants (`spec/record-model.md` §2-§3).
3
+ *
4
+ * Encoding decisions pinned by this reference implementation (the standard
5
+ * fixes field order and semantics; byte encodings are pinned here):
6
+ * - protocol_marker: UTF-8 "dpp"
7
+ * - version: UTF-8 "1"
8
+ * - passport_id, op, timestamp, actor_keyID, event_data, payload_public: UTF-8
9
+ * - owner_identity_key, actor_identity_key: 33-byte compressed public key (raw)
10
+ * - payload_owner_hash: 32-byte SHA-256 digest (raw). Zero-length when absent
11
+ * - previous_txid: 32-byte txid, big-endian display order (raw). Zero-length at genesis
12
+ * - user_signature, server_signature: DER-encoded ECDSA signature
13
+ *
14
+ * Zero-length fields are encoded as OP_0. Within the standard's value domain
15
+ * this is unambiguous: no field may legitimately be the single byte 0x00.
16
+ */
17
+ export const PROTOCOL_MARKER = 'dpp';
18
+ export const STANDARD_VERSION = '1';
19
+ /**
20
+ * BRC-43 protocol ID under which both token signatures are created, always
21
+ * with counterparty 'anyone' so any third party can derive the verification
22
+ * key from on-chain data alone (§3 fields 7/8, §5).
23
+ * - user_signature: actor identity key + keyID = actor_keyID (field 8)
24
+ * - server_signature: service identity key + keyID = passport_id (field 3)
25
+ */
26
+ export const DPP_PROTOCOL_ID = [1, 'dpp token v1'];
27
+ /**
28
+ * BRC-43 protocol ID of the owner key (`spec/custody.md` §2, `spec/record-model.md`
29
+ * §3 field 6): field 6 SHOULD be the owner's root derived under this protocol
30
+ * with keyID = passport_id and counterparty 'self', one level, so a BRC-100
31
+ * wallet produces it with getPublicKey and spends a tip locked to it with the
32
+ * PushDrop unlock (`spec/custody.md` §3). 'self' is what makes holdings
33
+ * unlinkable: nobody but the root can compute or confirm the child.
34
+ */
35
+ export const OWNER_PROTOCOL_ID = [1, 'dpp owner v1'];
36
+ /**
37
+ * The event_data property a TRANSFER carries to prove, under the optional
38
+ * owner-signed transfer invariant (`spec/custody.md` §4), that the actor's root
39
+ * derived the previous owner key: the BRC-69 specific key linkage, 64 lower-case
40
+ * hex characters. Reserved on TRANSFER; meaningless elsewhere.
41
+ */
42
+ export const OWNER_LINKAGE_KEY = 'owner_linkage';
43
+ /** The one accepted spelling of the linkage scalar: one value, one spelling. */
44
+ export const OWNER_LINKAGE_HEX = /^[0-9a-f]{64}$/;
45
+ /**
46
+ * What a BRC-100 wallet encrypts the linkage under when it reveals it
47
+ * (revealSpecificKeyLinkage: `[2, 'specific linkage revelation <level> <name>']`
48
+ * of the target protocol, keyID = the target keyID, counterparty = the
49
+ * verifier). The verifier decrypts with the prover as counterparty.
50
+ */
51
+ export const OWNER_LINKAGE_REVELATION_PROTOCOL_ID = [
52
+ 2,
53
+ `specific linkage revelation ${OWNER_PROTOCOL_ID[0]} ${OWNER_PROTOCOL_ID[1]}`,
54
+ ];
55
+ /**
56
+ * Upper bounds on the two fields that are also BRC-42 key identifiers
57
+ * (`spec/record-model.md` §3, §5): passport_id keys the server signature,
58
+ * actor_keyID keys the user signature. A conforming wallet refuses a key
59
+ * identifier above 800 characters, so an unbounded field would be a valid
60
+ * record no wallet can sign; the standard bounds them tighter, in bytes of
61
+ * UTF-8, and matches the anchor's subject bound for passport_id.
62
+ */
63
+ export const MAX_PASSPORT_ID_BYTES = 512;
64
+ export const MAX_ACTOR_KEY_ID_BYTES = 256;
65
+ /** Total PushDrop fields per state (`spec/record-model.md` §3). */
66
+ export const FIELD_COUNT = 14;
67
+ /** Zero-based indices into the 14-field layout. */
68
+ export const Field = {
69
+ protocolMarker: 0,
70
+ version: 1,
71
+ passportId: 2,
72
+ op: 3,
73
+ timestamp: 4,
74
+ ownerIdentityKey: 5,
75
+ actorIdentityKey: 6,
76
+ actorKeyId: 7,
77
+ eventData: 8,
78
+ payloadPublic: 9,
79
+ payloadOwnerHash: 10,
80
+ previousTxid: 11,
81
+ userSignature: 12,
82
+ serverSignature: 13,
83
+ };
84
+ export const DPP_OPS = [
85
+ 'ACTIVATE',
86
+ 'SOLD',
87
+ 'RESOLD',
88
+ 'REPAIRED',
89
+ 'RECYCLED',
90
+ 'EDIT',
91
+ 'TRANSFER',
92
+ ];
93
+ /** Ops that may change payload_public / payload_owner_hash (§6 invariant 7). */
94
+ export const PAYLOAD_CHANGE_OPS = ['ACTIVATE', 'EDIT', 'TRANSFER'];
95
+ /** Ops on which event_data must be the empty string (§3 field 9). */
96
+ export const NO_EVENT_OPS = ['ACTIVATE', 'EDIT'];
97
+ /**
98
+ * JSON property inside payload_public carrying the data-carrier reference
99
+ * (chip UID). The lookup service indexes it alongside passport_id, as the
100
+ * `uid` query key in `contracts/overlay.yaml`.
101
+ */
102
+ export const PAYLOAD_DATA_CARRIER_KEY = 'dataCarrier';
103
+ /*
104
+ * DPP Token Standard version 2 (`spec/record-model-v2.md`). A second wire
105
+ * contract beside version 1, never a reinterpretation of it: a reader decodes
106
+ * each version under its own rules, and a version 1 state keeps the meaning
107
+ * it had when it was written. What version 2 adds is stated once here and
108
+ * enforced in the codec, the preimages and the transition rules.
109
+ *
110
+ * - Four operations: ISSUE, UPDATE, TRANSFER, RETIRE. Sector events live on
111
+ * the attestation rail, not in the token.
112
+ * - Seventeen fields: the fourteen of version 1 with the predecessor named as
113
+ * an outpoint, the lineage bound to its genesis outpoint, the control proof
114
+ * carried as its own field and a commitment to off-chain authorisation
115
+ * evidence.
116
+ * - Both signature preimages are length-framed and domain-tagged, so two
117
+ * different field tuples never share signed bytes and a signature made for
118
+ * one purpose or version never verifies for another.
119
+ * - Retirement is terminal under the DPP validity rules: no state may follow
120
+ * a RETIRE. The simple locking script does not make a later Bitcoin spend
121
+ * impossible; a reader refuses what such a spend would carry.
122
+ */
123
+ export const STANDARD_VERSION_V2 = '2';
124
+ /** The record versions a reader of this release decodes; any other value is refused by name. */
125
+ export const SUPPORTED_VERSIONS = ['1', '2'];
126
+ /**
127
+ * BRC-43 protocol ID of both version 2 record signatures, counterparty
128
+ * 'anyone' as in version 1. Distinct from `DPP_PROTOCOL_ID` so a key derived
129
+ * for one version signs nothing under the other.
130
+ */
131
+ export const DPP_PROTOCOL_ID_V2 = [1, 'dpp token v2'];
132
+ /** Total PushDrop fields per version 2 state. */
133
+ export const FIELD_COUNT_V2 = 17;
134
+ /** Zero-based indices into the seventeen-field layout. */
135
+ export const FieldV2 = {
136
+ protocolMarker: 0,
137
+ version: 1,
138
+ passportId: 2,
139
+ op: 3,
140
+ timestamp: 4,
141
+ controllerKey: 5,
142
+ actorIdentityKey: 6,
143
+ actorKeyId: 7,
144
+ eventData: 8,
145
+ payloadPublic: 9,
146
+ payloadOwnerHash: 10,
147
+ lineageGenesis: 11,
148
+ previousOutpoint: 12,
149
+ controlLinkage: 13,
150
+ authorisationCommitment: 14,
151
+ actorSignature: 15,
152
+ publisherSignature: 16,
153
+ };
154
+ export const DPP_OPS_V2 = ['ISSUE', 'UPDATE', 'TRANSFER', 'RETIRE'];
155
+ /** Version 2 ops that may change payload_public / payload_owner_hash. RETIRE changes neither. */
156
+ export const PAYLOAD_CHANGE_OPS_V2 = ['ISSUE', 'UPDATE', 'TRANSFER'];
157
+ /** Version 2 ops whose actor must prove control of the predecessor. */
158
+ export const CONTROL_PROOF_OPS_V2 = ['UPDATE', 'TRANSFER', 'RETIRE'];
159
+ /**
160
+ * The domain tags that open the two version 2 preimages. Each preimage is the
161
+ * tag, then every signed field, each as a Bitcoin VarInt length followed by
162
+ * its bytes (`spec/record-model-v2.md` §5), so the actor preimage and the
163
+ * publisher preimage of one state, and the preimages of any two states,
164
+ * never share bytes by accident.
165
+ */
166
+ export const RECORD_V2_ACTOR_TAG = 'dpp-record-v2/actor-signature';
167
+ export const RECORD_V2_PUBLISHER_TAG = 'dpp-record-v2/publisher-signature';
168
+ /**
169
+ * Byte bounds on the two JSON fields, in UTF-8 bytes (§3). Version 1 left
170
+ * them unbounded; version 2 keeps on-chain data intentional. A profile may
171
+ * bound them tighter, never wider.
172
+ */
173
+ export const MAX_EVENT_DATA_BYTES_V2 = 4096;
174
+ export const MAX_PAYLOAD_PUBLIC_BYTES_V2 = 65535;
175
+ /** An outpoint field: the 32-byte txid in display order, then the output index as four big-endian bytes. */
176
+ export const OUTPOINT_FIELD_BYTES = 36;
177
+ /** The custody profile Part B delivers: managed custody with explicit recipient acceptance (`spec/managed-custody.md`). */
178
+ export const MANAGED_CUSTODY_PROFILE = 'managed-custody@1';
179
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAA;AAEhD,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAmB;IAClE,CAAC;IACD,+BAA+B,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAAE;CAC9E,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAEzC,mEAAmE;AACnE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAA;AAE7B,mDAAmD;AACnD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,CAAC;IACb,EAAE,EAAE,CAAC;IACL,SAAS,EAAE,CAAC;IACZ,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,CAAC;IACnB,UAAU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AgB,EAAE,EAAE;IACpB,cAAc,EAAE,EAAE;IAClB,uBAAuB,EAAE,EAAE;IAC3B,cAAc,EAAE,EAAE;IAClB,kBAAkB,EAAE,EAAE;CACd,CAAA;AAEV,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAA;AAE5E,iGAAiG;AACjG,MAAM,CAAC,MAAM,qBAAqB,GAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;AAEvF,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAsB,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;AAEvF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,+BAA+B,CAAA;AAClE,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAA;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAA;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAA;AAEhD,4GAA4G;AAC5G,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAEtC,2HAA2H;AAC3H,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAA"}
package/dist/did.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { DppState } from './types.js';
2
+ /** Thrown when a string is not a DID this method can read. */
3
+ export declare class DidFormatError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /**
7
+ * A `did:key` for a 33-byte compressed secp256k1 identity key.
8
+ *
9
+ * Pure, offline and bidirectional: no registry, no network call, and the DID
10
+ * document is computable from the string alone. That is the property that makes
11
+ * this worth doing at all, because it means a verifier needs nothing from us
12
+ * except the key we already published on chain.
13
+ */
14
+ export declare function didKeyFromIdentityKey(identityKeyHex: string): string;
15
+ /**
16
+ * The identity key inside a `did:key`, or a refusal.
17
+ *
18
+ * Refuses another curve rather than returning bytes that would fail to verify
19
+ * later: an Ed25519 DID is a well-formed `did:key` and a meaningless secp256k1
20
+ * identity key, and the difference is two bytes at the front.
21
+ */
22
+ export declare function identityKeyFromDidKey(did: string): string;
23
+ /**
24
+ * The public key that actually signed a state's `user_signature`.
25
+ *
26
+ * The step `spec/identity.md` §2 names. `verifyUserSignature` derives exactly this and then
27
+ * throws it away inside a boolean; a verifier who wants to say *which key* signed,
28
+ * or to match a chain state against an SD-JWT's `iss`, needs it in the open.
29
+ *
30
+ * Counterparty `'anyone'`, so this runs with no wallet and no secret, which is the
31
+ * whole reason the standard chose that counterparty for both signatures
32
+ * (`spec/record-model.md` §3 fields 7/8, §5).
33
+ */
34
+ export declare function signingPublicKeyFor(state: Pick<DppState, 'actorKeyId' | 'actorIdentityKey'>): string;
35
+ /** The `did:key` of the key that signed, as distinct from the actor it belongs to. */
36
+ export declare function signingDidFor(state: Pick<DppState, 'actorKeyId' | 'actorIdentityKey'>): string;
37
+ //# sourceMappingURL=did.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA4C1C,8DAA8D;AAC9D,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAsBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,MAAM,CAIpG;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,MAAM,CAE9F"}
package/dist/did.js ADDED
@@ -0,0 +1,129 @@
1
+ import { CachedKeyDeriver, PublicKey, Utils } from '@bsv/sdk';
2
+ import { DPP_PROTOCOL_ID } from './constants.js';
3
+ /**
4
+ * `did:key` for the identity keys this standard already carries, and the one
5
+ * derivation step a verifier needs to get from a DID back to a signature.
6
+ *
7
+ * **Additive by construction.** Nothing here touches the field layout, the field
8
+ * count, either signature preimage or the codec: it re-encodes bytes that are
9
+ * already on chain and re-derives a key that is already derivable. Hard rule 3
10
+ * holds, and no published record moves.
11
+ *
12
+ * **Why it lives in the token core rather than in a consumer.** The standard
13
+ * says actor identity keys must be representable as `did:key`, so token
14
+ * signatures and SD-JWT attestations are provably the same actor, and the
15
+ * derivation lives beside the signatures it explains (`spec/identity.md`).
16
+ *
17
+ * **The step nobody had written down, and the reason `signingPublicKeyFor`
18
+ * exists.** `actor_identity_key` (field 7) is the BRC-42 *parent*. The key that
19
+ * actually signs is its child at `(DPP_PROTOCOL_ID, actor_keyID, 'anyone')`, which
20
+ * is what `verifyUserSignature` derives. So there are two candidate DIDs per actor
21
+ * and the difference matters to exactly one reader: someone holding an SD-JWT whose
22
+ * `iss` is a `did:key`, trying to reach the chain. Give them the parent and they
23
+ * cannot verify a signature; give them the child and they cannot find the actor.
24
+ * They need both and the step between, which `@bsv/did` does not supply because it
25
+ * knows nothing of BRC-42.
26
+ *
27
+ * **No new dependency.** `@bsv/did` 0.1.1 would do the encoding and is compatible
28
+ * with the pinned `@bsv/sdk` 2.1.4, but it pulls `qrcode` into a package that
29
+ * promises to stay dependency-light. The encoding below is the same
30
+ * fifteen lines that library's `multibase.ts` runs, over the SDK's own base58.
31
+ */
32
+ /**
33
+ * The multicodec prefix for a compressed secp256k1 public key: unsigned varint
34
+ * `0xe7`, which is two bytes once encoded. Fixed by the multicodec table, not by
35
+ * us, and the reason a `did:key` for this curve always starts `did:key:zQ3s`.
36
+ */
37
+ const SECP256K1_PUB_MULTICODEC = [0xe7, 0x01];
38
+ /** Multibase's prefix for base58btc. One character, and it is not optional. */
39
+ const BASE58BTC = 'z';
40
+ const anyone = new CachedKeyDeriver('anyone');
41
+ /** Thrown when a string is not a DID this method can read. */
42
+ export class DidFormatError extends Error {
43
+ constructor(message) {
44
+ super(message);
45
+ this.name = 'DidFormatError';
46
+ }
47
+ }
48
+ /**
49
+ * The canonical compressed key, or a refusal.
50
+ *
51
+ * The same rule the codec applies to fields 6 and 7 (`identityKeyHex`): the SDK
52
+ * accepts `x >= p` by reducing mod p, so a non-canonical encoding would produce a
53
+ * DID that resolves to a key nobody can find on chain.
54
+ */
55
+ function canonicalKey(hex) {
56
+ let parsed;
57
+ try {
58
+ parsed = PublicKey.fromString(hex);
59
+ }
60
+ catch {
61
+ throw new DidFormatError('not a valid public key');
62
+ }
63
+ if (parsed.toString() !== hex) {
64
+ throw new DidFormatError('not a canonical compressed public key');
65
+ }
66
+ return parsed;
67
+ }
68
+ /**
69
+ * A `did:key` for a 33-byte compressed secp256k1 identity key.
70
+ *
71
+ * Pure, offline and bidirectional: no registry, no network call, and the DID
72
+ * document is computable from the string alone. That is the property that makes
73
+ * this worth doing at all, because it means a verifier needs nothing from us
74
+ * except the key we already published on chain.
75
+ */
76
+ export function didKeyFromIdentityKey(identityKeyHex) {
77
+ const key = canonicalKey(identityKeyHex);
78
+ const bytes = [...SECP256K1_PUB_MULTICODEC, ...key.encode(true)];
79
+ return `did:key:${BASE58BTC}${Utils.toBase58(bytes)}`;
80
+ }
81
+ /**
82
+ * The identity key inside a `did:key`, or a refusal.
83
+ *
84
+ * Refuses another curve rather than returning bytes that would fail to verify
85
+ * later: an Ed25519 DID is a well-formed `did:key` and a meaningless secp256k1
86
+ * identity key, and the difference is two bytes at the front.
87
+ */
88
+ export function identityKeyFromDidKey(did) {
89
+ if (!did.startsWith(`did:key:${BASE58BTC}`)) {
90
+ throw new DidFormatError('not a did:key in base58btc');
91
+ }
92
+ let bytes;
93
+ try {
94
+ bytes = Utils.fromBase58(did.slice(`did:key:${BASE58BTC}`.length));
95
+ }
96
+ catch {
97
+ throw new DidFormatError('did:key is not valid base58btc');
98
+ }
99
+ const [first, second] = bytes;
100
+ if (first !== SECP256K1_PUB_MULTICODEC[0] || second !== SECP256K1_PUB_MULTICODEC[1]) {
101
+ throw new DidFormatError('did:key is not a compressed secp256k1 key');
102
+ }
103
+ const key = bytes.slice(2);
104
+ if (key.length !== 33) {
105
+ throw new DidFormatError('did:key payload must be 33 bytes');
106
+ }
107
+ return canonicalKey(Utils.toHex(key)).toString();
108
+ }
109
+ /**
110
+ * The public key that actually signed a state's `user_signature`.
111
+ *
112
+ * The step `spec/identity.md` §2 names. `verifyUserSignature` derives exactly this and then
113
+ * throws it away inside a boolean; a verifier who wants to say *which key* signed,
114
+ * or to match a chain state against an SD-JWT's `iss`, needs it in the open.
115
+ *
116
+ * Counterparty `'anyone'`, so this runs with no wallet and no secret, which is the
117
+ * whole reason the standard chose that counterparty for both signatures
118
+ * (`spec/record-model.md` §3 fields 7/8, §5).
119
+ */
120
+ export function signingPublicKeyFor(state) {
121
+ return anyone
122
+ .derivePublicKey(DPP_PROTOCOL_ID, state.actorKeyId, state.actorIdentityKey)
123
+ .toString();
124
+ }
125
+ /** The `did:key` of the key that signed, as distinct from the actor it belongs to. */
126
+ export function signingDidFor(state) {
127
+ return didKeyFromIdentityKey(signingPublicKeyFor(state));
128
+ }
129
+ //# sourceMappingURL=did.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.js","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,IAAI,CAA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I,CAAC;QACH,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,cAAc,CAAC,gCAAgC,CAAC,CAAA;IAC5D,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,KAAK,CAAA;IAC7B,IAAI,KAAK,KAAK,wBAAwB,CAAC,CAAC,CAAC,IAAI,MAAM,KAAK,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,MAAM,IAAI,cAAc,CAAC,2CAA2C,CAAC,CAAA;IACvE,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,kCAAkC,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAClD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAwD;IAC1F,OAAO,MAAM;SACV,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC;SAC1E,QAAQ,EAAE,CAAA;AACf,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,KAAwD;IACpF,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1D,CAAC"}
@@ -0,0 +1,224 @@
1
+ import { LockingScript, Transaction, type ChainTracker } from '@bsv/sdk';
2
+ import { type SignedLifecycleClaim } from './attestation.js';
3
+ import { type PublisherPolicy } from './publisherPolicy.js';
4
+ import type { Outpoint } from './types.js';
5
+ /**
6
+ * The one verification contract (`spec/verification.md`): sixteen named checks,
7
+ * four answers each, an independently expected subject and an observation of
8
+ * the latest state that is never a proof. `verifyChain` stays the verifier of
9
+ * supplied history; this is the report every surface produces from it and
10
+ * from the attestation, anchor and credential rails beside it.
11
+ *
12
+ * The core is dependency-light, so the pieces that need a proof suite, a
13
+ * status list or an authority registry arrive through the policy as
14
+ * functions. A caller that supplies none gets `unknown` on those checks, with
15
+ * a reason that says why, which is the contract's whole point: nothing is
16
+ * passed because it was not looked at.
17
+ */
18
+ export declare const REPORT_VERSION: "1";
19
+ export declare const EVIDENCE_CHECK_NAMES: readonly ["recordEncoding", "actorSignatures", "publisherSignatures", "linkage", "inclusion", "nativeAttestationSignature", "anchorSignature", "anchorKeyDerivation", "anchorDigestAndMetadataBinding", "externalCredentialProof", "subjectBinding", "issuerAuthority", "schema", "credentialTime", "credentialStatus", "evidenceAvailability"];
20
+ export type EvidenceCheckName = (typeof EVIDENCE_CHECK_NAMES)[number];
21
+ export type CheckStatus = 'pass' | 'fail' | 'unknown' | 'not-applicable';
22
+ export type { Outpoint };
23
+ export interface CheckScope {
24
+ artefact?: string;
25
+ digest?: string;
26
+ outpoint?: Outpoint;
27
+ stateIndex?: number;
28
+ }
29
+ export interface EvidenceCheck {
30
+ name: EvidenceCheckName;
31
+ status: CheckStatus;
32
+ reasonCode?: string;
33
+ evidenceRefs: string[];
34
+ scope?: CheckScope;
35
+ detail?: unknown;
36
+ }
37
+ export interface ExpectedSubject {
38
+ passportId: string;
39
+ source: 'request-context' | 'established-binding' | 'none';
40
+ productIdentifier?: string;
41
+ expectedIssuer?: string;
42
+ expectedGenesisOutpoint?: Outpoint;
43
+ expectedStateOutpoint?: Outpoint;
44
+ }
45
+ export type ObservationKind = 'overlay-lookup' | 'spend-status' | 'header-source' | 'registry' | 'other';
46
+ export type ObservationResult = 'unspent' | 'spent' | 'not-found' | 'unavailable' | 'conflicting';
47
+ export interface ObservationSource {
48
+ id: string;
49
+ kind: ObservationKind;
50
+ observedAt: string;
51
+ result: ObservationResult;
52
+ height?: number;
53
+ blockHash?: string;
54
+ spendingTxid?: string;
55
+ detail?: string;
56
+ }
57
+ export interface Observations {
58
+ latestState: 'observed' | 'superseded' | 'conflicting' | 'unknown';
59
+ sources: ObservationSource[];
60
+ queryScope: string;
61
+ observedAt: string;
62
+ candidateOutpoints: Outpoint[];
63
+ }
64
+ export interface EvidenceReport {
65
+ reportVersion: typeof REPORT_VERSION;
66
+ checkedAt: string;
67
+ expectedSubject: ExpectedSubject;
68
+ suppliedTip: Outpoint | null;
69
+ policyId: string;
70
+ checks: EvidenceCheck[];
71
+ observations: Observations;
72
+ limits: string[];
73
+ }
74
+ /** An anchor output as evidence: the script, where it sits, and the bytes it commits to when the caller has them. */
75
+ export interface AnchorEvidence {
76
+ lockingScript: LockingScript | string;
77
+ txid?: string;
78
+ outputIndex?: number;
79
+ /** The complete secured representation, as bytes or as the exact UTF-8 string. */
80
+ securedBytes?: number[] | string;
81
+ }
82
+ /** A credential in a non-native representation, as the exact bytes that were issued. */
83
+ export interface ExternalCredentialEvidence {
84
+ representation: string;
85
+ mediaType?: string;
86
+ bytes: number[] | string;
87
+ }
88
+ export interface PassportEvidence {
89
+ /** The token history, genesis first, as `chainFromBeef` orders it. */
90
+ tokenHistory?: Transaction[];
91
+ /**
92
+ * Other histories supplied under the same passport identifier: a second
93
+ * genesis is two candidates, not one winner (`spec/verification.md` §3).
94
+ */
95
+ alternativeHistories?: Transaction[][];
96
+ nativeClaims?: unknown[];
97
+ anchors?: AnchorEvidence[];
98
+ externalCredentials?: ExternalCredentialEvidence[];
99
+ /**
100
+ * Managed acceptance records (`spec/managed-custody.md` §3) the custodian
101
+ * retained for the version 2 TRANSFERs in the history. Each is bound to the
102
+ * TRANSFER whose `authorisation_commitment` names it; a commitment with no
103
+ * record supplied leaves `evidenceAvailability` unknown, never passed.
104
+ */
105
+ acceptanceRecords?: unknown[];
106
+ }
107
+ /** A check's answer from a pluggable verifier, before the report names and orders it. */
108
+ export interface PartialCheck {
109
+ status: CheckStatus;
110
+ reasonCode?: string;
111
+ evidenceRefs?: string[];
112
+ detail?: unknown;
113
+ }
114
+ /** What a representation-specific verifier reports for one credential. */
115
+ export interface ExternalCredentialVerification {
116
+ /** The credential's own identifier, when its representation defines one. */
117
+ id?: string;
118
+ issuer?: string;
119
+ /** Every subject identifier the credential names; the anchor's `subject` must be one of them. */
120
+ subjects?: string[];
121
+ /** The type the anchor's `attestationType` must carry for this credential. */
122
+ attestationType?: string;
123
+ proof: PartialCheck;
124
+ schema: PartialCheck;
125
+ time: PartialCheck;
126
+ status: PartialCheck;
127
+ authority: PartialCheck;
128
+ /** Whether every artefact the credential referenced (status list, DID document, predecessor) was available. */
129
+ availability?: PartialCheck;
130
+ }
131
+ export type ExternalCredentialVerifier = (input: {
132
+ representation: string;
133
+ mediaType?: string;
134
+ bytes: number[];
135
+ digest: string;
136
+ checkedAt: string;
137
+ }) => Promise<ExternalCredentialVerification>;
138
+ export interface AuthorityQuestion {
139
+ role: 'genesis-issuer' | 'lifecycle-claimant' | 'anchoring-service' | 'acceptance-custodian';
140
+ /** The identity as the evidence names it: a compressed key for native roles, a DID for claims. */
141
+ identity: string;
142
+ at?: string;
143
+ ref: string;
144
+ }
145
+ export type AuthorityPolicy = {
146
+ required: false;
147
+ reason: string;
148
+ } | {
149
+ required: true;
150
+ /** Identity keys (hex) or did:key strings permitted to write a genesis state. */
151
+ genesisIssuers?: string[];
152
+ /** Issuer DIDs permitted to sign native lifecycle claims. */
153
+ claimIssuers?: string[];
154
+ /** Anchoring service identity keys whose anchors this policy accepts. */
155
+ anchoringServices?: string[];
156
+ /** Custodian identity keys whose managed acceptance records this policy accepts. */
157
+ acceptanceCustodians?: string[];
158
+ /** Verifies a role the lists above do not settle, on evidence the policy names. */
159
+ verify?: (question: AuthorityQuestion) => Promise<PartialCheck>;
160
+ };
161
+ export interface LatestStateObserver {
162
+ id: string;
163
+ kind: ObservationKind;
164
+ observe: (input: {
165
+ passportId: string;
166
+ tip: Outpoint | null;
167
+ }) => Promise<{
168
+ result: ObservationResult;
169
+ height?: number;
170
+ blockHash?: string;
171
+ spendingTxid?: string;
172
+ detail?: string;
173
+ candidateOutpoints?: Outpoint[];
174
+ }>;
175
+ }
176
+ export interface EvidencePolicy {
177
+ policyId?: string;
178
+ /** Publisher identity keys any one of which may have countersigned a state. None, and no `publisherPolicy`, means the check is not selected. */
179
+ publisherKeys?: string[];
180
+ /**
181
+ * A publisher key policy chain with the operator identity keys it is
182
+ * verified against (`spec/services.md` §1). The chain is verified first; if
183
+ * it does not hold, `publisherSignatures` is unknown with
184
+ * `publisher-policy-invalid` and no key from it is trusted. When it holds,
185
+ * each state is checked against the keys active at its own timestamp, and a
186
+ * countersignature by a policy key outside its window fails with
187
+ * `publisher-not-authorised`.
188
+ */
189
+ publisherPolicy?: {
190
+ chain: PublisherPolicy[];
191
+ operatorIdentityKeys: Record<string, string>;
192
+ };
193
+ ownerConsent?: boolean | {
194
+ authorities: string[];
195
+ };
196
+ /** Authorities for version 2 control proofs; defaults to the `ownerConsent` authorities (`VerifyChainOptions.controlAuthorities`). */
197
+ controlAuthorities?: string[];
198
+ /**
199
+ * The managed-custody profile (`spec/managed-custody.md`). `required` makes
200
+ * every version 2 TRANSFER carry an acceptance commitment; the check is
201
+ * otherwise read but not demanded. Supplied acceptance records are verified
202
+ * either way, and the custodian's authority is the `authority` policy's.
203
+ */
204
+ managedAcceptance?: {
205
+ required?: boolean;
206
+ };
207
+ chainTracker?: ChainTracker | 'scripts only';
208
+ authority?: AuthorityPolicy;
209
+ credentialVerifier?: ExternalCredentialVerifier;
210
+ /** Validates a native claim's payload against its declared profile and version; absent means `schema` is unknown for native claims. */
211
+ profileValidator?: (claim: SignedLifecycleClaim) => Promise<PartialCheck>;
212
+ observers?: LatestStateObserver[];
213
+ /** The observation time, injected for reproducibility. Defaults to now. */
214
+ checkedAt?: string;
215
+ }
216
+ /**
217
+ * Evaluate the evidence for one passport and report it as `spec/verification.md`
218
+ * requires. Never throws for evidence that fails: every failure is a check with
219
+ * a reason. It throws only for a caller error, such as a malformed policy key.
220
+ */
221
+ export declare function verifyPassportEvidence(evidence: PassportEvidence, expected: ExpectedSubject, policy?: EvidencePolicy): Promise<EvidenceReport>;
222
+ /** The short label a surface may show beside a check; the technical name stays in the report. */
223
+ export declare const EVIDENCE_CHECK_LABELS: Record<EvidenceCheckName, string>;
224
+ //# sourceMappingURL=evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,WAAW,EAAS,KAAK,YAAY,EAAE,MAAM,UAAU,CAAA;AAErF,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE9E,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEtD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,cAAc,EAAG,GAAY,CAAA;AAE1C,eAAO,MAAM,oBAAoB,iVAiBvB,CAAA;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AACrE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAAA;AAExE,YAAY,EAAE,QAAQ,EAAE,CAAA;AAExB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAA;IACvB,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB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