bsv-bap 0.0.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 (62) hide show
  1. package/.babelrc +20 -0
  2. package/.eslintrc +46 -0
  3. package/LICENSE +25 -0
  4. package/README.md +819 -0
  5. package/babel.config.js +6 -0
  6. package/bun.lockb +0 -0
  7. package/coverage/clover.xml +6 -0
  8. package/coverage/coverage-final.json +1 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +101 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +196 -0
  17. package/coverage/lcov-report/src/constants.ts.html +113 -0
  18. package/coverage/lcov-report/src/id.ts.html +2207 -0
  19. package/coverage/lcov-report/src/index.html +156 -0
  20. package/coverage/lcov-report/src/index.ts.html +1877 -0
  21. package/coverage/lcov-report/src/utils.ts.html +404 -0
  22. package/coverage/lcov-report/tests/data/index.html +111 -0
  23. package/coverage/lcov-report/tests/data/keys.js.html +86 -0
  24. package/coverage/lcov.info +0 -0
  25. package/dist/jest.config.d.ts +8 -0
  26. package/dist/src/constants.d.ts +8 -0
  27. package/dist/src/id.d.ts +295 -0
  28. package/dist/src/index.d.ts +238 -0
  29. package/dist/src/interface.d.ts +23 -0
  30. package/dist/src/poa.d.ts +6 -0
  31. package/dist/src/utils.d.ts +54 -0
  32. package/dist/typescript-npm-package.cjs.d.ts +554 -0
  33. package/dist/typescript-npm-package.cjs.js +1320 -0
  34. package/dist/typescript-npm-package.cjs.js.map +1 -0
  35. package/dist/typescript-npm-package.esm.d.ts +554 -0
  36. package/dist/typescript-npm-package.esm.js +1312 -0
  37. package/dist/typescript-npm-package.esm.js.map +1 -0
  38. package/dist/typescript-npm-package.umd.d.ts +554 -0
  39. package/dist/typescript-npm-package.umd.js +110193 -0
  40. package/dist/typescript-npm-package.umd.js.map +1 -0
  41. package/jest.config.ts +196 -0
  42. package/jsdoc.json +16 -0
  43. package/package.json +80 -0
  44. package/rollup.config.js +64 -0
  45. package/setup-jest.js +1 -0
  46. package/src/README.md +80 -0
  47. package/src/attributes.json +119 -0
  48. package/src/constants.ts +11 -0
  49. package/src/id.ts +783 -0
  50. package/src/index.ts +631 -0
  51. package/src/interface.ts +26 -0
  52. package/src/poa.ts +9 -0
  53. package/src/utils.ts +111 -0
  54. package/tests/data/ids.json +30 -0
  55. package/tests/data/keys.js +2 -0
  56. package/tests/data/old-ids.json +25 -0
  57. package/tests/data/test-vectors.json +122 -0
  58. package/tests/id.test.js +286 -0
  59. package/tests/index.test.js +335 -0
  60. package/tests/regression.test.js +28 -0
  61. package/tests/utils.test.js +27 -0
  62. package/tsconfig.json +17 -0
