@did-btcr2/method 0.18.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/dist/browser.js +4917 -6487
  2. package/dist/browser.mjs +4917 -6487
  3. package/dist/cjs/core/beacon/aggregation/cohort/index.js +3 -3
  4. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
  5. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +1 -9
  6. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  7. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  8. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  9. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  10. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  11. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  12. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  13. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  14. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  15. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  16. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  17. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  18. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  19. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  20. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  21. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  22. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  23. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  24. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  25. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  26. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  27. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  28. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  29. package/dist/cjs/core/beacon/aggregation/coordinator.js +14 -14
  30. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  31. package/dist/cjs/core/beacon/aggregation/participant.js +4 -3
  32. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  33. package/dist/cjs/core/beacon/aggregation/session/index.js +1 -1
  34. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
  35. package/dist/cjs/core/beacon/beacon.js +25 -0
  36. package/dist/cjs/core/beacon/beacon.js.map +1 -0
  37. package/dist/cjs/core/beacon/cas-beacon.js +39 -0
  38. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
  39. package/dist/cjs/core/beacon/error.js +4 -4
  40. package/dist/cjs/core/beacon/error.js.map +1 -1
  41. package/dist/cjs/core/beacon/factory.js +10 -11
  42. package/dist/cjs/core/beacon/factory.js.map +1 -1
  43. package/dist/cjs/core/beacon/interfaces.js +2 -0
  44. package/dist/cjs/core/beacon/interfaces.js.map +1 -0
  45. package/dist/cjs/core/beacon/signal-discovery.js +183 -0
  46. package/dist/cjs/core/beacon/signal-discovery.js.map +1 -0
  47. package/dist/cjs/core/beacon/singleton.js +75 -178
  48. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  49. package/dist/cjs/core/beacon/smt-beacon.js +39 -0
  50. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
  51. package/dist/cjs/core/beacon/utils.js +71 -114
  52. package/dist/cjs/core/beacon/utils.js.map +1 -1
  53. package/dist/cjs/core/identifier.js +18 -21
  54. package/dist/cjs/core/identifier.js.map +1 -1
  55. package/dist/cjs/core/interfaces.js +2 -0
  56. package/dist/cjs/core/interfaces.js.map +1 -0
  57. package/dist/cjs/core/resolve.js +321 -0
  58. package/dist/cjs/core/resolve.js.map +1 -0
  59. package/dist/cjs/{utils → core}/types.js.map +1 -1
  60. package/dist/cjs/core/update.js +113 -0
  61. package/dist/cjs/core/update.js.map +1 -0
  62. package/dist/cjs/did-btcr2.js +168 -129
  63. package/dist/cjs/did-btcr2.js.map +1 -1
  64. package/dist/cjs/index.js +17 -16
  65. package/dist/cjs/index.js.map +1 -1
  66. package/dist/cjs/utils/appendix.js +16 -33
  67. package/dist/cjs/utils/appendix.js.map +1 -1
  68. package/dist/cjs/utils/did-document-builder.js +5 -0
  69. package/dist/cjs/utils/did-document-builder.js.map +1 -1
  70. package/dist/cjs/utils/did-document.js +62 -72
  71. package/dist/cjs/utils/did-document.js.map +1 -1
  72. package/dist/cjs/utils/general.js +1 -1
  73. package/dist/cjs/utils/general.js.map +1 -1
  74. package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
  75. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
  76. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
  77. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  90. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  91. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  92. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  93. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  94. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  95. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  96. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  97. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  98. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  99. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  100. package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
  101. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  102. package/dist/esm/core/beacon/aggregation/participant.js +4 -3
  103. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  104. package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
  105. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  106. package/dist/esm/core/beacon/beacon.js +25 -0
  107. package/dist/esm/core/beacon/beacon.js.map +1 -0
  108. package/dist/esm/core/beacon/cas-beacon.js +39 -0
  109. package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
  110. package/dist/esm/core/beacon/error.js +4 -4
  111. package/dist/esm/core/beacon/error.js.map +1 -1
  112. package/dist/esm/core/beacon/factory.js +10 -11
  113. package/dist/esm/core/beacon/factory.js.map +1 -1
  114. package/dist/esm/core/beacon/interfaces.js +2 -0
  115. package/dist/esm/core/beacon/interfaces.js.map +1 -0
  116. package/dist/esm/core/beacon/signal-discovery.js +183 -0
  117. package/dist/esm/core/beacon/signal-discovery.js.map +1 -0
  118. package/dist/esm/core/beacon/singleton.js +75 -178
  119. package/dist/esm/core/beacon/singleton.js.map +1 -1
  120. package/dist/esm/core/beacon/smt-beacon.js +39 -0
  121. package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
  122. package/dist/esm/core/beacon/utils.js +71 -114
  123. package/dist/esm/core/beacon/utils.js.map +1 -1
  124. package/dist/esm/core/identifier.js +18 -21
  125. package/dist/esm/core/identifier.js.map +1 -1
  126. package/dist/esm/core/interfaces.js +2 -0
  127. package/dist/esm/core/interfaces.js.map +1 -0
  128. package/dist/esm/core/resolve.js +321 -0
  129. package/dist/esm/core/resolve.js.map +1 -0
  130. package/dist/esm/{utils → core}/types.js.map +1 -1
  131. package/dist/esm/core/update.js +113 -0
  132. package/dist/esm/core/update.js.map +1 -0
  133. package/dist/esm/did-btcr2.js +168 -129
  134. package/dist/esm/did-btcr2.js.map +1 -1
  135. package/dist/esm/index.js +17 -16
  136. package/dist/esm/index.js.map +1 -1
  137. package/dist/esm/utils/appendix.js +16 -33
  138. package/dist/esm/utils/appendix.js.map +1 -1
  139. package/dist/esm/utils/did-document-builder.js +5 -0
  140. package/dist/esm/utils/did-document-builder.js.map +1 -1
  141. package/dist/esm/utils/did-document.js +62 -72
  142. package/dist/esm/utils/did-document.js.map +1 -1
  143. package/dist/esm/utils/general.js +1 -1
  144. package/dist/esm/utils/general.js.map +1 -1
  145. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
  146. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
  147. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
  148. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
  149. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  150. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
  151. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
  152. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
  153. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
  154. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
  155. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
  156. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
  157. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
  158. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
  159. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  160. package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
  161. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  162. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  163. package/dist/types/core/beacon/beacon.d.ts +44 -0
  164. package/dist/types/core/beacon/beacon.d.ts.map +1 -0
  165. package/dist/types/core/beacon/cas-beacon.d.ts +36 -0
  166. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
  167. package/dist/types/core/beacon/error.d.ts +2 -2
  168. package/dist/types/core/beacon/error.d.ts.map +1 -1
  169. package/dist/types/core/beacon/factory.d.ts +4 -5
  170. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  171. package/dist/types/core/beacon/interfaces.d.ts +59 -0
  172. package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
  173. package/dist/types/core/beacon/signal-discovery.d.ts +25 -0
  174. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -0
  175. package/dist/types/core/beacon/singleton.d.ts +20 -76
  176. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  177. package/dist/types/core/beacon/smt-beacon.d.ts +36 -0
  178. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
  179. package/dist/types/core/beacon/utils.d.ts +19 -97
  180. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  181. package/dist/types/core/identifier.d.ts.map +1 -1
  182. package/dist/types/core/interfaces.d.ts +87 -0
  183. package/dist/types/core/interfaces.d.ts.map +1 -0
  184. package/dist/types/core/resolve.d.ts +89 -0
  185. package/dist/types/core/resolve.d.ts.map +1 -0
  186. package/dist/types/core/types.d.ts +84 -0
  187. package/dist/types/core/types.d.ts.map +1 -0
  188. package/dist/types/core/update.d.ts +51 -0
  189. package/dist/types/core/update.d.ts.map +1 -0
  190. package/dist/types/did-btcr2.d.ts +70 -89
  191. package/dist/types/did-btcr2.d.ts.map +1 -1
  192. package/dist/types/index.d.ts +17 -16
  193. package/dist/types/index.d.ts.map +1 -1
  194. package/dist/types/utils/appendix.d.ts +5 -10
  195. package/dist/types/utils/appendix.d.ts.map +1 -1
  196. package/dist/types/utils/did-document-builder.d.ts +6 -1
  197. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  198. package/dist/types/utils/did-document.d.ts +46 -42
  199. package/dist/types/utils/did-document.d.ts.map +1 -1
  200. package/package.json +6 -6
  201. package/src/core/beacon/aggregation/cohort/index.ts +3 -3
  202. package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
  203. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
  204. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
  205. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
  206. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
  207. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
  208. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
  209. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
  210. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
  211. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
  212. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
  213. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
  214. package/src/core/beacon/aggregation/coordinator.ts +41 -29
  215. package/src/core/beacon/aggregation/participant.ts +4 -3
  216. package/src/core/beacon/aggregation/session/index.ts +1 -1
  217. package/src/core/beacon/beacon.ts +58 -0
  218. package/src/core/beacon/cas-beacon.ts +53 -0
  219. package/src/core/beacon/error.ts +5 -6
  220. package/src/core/beacon/factory.ts +12 -16
  221. package/src/core/beacon/interfaces.ts +67 -0
  222. package/src/core/beacon/signal-discovery.ts +237 -0
  223. package/src/core/beacon/singleton.ts +107 -197
  224. package/src/core/beacon/smt-beacon.ts +53 -0
  225. package/src/core/beacon/utils.ts +95 -182
  226. package/src/core/identifier.ts +21 -24
  227. package/src/core/interfaces.ts +93 -0
  228. package/src/core/resolve.ts +463 -0
  229. package/src/core/types.ts +95 -0
  230. package/src/core/update.ts +154 -0
  231. package/src/did-btcr2.ts +255 -159
  232. package/src/index.ts +19 -22
  233. package/src/utils/appendix.ts +26 -44
  234. package/src/utils/did-document-builder.ts +6 -1
  235. package/src/utils/did-document.ts +105 -113
  236. package/src/utils/general.ts +1 -1
  237. package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
  238. package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
  239. package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
  240. package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
  241. package/dist/cjs/core/crud/deactivate.js +0 -14
  242. package/dist/cjs/core/crud/deactivate.js.map +0 -1
  243. package/dist/cjs/core/crud/read.js +0 -679
  244. package/dist/cjs/core/crud/read.js.map +0 -1
  245. package/dist/cjs/core/crud/update.js +0 -194
  246. package/dist/cjs/core/crud/update.js.map +0 -1
  247. package/dist/cjs/interfaces/beacon.js +0 -41
  248. package/dist/cjs/interfaces/beacon.js.map +0 -1
  249. package/dist/cjs/interfaces/crud.js +0 -2
  250. package/dist/cjs/interfaces/crud.js.map +0 -1
  251. package/dist/esm/core/beacon/cid-aggregate.js +0 -116
  252. package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
  253. package/dist/esm/core/beacon/smt-aggregate.js +0 -126
  254. package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
  255. package/dist/esm/core/crud/deactivate.js +0 -14
  256. package/dist/esm/core/crud/deactivate.js.map +0 -1
  257. package/dist/esm/core/crud/read.js +0 -679
  258. package/dist/esm/core/crud/read.js.map +0 -1
  259. package/dist/esm/core/crud/update.js +0 -194
  260. package/dist/esm/core/crud/update.js.map +0 -1
  261. package/dist/esm/interfaces/beacon.js +0 -41
  262. package/dist/esm/interfaces/beacon.js.map +0 -1
  263. package/dist/esm/interfaces/crud.js +0 -2
  264. package/dist/esm/interfaces/crud.js.map +0 -1
  265. package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
  266. package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
  267. package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
  268. package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
  269. package/dist/types/core/crud/deactivate.d.ts +0 -13
  270. package/dist/types/core/crud/deactivate.d.ts.map +0 -1
  271. package/dist/types/core/crud/read.d.ts +0 -334
  272. package/dist/types/core/crud/read.d.ts.map +0 -1
  273. package/dist/types/core/crud/update.d.ts +0 -93
  274. package/dist/types/core/crud/update.d.ts.map +0 -1
  275. package/dist/types/interfaces/beacon.d.ts +0 -116
  276. package/dist/types/interfaces/beacon.d.ts.map +0 -1
  277. package/dist/types/interfaces/crud.d.ts +0 -32
  278. package/dist/types/interfaces/crud.d.ts.map +0 -1
  279. package/dist/types/utils/types.d.ts +0 -38
  280. package/dist/types/utils/types.d.ts.map +0 -1
  281. package/src/canonicalize.d.ts +0 -6
  282. package/src/core/beacon/cid-aggregate.ts +0 -153
  283. package/src/core/beacon/smt-aggregate.ts +0 -135
  284. package/src/core/crud/deactivate.ts +0 -13
  285. package/src/core/crud/read.ts +0 -948
  286. package/src/core/crud/update.ts +0 -292
  287. package/src/interfaces/beacon.ts +0 -137
  288. package/src/interfaces/crud.ts +0 -33
  289. package/src/utils/types.ts +0 -41
  290. /package/dist/cjs/{utils → core}/types.js +0 -0
  291. /package/dist/esm/{utils → core}/types.js +0 -0
