@did-btcr2/method 0.25.3 → 0.27.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.
- package/README.md +86 -233
- package/dist/.tsbuildinfo +1 -0
- package/dist/browser.js +129207 -122358
- package/dist/browser.mjs +129235 -122386
- package/dist/cjs/index.js +5332 -43
- package/dist/esm/core/aggregation/cohort.js +178 -0
- package/dist/esm/core/aggregation/cohort.js.map +1 -0
- package/dist/esm/core/aggregation/errors.js +22 -0
- package/dist/esm/core/aggregation/errors.js.map +1 -0
- package/dist/esm/core/{beacon/aggregation/cohort → aggregation}/messages/base.js +0 -1
- package/dist/esm/core/aggregation/messages/base.js.map +1 -0
- package/dist/esm/core/aggregation/messages/constants.js +26 -0
- package/dist/esm/core/aggregation/messages/constants.js.map +1 -0
- package/dist/esm/core/aggregation/messages/factories.js +113 -0
- package/dist/esm/core/aggregation/messages/factories.js.map +1 -0
- package/dist/esm/core/aggregation/messages/guards.js +37 -0
- package/dist/esm/core/aggregation/messages/guards.js.map +1 -0
- package/dist/esm/core/aggregation/messages/index.js +5 -0
- package/dist/esm/core/aggregation/messages/index.js.map +1 -0
- package/dist/esm/core/aggregation/participant.js +376 -0
- package/dist/esm/core/aggregation/participant.js.map +1 -0
- package/dist/esm/core/aggregation/phases.js +39 -0
- package/dist/esm/core/aggregation/phases.js.map +1 -0
- package/dist/esm/core/aggregation/runner/events.js +2 -0
- package/dist/esm/core/aggregation/runner/events.js.map +1 -0
- package/dist/esm/core/aggregation/runner/index.js +5 -0
- package/dist/esm/core/aggregation/runner/index.js.map +1 -0
- package/dist/esm/core/aggregation/runner/participant-runner.js +282 -0
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/service-runner.js +290 -0
- package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/typed-emitter.js +80 -0
- package/dist/esm/core/aggregation/runner/typed-emitter.js.map +1 -0
- package/dist/esm/core/aggregation/service.js +416 -0
- package/dist/esm/core/aggregation/service.js.map +1 -0
- package/dist/esm/core/aggregation/signing-session.js +133 -0
- package/dist/esm/core/aggregation/signing-session.js.map +1 -0
- package/dist/esm/core/aggregation/transport/didcomm.js +32 -0
- package/dist/esm/core/aggregation/transport/didcomm.js.map +1 -0
- package/dist/esm/core/aggregation/transport/error.js +12 -0
- package/dist/esm/core/aggregation/transport/error.js.map +1 -0
- package/dist/esm/core/aggregation/transport/factory.js +20 -0
- package/dist/esm/core/aggregation/transport/factory.js.map +1 -0
- package/dist/esm/core/aggregation/transport/index.js +6 -0
- package/dist/esm/core/aggregation/transport/index.js.map +1 -0
- package/dist/esm/core/aggregation/transport/nostr.js +262 -0
- package/dist/esm/core/aggregation/transport/nostr.js.map +1 -0
- package/dist/esm/core/aggregation/transport/transport.js +2 -0
- package/dist/esm/core/aggregation/transport/transport.js.map +1 -0
- package/dist/esm/core/beacon/beacon.js +80 -0
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +21 -60
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/error.js +0 -10
- package/dist/esm/core/beacon/error.js.map +1 -1
- package/dist/esm/core/beacon/fee-estimator.js +30 -0
- package/dist/esm/core/beacon/fee-estimator.js.map +1 -0
- package/dist/esm/core/beacon/signal-discovery.js +1 -1
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
- package/dist/esm/core/beacon/singleton-beacon.js +13 -56
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +85 -9
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/identifier.js +13 -0
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +50 -35
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +1 -1
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +14 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appendix.js +7 -6
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +2 -2
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/aggregation/cohort.d.ts +94 -0
- package/dist/types/core/aggregation/cohort.d.ts.map +1 -0
- package/dist/types/core/aggregation/errors.d.ts +14 -0
- package/dist/types/core/aggregation/errors.d.ts.map +1 -0
- package/dist/types/core/{beacon/aggregation/cohort → aggregation}/messages/base.d.ts +7 -1
- package/dist/types/core/aggregation/messages/base.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/constants.d.ts +23 -0
- package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/factories.d.ts +177 -0
- package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/guards.d.ts +11 -0
- package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/index.d.ts +5 -0
- package/dist/types/core/aggregation/messages/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/participant.d.ts +101 -0
- package/dist/types/core/aggregation/participant.d.ts.map +1 -0
- package/dist/types/core/aggregation/phases.d.ts +49 -0
- package/dist/types/core/aggregation/phases.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/events.d.ts +89 -0
- package/dist/types/core/aggregation/runner/events.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts +5 -0
- package/dist/types/core/aggregation/runner/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +107 -0
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -0
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts +41 -0
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +1 -0
- package/dist/types/core/aggregation/service.d.ts +112 -0
- package/dist/types/core/aggregation/service.d.ts.map +1 -0
- package/dist/types/core/aggregation/signing-session.d.ts +69 -0
- package/dist/types/core/aggregation/signing-session.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/didcomm.d.ts +20 -0
- package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -0
- package/dist/types/core/{beacon/aggregation/communication → aggregation/transport}/error.d.ts +2 -2
- package/dist/types/core/aggregation/transport/error.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/factory.d.ts +13 -0
- package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts +6 -0
- package/dist/types/core/aggregation/transport/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/nostr.d.ts +55 -0
- package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/transport.d.ts +37 -0
- package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -0
- package/dist/types/core/beacon/beacon.d.ts +41 -6
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +23 -11
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +0 -6
- package/dist/types/core/beacon/error.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +2 -2
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/fee-estimator.d.ts +40 -0
- package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -0
- package/dist/types/core/beacon/interfaces.d.ts +11 -3
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/signal-discovery.d.ts +3 -3
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +14 -7
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +32 -12
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts +4 -4
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts +10 -2
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +4 -4
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +19 -9
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +6 -5
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/update.d.ts +5 -5
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +6 -6
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -24
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +7 -7
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +3 -2
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +3 -3
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +35 -33
- package/src/core/aggregation/cohort.ts +247 -0
- package/src/core/aggregation/errors.ts +25 -0
- package/src/core/{beacon/aggregation/cohort → aggregation}/messages/base.ts +8 -3
- package/src/core/aggregation/messages/constants.ts +28 -0
- package/src/core/aggregation/messages/factories.ts +240 -0
- package/src/core/aggregation/messages/guards.ts +55 -0
- package/src/core/aggregation/messages/index.ts +4 -0
- package/src/core/aggregation/participant.ts +510 -0
- package/src/core/aggregation/phases.ts +82 -0
- package/src/core/aggregation/runner/events.ts +77 -0
- package/src/core/aggregation/runner/index.ts +4 -0
- package/src/core/aggregation/runner/participant-runner.ts +360 -0
- package/src/core/aggregation/runner/service-runner.ts +365 -0
- package/src/core/aggregation/runner/typed-emitter.ts +87 -0
- package/src/core/aggregation/service.ts +547 -0
- package/src/core/aggregation/signing-session.ts +209 -0
- package/src/core/aggregation/transport/didcomm.ts +42 -0
- package/src/core/aggregation/transport/error.ts +13 -0
- package/src/core/aggregation/transport/factory.ts +29 -0
- package/src/core/aggregation/transport/index.ts +5 -0
- package/src/core/aggregation/transport/nostr.ts +333 -0
- package/src/core/aggregation/transport/transport.ts +46 -0
- package/src/core/beacon/beacon.ts +126 -6
- package/src/core/beacon/cas-beacon.ts +39 -83
- package/src/core/beacon/error.ts +0 -12
- package/src/core/beacon/factory.ts +2 -2
- package/src/core/beacon/fee-estimator.ts +52 -0
- package/src/core/beacon/interfaces.ts +13 -4
- package/src/core/beacon/signal-discovery.ts +5 -4
- package/src/core/beacon/singleton-beacon.ts +21 -81
- package/src/core/beacon/smt-beacon.ts +113 -15
- package/src/core/beacon/utils.ts +6 -4
- package/src/core/identifier.ts +20 -2
- package/src/core/interfaces.ts +4 -4
- package/src/core/resolver.ts +84 -53
- package/src/core/types.ts +6 -5
- package/src/core/update.ts +11 -7
- package/src/did-btcr2.ts +12 -10
- package/src/index.ts +15 -29
- package/src/utils/appendix.ts +14 -16
- package/src/utils/did-document-builder.ts +3 -2
- package/src/utils/did-document.ts +10 -8
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +0 -237
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +0 -26
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +0 -11
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +0 -98
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/status.js +0 -8
- package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/error.js +0 -12
- package/dist/cjs/core/beacon/aggregation/communication/error.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/factory.js +0 -21
- package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/service.js +0 -2
- package/dist/cjs/core/beacon/aggregation/communication/service.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +0 -343
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +0 -435
- package/dist/cjs/core/beacon/aggregation/participant.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +0 -244
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/status.js +0 -11
- package/dist/cjs/core/beacon/aggregation/session/status.js.map +0 -1
- package/dist/cjs/core/beacon/beacon.js +0 -25
- package/dist/cjs/core/beacon/beacon.js.map +0 -1
- package/dist/cjs/core/beacon/cas-beacon.js +0 -152
- package/dist/cjs/core/beacon/cas-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/error.js +0 -37
- package/dist/cjs/core/beacon/error.js.map +0 -1
- package/dist/cjs/core/beacon/factory.js +0 -29
- package/dist/cjs/core/beacon/factory.js.map +0 -1
- package/dist/cjs/core/beacon/interfaces.js +0 -2
- package/dist/cjs/core/beacon/interfaces.js.map +0 -1
- package/dist/cjs/core/beacon/signal-discovery.js +0 -183
- package/dist/cjs/core/beacon/signal-discovery.js.map +0 -1
- package/dist/cjs/core/beacon/singleton-beacon.js +0 -107
- package/dist/cjs/core/beacon/singleton-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/smt-beacon.js +0 -39
- package/dist/cjs/core/beacon/smt-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/utils.js +0 -163
- package/dist/cjs/core/beacon/utils.js.map +0 -1
- package/dist/cjs/core/identifier.js +0 -248
- package/dist/cjs/core/identifier.js.map +0 -1
- package/dist/cjs/core/interfaces.js +0 -2
- package/dist/cjs/core/interfaces.js.map +0 -1
- package/dist/cjs/core/resolver.js +0 -476
- package/dist/cjs/core/resolver.js.map +0 -1
- package/dist/cjs/core/types.js +0 -2
- package/dist/cjs/core/types.js.map +0 -1
- package/dist/cjs/core/update.js +0 -112
- package/dist/cjs/core/update.js.map +0 -1
- package/dist/cjs/did-btcr2.js +0 -193
- package/dist/cjs/did-btcr2.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/appendix.js +0 -203
- package/dist/cjs/utils/appendix.js.map +0 -1
- package/dist/cjs/utils/did-document-builder.js +0 -60
- package/dist/cjs/utils/did-document-builder.js.map +0 -1
- package/dist/cjs/utils/did-document.js +0 -424
- package/dist/cjs/utils/did-document.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/index.js +0 -237
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +0 -11
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +0 -98
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/status.js +0 -8
- package/dist/esm/core/beacon/aggregation/cohort/status.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/error.js +0 -12
- package/dist/esm/core/beacon/aggregation/communication/error.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/factory.js +0 -21
- package/dist/esm/core/beacon/aggregation/communication/factory.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/service.js +0 -2
- package/dist/esm/core/beacon/aggregation/communication/service.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +0 -343
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/participant.js +0 -435
- package/dist/esm/core/beacon/aggregation/participant.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +0 -244
- package/dist/esm/core/beacon/aggregation/session/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/session/status.js +0 -11
- package/dist/esm/core/beacon/aggregation/session/status.js.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +0 -136
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +0 -11
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +0 -65
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +0 -29
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +0 -24
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +0 -20
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +0 -25
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +0 -25
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +0 -27
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts +0 -8
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +0 -89
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +0 -103
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +0 -10
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +0 -36
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +0 -116
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +0 -192
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +0 -156
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/session/status.d.ts +0 -11
- package/dist/types/core/beacon/aggregation/session/status.d.ts.map +0 -1
- package/src/core/beacon/aggregation/cohort/index.ts +0 -304
- package/src/core/beacon/aggregation/cohort/messages/constants.ts +0 -12
- package/src/core/beacon/aggregation/cohort/messages/index.ts +0 -143
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +0 -43
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -34
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -33
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -35
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -38
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -40
- package/src/core/beacon/aggregation/cohort/status.ts +0 -7
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -147
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -321
- package/src/core/beacon/aggregation/communication/error.ts +0 -13
- package/src/core/beacon/aggregation/communication/factory.ts +0 -25
- package/src/core/beacon/aggregation/communication/service.ts +0 -42
- package/src/core/beacon/aggregation/coordinator.ts +0 -415
- package/src/core/beacon/aggregation/participant.ts +0 -512
- package/src/core/beacon/aggregation/session/index.ts +0 -300
- package/src/core/beacon/aggregation/session/status.ts +0 -18
|
@@ -4,16 +4,6 @@ export class BeaconError extends MethodError {
|
|
|
4
4
|
super(message, type, data);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export class BeaconCoordinatorError extends MethodError {
|
|
8
|
-
constructor(message, type = 'BeaconCoordinatorError', data) {
|
|
9
|
-
super(message, type, data);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class BeaconParticipantError extends MethodError {
|
|
13
|
-
constructor(message, type = 'BeaconParticipantError', data) {
|
|
14
|
-
super(message, type, data);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
7
|
export class SingletonBeaconError extends MethodError {
|
|
18
8
|
constructor(message, type = 'SingletonBeaconError', data) {
|
|
19
9
|
super(message, type, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/core/beacon/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,OAAe,EAAE,OAAe,aAAa,EAAE,IAA0B;QACnF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/core/beacon/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,OAAe,EAAE,OAAe,aAAa,EAAE,IAA0B;QACnF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe,EAAE,OAAe,sBAAsB,EAAE,IAA0B;QAC5F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,OAAe,EAAE,OAAe,sBAAsB,EAAE,IAA0B;QAC5F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAAe,gBAAgB,EAAE,IAA0B;QACtF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAAe,gBAAgB,EAAE,IAA0B;QACtF,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fee estimator that returns a fixed fee rate regardless of network conditions.
|
|
3
|
+
*
|
|
4
|
+
* Suitable for:
|
|
5
|
+
* - Tests (deterministic outputs)
|
|
6
|
+
* - Regtest (no real fee market)
|
|
7
|
+
* - Environments where a fee rate is supplied out-of-band
|
|
8
|
+
*
|
|
9
|
+
* For mainnet production use, prefer a dynamic estimator that queries current
|
|
10
|
+
* network conditions (mempool APIs, Bitcoin Core RPC).
|
|
11
|
+
*/
|
|
12
|
+
export class StaticFeeEstimator {
|
|
13
|
+
satsPerVbyte;
|
|
14
|
+
/**
|
|
15
|
+
* @param satsPerVbyte Fee rate in satoshis per virtual byte. Default: 5 sat/vB.
|
|
16
|
+
*/
|
|
17
|
+
constructor(satsPerVbyte = 5) {
|
|
18
|
+
if (satsPerVbyte < 0 || !Number.isFinite(satsPerVbyte)) {
|
|
19
|
+
throw new Error(`Invalid satsPerVbyte: ${satsPerVbyte}`);
|
|
20
|
+
}
|
|
21
|
+
this.satsPerVbyte = satsPerVbyte;
|
|
22
|
+
}
|
|
23
|
+
async estimateFee(vsize) {
|
|
24
|
+
if (vsize < 0 || !Number.isFinite(vsize)) {
|
|
25
|
+
throw new Error(`Invalid vsize: ${vsize}`);
|
|
26
|
+
}
|
|
27
|
+
return BigInt(Math.ceil(vsize * this.satsPerVbyte));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=fee-estimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee-estimator.js","sourceRoot":"","sources":["../../../../src/core/beacon/fee-estimator.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IACpB,YAAY,CAAS;IAE9B;;OAEG;IACH,YAAY,eAAuB,CAAC;QAClC,IAAG,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,IAAG,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -3,7 +3,7 @@ import { ResolveError } from '@did-btcr2/common';
|
|
|
3
3
|
import { BeaconUtils } from './utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* Static utility class for discovering Beacon Signals on the Bitcoin blockchain.
|
|
6
|
-
* Extracted from
|
|
6
|
+
* Extracted from `Resolver` for single-responsibility and independent testability.
|
|
7
7
|
*
|
|
8
8
|
* @class BeaconSignalDiscovery
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal-discovery.js","sourceRoot":"","sources":["../../../../src/core/beacon/signal-discovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signal-discovery.js","sourceRoot":"","sources":["../../../../src/core/beacon/signal-discovery.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAEhC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,cAAoC,EACpC,OAA0B;QAE1B,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAsC,CAAC;QAE3E,qDAAqD;QACrD,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAE3D,2BAA2B;QAC3B,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;YAC3C,oBAAoB,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC5C,uDAAuD;YACvD,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CACrD,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,eAAyB,CAAC,CACzE,CAAC;YAEF,oCAAoC;YACpC,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;gBAC5C,SAAS;YACX,CAAC;YAED,2BAA2B;YAC3B,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;gBACzC,uCAAuC;gBACvC,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAElD;;;;;;;;;mBASG;gBACH,IAAG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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjE,IAAG,CAAC,UAAU,EAAE,CAAC;wBACf,SAAS;oBACX,CAAC;oBAED,oFAAoF;oBACpF,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;wBAC5C,EAAE;wBACF,WAAW,EAAK,UAAU;wBAC1B,aAAa,EAAG;4BACd,MAAM,EAAU,KAAK,CAAC,MAAM;4BAC5B,IAAI,EAAY,KAAK,CAAC,IAAI;4BAC1B,aAAa,EAAG,KAAK,CAAC,aAAa;yBACpC;qBACF,CAAC,CAAC;gBACL,CAAC;gBAAA,CAAC;YACJ,CAAC;YAED,uBAAuB;YACvB,MAAM,IAAI,CAAC,CAAC;YAEZ,sFAAsF;YACtF,IAAG,MAAM,GAAG,YAAY,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,qBAAqB,MAAM,gBAAgB,CAAC,CAAC;gBAC1D,MAAM;YACR,CAAC;YAED,6CAA6C;YAC7C,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAY,CAAC;QACpD,CAAC;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { canonicalize,
|
|
2
|
-
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import { hexToBytes } from '@noble/hashes/utils';
|
|
4
|
-
import { opcodes, Psbt, script } from 'bitcoinjs-lib';
|
|
1
|
+
import { canonicalize, hash } from '@did-btcr2/common';
|
|
5
2
|
import { Beacon } from './beacon.js';
|
|
6
|
-
import { SingletonBeaconError } from './error.js';
|
|
7
3
|
/**
|
|
8
4
|
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
|
|
9
5
|
* @class SingletonBeacon
|
|
@@ -28,8 +24,8 @@ export class SingletonBeacon extends Beacon {
|
|
|
28
24
|
const updates = new Array();
|
|
29
25
|
const needs = new Array();
|
|
30
26
|
for (const signal of signals) {
|
|
31
|
-
//
|
|
32
|
-
const updateHash =
|
|
27
|
+
// Signal bytes are hex — matches hex-keyed sidecar maps directly
|
|
28
|
+
const updateHash = signal.signalBytes;
|
|
33
29
|
// Look up the signed update in sidecar updateMap
|
|
34
30
|
const signedUpdate = sidecar.updateMap.get(updateHash);
|
|
35
31
|
if (!signedUpdate) {
|
|
@@ -47,60 +43,21 @@ export class SingletonBeacon extends Beacon {
|
|
|
47
43
|
}
|
|
48
44
|
/**
|
|
49
45
|
* Broadcasts a SingletonBeacon signal to the Bitcoin network.
|
|
46
|
+
*
|
|
47
|
+
* The signal bytes embedded in OP_RETURN are the SHA-256 canonical hash of the signed update.
|
|
48
|
+
* UTXO selection, PSBT construction, fee estimation, signing, and broadcast are delegated to
|
|
49
|
+
* {@link Beacon.buildSignAndBroadcast}.
|
|
50
|
+
*
|
|
50
51
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
51
52
|
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
52
53
|
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
54
|
+
* @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
|
|
53
55
|
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
54
|
-
* @throws {
|
|
56
|
+
* @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
|
|
55
57
|
*/
|
|
56
|
-
async broadcastSignal(signedUpdate, secretKey, bitcoin) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// Query the Bitcoin network for UTXOs associated with the bitcoinAddress
|
|
60
|
-
const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
|
|
61
|
-
// If no utxos are found, throw an error indicating the address is unfunded.
|
|
62
|
-
if (!utxos.length) {
|
|
63
|
-
throw new SingletonBeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
64
|
-
}
|
|
65
|
-
// Sort utxos by block height and take the most recent one
|
|
66
|
-
const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
|
|
67
|
-
// If no utxos are found, throw an error.
|
|
68
|
-
if (!utxo) {
|
|
69
|
-
throw new SingletonBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
70
|
-
}
|
|
71
|
-
// Get the previous tx to the utxo being spent
|
|
72
|
-
const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
|
|
73
|
-
// Canonicalize and hash the signed update for OP_RETURN output
|
|
74
|
-
const updateHash = hash(canonicalize(signedUpdate));
|
|
75
|
-
// Construct a spend transaction
|
|
76
|
-
const spendTx = new Psbt({ network: bitcoin.data })
|
|
77
|
-
// Spend tx contains the utxo as its input
|
|
78
|
-
.addInput({
|
|
79
|
-
hash: utxo.txid,
|
|
80
|
-
index: utxo.vout,
|
|
81
|
-
nonWitnessUtxo: hexToBytes(prevTx)
|
|
82
|
-
})
|
|
83
|
-
// Add a change output minus a fee of 500 sats
|
|
84
|
-
// TODO: calculate fee based on transaction vsize and current fee rates
|
|
85
|
-
.addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
|
|
86
|
-
// Add an OP_RETURN output containing the update hash
|
|
87
|
-
.addOutput({ script: script.compile([opcodes.OP_RETURN, updateHash]), value: 0n });
|
|
88
|
-
// Construct a key pair and PSBT signer from the secret key
|
|
89
|
-
const keyPair = SchnorrKeyPair.fromSecret(secretKey);
|
|
90
|
-
const signer = {
|
|
91
|
-
publicKey: keyPair.publicKey.compressed,
|
|
92
|
-
sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
|
|
93
|
-
};
|
|
94
|
-
// Sign 0th input, finalize extract to hex in prep for broadcast
|
|
95
|
-
const signedTx = spendTx.signInput(0, signer)
|
|
96
|
-
.finalizeAllInputs()
|
|
97
|
-
.extractTransaction()
|
|
98
|
-
.toHex();
|
|
99
|
-
// Broadcast spendTx to the Bitcoin network.
|
|
100
|
-
const txid = await bitcoin.rest.transaction.send(signedTx);
|
|
101
|
-
// Log the txid of the broadcasted transaction
|
|
102
|
-
console.info(`Singleton Beacon Signal Broadcasted with txid: ${txid}`);
|
|
103
|
-
// Return the signed update
|
|
58
|
+
async broadcastSignal(signedUpdate, secretKey, bitcoin, options) {
|
|
59
|
+
const signalBytes = hash(canonicalize(signedUpdate));
|
|
60
|
+
await this.buildSignAndBroadcast(signalBytes, secretKey, bitcoin, options);
|
|
104
61
|
return signedUpdate;
|
|
105
62
|
}
|
|
106
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/singleton-beacon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"singleton-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/singleton-beacon.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAKvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM;IAEzC;;;OAGG;IACH,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,cAAc,CACZ,OAA4B,EAC5B,OAAoB;QAEpB,MAAM,OAAO,GAAG,IAAI,KAAK,EAAsC,CAAC;QAChE,MAAM,KAAK,GAAG,IAAI,KAAK,EAAY,CAAC;QAEpC,KAAI,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC5B,iEAAiE;YACjE,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;YAEtC,iDAAiD;YACjD,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAEvD,IAAG,CAAC,YAAY,EAAE,CAAC;gBACjB,uDAAuD;gBACvD,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAe,kBAAkB;oBACrC,UAAU;oBACV,eAAe,EAAI,IAAI,CAAC,OAAO,CAAC,EAAE;iBACnC,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,eAAe,CACnB,YAA+B,EAC/B,SAAmB,EACnB,OAA0B,EAC1B,OAA0B;QAE1B,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3E,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { canonicalize } from '@did-btcr2/common';
|
|
2
|
+
import { blockHash, BTCR2MerkleTree, didToIndex, hexToHash, verifySerializedProof } from '@did-btcr2/smt';
|
|
3
|
+
import { randomBytes } from '@noble/hashes/utils';
|
|
1
4
|
import { Beacon } from './beacon.js';
|
|
2
5
|
import { SMTBeaconError } from './error.js';
|
|
3
6
|
/**
|
|
4
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon |
|
|
7
|
+
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon | SMT Beacon}.
|
|
8
|
+
*
|
|
9
|
+
* An SMT (Sparse Merkle Tree) Beacon aggregates updates for multiple DIDs
|
|
10
|
+
* into a single Merkle root hash broadcast on-chain via OP_RETURN.
|
|
11
|
+
* During resolution, the SMT Proof from the sidecar is verified against the
|
|
12
|
+
* on-chain root, and the proof's updateId is used to retrieve the signed update.
|
|
13
|
+
*
|
|
5
14
|
* @class SMTBeacon
|
|
6
15
|
* @type {SMTBeacon}
|
|
7
16
|
* @extends {Beacon}
|
|
@@ -16,24 +25,91 @@ export class SMTBeacon extends Beacon {
|
|
|
16
25
|
}
|
|
17
26
|
/**
|
|
18
27
|
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
|
|
28
|
+
*
|
|
29
|
+
* For each signal, the signalBytes contain the hex-encoded SMT root hash.
|
|
30
|
+
* This method looks up the SMT Proof from the sidecar by root hash,
|
|
31
|
+
* validates the Merkle inclusion proof, and retrieves the corresponding
|
|
32
|
+
* signed update using the proof's updateId.
|
|
33
|
+
*
|
|
19
34
|
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
20
35
|
* @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
|
|
21
|
-
* @returns {BeaconProcessResult}
|
|
22
|
-
* @throws {SMTBeaconError} if
|
|
36
|
+
* @returns {BeaconProcessResult} Successfully resolved updates and any data needs.
|
|
37
|
+
* @throws {SMTBeaconError} if proof verification fails or proof is malformed.
|
|
23
38
|
*/
|
|
24
39
|
processSignals(signals, sidecar) {
|
|
25
|
-
|
|
40
|
+
const updates = new Array();
|
|
41
|
+
const needs = new Array();
|
|
42
|
+
// Extract the DID from the beacon service id (strip the #fragment)
|
|
43
|
+
const did = this.service.id.split('#')[0];
|
|
44
|
+
for (const signal of signals) {
|
|
45
|
+
// Signal bytes are the hex-encoded SMT root hash; smtMap is keyed by proof.id (also hex)
|
|
46
|
+
const smtProof = sidecar.smtMap.get(signal.signalBytes);
|
|
47
|
+
if (!smtProof) {
|
|
48
|
+
// SMT Proof not available — emit a need
|
|
49
|
+
needs.push({
|
|
50
|
+
kind: 'NeedSMTProof',
|
|
51
|
+
smtRootHash: signal.signalBytes,
|
|
52
|
+
beaconServiceId: this.service.id
|
|
53
|
+
});
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Non-inclusion proof — no update for this DID in this epoch, skip
|
|
57
|
+
if (!smtProof.updateId) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
// Nonce is required for proof verification
|
|
61
|
+
if (!smtProof.nonce) {
|
|
62
|
+
throw new SMTBeaconError('SMT proof missing required nonce field.', 'INVALID_SMT_PROOF', { smtProof, did });
|
|
63
|
+
}
|
|
64
|
+
// Verify Merkle inclusion: leaf = hash(hash(nonce) || updateId)
|
|
65
|
+
const index = didToIndex(did);
|
|
66
|
+
const candidateHash = blockHash(blockHash(hexToHash(smtProof.nonce)), hexToHash(smtProof.updateId));
|
|
67
|
+
const valid = verifySerializedProof(smtProof, index, candidateHash);
|
|
68
|
+
if (!valid) {
|
|
69
|
+
throw new SMTBeaconError('SMT proof verification failed.', 'INVALID_SMT_PROOF', { smtProof, did });
|
|
70
|
+
}
|
|
71
|
+
// Look up the signed update in sidecar updateMap (keyed by hex canonical hash)
|
|
72
|
+
const signedUpdate = sidecar.updateMap.get(smtProof.updateId);
|
|
73
|
+
if (!signedUpdate) {
|
|
74
|
+
// Signed update not available — emit a need
|
|
75
|
+
needs.push({
|
|
76
|
+
kind: 'NeedSignedUpdate',
|
|
77
|
+
updateHash: smtProof.updateId,
|
|
78
|
+
beaconServiceId: this.service.id
|
|
79
|
+
});
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
updates.push([signedUpdate, signal.blockMetadata]);
|
|
83
|
+
}
|
|
84
|
+
return { updates, needs };
|
|
26
85
|
}
|
|
27
86
|
/**
|
|
28
|
-
*
|
|
87
|
+
* Broadcasts an SMT Beacon signal to the Bitcoin network.
|
|
88
|
+
*
|
|
89
|
+
* Builds a single-entry Sparse Merkle Tree from the signed update, then broadcasts the tree's
|
|
90
|
+
* root hash via OP_RETURN. For multi-party aggregation, use the {@link AggregationService}
|
|
91
|
+
* subsystem directly instead of this method. UTXO selection, PSBT construction, fee estimation,
|
|
92
|
+
* signing, and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
|
|
93
|
+
*
|
|
29
94
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
30
95
|
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
31
96
|
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
97
|
+
* @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
|
|
98
|
+
* @return {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
99
|
+
* @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
|
|
34
100
|
*/
|
|
35
|
-
async broadcastSignal(signedUpdate, secretKey, bitcoin) {
|
|
36
|
-
|
|
101
|
+
async broadcastSignal(signedUpdate, secretKey, bitcoin, options) {
|
|
102
|
+
// Extract the DID from the beacon service id (strip the #fragment)
|
|
103
|
+
const did = this.service.id.split('#')[0];
|
|
104
|
+
// Build a single-entry SMT from the signed update
|
|
105
|
+
const canonicalBytes = new TextEncoder().encode(canonicalize(signedUpdate));
|
|
106
|
+
const nonce = randomBytes(32);
|
|
107
|
+
const tree = new BTCR2MerkleTree();
|
|
108
|
+
tree.addEntries([{ did, nonce, signedUpdate: canonicalBytes }]);
|
|
109
|
+
tree.finalize();
|
|
110
|
+
// Root hash is the signal bytes for the OP_RETURN output
|
|
111
|
+
await this.buildSignAndBroadcast(tree.rootHash, secretKey, bitcoin, options);
|
|
112
|
+
return signedUpdate;
|
|
37
113
|
}
|
|
38
114
|
}
|
|
39
115
|
//# sourceMappingURL=smt-beacon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smt-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings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AC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,eAAe,CACnB,YAA+B,EAC/B,SAAmB,EACnB,OAA0B,EAC1B,OAA0B;QAE1B,mEAAmE;QACnE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,kDAAkD;QAClD,MAAM,cAAc,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,yDAAyD;QACzD,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAE7E,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEn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M,IAAI,WAAW,CACnB,oCAAoC,GAAG,KAAK,CAAC,OAAO,EACpD,sBAAsB,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAC/D,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAqB;QACrD,OAAO,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAC,CAAC;IACvF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAA6B;QACvD,OAAO,IAAI,GAAG,CACZ,OAAO;aACJ,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC;aACpC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,eAAyB,EAAE,MAAM,CAAC,CAAC,CAAC,CACjE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAwB;QACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -230,6 +230,19 @@ export class Identifier {
|
|
|
230
230
|
});
|
|
231
231
|
return { keyPair: keyPair.exportJSON(), did };
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Extracts the compressed secp256k1 public key from a KEY-type did:btcr2 identifier.
|
|
235
|
+
* @param {string} did The did:btcr2 identifier to extract the public key from.
|
|
236
|
+
* @returns {CompressedSecp256k1PublicKey} The compressed public key.
|
|
237
|
+
* @throws {IdentifierError} If the DID is EXTERNAL type (genesis bytes are a hash, not a pubkey).
|
|
238
|
+
*/
|
|
239
|
+
static getPublicKey(did) {
|
|
240
|
+
const { idType, genesisBytes } = Identifier.decode(did);
|
|
241
|
+
if (idType !== 'KEY') {
|
|
242
|
+
throw new IdentifierError(`Cannot extract public key from EXTERNAL DID: ${did}. EXTERNAL DIDs encode a document hash, not a public key.`, INVALID_DID, { did, idType });
|
|
243
|
+
}
|
|
244
|
+
return new CompressedSecp256k1PublicKey(genesisBytes);
|
|
245
|
+
}
|
|
233
246
|
/**
|
|
234
247
|
* Validates a did:btcr2 identifier.
|
|
235
248
|
* @param {string} identifier The did:btcr2 identifier to validate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/core/identifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/core/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAWrC,CAAC;AAgBF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IACrB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,CAAC,YAAsC,EAAE,OAAyB;QAC7E,0BAA0B;QAC1B,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAEjD,oEAAoE;QACpE,IAAI,CAAC,CAAC,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,eAAe,CAAC,6CAA6C,EAAE,WAAW,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;QAClG,CAAC;QAED,2DAA2D;QAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,eAAe,CAAC,4BAA4B,EAAE,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r2/bitcoin';
|
|
2
|
-
import { canonicalHash, canonicalize, DateUtils, encode as encodeHash, decode as decodeHash, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, JSONPatch, JSONUtils, LATE_PUBLISHING_ERROR, ResolveError } from '@did-btcr2/common';
|
|
2
|
+
import { canonicalHash, canonicalHashBytes, canonicalize, DateUtils, encode as encodeHash, decode as decodeHash, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, JSONPatch, JSONUtils, LATE_PUBLISHING_ERROR, ResolveError } from '@did-btcr2/common';
|
|
3
3
|
import { BIP340Cryptosuite, BIP340DataIntegrityProof, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
4
4
|
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
5
5
|
import { DidBtcr2 } from '../did-btcr2.js';
|
|
@@ -8,6 +8,7 @@ import { DidDocument, ID_PLACEHOLDER_VALUE } from '../utils/did-document.js';
|
|
|
8
8
|
import { BeaconFactory } from './beacon/factory.js';
|
|
9
9
|
import { BeaconUtils } from './beacon/utils.js';
|
|
10
10
|
import { Identifier } from './identifier.js';
|
|
11
|
+
import { equalBytes } from '@noble/curves/utils.js';
|
|
11
12
|
/**
|
|
12
13
|
* Different possible Resolver states representing phases in the resolution process.
|
|
13
14
|
*/
|
|
@@ -114,16 +115,17 @@ export class Resolver {
|
|
|
114
115
|
* @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
|
|
115
116
|
*/
|
|
116
117
|
static external(didComponents, genesisDocument) {
|
|
117
|
-
//
|
|
118
|
-
const
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
// Canonicalize and sha256 hash the genesis document
|
|
119
|
+
const genesisDocumentHash = canonicalHashBytes(genesisDocument);
|
|
120
|
+
// Compare genesis bytes from identifier against the document hash (byte comparison)
|
|
121
|
+
if (!equalBytes(didComponents.genesisBytes, genesisDocumentHash)) {
|
|
122
|
+
throw new ResolveError(`Initial document mismatch: genesisBytes !== genesisDocumentHash`, INVALID_DID_DOCUMENT, {
|
|
123
|
+
genesisBytes: encodeHash(didComponents.genesisBytes, 'hex'),
|
|
124
|
+
genesisDocumentHash: encodeHash(genesisDocumentHash, 'hex')
|
|
125
|
+
});
|
|
124
126
|
}
|
|
125
127
|
// Encode the did from the didComponents
|
|
126
|
-
const did = Identifier.encode(
|
|
128
|
+
const did = Identifier.encode(didComponents.genesisBytes, didComponents);
|
|
127
129
|
// Replace the placeholder did with the did throughout the currentDocument.
|
|
128
130
|
const currentDocument = JSON.parse(JSON.stringify(genesisDocument).replaceAll(ID_PLACEHOLDER_VALUE, did));
|
|
129
131
|
// Return a W3C conformant DID Document
|
|
@@ -139,13 +141,13 @@ export class Resolver {
|
|
|
139
141
|
const updateMap = new Map();
|
|
140
142
|
if (sidecar.updates?.length)
|
|
141
143
|
for (const update of sidecar.updates) {
|
|
142
|
-
updateMap.set(canonicalHash(update), update);
|
|
144
|
+
updateMap.set(canonicalHash(update, { encoding: 'hex' }), update);
|
|
143
145
|
}
|
|
144
146
|
// CAS Announcements map
|
|
145
147
|
const casMap = new Map();
|
|
146
148
|
if (sidecar.casUpdates?.length)
|
|
147
149
|
for (const update of sidecar.casUpdates) {
|
|
148
|
-
casMap.set(canonicalHash(update), update);
|
|
150
|
+
casMap.set(canonicalHash(update, { encoding: 'hex' }), update);
|
|
149
151
|
}
|
|
150
152
|
// SMT Proofs map
|
|
151
153
|
const smtMap = new Map();
|
|
@@ -166,7 +168,7 @@ export class Resolver {
|
|
|
166
168
|
static updates(currentDocument, unsortedUpdates, versionTime, versionId) {
|
|
167
169
|
// Start the version number being processed at 1
|
|
168
170
|
let currentVersionId = 1;
|
|
169
|
-
// Initialize an empty array to hold the update hashes
|
|
171
|
+
// Initialize an empty array to hold the update hashes (raw bytes)
|
|
170
172
|
const updateHashHistory = [];
|
|
171
173
|
// 1. Sort updates by targetVersionId (ascending), using blockheight as tie-breaker
|
|
172
174
|
const updates = unsortedUpdates.sort(([upd0, blk0], [upd1, blk1]) => upd0.targetVersionId - upd1.targetVersionId || blk0.height - blk1.height);
|
|
@@ -182,8 +184,8 @@ export class Resolver {
|
|
|
182
184
|
};
|
|
183
185
|
// Iterate over each (update block) pair
|
|
184
186
|
for (const [update, block] of updates) {
|
|
185
|
-
// Get the hash of the current document
|
|
186
|
-
const currentDocumentHash =
|
|
187
|
+
// Get the hash of the current document as raw bytes
|
|
188
|
+
const currentDocumentHash = canonicalHashBytes(response.didDocument);
|
|
187
189
|
// Safely convert block.time to timestamp
|
|
188
190
|
const blocktime = DateUtils.blocktimeToTimestamp(block.time);
|
|
189
191
|
// TODO: How to detect if block is unconfirmed and exit gracefully or return without it
|
|
@@ -206,17 +208,20 @@ export class Resolver {
|
|
|
206
208
|
}
|
|
207
209
|
// If update.targetVersionId == currentVersionId + 1, apply the update
|
|
208
210
|
else if (update.targetVersionId === currentVersionId + 1) {
|
|
209
|
-
// Check if update.sourceHash !== currentDocumentHash
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
throw new ResolveError(`Hash mismatch: update.sourceHash !== currentDocumentHash`, INVALID_DID_UPDATE, {
|
|
211
|
+
// Check if update.sourceHash !== currentDocumentHash (byte comparison)
|
|
212
|
+
const sourceHashBytes = decodeHash(update.sourceHash, 'base64urlnopad');
|
|
213
|
+
if (!equalBytes(sourceHashBytes, currentDocumentHash)) {
|
|
214
|
+
throw new ResolveError(`Hash mismatch: update.sourceHash !== currentDocumentHash`, INVALID_DID_UPDATE, {
|
|
215
|
+
sourceHash: update.sourceHash,
|
|
216
|
+
currentDocumentHash: encodeHash(currentDocumentHash, 'hex')
|
|
217
|
+
});
|
|
213
218
|
}
|
|
214
219
|
// Apply the update to the currentDocument and set it in the response
|
|
215
220
|
response.didDocument = this.applyUpdate(response.didDocument, update);
|
|
216
221
|
// Create unsigned_update by removing the proof property from update.
|
|
217
222
|
const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']);
|
|
218
|
-
// Push the canonicalized unsigned update hash to the updateHashHistory
|
|
219
|
-
updateHashHistory.push(
|
|
223
|
+
// Push the canonicalized unsigned update hash bytes to the updateHashHistory
|
|
224
|
+
updateHashHistory.push(canonicalHashBytes(unsignedUpdate));
|
|
220
225
|
}
|
|
221
226
|
// If update.targetVersionId > currentVersionId + 1, throw LATE_PUBLISHING error
|
|
222
227
|
else if (update.targetVersionId > currentVersionId + 1) {
|
|
@@ -245,24 +250,26 @@ export class Resolver {
|
|
|
245
250
|
// Return response data
|
|
246
251
|
return response;
|
|
247
252
|
}
|
|
248
|
-
// ─── Private static: update internals ──────────────────────────────
|
|
249
253
|
/**
|
|
250
254
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
|
|
251
255
|
* This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
|
|
252
256
|
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
|
|
253
|
-
* @param {
|
|
257
|
+
* @param {HashBytes[]} updateHashHistory The accumulated hash history for comparison.
|
|
254
258
|
* @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
|
|
255
259
|
*/
|
|
256
260
|
static confirmDuplicate(update, updateHashHistory) {
|
|
257
261
|
// Create unsigned_update by removing the proof property from update.
|
|
258
262
|
const { proof: _, ...unsignedUpdate } = update;
|
|
259
|
-
// Hash unsignedUpdate with JSON Document Hashing algorithm
|
|
260
|
-
const unsignedUpdateHash =
|
|
263
|
+
// Hash unsignedUpdate with JSON Document Hashing algorithm (raw bytes)
|
|
264
|
+
const unsignedUpdateHash = canonicalHashBytes(unsignedUpdate);
|
|
261
265
|
// Let historicalUpdateHash equal updateHashHistory[updateHashIndex].
|
|
262
266
|
const historicalUpdateHash = updateHashHistory[update.targetVersionId - 2];
|
|
263
|
-
// Check if the updateHash matches the historical hash
|
|
264
|
-
if (
|
|
265
|
-
throw new ResolveError(`Invalid duplicate:
|
|
267
|
+
// Check if the updateHash matches the historical hash (byte comparison)
|
|
268
|
+
if (!equalBytes(historicalUpdateHash, unsignedUpdateHash)) {
|
|
269
|
+
throw new ResolveError(`Invalid duplicate: unsigned update hash does not match historical hash`, LATE_PUBLISHING_ERROR, {
|
|
270
|
+
unsignedUpdateHash: encodeHash(unsignedUpdateHash, 'hex'),
|
|
271
|
+
historicalHash: encodeHash(historicalUpdateHash, 'hex')
|
|
272
|
+
});
|
|
266
273
|
}
|
|
267
274
|
}
|
|
268
275
|
/**
|
|
@@ -316,19 +323,18 @@ export class Resolver {
|
|
|
316
323
|
const updatedDocument = JSONPatch.apply(currentDocument, update.patch);
|
|
317
324
|
// Verify that updatedDocument is conformant to DID Core v1.1.
|
|
318
325
|
DidDocument.validate(updatedDocument);
|
|
319
|
-
// Canonicalize and hash the updatedDocument to get the currentDocumentHash.
|
|
320
|
-
const currentDocumentHash =
|
|
326
|
+
// Canonicalize and hash the updatedDocument to get the currentDocumentHash (raw bytes).
|
|
327
|
+
const currentDocumentHash = canonicalHashBytes(updatedDocument);
|
|
321
328
|
// Prepare the update targetHash for comparison with currentDocumentHash.
|
|
322
|
-
const updateTargetHash = update.targetHash;
|
|
329
|
+
const updateTargetHash = decodeHash(update.targetHash);
|
|
323
330
|
// Make sure the update.targetHash equals currentDocumentHash.
|
|
324
|
-
if (
|
|
331
|
+
if (!equalBytes(updateTargetHash, currentDocumentHash)) {
|
|
325
332
|
// If they do not match, throw INVALID_DID_UPDATE error.
|
|
326
333
|
throw new ResolveError(`Invalid update: update.targetHash !== currentDocumentHash`, INVALID_DID_UPDATE, { updateTargetHash, currentDocumentHash });
|
|
327
334
|
}
|
|
328
335
|
// Return final updatedDocument.
|
|
329
336
|
return updatedDocument;
|
|
330
337
|
}
|
|
331
|
-
// ─── Instance: state machine ───────────────────────────────────────
|
|
332
338
|
/**
|
|
333
339
|
* Advance the state machine. Returns either:
|
|
334
340
|
* - `{ status: 'action-required', needs }` — caller must provide data via {@link provide}
|
|
@@ -351,7 +357,7 @@ export class Resolver {
|
|
|
351
357
|
continue;
|
|
352
358
|
}
|
|
353
359
|
// Need genesis document from caller
|
|
354
|
-
const genesisHash = encodeHash(this.#didComponents.genesisBytes);
|
|
360
|
+
const genesisHash = encodeHash(this.#didComponents.genesisBytes, 'hex');
|
|
355
361
|
return {
|
|
356
362
|
status: 'action-required',
|
|
357
363
|
needs: [{ kind: 'NeedGenesisDocument', genesisHash }]
|
|
@@ -462,12 +468,21 @@ export class Resolver {
|
|
|
462
468
|
}
|
|
463
469
|
case 'NeedCASAnnouncement': {
|
|
464
470
|
const announcement = data;
|
|
465
|
-
this.#sidecarData.casMap.set(canonicalHash(announcement), announcement);
|
|
471
|
+
this.#sidecarData.casMap.set(canonicalHash(announcement, { encoding: 'hex' }), announcement);
|
|
466
472
|
break;
|
|
467
473
|
}
|
|
468
474
|
case 'NeedSignedUpdate': {
|
|
469
475
|
const update = data;
|
|
470
|
-
this.#sidecarData.updateMap.set(canonicalHash(update), update);
|
|
476
|
+
this.#sidecarData.updateMap.set(canonicalHash(update, { encoding: 'hex' }), update);
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
case 'NeedSMTProof': {
|
|
480
|
+
const smtNeed = need;
|
|
481
|
+
const proof = data;
|
|
482
|
+
if (proof.id !== smtNeed.smtRootHash) {
|
|
483
|
+
throw new ResolveError(`SMT proof root hash mismatch: expected ${smtNeed.smtRootHash}, got ${proof.id}`, INVALID_DID_UPDATE, { expected: smtNeed.smtRootHash, actual: proof.id });
|
|
484
|
+
}
|
|
485
|
+
this.#sidecarData.smtMap.set(smtNeed.smtRootHash, proof);
|
|
471
486
|
break;
|
|
472
487
|
}
|
|
473
488
|
}
|