package/README.md ADDED
@@ -0,0 +1,819 @@
1
+ # Bitcoin Attestation Protocol - BAP
2
+ > A simple protocol to create a chain of trust for any kind of data on the Bitcoin blockchain
3
+
4
+ Authors: Siggi
5
+
6
+ Special thanks to Attila Aros & Satchmo
7
+
8
+ Inspired by the [AUTHOR IDENTITY Protocol](https://github.com/BitcoinFiles/AUTHOR_IDENTITY_PROTOCOL)
9
+
10
+ NOTE: All examples in this document use fake identity keys, addresses and signatures. See the test data sets for real world examples that can be used in a test suite when developing a library.
11
+
12
+ - [Intro](#intro)
13
+ - [Protocol](#protocol)
14
+ * [URN - Uniform Resource Names](#urn---uniform-resource-names)
15
+ * [Attributes are defined at schema.org](#attributes-are-defined-at-schemaorg)
16
+ - [Creating an identity (ID)](#creating-an-identity-id)
17
+ - [Usage in an identity system (BAP-ID)](#usage-in-an-identity-system-bap-id)
18
+ * [Attesting (ATTEST)](#attesting-attest)
19
+ * [Verifying an identity attribute](#verifying-an-identity-attribute)
20
+ * [Delegating signing to another identity](#delegating-signing-to-another-identity)
21
+ * [Publishing Identity information (ALIAS)](#publishing-identity-information-alias)
22
+ * [BAP uniKey](#bap-unikey)
23
+ - [Publishing data (DATA)](#publishing-data)
24
+ - [Using as a Power of Attorney](#using-as-a-power-of-attorney)
25
+ - [Blacklisting](#blacklisting)
26
+ * [Blacklisting transactions / addresses](#blacklisting-transactions--addresses)
27
+ * [Blacklisting IP addresses](#blacklisting-ip-addresses)
28
+ * [Final note on blacklisting](#final-note-on-blacklisting)
29
+ - [Giving consent to access of data](#giving-consent-to-access-of-data)
30
+ - [Simple asserts](#simple-asserts)
31
+ - [Revoking an attestation](#revoking-an-attestation)
32
+ - [BAP on the BSV Metanet - PROVISIONAL](#bap-on-the-bsv-metanet---provisional)
33
+ - [BAP w3c DID - PROVISIONAL](#bap-w3c-did---provisional)
34
+ - [Extending the protocol](#extending-the-protocol)
35
+
36
+ # TODO
37
+ - Finish DID specs - help needed
38
+ - Request feedback
39
+
40
+ # Intro
41
+
42
+ The design goals:
43
+
44
+ 1. A simple protocol for generic attestation of data, without the need to publish the data itself
45
+ 2. Decouple the signing with an address from the funding source address (ie: does not require any on-chain transactions from the signing identity address)
46
+ 3. Allow for rotation of signing keys without having to change the existing attestations
47
+ 4. Allow for creation of an infinite amount of identities, but still allow for proving of attested attributes between the identities
48
+
49
+ # Protocol
50
+
51
+ The protocol is defined using the [Bitcom](https://bitcom.bitdb.network/) convention. The signing is done using the [AUTHOR IDENTITY Protocol](https://github.com/BitcoinFiles/AUTHOR_IDENTITY_PROTOCOL).
52
+
53
+ - The prefix of the protocol is `1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT`;
54
+
55
+ ```
56
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
57
+ [ID|ATTEST|ALIAS|DATA|REVOKE]
58
+ [ID Key|URN Attestation Hash]
59
+ [Sequence|Address|Data]
60
+ |
61
+ [AIP protocol address]
62
+ [AIP Signing Algorithm]
63
+ [AIP Signing Address]
64
+ [AIP Signature]
65
+ ```
66
+ By default, all fields are signed, so the optional indices of the AIP can be left out.
67
+
68
+ The `Sequence` is added to the transaction to prevent replay of the transaction in case of a revocation. The transaction from the same signatory, with the highest `Sequence` is the current one.
69
+
70
+ The fourth field is used for the bitcoin signing address in an `ID` transaction only.
71
+
72
+ Example:
73
+
74
+ ```
75
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
76
+ ATTEST
77
+ d4bcdd0f437d0d3bc588bb4e861d2e83e26e8bf9566ae541a5d43329213b1b13
78
+ 0
79
+ |
80
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
81
+ BITCOIN_ECDSA
82
+ 1Po6MLAPJsSAGyE8sXw3CgWcgxumNGjyqm
83
+ G8wW0NOCPFgGSoCtB2DZ+0CrLrh9ywAl0C5hnx78Q+7QNyPYzsFtkt4/TXkzkTwqbOT3Ofb1CYdNUv5a/jviPVA=
84
+ ```
85
+
86
+ ## URN - Uniform Resource Names
87
+ The protocol makes use of URN's as a data carrier for the attestation data, as defined by the [w3c](https://www.w3.org/TR/uri-clarification/).
88
+
89
+ URN's look like:
90
+
91
+ ```
92
+ urn:[namespace identifier]:[...URN]
93
+ ```
94
+
95
+ Examples for use in BAP:
96
+
97
+ Identity:
98
+ ```
99
+ urn:bap:id:[Attribute name]:[Attribute value]:[Nonce]
100
+
101
+ urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa
102
+ ```
103
+
104
+ Attestations:
105
+ ```
106
+ urn:bap:attest:[Attribute hash]:[Identity key]
107
+
108
+ urn:bap:attest:42d2396ddfc3dec6acbd96830b844a10b8b2f065e60fbd5238b5267ab086bf4f:1CCWY6EXZwNqbrtW1SXGNFWdwipYT7Ur1Q
109
+ ```
110
+
111
+ The URN is hashed using sha256 when used in a transaction sent to the blockchain.
112
+
113
+ ## Attributes are defined at schema.org
114
+
115
+ Attributes used in BAP should be defined at https://schema.org.
116
+
117
+ Especially the Person attributes, found at https://schema.org/Person, should be used in BAP.
118
+
119
+ # Creating an identity (ID)
120
+
121
+ To create a new identity in BAP, we need to create 2 private keys and compute they public keys and the corresponding addresses. For easy management of the keys, it is recommended to use an [HD Private key](https://docs.moneybutton.com/docs/bsv-hd-private-key.html) with known derivations.
122
+
123
+ ```
124
+ rootAddress: 1WffojxvgpQBmUTigoss7VUdfN45JiiRK
125
+ firstAddress: 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
126
+ ```
127
+
128
+
129
+
130
+ Signing identities in BAP are created by linking a unique identity key with bitcoin signing addresses. The identity key should be computed as a hash of the rootAddress. This links the 2 together and prevents others from creating an identity using the same identity key to create confusion.
131
+
132
+ The identity key follows the way a Bitcoin address is hashed to reduce the size of the key.
133
+
134
+ ```
135
+ identityKey = base58( ripemd160 ( sha256 ( rootAddress ) ) )
136
+ ```
137
+
138
+ Example identity key, note the hex values are fed as binary buffers to the hash functions and not as a string:
139
+
140
+ ```
141
+ sha256(1WffojxvgpQBmUTigoss7VUdfN45JiiRK) = c38bc59316de9783b5f7a8ba19bc5d442f6c9b0988c48a241d1c58a1f4e9ae19
142
+
143
+ ripemd160(c38bc59316de9783b5f7a8ba19bc5d442f6c9b0988c48a241d1c58a1f4e9ae19) = afb3dcf52c2c661c35c8ec6a92cecbfc691ba371
144
+
145
+ base58(afb3dcf52c2c661c35c8ec6a92cecbfc691ba371) = 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
146
+
147
+ identityKey: 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
148
+ ```
149
+
150
+ **NOTE:** This has been changed with the release of the BAP library. This allows a verifier to link the root address to the identity key. In the past the identity key was random. Older identites created at random will still work with the BAP library, but new identities should be created in this way.
151
+
152
+ To link this identity key to the root address and the signing address, an `ID` transaction is sent to the blockchain:
153
+
154
+ ```
155
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
156
+ ID
157
+ 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
158
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
159
+ |
160
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
161
+ BITCOIN_ECDSA
162
+ 1WffojxvgpQBmUTigoss7VUdfN45JiiRK
163
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
164
+ ```
165
+
166
+ The address `1WffojxvgpQBmUTigoss7VUdfN45JiiRK` associated with the first instance of the identity key on-chain, is the identity control address (or rootAddress). This address should no be used anywhere, but can be used to destroy the identity, in case the latest linked key has been compromised.
167
+
168
+ When the signing address is rotated to a new key, a new ID transaction is created, this time signed by the previous address:
169
+
170
+ ```
171
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
172
+ ID
173
+ 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
174
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
175
+ |
176
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
177
+ BITCOIN_ECDSA
178
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
179
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
180
+ ```
181
+
182
+ In this way, we have created a way to rotate the signing keys for a certain identity as often as we want, with each signing key being immutably saved on the blockchain.
183
+
184
+ Any signatures done for the identity key should be done using the active key at that time.
185
+
186
+ To destroy the identity, an ID transaction is sent to 0, signed with the address from the first ever transaction `1WffojxvgpQBmUTigoss7VUdfN45JiiRK`;
187
+
188
+ ```
189
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
190
+ ID
191
+ 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
192
+ 0
193
+ |
194
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
195
+ BITCOIN_ECDSA
196
+ 1WffojxvgpQBmUTigoss7VUdfN45JiiRK
197
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
198
+ ```
199
+
200
+ # Usage in an identity system (BAP-ID)
201
+
202
+ A BAP identity is defined as an identity key that has attested identity attributes, verified by one or more authorities. These authorities are outside the scope of this description, but are not governed or controlled.
203
+
204
+ All identity attributes have the following characteristics:
205
+
206
+ ```
207
+ urn:bap:id:[Attribute name]:[Attribute value]:[Nonce]
208
+ ```
209
+
210
+ Attribute | Description
211
+ --------- | ----------
212
+ Attribute name | The name of the attribute being described
213
+ Attribute value | The value of the attribute being described with the name
214
+ Nonce | A unique random string to make sure the entropy of hashing the urn will not cause collision and not allow for dictionary attacks
215
+
216
+ A user may want to create multiple identities with a varying degree of details available about that identity. Let's take a couple of examples:
217
+
218
+ Identity 1 (`3SyWUZXvhidNcEHbAC3HkBnKoD2Q`):
219
+ ```
220
+ urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa
221
+ urn:bap:id:birthday:1990-05-22:e61f23cbbb2284842d77965e2b0e32f0ca890b1894ca4ce652831347ee3596d9
222
+ urn:bap:id:over18:1:480ca17ccaacd671b28dc811332525f2f2cd594d8e8e7825de515ce5d52d30e8
223
+ urn:bap:id:address:51391 Moorpark Ave #104, San Jose, CA 95129, United States:44d47d2375c8346c7ceeab1904360aaf572b1c940c1bd66ffd5cf88fdf06bc05
224
+ urn:bap:id:passportNr:US2343242:9c06a0fb0e2d9cef4928855076255e4df3375e2807cf37bc028ddb282f811ac8
225
+ urn:bap:id:passportExpiration:2022-02-23:d61a39afb463b42c3e419463a028deb3e9e2cebf67953864e9f9e7869677e7cb
226
+ ```
227
+
228
+ Identity 2 (`b71a658ec49a9cb099fd5d3cf0aafce28f1d464fa6e496f61c8048d8ed56edc1`):
229
+ ```
230
+ urn:bap:id:name:John Doe:6637be9df2e114ce19a287ff48841899ef4a5762a5f9dc47aef62fe4f579bf93
231
+ urn:bap:id:email:john.doen@example.com:2864fd138ab1e9ddaaea763c77a45898dac64a26229f9f3d0f2280e4bfa915de
232
+ urn:bap:id:over18:1:5f48f9be1644834933cec74a299d109d18f01e77c9552545d2eae4d0c929000b
233
+ ```
234
+
235
+ Identity 3 (`10ef2b1bb05185d0dbae41e1bfefe0c2deb2d389f38fe56daa2cc28a9ba82fc7`):
236
+ ```
237
+ urn:bap:id:alternateName:Johnny:7a8d693bce6b6c1cf1dd81468a52b69829e465ff9b0762cf77965309df3ad4c8
238
+ ```
239
+
240
+ NOTE: The random nonce should not be re-used across identities. Always create a new random secret for each attribute.
241
+
242
+ ## Attesting (ATTEST)
243
+
244
+ Anyone can attest for any identity by broadcasting a bitcoin transaction with a signature from their private key of the attributes of the identity.
245
+
246
+ All attestations have the following characteristics:
247
+
248
+ ```
249
+ urn:bap:attest:[Attribute hash]:[Identity key]
250
+ ```
251
+
252
+ Attribute | Description
253
+ --------- | ----------
254
+ Attribute hash | A hash of the urn attribute being attested
255
+ Identity key | The unique identity key of the owner of the attestation
256
+
257
+ Take for example a bank, Banco De Bitcoin, with a known and trusted identity key of `ezY2h8B5sj7SHGw8i1KhHtRvgM5` which is linked via an `ID` transaction to `1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo`. To attest that the bank has seen the information in the identity attribute and that it is correct, the bank would sign an attestation with the identity information together with the given identity key.
258
+
259
+ ```
260
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
261
+ ATTEST
262
+ [Attestation hash]
263
+ [Sequence]
264
+ |
265
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
266
+ [Signature algorithm]
267
+ [Address of signer]
268
+ [Signature]
269
+ ```
270
+
271
+ For the name urn for the Identity 1 (`3SyWUZXvhidNcEHbAC3HkBnKoD2Q`) in above example:
272
+
273
+ - We take the hash of `urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa` = `b17c8e606afcf0d8dca65bdf8f33d275239438116557980203c82b0fae259838`
274
+ - Then create an attestation urn for the address: `urn:bap:id:attest:b17c8e606afcf0d8dca65bdf8f33d275239438116557980203c82b0fae259838:3SyWUZXvhidNcEHbAC3HkBnKoD2Q`
275
+ - Then hash the attestation for our transaction: `89cd658c0ce3ff62db4270a317c35f8a7dfe1242e2cc94232aa3947d77f82431`
276
+ - Then the attestation is signed with the private key belonging to the trusted authority (with address `1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo`);
277
+
278
+ ```
279
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
280
+ ATTEST
281
+ 89cd658c0ce3ff62db4270a317c35f8a7dfe1242e2cc94232aa3947d77f82431
282
+ 0
283
+ |
284
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
285
+ BITCOIN_ECDSA
286
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
287
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
288
+ ```
289
+
290
+ Since the hash of our attestation is always the same, any authority attesting the identity attribute will broadcast a transaction where the 3rd item is the same. In this way it is possible to search (using for instance Planaria) through the blockchain for all attestations of the identity attribute and select the one most trusted.
291
+
292
+ ## Verifying an identity attribute
293
+
294
+ For a user to prove their identity, that has been verified by a trusted authority, the user does the following.
295
+
296
+ He shares his identity key `3SyWUZXvhidNcEHbAC3HkBnKoD2Q`, the full urn `urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa` and signs a challenge message from the party that request an identity verification.
297
+
298
+ The receiving party can now verify:
299
+ - That the user is the owner of the address `1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA` by verifying the signature
300
+ - That the identity `3SyWUZXvhidNcEHbAC3HkBnKoD2Q` is linked to the address via an `ID` record
301
+ - That the attestation urn has been signed by that latest valid address of Banco De Bitcoin.
302
+ - Thereby verifying that the user signing the message has been attested by the bank to have the name `John Doe`.
303
+
304
+ NOTE: No unneeded sensitive information has been shared and it is not possible to infer any other information from the information sent. The only thing the receiver now knows is that the person doing the signing is called John Doe.
305
+
306
+ ## Delegating signing to another identity
307
+
308
+ With BAP, it is very easy to create an infinite number of identities for a user. This is even encouraged to preserve privacy.
309
+
310
+ When for instance a KYC check is done, this check is done for a certain identity. Replicating this KYC check for all identities for a user, to be able to use in all access applications, is impractical. To solve this we must be able to link, or delegate, from one identity to another.
311
+
312
+ `urn:bap:delegate:<from idKey>:<to IdKey>:<Nonce>`
313
+
314
+ Example:
315
+ ```
316
+ var attestation = 'urn:bap:delegate:3SyWUZXvhidNcEHbAC3HkBnKoD2Q:341d782c56a588ccdd3ebb181d1dbb4699bdb5fb9956b7bd07e917d955acdb04:7f2fe5aac07e2d4c43bdb232029ed157acf0272eac94a2f75cc17566c01a5e89';
317
+ var attestationHash = sha256(attestation); // 2dbb381888f973a0db3bf311e551a6ac2f3ab792420262d8a6f65ef4feb8c1ef
318
+ ```
319
+
320
+ This links, or delegates, from identity `3SyWUZXvhidNcEHbAC3HkBnKoD2Q` to identity `341d782c56a588ccdd3ebb181d1dbb4699bdb5fb9956b7bd07e917d955acdb04`;
321
+
322
+ The attestation can be published to the blockchain, signed by the identity `3SyWUZXvhidNcEHbAC3HkBnKoD2Q`;
323
+
324
+ ```
325
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
326
+ ATTEST
327
+ 2dbb381888f973a0db3bf311e551a6ac2f3ab792420262d8a6f65ef4feb8c1ef
328
+ 0
329
+ |
330
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
331
+ BITCOIN_ECDSA
332
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
333
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
334
+ ```
335
+
336
+ Showing that it is possible to use the verified attributes from `3SyWUZXvhidNcEHbAC3HkBnKoD2Q` in identity `341d782c56a588ccdd3ebb181d1dbb4699bdb5fb9956b7bd07e917d955acdb04` can now be done by sharing the delegation. The delegation attestation will be available to check on-chain.
337
+
338
+ The challenge sent by the application requesting the attributes should be signed by **both (!)** identites, to proof access to the private keys of both identities.
339
+
340
+ NOTE: The grant published on-chain for the attributes shared must be signed by the delegating identity `3SyWUZXvhidNcEHbAC3HkBnKoD2Q`, and not `341d782c56a588ccdd3ebb181d1dbb4699bdb5fb9956b7bd07e917d955acdb04`;
341
+
342
+ NOTE: The receiving end should store both identity keys to be able to proof they have received access to the data of the user. The could be stored as a concatenation of the two identity strings: `341d782c56a588ccdd3ebb181d1dbb4699bdb5fb9956b7bd07e917d955acdb04<-3SyWUZXvhidNcEHbAC3HkBnKoD2Q`;
343
+
344
+ NOTE: The main identity, for which a KYC has been done, should never directly be used in any application. A new identity should be created for each and every application accessed.
345
+
346
+ ## Publishing Identity information (ALIAS)
347
+
348
+ It is possible to publish information about an identity by using the BAP ALIAS keyword. This tells the world that an identity key should be seen as belonging to the entity published in the alias.
349
+
350
+ It is recommended to only use the ALIAS keyword for companies that need (or want) to link an identity key to their business. It is not recommended for normal users to publish their identity using the ALIAS keyword.
351
+
352
+ The ALIAS data is a stringified JSON object that uses the w3c attributes from https://schema.org/. Example:
353
+ ```
354
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
355
+ ALIAS
356
+ 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
357
+ {"@type":"Organization","name":"Banco De Bitcoin","address":{"@type":"PostalAddress","addressLocality":"Mexico Beach","addressRegion":"FL","streetAddress":"3102 Highway 98"},"url":https://bancodebitcoin.com","logo":{"@type":"ImageObject","contentUrl":"data:image/png;base64,..."}
358
+ |
359
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
360
+ BITCOIN_ECDSA
361
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
362
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
363
+ ```
364
+
365
+ Organizations are encouraged to use attributes defined at https://schema.org/Organization when using the ALIAS keyword.
366
+
367
+ ## BAP uniKey
368
+
369
+ The BAP uniKey is a unique hash of identity attributes of a person to create a uniquely identifiable hash to use across services. The uniKey can also be used in a custodial identity service where the only thing shared with a service is the uniKey and the uniKey expiration. The real identity can be looked up at the custodial service.
370
+
371
+ The BAP uniKey is defined as follows:
372
+ ```
373
+ privateUniKey := sha256(
374
+ fullName
375
+ nationality
376
+ birthDate
377
+ socialSecurityNr
378
+ passportNr
379
+ passportExpirationDate
380
+ base64(passport image)
381
+ )
382
+ uniKey := sha256(privateUniKey)
383
+ ```
384
+ The privateUniKey should only be defined based on a digital (NFC) passport that supports all the attributes mentioned. Adding the base64 data of the image on the passport is especially important to create enough entropy for the hashing function to safe guard against dictionary attacks. The uniKey is a hash of the privateUniKey.
385
+
386
+ The privateUniKey should __never__ be shared. The uniKey should only be shared in situations where the user would normally share all his personal info (KYC check).
387
+
388
+ The `uniKeyExpirationDate` is equal to the `passportExpirationDate`.
389
+
390
+ Example:
391
+ ```
392
+ privateUniKey = "27dacfd5d0eefd927263a502bd2dea7b9b6193ba7f8bf98c2f4855b45e7d0008";
393
+ uniKey = "dce3ba1199b74d74a5fb941f92ed7e6adb97acc4dffdb055cf6867162dc8fa74";
394
+
395
+ urn:bap:id:uniKey:dce3ba1199b74d74a5fb941f92ed7e6adb97acc4dffdb055cf6867162dc8fa74:c490de4c40fecd9fa7c3979b9134d0a419fa77388d1535b48a24cdb69425b5d5
396
+
397
+ hash = "bc47cdfc44cc89519dca5f12bc10c53492c57090a012d2540257bf02772f82a5";
398
+ ```
399
+ `c490de4c40...` is just a random nonce to increase entropy.
400
+ ```
401
+ uniKeyExpirationDate = "2025-04-20";
402
+
403
+ urn:bap:id:uniKeyExpirationDate:2025-04-20:dce3ba1199b74d74a5fb941f92ed7e6adb97acc4dffdb055cf6867162dc8fa74
404
+
405
+ hash = "a67e363c4163b49f81529b8b5118670ffbf6d76e2b47a03a01e6e21805388f7f";
406
+ ```
407
+ The urn of the uniKeyExpirationDate should use the uniKey as the nonce. This links them together and makes it verifiable for third parties.
408
+
409
+ # Publishing data
410
+
411
+ The BAP protocol defines a way to publish data on-chain, optionally in a way that only the sender and receiver can read the data.
412
+
413
+ The data can be encrypted using the ECIES encryption scheme (specifically electrum-ecies, https://www.npmjs.com/package/electrum-ecies).
414
+
415
+ ```
416
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
417
+ DATA
418
+ [Attestation hash]
419
+ [[Optionally ECIES encrypted] data]
420
+ |
421
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
422
+ [Signature algorithm]
423
+ [Address of signer]
424
+ [Signature]
425
+ ```
426
+
427
+ Example:
428
+ ```
429
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
430
+ DATA
431
+ 2dbb381888f973a0db3bf311e551a6ac2f3ab792420262d8a6f65ef4feb8c1ef
432
+ QklFMQMFmPdvjFe8Wfo+JWmTpo+33LXc+4G8ThfaucU72kieb6lWEv4layTb0x5tzpi6lA2it8rO/ELrXomJqC53uBOd+DZSzDhCSpK6SwR+Itt+Pw==
433
+ |
434
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
435
+ BITCOIN_ECDSA
436
+ 1WffojxvgpQBmUTigoss7VUdfN45JiiRK
437
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
438
+ ```
439
+ When adding data like this to an attestation, the identity of the signing party should match the identity of the attestation, otherwise the data should be ignored.
440
+
441
+ Or as a part of an attestation transaction:
442
+ ```
443
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
444
+ ATTEST
445
+ 5e991865273588e8be0b834b013b7b3b7e4ff2c7517c9fcdf77da84502cebef1
446
+ 0
447
+ |
448
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
449
+ DATA
450
+ 5e991865273588e8be0b834b013b7b3b7e4ff2c7517c9fcdf77da84502cebef1
451
+ QklFMQMFmPdvjFe8Wfo+JWmTpo+33LXc+4G8ThfaucU72kieb6lWEv4layTb0x5tzpi6lA2it8rO/ELrXomJqC53uBOd+DZSzDhCSpK6SwR+Itt+Pw==
452
+ |
453
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
454
+ BITCOIN_ECDSA
455
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
456
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
457
+ ```
458
+
459
+ This can be used to append data to an attestation, for instance to add context to the attestation for a UI of an application.
460
+
461
+ For maximum compatibility with ECIES, the data should be encrypted using the private key of the attester and the public key of the owner of the identity for which the attestation is being done (Traditional 2 keys ECIES, https://www.npmjs.com/package/electrum-ecies#traditional-2-keys-ecies).
462
+
463
+ # Using as a Power of Attorney
464
+
465
+ All users that have an identity and an address registered, should be able to, for instance, give another user temporary rights to sign on their behalf. A Power of Attorney could be defined with the BAP protocol in the following way.
466
+ All users that have an identity and an address registered, should be able to, for instance, give another user temporary rights to sign on their behalf. A Power of Attorney could be defined with the BAP protocol in the following way.
467
+
468
+ (A power of attorney of this kind is only valid in the real world, but does not allow anyone else to sign anything on-chain)
469
+
470
+ The Power of Attorney would have the following characteristics:
471
+
472
+ ```
473
+ urn:bap:poa:[PoA Attribute]:[Address]:[Nonce]
474
+ ```
475
+ Attribute | Description
476
+ --------- | ----------
477
+ PoA Attribute | Power of Attorney attribute being handed over to the person with the identity associates with Address
478
+ Address | The bitcoin address of the person (or organisation) being handed the PoA
479
+ Nonce | A unique random string to make sure the entropy of hashing the urn will not cause collision and not allow for dictionary attacks
480
+
481
+ PoA attributes:
482
+
483
+ Attribute | Description
484
+ --------- | ----------
485
+ real-estate | To buy, sell, rent, or otherwise manage residential, commercial, and personal real estate
486
+ business | To invest, trade, and manage any and all business transactions and decisions, as well as handle any claim or litigation matters
487
+ finance | To control banking, tax, and government and retirement transactions, as well as living trust and estate decisions
488
+ family | To purchase gifts, employ professionals, and to buy, sell or trade any of your personal property
489
+ general | This grants the authority to make any decisions that you would be able to if you were personally present
490
+
491
+ Example, give the bank the Power of Attorney over finances:
492
+
493
+ For the Identity 1 (`3SyWUZXvhidNcEHbAC3HkBnKoD2Q`) given PoA to the bank `ezY2h8B5sj7SHGw8i1KhHtRvgM5`:
494
+
495
+ - We take the hash of `urn:bap:poa:finance:3SyWUZXvhidNcEHbAC3HkBnKoD2Q:ef4ef3b8847cf9533cc044dc032269f80ecf6fcbefbd4d6ac81dddc0124f50e7`
496
+ - Then hash the poa for the transaction: `77cdec21e1025f85a5cb3744d5515c54783c739b8fa7c72c9e24d83900261d7f`
497
+ - Then the poa is signed with the private key belonging to the identity handing over the PoA (with address `1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA`);
498
+
499
+ ```
500
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
501
+ ATTEST
502
+ 77cdec21e1025f85a5cb3744d5515c54783c739b8fa7c72c9e24d83900261d7f
503
+ 0
504
+ |
505
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
506
+ BITCOIN_ECDSA
507
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
508
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
509
+ ```
510
+
511
+ The bank will save the urn and can prove that the PoA is still valid on the blockchain.
512
+
513
+ The user can always revoke the PoA with a REVOKE transaction.
514
+
515
+ # Blacklisting
516
+
517
+ With more and more data being posted to the bitcoin blockchain it becomes ever more important to be able to block data from being viewed on sites offering that service. Especially illegal data needs to be filtered from viewing to prevent liability claims.
518
+
519
+ A proposed format for blacklisting any type of data could have the following format:
520
+ ```
521
+ urn:bap:blacklist:[type]:[attribute]:[key]
522
+ ```
523
+
524
+ ## Blacklisting transactions / addresses
525
+
526
+ Using the blacklisting format, a transaction ID blacklist would be of the following format for a transaction ID:
527
+ ```
528
+ urn:bap:blacklist:bitcoin:tx-id:[Transaction ID]
529
+ ```
530
+
531
+ Example, blacklisting transaction ID `9e4b52ca8abe317d246ae2e742898df0956eaf1cc8df7c02154d20c1f55f3f9b`:
532
+ ```
533
+ urn:bap:blacklist:bitcoin:tx-id:9e4b52ca8abe317d246ae2e742898df0956eaf1cc8df7c02154d20c1f55f3f9b
534
+ ```
535
+
536
+ The hash of this blacklisting is: `8a6bc20369171516fb9155a10f11caff8a51dbd8ae90c5bf3443fc4c83bdc8e8`
537
+
538
+ The attestation looks like:
539
+ ```
540
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
541
+ ATTEST
542
+ 8a6bc20369171516fb9155a10f11caff8a51dbd8ae90c5bf3443fc4c83bdc8e8
543
+ 0
544
+ |
545
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
546
+ BITCOIN_ECDSA
547
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
548
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
549
+ ```
550
+
551
+ Which would indicate that the ID signing with `1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA` is blacklisting the transaction. This way services can blacklist transactions and publish that on-chain for other services to see.
552
+
553
+ Third party services could be using this to check whether services they trust are blacklisting transactions and based on that decide not to show them in their viewer. A Simple query of the attestastion hash `8a6bc20369171516fb9155a10f11caff8a51dbd8ae90c5bf3443fc4c83bdc8e8` in a BAP index would return all the services that have blacklisted the transaction.
554
+
555
+ For a bitcoin address, the blacklist urn would look like:
556
+ ```
557
+ urn:bap:blacklist:bitcoin:address:[Address]
558
+ ```
559
+ Example:
560
+ ```
561
+ urn:bap:blacklist:bitcoin:address:1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
562
+ ```
563
+
564
+ ## Blacklisting IP addresses
565
+
566
+ This blacklisting urn could also be used to signal blacklisting of IP addresses, for instance IP addresses being used by known bot networks.
567
+
568
+ NOTE: Because IP addresses are personally identifiable information, we need to take more care when hashing these and publishing them on-chain to prevent reverse lookups of the IP addresses.
569
+
570
+ For IP addresses we could use a concatenation of the idKey of the signing party to add entropy to the hashing:
571
+ ```
572
+ urn:bap:blacklist:ip-address:[IP Address]:[ID key]
573
+ ```
574
+
575
+ This would prevent direct lookups and force services to only search for blacklisting by services they trust. A lookup of all attestations and all id's would be an extremly CPU intensive task.
576
+
577
+ For the Identity 1 (`3SyWUZXvhidNcEHbAC3HkBnKoD2Q`) blacklisting IP address `1.1.1.1`:
578
+ ```
579
+ urn:bap:blacklist:ip-address:1.1.1.1:3SyWUZXvhidNcEHbAC3HkBnKoD2Q
580
+ ```
581
+
582
+ The hash of this blacklisting is: `73df789478993f8f4e100be416811860d6fc2ae208fdfaf256788cd522f21219`
583
+
584
+ The attestation looks like:
585
+ ```
586
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
587
+ ATTEST
588
+ 73df789478993f8f4e100be416811860d6fc2ae208fdfaf256788cd522f21219
589
+ 0
590
+ |
591
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
592
+ BITCOIN_ECDSA
593
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
594
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
595
+ ```
596
+
597
+ A third party service that wants to make use of this information is forced to look through a BAP index in a targeted way, per IP address and for each attesting service separately and is not able to recreate a list of blocked IP addresses.
598
+
599
+ ## Final note on blacklisting
600
+
601
+ Using attestations for blacklists is a good way of creating one-way blacklists. It's easy to lookup whether some service has blacklisted something (transaction, address, IP address), but it is very hard to create a list of all things a service has blacklisted.
602
+
603
+ Also because the blacklist attestations look just like any other attestation, the blacklistings can not be identified as such which increases the difficulty of creating a list of blacklistings of a service.
604
+
605
+ # Simple asserts
606
+
607
+ BAP can also be used for simple assertions of any type of data or action.
608
+
609
+ Example:
610
+ ```
611
+ urn:bap:assert:[Some assertion you want to make]:[nonce]
612
+ ```
613
+
614
+ Example, asserting ownership of a file:
615
+ ```
616
+ urn:bap:assert:John Doe (john@example.com) owns the file with the sha256 hash 70eed96ac2900c68998a99166b4b4833ec311454dbbab82fc4ae028bbb802a35:02a043948c8185dab98456c20e5c68149e2fb9d52079068aeacb377240045515
617
+ ```
618
+ This has a hash of `e4d1c8868d143cb8eaf240c0191c19e513a4f58a8eb8243af00b5626fe2eb764`.
619
+
620
+ The user then needs to attest to this on-chain, and sign:
621
+ ```
622
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
623
+ ATTEST
624
+ e4d1c8868d143cb8eaf240c0191c19e513a4f58a8eb8243af00b5626fe2eb764
625
+ 0
626
+ |
627
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
628
+ BITCOIN_ECDSA
629
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
630
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
631
+ ```
632
+
633
+ # Giving consent to access of data
634
+
635
+ When a website requests data from a user, the user should leave a record on-chain that this data was freely given to the service by the user. The user should also be able to revoke the access to the data, which would imply that the service needs to delete any copy's of the data shared. This is the only way the user is (legally) in charge of what data the service has access to.
636
+
637
+ A possible way to do this, using BAP:
638
+ ```
639
+ urn:bap:grant:[Attribute names]:[Identity key]
640
+ ```
641
+
642
+ Example, for a service with identity key `ezY2h8B5sj7SHGw8i1KhHtRvgM5`:
643
+ ```
644
+ urn:bap:grant:name,email,alternateName:ezY2h8B5sj7SHGw8i1KhHtRvgM5
645
+ ```
646
+ This has a hash of `b88bd23005be7e0737f02e67de8b392df834ba27caed1e7774aec77c9dcb85d0`.
647
+
648
+ The user then needs to attest to this on-chain:
649
+ ```
650
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
651
+ ATTEST
652
+ b88bd23005be7e0737f02e67de8b392df834ba27caed1e7774aec77c9dcb85d0
653
+ 0
654
+ |
655
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
656
+ BITCOIN_ECDSA
657
+ 1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo
658
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
659
+ ```
660
+
661
+ NOTE: this could be given to the service directly as proof of granting access to the data by the user. The service could then put the data on-chain, paying the necessary fees.
662
+
663
+ The service should be monitoring the blockchain for a revocation of the data sharing grant and remove any data related to this user of the revocation is seen. Alternatively, the user could notify the service of a revocation transaction when made on-chain.
664
+
665
+ # Revoking an attestation
666
+
667
+ In rare cases when the attestation needs to be revoked, this can be done using the `REVOKE` keyword. The revocation transaction has exactly the same format as the attestation transaction, except for the REVOKE keyword.
668
+
669
+ ```
670
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
671
+ REVOKE
672
+ 77cdec21e1025f85a5cb3744d5515c54783c739b8fa7c72c9e24d83900261d7f
673
+ 1
674
+ |
675
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
676
+ BITCOIN_ECDSA
677
+ 1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA
678
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
679
+ ```
680
+
681
+ The sequence number is important here to prevent replays of the transaction.
682
+
683
+ # BAP on the BSV Metanet - PROVISIONAL
684
+
685
+ NOTE: This is still very much work in progress. Feedback is very welcome.
686
+
687
+ https://bitcoinsv.io/wp-content/uploads/2020/10/The-Metanet-Technical-Summary-v1.0.pdf
688
+
689
+ BAP transactions can also be published on-chain using the BSV metanet protocol. The biggest difference is that those transactions will not use the AIP signing protocol, but the native BSV transaction signing.
690
+
691
+ ## An example.
692
+
693
+ A transaction like this, creating a new identity with root address `1WffojxvgpQBmUTigoss7VUdfN45JiiRK`:
694
+
695
+ ```
696
+ 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT
697
+ ID
698
+ 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
699
+ 1KJ8vx8adZeznoDfoGf632rNkzxK2ZwzSG
700
+ |
701
+ 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
702
+ BITCOIN_ECDSA
703
+ 1WffojxvgpQBmUTigoss7VUdfN45JiiRK
704
+ HB6Ye7ekxjKDkblJYL9lX3J2vhY75vl+WfVCq+wW3+y6S7XECkgYwUEVH3WEArRuDb/aVZ8ntLI/D0Yolb1dhD8=
705
+ ```
706
+
707
+ Would then look more like this:
708
+
709
+ ```
710
+ Input:
711
+ <𝑆𝑖𝑔 π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> <π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘>
712
+
713
+ Output:
714
+ OP_RETURN meta <π‘ƒπ‘›π‘œπ‘‘π‘’> <𝑇π‘₯πΌπ·π‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT ID 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
715
+ ```
716
+
717
+ Where `Pparent` is the public key associated with the root address `1WffojxvgpQBmUTigoss7VUdfN45JiiRK`, and `Pnode` is the public key associated with the new signing address `1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo`.
718
+
719
+ Rotating to a new signing key (`1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA`) is now possible by creating a new metanet edge:
720
+
721
+ ```
722
+ Input:
723
+ <𝑆𝑖𝑔 π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> <π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘>
724
+
725
+ Output:
726
+ OP_RETURN meta <π‘ƒπ‘›π‘œπ‘‘π‘’> <𝑇π‘₯πΌπ·π‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT ID 3SyWUZXvhidNcEHbAC3HkBnKoD2Q
727
+ ```
728
+
729
+ Where `Pparent` is the public key associated with the address `1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo`, and `Pnode` is the public key associated with the new signing address `1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA`.
730
+
731
+ An attestation could then be written like this on-chain:
732
+
733
+ ```
734
+ Input:
735
+ <𝑆𝑖𝑔 π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> <π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘>
736
+
737
+ Output:
738
+ OP_RETURN meta <π‘ƒπ‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> <𝑇π‘₯πΌπ·π‘π‘Žπ‘Ÿπ‘’π‘›π‘‘> 1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT ATTEST 2dbb381888f973a0db3bf311e551a6ac2f3ab792420262d8a6f65ef4feb8c1ef 0
739
+ ```
740
+
741
+ Where `Pparent` is the public key associated with the latest valid address `1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA`. Note that the node links back to itself, creating a metanet leaf and not a new edge, where the `TxIDParent` points to the transaction where the edge was created.
742
+
743
+ # BAP w3c DID - PROVISIONAL
744
+
745
+ A w3c compatible DID can be created from a BAP ID in the following manner:
746
+
747
+ ```
748
+ {
749
+ "@context": ["https://w3id.org/did/v0.11", "https://w3id.org/bap/v1"],
750
+ "id": "did:bap:id:<Identity Key>",
751
+ "publicKey": [
752
+ {
753
+ "id": "did:bap:id:<Identity Key>#<key identifier>",
754
+ "controller": "did:bap:id:<Identity Key>",
755
+ "type": "EcdsaSecp256k1VerificationKey2019",
756
+ "bitcoinAddress": "<Base58 bitcoin address>"
757
+ }
758
+ ],
759
+ "authentication": ["#key1"],
760
+ "assertionMethod": ["#key1"]
761
+ }
762
+ ```
763
+ Example:
764
+ ```
765
+ {
766
+ "@context": ["https://w3id.org/did/v0.11", "https://w3id.org/bap/v1"],
767
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
768
+ "publicKey": [
769
+ {
770
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q#root",
771
+ "controller": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
772
+ "type": "EcdsaSecp256k1VerificationKey2019",
773
+ "bitcoinAddress": "1WffojxvgpQBmUTigoss7VUdfN45JiiRK"
774
+ },
775
+ {
776
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q#key1",
777
+ "controller": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
778
+ "type": "EcdsaSecp256k1VerificationKey2019",
779
+ "bitcoinAddress": "1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo"
780
+ }
781
+ ],
782
+ "authentication": ["#key1"],
783
+ "assertionMethod": ["#key1"]
784
+ }
785
+ ```
786
+
787
+ When keys are rotated to a new signing key the new key can be added to the DID and all authentication and assertion set to that new key.
788
+ ```
789
+ {
790
+ "@context": ["https://w3id.org/did/v0.11", "https://w3id.org/bap/v1"],
791
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
792
+ "publicKey": [
793
+ {
794
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q#root",
795
+ "controller": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
796
+ "type": "EcdsaSecp256k1VerificationKey2019",
797
+ "bitcoinAddress": "1WffojxvgpQBmUTigoss7VUdfN45JiiRK"
798
+ },
799
+ {
800
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q#key1",
801
+ "controller": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
802
+ "type": "EcdsaSecp256k1VerificationKey2019",
803
+ "bitcoinAddress": "1K4c6YXR1ixNLAqrL8nx5HUQAPKbACTwDo"
804
+ },
805
+ {
806
+ "id": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q#key2",
807
+ "controller": "did:bap:id:3SyWUZXvhidNcEHbAC3HkBnKoD2Q",
808
+ "type": "EcdsaSecp256k1VerificationKey2019",
809
+ "bitcoinAddress": "1JfMQDtBKYi6z65M9uF2gxgLv7E8pPR6MA"
810
+ }
811
+ ],
812
+ "authentication": ["#key2"],
813
+ "assertionMethod": ["#key2"]
814
+ }
815
+ ```
816
+
817
+ # Extending the protocol
818
+
819
+ The protocol could be extended for other use cases, by introducing new keywords (next to ATTEST, REVOKE, ID AND ALIAS) or introducing other `urn:bap:...` schemes.