@@ -1,219 +1,116 @@
1
- import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
- import { INVALID_SIDECAR_DATA, LATE_PUBLISHING_ERROR, SingletonBeaconError } from '@did-btcr2/common';
3
- import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
4
- import { Kms, Signer } from '@did-btcr2/kms';
1
+ import { INVALID_SIDECAR_DATA, MISSING_UPDATE_DATA } from '@did-btcr2/common';
2
+ import { SchnorrKeyPair } from '@did-btcr2/keypair';
3
+ import { Signer } from '@did-btcr2/kms';
5
4
  import { opcodes, Psbt, script } from 'bitcoinjs-lib';
6
5
  import { base58btc } from 'multiformats/bases/base58';
7
- import { Beacon } from '../../interfaces/beacon.js';
8
- import { Appendix } from '../../utils/appendix.js';
9
- import { Identifier } from '../identifier.js';
10
- const bitcoin = new BitcoinNetworkConnection();
6
+ import { canonicalization } from '../../did-btcr2.js';
7
+ import { Beacon } from './beacon.js';
8
+ import { SingletonBeaconError } from './error.js';
11
9
  /**
12
- * Implements {@link https://dcdpr.github.io/did-btcr2/#singleton-beacon | 5.1 Singleton Beacon}.
13
- *
14
- * A Singleton Beacon enables a single entity to independently post a DID Update Payload in a Beacon Signal. Its is a
15
- * Beacon that can be used to publish a single DID Update Payload targeting a single DID document. The serviceEndpoint
16
- * for this Beacon Type is a Bitcoin address represented as a URI following the BIP21 scheme. It is recommended that
17
- * this Bitcoin address be under the sole control of the DID controller. How the Bitcoin address and the cryptographic
18
- * material that controls it are generated is left to the implementation.
19
- *
10
+ * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
20
11
  * @class SingletonBeacon
21
12
  * @type {SingletonBeacon}
22
- * @extends {Beacon}
13
+ * @extends {AggregateBeacon}
23
14
  */
24
15
  export class SingletonBeacon extends Beacon {
25
16
  /**
26
17
  * Creates an instance of SingletonBeacon.
27
- * @param {BeaconService} service The Beacon service.
28
- * @param {?BeaconSidecarData} [sidecar] Optional sidecar data.
29
- */
30
- constructor(service, sidecar) {
31
- super({ ...service, type: 'SingletonBeacon' }, sidecar);
32
- }
33
- /**
34
- * Get the Beacon service.
35
- * @readonly
36
- * @type {BeaconService} The Beacon service.
37
- */
38
- get service() {
39
- return {
40
- type: this.type,
41
- id: this.id,
42
- serviceEndpoint: this.serviceEndpoint
43
- };
44
- }
45
- /**
46
- * Implements {@link https://dcdpr.github.io/did-btcr2/#establish-singleton-beacon | 5.1.1 Establish Singleton Beacon}.
18
+ * @param {BeaconService} service The BeaconService object representing the funded beacon to announce the update to.
47
19
  *
48
- * Static, convenience method for establishing a Beacon object.
49
- *
50
- * A Singleton Beacon is a Beacon that can be used to publish a single DID Update Payload targeting a single DID
51
- * document. The serviceEndpoint for this Beacon Type is a Bitcoin address represented as a URI following the BIP21
52
- * scheme. It is RECOMMENDED that this Bitcoin address be under the sole control of the DID controller. How the
53
- * Bitcoin address and the cryptographic material that controls it are generated is left to the implementation.
54
- * The Establish Singleton Beacon algorithm takes in a Bitcoin address and a serviceId and returns a Singleton Beacon service.
55
- * It returns a SignletonBeacon object with the given id, type, and serviceEndpoint.
56
- *
57
- * @param {string} service The Beacon service.
58
- * @param {BeaconSidecarData<SingletonSidecar>} sidecar The sidecar data.
59
- * @returns {SingletonBeacon} The Singleton Beacon.
60
20
  */
61
- static establish(service, sidecar) {
62
- return new SingletonBeacon(service, sidecar);
21
+ constructor(service) {
22
+ super({ ...service, type: 'SingletonBeacon' });
63
23
  }
64
24
  /**
65
- * TODO: Figure out if this is necessary or not.
66
- * @param {string} didUpdatePayload The DID Update Payload to generate the signal for.
67
- * @returns {BeaconSignal} The generated signal.
68
- * @throws {MethodError} if the signal is invalid.
25
+ * Processes an array of Beacon Signals associated with a Singleton Beacon Service.
26
+ * @returns {Promise<SignedBTCR2Update | undefined>} The DID Update payload announced by the Beacon Signal.
27
+ * @throws {SingletonBeaconError} if the signalTx is invalid or the signalSidecarData is invalid.
69
28
  */
70
- generateSignal(didUpdatePayload) {
71
- throw new Error('Method not implemented.' + didUpdatePayload);
72
- }
73
- /**
74
- * TODO: Finish implementation per spec
75
- *
76
- * Implements {@link https://dcdpr.github.io/did-btcr2/#process-singleton-beacon-signal | 5.1.3 Process Singleton Beacon Signal}.
77
- * See {@link Beacon.processSignal | Abstract Beacon Interface Method processSignal} for more details.
78
- *
79
- * The Process Singleton Beacon Signal algorithm is called by the Process Beacon Signals algorithm as part of the Read
80
- * operation. It takes a Bitcoin transaction representing a Beacon Signal and optional signalSidecarData containing
81
- * any sidecar data provided to the resolver for the Beacon Signal identified by the Bitcoin transaction identifier.
82
- * It returns the DID Update payload announced by the Beacon Signal or throws an error.
83
- *
84
- * @param {RawTransactionV2} signal Bitcoin transaction representing a Beacon Signal.
85
- * @param {SignalsMetadata} signalsMetadata: SignalsMetadata Optional sidecar data for the Beacon Signal.
86
- * @returns {Promise<DidUpdatePayload | undefined>} The DID Update payload announced by the Beacon Signal.
87
- * @throws {DidError} if the signalTx is invalid or the signalSidecarData is invalid.
88
- */
89
- async processSignal(signal, signalsMetadata) {
90
- // 1. Initialize a txOut variable to the 0th transaction output of the tx.
91
- const output = signal.vout.filter((vout) => (vout['scriptpubkey_asm'] || vout['scriptPubKey'].asm).includes('OP_RETURN'))?.[0];
92
- if (!output) {
93
- throw new SingletonBeaconError('No OP_RETURN output found in transaction outputs.', 'NO_OP_RETURN', { signal });
94
- }
95
- const outputMap = new Map(Object.entries(output));
96
- // 2. Set didUpdatePayload to null.
97
- let didUpdatePayload = undefined;
98
- // 3. Check txout is of the format [OP_RETURN, OP_PUSH32, <32bytes>], if not, then return didUpdatePayload.
99
- // The Bitcoin transaction is not a Beacon Signal.
100
- const UPDATE_PAYLOAD_HASH = (outputMap.get('scriptpubkey_asm') ?? outputMap.get('scriptPubKey').asm).split(' ').last();
101
- if (!UPDATE_PAYLOAD_HASH) {
102
- return undefined;
103
- }
104
- // 4. Set hashBytes to the 32 bytes in the txout.
105
- const hashBytes = JSON.canonicalization.encode(Buffer.fromHex(UPDATE_PAYLOAD_HASH), 'base58');
106
- // Convert signalsMetadata to a Map for easier access
107
- const signalsMetadataMap = new Map(Object.entries(signalsMetadata));
108
- // 5. If signalsMetadata:
109
- if (signalsMetadata) {
110
- // 5.1 Set didUpdatePayload to signalsMetadata.updatePayload
111
- didUpdatePayload = signalsMetadataMap.get(signal.txid)?.didUpdate;
112
- if (!didUpdatePayload) {
113
- throw new SingletonBeaconError('Update Payload not found in signal metadata.', 'PROCESS_SIGNAL_ERROR');
29
+ async processSignals(signals, sidecar) {
30
+ // Initialize an empty array to hold the BTCR2 signed updates
31
+ const updates = new Array();
32
+ // Loop through each signal in signals
33
+ for (const signal of signals) {
34
+ // Grab the beacon signal bytes hash from the signal
35
+ const updateHash = signal.signalBytes;
36
+ // Use the updateHash as the sidecar data lookup key to retrieve the btcr2 update
37
+ const signedUpdate = sidecar.updateMap.get(updateHash);
38
+ // If no btcr2 update is found in sidecar data maps, throw missingUpdateData error.
39
+ if (!signedUpdate) {
40
+ throw new SingletonBeaconError(`BTCR2 Signed Update not found for update hash ${updateHash}.`, MISSING_UPDATE_DATA, signal);
114
41
  }
115
- // 5.2 Set updateHashBytes to the result of passing didUpdatePayload to the JSON Canonicalization and Hash algorithm.
116
- const updateHashBytes = await JSON.canonicalization.process(didUpdatePayload, 'base58');
117
- // 5.3 If updateHashBytes does not equal hashBytes, MUST throw an invalidSidecarData error.
118
- if (updateHashBytes !== hashBytes) {
119
- throw new SingletonBeaconError(`Hash mismatch: updateHashBytes ${updateHashBytes} !== hashBytes ${hashBytes}.`, INVALID_SIDECAR_DATA, { UPDATE_PAYLOAD_HASH, didUpdatePayload });
42
+ // Canonicalize, hash and encode to base58 the signed update object found in sidecar or CAS
43
+ const encodedUpdate = canonicalization.process(signedUpdate, { encoding: 'base58' });
44
+ // Encode the signal bytes hex string to base58
45
+ const signalBytes = base58btc.encode(Buffer.from(updateHash, 'hex'));
46
+ // Check for mismatch between found sidecar/cas update hash and onchain beacon signal hash
47
+ if (encodedUpdate !== signalBytes) {
48
+ // If mismatch, throw invalidSidecarData error.
49
+ throw new SingletonBeaconError(`Hash mismatch: sidecar update ${encodedUpdate} !== signal bytes ${signalBytes}.`, INVALID_SIDECAR_DATA, { encodedUpdate, signalBytes });
120
50
  }
121
- // 7. Return didUpdatePayload.
122
- return didUpdatePayload;
123
- }
124
- // 6. Else:
125
- // 6.1 Set didUpdatePayload to the result of passing hashBytes into the Fetch Content from Addressable Storage algorithm.
126
- const didUpdatePayloadString = await Appendix.fetchFromCas(base58btc.decode(hashBytes));
127
- if (!didUpdatePayloadString || !JSON.parse(didUpdatePayloadString)) {
128
- throw new SingletonBeaconError('Update payload not found in addressable storage.', INVALID_SIDECAR_DATA);
129
- }
130
- didUpdatePayload = JSON.parse(didUpdatePayloadString);
131
- // 6.2 If didUpdatePayload is null, MUST raise a latePublishingError. MAY identify Beacon Signal to resolver and request additional Sidecar data be provided.
132
- if (!didUpdatePayload) {
133
- throw new SingletonBeaconError('Update payload hash does not match transaction hash.', LATE_PUBLISHING_ERROR);
51
+ // Push signedUpdate to updates array
52
+ updates.push([signedUpdate, signal.blockMetadata]);
134
53
  }
135
- // 7. Return didUpdatePayload.
136
- return didUpdatePayload;
54
+ // Return the array of signed updates
55
+ return updates;
137
56
  }
138
57
  /**
139
- * Implements {@link https://dcdpr.github.io/did-btcr2/#broadcast-singleton-beacon-signal | 5.1.2 Broadcast Singleton Beacon Signal}.
140
- *
141
- * The Broadcast Singleton Beacon Signal algorithm is called by the Announce DID Update algorithm as part of the
142
- * Update operation, if the Beacon being used is of the type SingletonBeacon. It takes as input a Beacon service and a
143
- * secured didUpdatePayload. The algorithm constructs a Bitcoin transaction that spends from the Beacon address
144
- * identified in the service and contains a transaction output of the format [OP_RETURN, OP_PUSH32, <hashBytes>],
145
- * where hashBytes is the SHA256 hash of the canonical didUpdatePayload. The Bitcoin transaction is then signed and
146
- * broadcast to the Bitcoin network, thereby publicly announcing a DID update in a Beacon Signal. It returns a
147
- * signalMetadata object mapping the Bitcoin transaction identifier of the Beacon Signal to the necessary data needed
148
- * to verify the signal announces a specific DID Update Payload.
149
- *
150
- * TODO: Design and implement a way to construct, sign and send via RPC
151
- *
152
- * @param {DidUpdatePayload} didUpdatePayload The verificationMethod object to be used for signing.
153
- * @returns {SignedRawTx} Successful output of a bitcoin transaction.
58
+ * Broadcasts a SingletonBeacon signal to the Bitcoin network.
59
+ * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
60
+ * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
61
+ * @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
62
+ * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
154
63
  * @throws {SingletonBeaconError} if the bitcoin address is invalid or unfunded.
155
64
  */
156
- async broadcastSignal(didUpdatePayload) {
157
- // 1. Initialize an addressURI variable to beacon.serviceEndpoint.
158
- // 2. Set bitcoinAddress to the decoding of addressURI following BIP21.
65
+ async broadcastSignal(signedUpdate, secretKey, bitcoin) {
66
+ // Convert the serviceEndpoint to a bitcoin address by removing the 'bitcoin:' prefix
159
67
  const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
160
- // 3. Ensure bitcoinAddress is funded, if not, fund this address.
161
- // let inputs: Array<CreateRawTxInputs> = [];
68
+ // Query the Bitcoin network for UTXOs associated with the bitcoinAddress
162
69
  const utxos = await bitcoin.network.rest.address.getUtxos(bitcoinAddress);
70
+ // If no utxos are found, throw an error indicating the address is unfunded.
163
71
  if (!utxos.length) {
164
- // TODO: Discuss what to do here because sending to a beacon address does not allow you to spend from it immediately.
165
72
  throw new SingletonBeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
166
73
  }
167
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height)[0];
74
+ // Sort utxos by block height and take the most recent one
75
+ const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
76
+ // If no utxos are found, throw an error.
168
77
  if (!utxo) {
169
78
  throw new SingletonBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
170
79
  }
171
- // 4. Set hashBytes to the result of passing didUpdatePayload to the JSON Canonicalization and Hash algorithm.
172
- const hashBytes = Buffer.fromHex(await JSON.canonicalization.process(didUpdatePayload));
173
- if (hashBytes.length !== 32)
174
- throw new SingletonBeaconError('Hash must be 32 bytes');
175
- // 5. Initialize spendTx to a Bitcoin transaction that spends a transaction controlled by the bitcoinAddress and
176
- // contains at least one transaction output. This output MUST have the following format
177
- // [OP_RETURN, OP_PUSH32, hashBytes]
178
- const { txid, vout } = utxo;
179
- const prevTx = await bitcoin.network.rest.transaction.getHex(txid);
180
- const input = {
181
- hash: txid,
182
- index: vout,
183
- nonWitnessUtxo: Buffer.fromHex(prevTx)
184
- };
185
- // TODO: Figure out a good way to estimate fees
80
+ // Get the previous tx to the utxo being spent
81
+ const prevTx = await bitcoin.network.rest.transaction.getHex(utxo.txid);
82
+ // Canonicalize and hash the signed update for OP_RETURN output
83
+ const updateHash = canonicalization.canonicalhash(signedUpdate);
84
+ // Construct a spend transaction
186
85
  const spendTx = new Psbt({ network: bitcoin.network.data })
187
- .addInput(input)
86
+ // Spend tx contains the utxo as its input
87
+ .addInput({
88
+ hash: utxo.txid,
89
+ index: utxo.vout,
90
+ nonWitnessUtxo: Buffer.from(prevTx, 'hex')
91
+ })
92
+ // Add a change output minus a fee of 500 sats
93
+ // TODO: calculate fee based on transaction vsize and current fee rates
188
94
  .addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
189
- .addOutput({ script: script.compile([opcodes.OP_RETURN, hashBytes]), value: 0n });
190
- // 6. Retrieve the cryptographic material, e.g private key or signing capability, associated with the bitcoinAddress
191
- // or service. How this is done is left to the implementer.
192
- const components = Identifier.decode(this.service.id);
193
- const keyUri = new CompressedSecp256k1PublicKey(components.genesisBytes).hex;
194
- const keyPair = Kms.getKey(keyUri);
95
+ // Add an OP_RETURN output containing the update hash
96
+ .addOutput({ script: script.compile([opcodes.OP_RETURN, updateHash]), value: 0n });
97
+ // Construct a Schnorr key pair from the secret key
98
+ const keyPair = SchnorrKeyPair.fromSecret(secretKey);
195
99
  if (!keyPair) {
196
- throw new Error('Key pair not found.');
100
+ throw new SingletonBeaconError('Key pair not found.', 'KEY_PAIR_NOT_FOUND', { secretKey });
197
101
  }
102
+ // Construct a signer object from the key pair and bitcoin network
198
103
  const signer = new Signer({ keyPair, network: bitcoin.network.name });
199
- // 7. Sign the spendTx.
104
+ // Sign 0th input, finalize extract to hex in prep for broadcast
200
105
  const signedTx = spendTx.signInput(0, signer)
201
106
  .finalizeAllInputs()
202
107
  .extractTransaction()
203
108
  .toHex();
204
- if (!spendTx) {
205
- throw new SingletonBeaconError('Failed to sign raw transaction.', 'RAW_TX_SIGN_FAILED', { spendTx });
206
- }
207
- // 8. Broadcast spendTx to the Bitcoin network.
208
- const spentTx = await bitcoin.network.rest.transaction.send(signedTx);
209
- if (!spentTx) {
210
- throw new SingletonBeaconError('Failed to send raw transaction.', 'SEND_FAILED', { spentTx });
211
- }
212
- // 9. Set signalId to the Bitcoin transaction identifier of spendTx.
213
- // 10. Initialize signalMetadata to an empty object.
214
- // 11. Set signalMetadata.updatePayload to didUpdatePayload.
215
- // 12. Return the object {<signalId>: { updatePayload: DidUpdatePayload; proofs?: any; }}.
216
- return { [spentTx]: { didUpdate: didUpdatePayload } };
109
+ // Broadcast spendTx to the Bitcoin network.
110
+ const txid = await bitcoin.network.rest.transaction.send(signedTx);
111
+ console.info(`Broadcasted Singleton Beacon signal with txid ${txid}`);
112
+ // Return the signed update
113
+ return signedUpdate;
217
114
  }
218
115
  }
219
116
  //# sourceMappingURL=singleton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../../../src/core/beacon/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,wBAAwB,EAAqD,MAAM,oBAAoB,CAAC;AAC9H,OAAO,EAAoB,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAA+B,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM;IAEzC;;;;OAIG;IACH,YAAY,OAAsB,EAAE,OAA6C;QAC/E,KAAK,CAAC,EAAE,G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,gEAAgE;QAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC;aAC1C,iBAAiB,EAAE;aACnB,kBAAkB,EAAE;aACpB,KAAK,EAAE,CAAC;QAEX,4CAA4C;QAC5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;QAEtE,2BAA2B;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,39 @@
1
+ import { Beacon } from './beacon.js';
2
+ import { SMTBeaconError } from './error.js';
3
+ /**
4
+ * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon | SMTBeacon}.
5
+ * @class SMTBeacon
6
+ * @type {SMTBeacon}
7
+ * @extends {Beacon}
8
+ */
9
+ export class SMTBeacon extends Beacon {
10
+ /**
11
+ * Creates an instance of SMTBeacon.
12
+ * @param {BeaconService} service The Beacon service.
13
+ */
14
+ constructor(service) {
15
+ super({ ...service, type: 'SMTBeacon' });
16
+ }
17
+ /**
18
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
19
+ * @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
20
+ * @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
21
+ * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The processed signals.
22
+ * @throws {SMTBeaconError} if processing fails.
23
+ */
24
+ processSignals(signals, sidecar) {
25
+ throw new SMTBeaconError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signals, sidecar });
26
+ }
27
+ /**
28
+ * Broadcast CAS Beacon signal to the Bitcoin network.
29
+ * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
30
+ * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
31
+ * @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
32
+ * @return {Promise<SignedBTCR2Update>} The signed update that was broadcasted.
33
+ * @throws {SMTBeaconError} if broadcasting fails.
34
+ */
35
+ async broadcastSignal(signedUpdate, secretKey, bitcoin) {
36
+ throw new SMTBeaconError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signedUpdate, secretKey, bitcoin });
37
+ }
38
+ }
39
+ //# sourceMappingURL=smt-beacon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smt-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;GAKG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC;;;OAGG;IACH,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CACZ,OAA4B,EAC5B,OAAoB;QAEpB,MAAM,IAAI,cAAc,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC;IACpG,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CACnB,YAA+B,EAC/B,SAAmB,EACnB,OAAiC;QAEjC,MAAM,IAAI,cAAc,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAC,CAAC,CAAC;IACpH,CAAC;CACF"}