@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
package/src/index.ts
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './core/
|
|
3
|
-
|
|
4
|
-
export * from './core/
|
|
5
|
-
export * from './core/
|
|
6
|
-
export * from './core/
|
|
7
|
-
export * from './core/
|
|
8
|
-
export * from './core/
|
|
9
|
-
export * from './core/
|
|
10
|
-
export * from './core/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export * from './core/beacon/aggregation/cohort/messages/sign/authorization-request.js';
|
|
14
|
-
export * from './core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js';
|
|
15
|
-
export * from './core/beacon/aggregation/cohort/messages/sign/request-signature.js';
|
|
16
|
-
export * from './core/beacon/aggregation/cohort/messages/sign/signature-authorization.js';
|
|
17
|
-
|
|
18
|
-
export * from './core/beacon/aggregation/communication/adapter/did-comm.js';
|
|
19
|
-
export * from './core/beacon/aggregation/communication/adapter/nostr.js';
|
|
20
|
-
|
|
21
|
-
export * from './core/beacon/aggregation/communication/error.js';
|
|
22
|
-
export * from './core/beacon/aggregation/communication/factory.js';
|
|
23
|
-
export * from './core/beacon/aggregation/communication/service.js';
|
|
24
|
-
|
|
25
|
-
export * from './core/beacon/aggregation/coordinator.js';
|
|
26
|
-
export * from './core/beacon/aggregation/participant.js';
|
|
27
|
-
export * from './core/beacon/aggregation/session/index.js';
|
|
28
|
-
export * from './core/beacon/aggregation/session/status.js';
|
|
29
|
-
|
|
1
|
+
// Aggregation
|
|
2
|
+
export * from './core/aggregation/service.js';
|
|
3
|
+
export * from './core/aggregation/participant.js';
|
|
4
|
+
export * from './core/aggregation/cohort.js';
|
|
5
|
+
export * from './core/aggregation/signing-session.js';
|
|
6
|
+
export * from './core/aggregation/phases.js';
|
|
7
|
+
export * from './core/aggregation/errors.js';
|
|
8
|
+
export * from './core/aggregation/messages/index.js';
|
|
9
|
+
export * from './core/aggregation/transport/index.js';
|
|
10
|
+
export * from './core/aggregation/runner/index.js';
|
|
11
|
+
|
|
12
|
+
// Beacons
|
|
30
13
|
export * from './core/beacon/beacon.js';
|
|
31
14
|
export * from './core/beacon/cas-beacon.js';
|
|
32
15
|
export * from './core/beacon/error.js';
|
|
@@ -37,14 +20,17 @@ export * from './core/beacon/singleton-beacon.js';
|
|
|
37
20
|
export * from './core/beacon/smt-beacon.js';
|
|
38
21
|
export * from './core/beacon/utils.js';
|
|
39
22
|
|
|
23
|
+
// Core
|
|
40
24
|
export * from './core/identifier.js';
|
|
41
25
|
export * from './core/interfaces.js';
|
|
42
26
|
export * from './core/resolver.js';
|
|
43
27
|
export * from './core/types.js';
|
|
44
28
|
export * from './core/update.js';
|
|
45
29
|
|
|
30
|
+
// Utils
|
|
46
31
|
export * from './utils/appendix.js';
|
|
47
32
|
export * from './utils/did-document-builder.js';
|
|
48
33
|
export * from './utils/did-document.js';
|
|
49
34
|
|
|
35
|
+
// Facade
|
|
50
36
|
export * from './did-btcr2.js';
|
package/src/utils/appendix.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { HashBytes } from '@did-btcr2/common';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { HashBytes } from '@did-btcr2/common';
|
|
2
|
+
import type {
|
|
4
3
|
DidDocument,
|
|
4
|
+
DidService,
|
|
5
|
+
DidVerificationMethod} from '@web5/dids';
|
|
6
|
+
import {
|
|
5
7
|
DidError,
|
|
6
8
|
DidErrorCode,
|
|
7
|
-
DidService,
|
|
8
|
-
DidVerificationMethod,
|
|
9
9
|
DidVerificationRelationship
|
|
10
10
|
} from '@web5/dids';
|
|
11
|
-
import { createHelia } from 'helia';
|
|
12
11
|
import { CID } from 'multiformats';
|
|
13
12
|
import { create as createDigest } from 'multiformats/hashes/digest';
|
|
14
|
-
import { RootCapability } from '../core/interfaces.js';
|
|
13
|
+
import type { RootCapability } from '../core/interfaces.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Implements {@link https://dcdpr.github.io/did-btcr2/#appendix | 9. Appendix} methods.
|
|
@@ -67,10 +66,10 @@ export class Appendix {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
|
-
* Extracts the verification methods from a given DID Document
|
|
71
|
-
* @param
|
|
72
|
-
* @returns
|
|
73
|
-
* @throws
|
|
69
|
+
* Extracts the verification methods from a given DID Document.
|
|
70
|
+
* @param didDocument The DID Document to extract the verification methods from
|
|
71
|
+
* @returns An array of DidVerificationMethod objects
|
|
72
|
+
* @throws TypeError if the didDocument is not provided
|
|
74
73
|
*/
|
|
75
74
|
public static getVerificationMethods(didDocument: DidDocument): DidVerificationMethod[] {
|
|
76
75
|
if (!didDocument) throw new TypeError(`Required parameter missing: 'didDocument'`);
|
|
@@ -215,6 +214,10 @@ export class Appendix {
|
|
|
215
214
|
// Construct CID from hash bytes
|
|
216
215
|
const cid = CID.create(1, 1, createDigest(1, hashBytes));
|
|
217
216
|
|
|
217
|
+
// Lazy-load helia to avoid bundling its native deps into downstream CJS builds.
|
|
218
|
+
const { createHelia } = await import('helia');
|
|
219
|
+
const { strings } = await import('@helia/strings');
|
|
220
|
+
|
|
218
221
|
// Connect to IPFS/Helia node
|
|
219
222
|
const helia = await createHelia();
|
|
220
223
|
const node = strings(helia);
|
|
@@ -223,8 +226,3 @@ export class Appendix {
|
|
|
223
226
|
return await node.get(cid, {});
|
|
224
227
|
}
|
|
225
228
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DidDocumentError, INVALID_DID_DOCUMENT } from '@did-btcr2/common';
|
|
2
|
-
import { BeaconService } from '../core/beacon/interfaces.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { BeaconService } from '../core/beacon/interfaces.js';
|
|
3
|
+
import type { DidVerificationMethod } from './did-document.js';
|
|
4
|
+
import { DidDocument } from './did-document.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A builder class for constructing DID Documents.
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
2
|
+
import type {
|
|
3
|
+
HashBytes,
|
|
4
|
+
JSONObject,
|
|
5
|
+
KeyBytes
|
|
6
|
+
} from '@did-btcr2/common';
|
|
2
7
|
import {
|
|
3
8
|
canonicalize,
|
|
4
9
|
DidDocumentError,
|
|
5
10
|
hash,
|
|
6
|
-
HashBytes,
|
|
7
11
|
IdentifierTypes,
|
|
8
12
|
INVALID_DID_DOCUMENT,
|
|
9
|
-
|
|
10
|
-
JSONUtils,
|
|
11
|
-
KeyBytes
|
|
13
|
+
JSONUtils
|
|
12
14
|
} from '@did-btcr2/common';
|
|
13
15
|
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
14
|
-
import { DidDocument as W3CDidDocument, DidVerificationMethod as W3CDidVerificationMethod } from '@web5/dids';
|
|
16
|
+
import type { DidDocument as W3CDidDocument, DidVerificationMethod as W3CDidVerificationMethod } from '@web5/dids';
|
|
17
|
+
import { isDidService } from '@web5/dids/utils';
|
|
15
18
|
import { payments } from 'bitcoinjs-lib';
|
|
16
|
-
import { BeaconService } from '../core/beacon/interfaces.js';
|
|
17
|
-
import { BeaconUtils } from '../core/beacon/utils.js';
|
|
19
|
+
import type { BeaconService } from '../core/beacon/interfaces.js';
|
|
18
20
|
import { Identifier } from '../core/identifier.js';
|
|
19
21
|
import { Appendix } from './appendix.js';
|
|
20
22
|
|
|
@@ -342,7 +344,7 @@ export class DidDocument implements Btcr2DidDocument {
|
|
|
342
344
|
* @returns {boolean} True if the services are valid.
|
|
343
345
|
*/
|
|
344
346
|
private static isValidServices(service: unknown): boolean {
|
|
345
|
-
return Array.isArray(service) && service.every(
|
|
347
|
+
return Array.isArray(service) && service.every(isDidService);
|
|
346
348
|
}
|
|
347
349
|
|
|
348
350
|
/**
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { hexToBytes } from '@noble/hashes/utils';
|
|
2
|
-
import { keyAggExport, keyAggregate, sortKeys } from '@scure/btc-signer/musig2';
|
|
3
|
-
import { payments, Transaction } from 'bitcoinjs-lib';
|
|
4
|
-
import { BeaconCoordinatorError } from '../../error.js';
|
|
5
|
-
import { BeaconCohortSigningSession } from '../session/index.js';
|
|
6
|
-
import { BeaconCohortReadyMessage } from './messages/keygen/cohort-ready.js';
|
|
7
|
-
import { COHORT_STATUS } from './status.js';
|
|
8
|
-
export class AggregateBeaconCohort {
|
|
9
|
-
/**
|
|
10
|
-
* Unique identifier for the cohort.
|
|
11
|
-
* @type {string}
|
|
12
|
-
*/
|
|
13
|
-
id;
|
|
14
|
-
/**
|
|
15
|
-
* DID of the coordinator.
|
|
16
|
-
* @type {string}
|
|
17
|
-
*/
|
|
18
|
-
coordinatorDid;
|
|
19
|
-
/**
|
|
20
|
-
* Minimum number of participants required to finalize the cohort.
|
|
21
|
-
* @type {number}
|
|
22
|
-
*/
|
|
23
|
-
minParticipants;
|
|
24
|
-
/**
|
|
25
|
-
* Status of the cohort.
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
status;
|
|
29
|
-
/**
|
|
30
|
-
* Network on which the cohort operates (e.g., 'mainnet', 'testnet').
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
33
|
-
network;
|
|
34
|
-
/**
|
|
35
|
-
* Pending signature requests, mapping participant DIDs to their pending signatures.
|
|
36
|
-
* @type {Record<string, string>}
|
|
37
|
-
*/
|
|
38
|
-
pendingSignatureRequests = {};
|
|
39
|
-
/**
|
|
40
|
-
* List of participant DIDs.
|
|
41
|
-
* @type {Array<string>}
|
|
42
|
-
*/
|
|
43
|
-
participants = new Array();
|
|
44
|
-
/**
|
|
45
|
-
* List of cohort keys.
|
|
46
|
-
* @type {Array<Uint8Array>}
|
|
47
|
-
*/
|
|
48
|
-
_cohortKeys = new Array();
|
|
49
|
-
/**
|
|
50
|
-
* Taproot Merkle root for the cohort.
|
|
51
|
-
* @type {Uint8Array}
|
|
52
|
-
*/
|
|
53
|
-
trMerkleRoot = new Uint8Array();
|
|
54
|
-
/**
|
|
55
|
-
* Beacon address for the cohort, calculated from the Taproot multisig.
|
|
56
|
-
* @type {string}
|
|
57
|
-
*/
|
|
58
|
-
beaconAddress = '';
|
|
59
|
-
/**
|
|
60
|
-
* Type of beacon used in the cohort (default is 'SMTBeacon').
|
|
61
|
-
* @type {string}
|
|
62
|
-
*/
|
|
63
|
-
beaconType;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a new Musig2Cohort instance.
|
|
66
|
-
* @param {Musig2CohortObject} params Parameters for initializing the cohort.
|
|
67
|
-
* @param {string} [params.id] Optional unique identifier for the cohort. If not provided, a random UUID will be generated.
|
|
68
|
-
* @param {number} params.minParticipants Minimum number of participants required to finalize the cohort.
|
|
69
|
-
* @param {string} [params.coordinatorDid] DID of the coordinator managing the cohort.
|
|
70
|
-
* @param {string} params.status Initial status of the cohort (e.g., 'PENDING', 'COHORT_SET').
|
|
71
|
-
* @param {string} params.network Network on which the cohort operates (e.g., 'mainnet', 'testnet').
|
|
72
|
-
*/
|
|
73
|
-
constructor({ id, minParticipants, coordinatorDid, status, network, beaconType }) {
|
|
74
|
-
this.id = id || crypto.randomUUID();
|
|
75
|
-
this.minParticipants = minParticipants || 2;
|
|
76
|
-
this.coordinatorDid = coordinatorDid || '';
|
|
77
|
-
this.status = status || COHORT_STATUS.COHORT_ADVERTISED;
|
|
78
|
-
this.network = network;
|
|
79
|
-
this.beaconType = beaconType || 'SMTBeacon';
|
|
80
|
-
}
|
|
81
|
-
set cohortKeys(keys) {
|
|
82
|
-
this.cohortKeys = sortKeys(keys);
|
|
83
|
-
}
|
|
84
|
-
validateCohort(participantKeys, cohortKeys, beaconAddress) {
|
|
85
|
-
for (const key of participantKeys) {
|
|
86
|
-
if (!cohortKeys.includes(key)) {
|
|
87
|
-
this.status = COHORT_STATUS.COHORT_FAILED;
|
|
88
|
-
throw new BeaconCoordinatorError(`Participant key ${key} not found in cohort ${this.id}.`, 'COHORT_VALIDATION_ERROR', {
|
|
89
|
-
cohortId: this.id,
|
|
90
|
-
participantKeys: participantKeys,
|
|
91
|
-
cohortKeys: cohortKeys,
|
|
92
|
-
beaconAddress: beaconAddress
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
this.cohortKeys = cohortKeys.map(key => hexToBytes(key));
|
|
97
|
-
const calculatedAddress = this.calulateBeaconAddress();
|
|
98
|
-
if (calculatedAddress !== beaconAddress) {
|
|
99
|
-
this.status = COHORT_STATUS.COHORT_FAILED;
|
|
100
|
-
throw new BeaconCoordinatorError(`Calculated beacon address ${calculatedAddress} does not match provided address ${beaconAddress}.`, 'COHORT_ADDRESS_MISMATCH_ERROR', {
|
|
101
|
-
cohortId: this.id,
|
|
102
|
-
calculatedAddress,
|
|
103
|
-
providedAddress: beaconAddress
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
this.beaconAddress = beaconAddress;
|
|
107
|
-
this.status = COHORT_STATUS.COHORT_SET_STATUS;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Finalizes the cohort by checking if the minimum number of participants is met.
|
|
111
|
-
* If the minimum is met, it sets the status to 'COHORT_SET_STATUS' and calculates the beacon address.
|
|
112
|
-
* @throws {BeaconCoordinatorError} If the number of participants is less than the minimum required.
|
|
113
|
-
* @returns {void}
|
|
114
|
-
*/
|
|
115
|
-
finalize() {
|
|
116
|
-
if (this.participants.length < this.minParticipants) {
|
|
117
|
-
throw new BeaconCoordinatorError('Not enough participants to finalize the cohort', 'FINALIZE_COHORT_ERROR', {
|
|
118
|
-
cohortId: this.id,
|
|
119
|
-
participants: this.participants,
|
|
120
|
-
minParticipants: this.minParticipants
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
this.status = COHORT_STATUS.COHORT_SET_STATUS;
|
|
124
|
-
this.beaconAddress = this.calulateBeaconAddress();
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Calculates the beacon Taproot multisig address for the cohort using participant keys.
|
|
128
|
-
* @returns {string} The Taproot address for the cohort.
|
|
129
|
-
* @throws {BeaconCoordinatorError} If the Taproot address cannot be calculated.
|
|
130
|
-
*/
|
|
131
|
-
calulateBeaconAddress() {
|
|
132
|
-
const keyAggContext = keyAggregate(this.cohortKeys);
|
|
133
|
-
const aggPubkey = keyAggExport(keyAggContext);
|
|
134
|
-
const payment = payments.p2tr({ internalPubkey: aggPubkey });
|
|
135
|
-
if (!payment.hash) {
|
|
136
|
-
throw new BeaconCoordinatorError('Failed to calculate Taproot Merkle root', 'CALCULATE_BEACON_MERKLE_ROOT_ERROR', {
|
|
137
|
-
cohortId: this.id,
|
|
138
|
-
cohortKeys: this.cohortKeys,
|
|
139
|
-
minParticipants: this.minParticipants
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
this.trMerkleRoot = payment.hash;
|
|
143
|
-
if (!payment.address) {
|
|
144
|
-
throw new BeaconCoordinatorError('Failed to calculate Taproot address', 'CALCULATE_BEACON_ADDRESS_ERROR', {
|
|
145
|
-
cohortId: this.id,
|
|
146
|
-
cohortKeys: this.cohortKeys,
|
|
147
|
-
minParticipants: this.minParticipants
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return payment.address;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Generates a CohortReadyMessage to be sent to participants when the cohort is set.
|
|
154
|
-
* @param {string} to The DID of the participant to whom the message is sent.
|
|
155
|
-
* @param {string} from The DID of the coordinator sending the message.
|
|
156
|
-
* @returns {BeaconCohortReadyMessage} The CohortReadyMessage containing the cohort details.
|
|
157
|
-
*/
|
|
158
|
-
getCohortReadyMessage(to, from) {
|
|
159
|
-
if (this.status !== COHORT_STATUS.COHORT_SET_STATUS) {
|
|
160
|
-
throw new BeaconCoordinatorError('Cohort status not "COHORT_SET".');
|
|
161
|
-
}
|
|
162
|
-
return new BeaconCohortReadyMessage({
|
|
163
|
-
to,
|
|
164
|
-
from,
|
|
165
|
-
cohortId: this.id,
|
|
166
|
-
beaconAddress: this.beaconAddress,
|
|
167
|
-
cohortKeys: this.cohortKeys,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Adds a signature request to the pending requests for the cohort.
|
|
172
|
-
* @param {BeaconCohortRequestSignatureMessage} message The signature request message to add.
|
|
173
|
-
* @throws {Error} If a signature request from the same participant already exists.
|
|
174
|
-
*/
|
|
175
|
-
addSignatureRequest(message) {
|
|
176
|
-
if (!this.validateSignatureRequest(message)) {
|
|
177
|
-
throw new BeaconCoordinatorError(`No signature request from ${message.from} in cohort ${this.id}.`);
|
|
178
|
-
}
|
|
179
|
-
if (!message.body?.data) {
|
|
180
|
-
throw new BeaconCoordinatorError(`No signature data in request from ${message.from} in cohort ${this.id}.`);
|
|
181
|
-
}
|
|
182
|
-
this.pendingSignatureRequests[message.from] = message.body.data;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Validates a signature request message to ensure it is from a participant in the cohort.
|
|
186
|
-
* @param {BeaconCohortRequestSignatureMessage} message The signature request message to validate.
|
|
187
|
-
* @returns {boolean} True if the message is valid, false otherwise.
|
|
188
|
-
*/
|
|
189
|
-
validateSignatureRequest(message) {
|
|
190
|
-
const cohortId = message.body?.cohortId;
|
|
191
|
-
if (cohortId !== this.id) {
|
|
192
|
-
console.info(`Signature request for wrong cohort: ${cohortId}.`);
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
if (!this.participants.includes(message.from)) {
|
|
196
|
-
console.info(`Participant ${message.from} not in cohort ${this.id}.`);
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Starts a signing session for the cohort.
|
|
203
|
-
* @returns {BeaconCohortSigningSession} The request signature message for the signing session.
|
|
204
|
-
*/
|
|
205
|
-
startSigningSession() {
|
|
206
|
-
console.debug(`Starting signing session for cohort ${this.id} with status ${this.status}`);
|
|
207
|
-
if (this.status !== COHORT_STATUS.COHORT_SET_STATUS) {
|
|
208
|
-
throw new BeaconCoordinatorError(`Cohort ${this.id} is not set.`);
|
|
209
|
-
}
|
|
210
|
-
// const smtRootBytes = new Uint8Array(32).map(() => Math.floor(Math.random() * 256));
|
|
211
|
-
const cohort = new AggregateBeaconCohort(this);
|
|
212
|
-
return new BeaconCohortSigningSession({
|
|
213
|
-
cohort,
|
|
214
|
-
pendingTx: new Transaction(),
|
|
215
|
-
processedRequests: this.pendingSignatureRequests,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Converts the cohort instance to a JSON object representation.
|
|
220
|
-
* @returns {BeaconCohort} The JSON object representation of the cohort.
|
|
221
|
-
*/
|
|
222
|
-
toJSON() {
|
|
223
|
-
return {
|
|
224
|
-
id: this.id,
|
|
225
|
-
coordinatorDid: this.coordinatorDid,
|
|
226
|
-
minParticipants: this.minParticipants,
|
|
227
|
-
status: this.status,
|
|
228
|
-
network: this.network,
|
|
229
|
-
pendingSignatureRequests: this.pendingSignatureRequests,
|
|
230
|
-
participants: this.participants,
|
|
231
|
-
cohortKeys: this.cohortKeys,
|
|
232
|
-
trMerkleRoot: this.trMerkleRoot,
|
|
233
|
-
beaconAddress: this.beaconAddress,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/cohort/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE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GG;IACI,mBAAmB;QACxB,OAAO,CAAC,KAAK,CAAC,uCAAuC,IAAI,CAAC,EAAE,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3F,IAAG,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,iBAAiB,EAAE,CAAC;YACnD,MAAM,IAAI,sBAAsB,CAAC,UAAU,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;QACpE,CAAC;QACD,sFAAsF;QACtF,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,IAAI,0BAA0B,CAAC;YACpC,MAAM;YACN,SAAS,EAAW,IAAI,WAAW,EAAE;YACrC,iBAAiB,EAAG,IAAI,CAAC,wBAAwB;SAClD,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,OAAO;YACL,EAAE,EAAyB,IAAI,CAAC,EAAE;YAClC,cAAc,EAAa,IAAI,CAAC,cAAc;YAC9C,eAAe,EAAY,IAAI,CAAC,eAAe;YAC/C,MAAM,EAAqB,IAAI,CAAC,MAAM;YACtC,OAAO,EAAoB,IAAI,CAAC,OAAO;YACvC,wBAAwB,EAAG,IAAI,CAAC,wBAAwB;YACxD,YAAY,EAAe,IAAI,CAAC,YAAY;YAC5C,UAAU,EAAiB,IAAI,CAAC,UAAU;YAC1C,YAAY,EAAe,IAAI,CAAC,YAAY;YAC5C,aAAa,EAAc,IAAI,CAAC,aAAa;SAC9C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const MESSAGE_PREFIX = 'https://btcr2.tools/';
|
|
2
|
-
export class BaseMessage {
|
|
3
|
-
type;
|
|
4
|
-
to;
|
|
5
|
-
from;
|
|
6
|
-
body;
|
|
7
|
-
constructor({ type, to, from, body }) {
|
|
8
|
-
this.type = type;
|
|
9
|
-
this.to = to;
|
|
10
|
-
this.from = from;
|
|
11
|
-
this.body = body;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Converts a BaseMessage to a JSON object.
|
|
15
|
-
* @returns {Base} The JSON representation of the BaseMessage.
|
|
16
|
-
*/
|
|
17
|
-
toJSON() {
|
|
18
|
-
return {
|
|
19
|
-
type: this.type,
|
|
20
|
-
to: this.to,
|
|
21
|
-
from: this.from,
|
|
22
|
-
body: this.body
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/cohort/messages/base.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAyBrD,MAAM,OAAO,WAAW;IACf,IAAI,CAAS;IACb,EAAE,CAAU;IACZ,IAAI,CAAS;IACb,IAAI,CAAY;IAEvB,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAQ;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,OAAO;YACL,IAAI,EAAG,IAAI,CAAC,IAAI;YAChB,EAAE,EAAK,IAAI,CAAC,EAAE;YACd,IAAI,EAAG,IAAI,CAAC,IAAI;YAChB,IAAI,EAAG,IAAI,CAAC,IAAI;SACjB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const BEACON_COHORT_MESSAGE_PREFIX = 'https://btcr2.dev';
|
|
2
|
-
export const BEACON_COHORT_ADVERT = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_advert`;
|
|
3
|
-
export const BEACON_COHORT_OPT_IN = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_opt_in`;
|
|
4
|
-
export const BEACON_COHORT_OPT_IN_ACCEPT = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_opt_in_accept`;
|
|
5
|
-
export const BEACON_COHORT_READY = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/keygen/beacon/cohort_ready`;
|
|
6
|
-
export const BEACON_COHORT_REQUEST_SIGNATURE = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_request_signature`;
|
|
7
|
-
export const BEACON_COHORT_AUTHORIZATION_REQUEST = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_authorization_request`;
|
|
8
|
-
export const BEACON_COHORT_NONCE_CONTRIBUTION = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_nonce_contribution`;
|
|
9
|
-
export const BEACON_COHORT_AGGREGATED_NONCE = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_aggregated_nonce`;
|
|
10
|
-
export const BEACON_COHORT_SIGNATURE_AUTHORIZATION = `${BEACON_COHORT_MESSAGE_PREFIX}/musig2/sign/beacon/cohort_signature_authorization`;
|
|
11
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/cohort/messages/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAEhE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,4BAA4B,qCAAqC,CAAC;AACzG,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,4BAA4B,qCAAqC,CAAC;AACzG,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,4BAA4B,4CAA4C,CAAC;AACvH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,4BAA4B,oCAAoC,CAAC;AAEvG,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,4BAA4B,8CAA8C,CAAC;AAC7H,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,4BAA4B,kDAAkD,CAAC;AACrI,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,4BAA4B,+CAA+C,CAAC;AAC/H,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,4BAA4B,6CAA6C,CAAC;AAC3H,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,4BAA4B,oDAAoD,CAAC"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { BEACON_COHORT_ADVERT, BEACON_COHORT_AGGREGATED_NONCE, BEACON_COHORT_AUTHORIZATION_REQUEST, BEACON_COHORT_NONCE_CONTRIBUTION, BEACON_COHORT_OPT_IN, BEACON_COHORT_OPT_IN_ACCEPT, BEACON_COHORT_READY, BEACON_COHORT_REQUEST_SIGNATURE, BEACON_COHORT_SIGNATURE_AUTHORIZATION } from './constants.js';
|
|
2
|
-
/**
|
|
3
|
-
* AggregateBeaconMessage is a utility class that provides constants and type checks
|
|
4
|
-
* for various message types used in the aggregate beacon communication protocol.
|
|
5
|
-
* It includes methods to validate message types and retrieve message types from objects.
|
|
6
|
-
* @class AggregateBeaconMessage
|
|
7
|
-
* @type {AggregateBeaconMessageType}
|
|
8
|
-
*/
|
|
9
|
-
export class AggregateBeaconMessage {
|
|
10
|
-
static BEACON_COHORT_ADVERT = BEACON_COHORT_ADVERT;
|
|
11
|
-
static BEACON_COHORT_OPT_IN = BEACON_COHORT_OPT_IN;
|
|
12
|
-
static BEACON_COHORT_READY = BEACON_COHORT_READY;
|
|
13
|
-
static BEACON_COHORT_OPT_IN_ACCEPT = BEACON_COHORT_OPT_IN_ACCEPT;
|
|
14
|
-
static BEACON_COHORT_KEY_GEN_MESSAGES = new Map([
|
|
15
|
-
['BEACON_COHORT_ADVERT', 'BEACON_COHORT_ADVERT'],
|
|
16
|
-
['BEACON_COHORT_OPT_IN', 'BEACON_COHORT_OPT_IN'],
|
|
17
|
-
['BEACON_COHORT_READY', 'BEACON_COHORT_READY'],
|
|
18
|
-
['BEACON_COHORT_OPT_IN_ACCEPT', 'BEACON_COHORT_OPT_IN_ACCEPT'],
|
|
19
|
-
]);
|
|
20
|
-
static BEACON_COHORT_REQUEST_SIGNATURE = BEACON_COHORT_REQUEST_SIGNATURE;
|
|
21
|
-
static BEACON_COHORT_AUTHORIZATION_REQUEST = BEACON_COHORT_AUTHORIZATION_REQUEST;
|
|
22
|
-
static BEACON_COHORT_NONCE_CONTRIBUTION = BEACON_COHORT_NONCE_CONTRIBUTION;
|
|
23
|
-
static BEACON_COHORT_AGGREGATED_NONCE = BEACON_COHORT_AGGREGATED_NONCE;
|
|
24
|
-
static BEACON_COHORT_SIGNATURE_AUTHORIZATION = BEACON_COHORT_SIGNATURE_AUTHORIZATION;
|
|
25
|
-
static BEACON_COHORT_SIGN_MESSAGES = new Map([
|
|
26
|
-
['BEACON_COHORT_REQUEST_SIGNATURE', 'BEACON_COHORT_REQUEST_SIGNATURE'],
|
|
27
|
-
['BEACON_COHORT_AUTHORIZATION_REQUEST', 'BEACON_COHORT_AUTHORIZATION_REQUEST'],
|
|
28
|
-
['BEACON_COHORT_NONCE_CONTRIBUTION', 'BEACON_COHORT_NONCE_CONTRIBUTION'],
|
|
29
|
-
['BEACON_COHORT_AGGREGATED_NONCE', 'BEACON_COHORT_AGGREGATED_NONCE'],
|
|
30
|
-
['BEACON_COHORT_SIGNATURE_AUTHORIZATION', 'BEACON_COHORT_SIGNATURE_AUTHORIZATION'],
|
|
31
|
-
]);
|
|
32
|
-
static ALL_MESSAGES = [
|
|
33
|
-
BEACON_COHORT_ADVERT,
|
|
34
|
-
BEACON_COHORT_OPT_IN,
|
|
35
|
-
BEACON_COHORT_READY,
|
|
36
|
-
BEACON_COHORT_OPT_IN_ACCEPT,
|
|
37
|
-
BEACON_COHORT_REQUEST_SIGNATURE,
|
|
38
|
-
BEACON_COHORT_AUTHORIZATION_REQUEST,
|
|
39
|
-
BEACON_COHORT_NONCE_CONTRIBUTION,
|
|
40
|
-
BEACON_COHORT_AGGREGATED_NONCE,
|
|
41
|
-
BEACON_COHORT_SIGNATURE_AUTHORIZATION
|
|
42
|
-
];
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the name provided is a valid message name.
|
|
45
|
-
* @param {string} type - The type of the message.
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
static isValidType(type) {
|
|
49
|
-
return this.BEACON_COHORT_KEY_GEN_MESSAGES.has(type) || this.BEACON_COHORT_SIGN_MESSAGES.has(type);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the message value based on the type.
|
|
53
|
-
* @param {string} type - The type (or name) of the message.
|
|
54
|
-
* @returns {string | undefined} - The corresponding type value.
|
|
55
|
-
*/
|
|
56
|
-
static getMessageValueByType(type) {
|
|
57
|
-
if (!this.isValidType(type)) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
return this.BEACON_COHORT_KEY_GEN_MESSAGES.get(type) || this.BEACON_COHORT_SIGN_MESSAGES.get(type);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Checks if the provided type is a valid AggregateBeaconMessageType.
|
|
64
|
-
* @param {string} type - The message type to check.
|
|
65
|
-
* @returns {boolean} - Returns true if the type is valid, otherwise false.
|
|
66
|
-
*/
|
|
67
|
-
static isValidValue(type) {
|
|
68
|
-
return this.ALL_MESSAGES.includes(type);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks if the provided type is a valid KeyGenMessageType.
|
|
72
|
-
* @param {string} value - The message type to check.
|
|
73
|
-
* @returns {boolean} - Returns true if the type is a key generation message type, otherwise false.
|
|
74
|
-
*/
|
|
75
|
-
static isKeyGenMessageValue(value) {
|
|
76
|
-
return this.isValidValue(value) && [
|
|
77
|
-
BEACON_COHORT_ADVERT,
|
|
78
|
-
BEACON_COHORT_READY,
|
|
79
|
-
BEACON_COHORT_OPT_IN,
|
|
80
|
-
BEACON_COHORT_OPT_IN_ACCEPT,
|
|
81
|
-
].includes(value);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Checks if the provided type is a valid SignMessageType.
|
|
85
|
-
* @param {string} value - The message type to check.
|
|
86
|
-
* @returns {boolean} - Returns true if the type is a sign message type, otherwise false.
|
|
87
|
-
*/
|
|
88
|
-
static isSignMessageValue(value) {
|
|
89
|
-
return this.isValidValue(value) && [
|
|
90
|
-
BEACON_COHORT_AGGREGATED_NONCE,
|
|
91
|
-
BEACON_COHORT_AUTHORIZATION_REQUEST,
|
|
92
|
-
BEACON_COHORT_NONCE_CONTRIBUTION,
|
|
93
|
-
BEACON_COHORT_REQUEST_SIGNATURE,
|
|
94
|
-
BEACON_COHORT_SIGNATURE_AUTHORIZATION
|
|
95
|
-
].includes(value);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/core/beacon/aggregation/cohort/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,mCAAmC,EACnC,gCAAgC,EAChC,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,+BAA+B,EAC/B,qCAAqC,EACtC,MAAM,gBAAgB,CAAC;AA4BxB;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IACjC,MAAM,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,MAAM,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,MAAM,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;IAEjE,MAAM,CAAC,8BAA8B,GAAwB,IAAI,GAAG,CAAC;QACnE,CAA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AA8B,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrG,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAa;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI;YACjC,oBAAoB;YACpB,mBAAmB;YACnB,oBAAoB;YACpB,2BAA2B;SAC5B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,KAAa;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI;YACjC,8BAA8B;YAC9B,mCAAmC;YACnC,gCAAgC;YAChC,+BAA+B;YAC/B,qCAAqC;SACtC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { JSONUtils } from '@did-btcr2/common';
|
|
2
|
-
import { BaseMessage } from '../base.js';
|
|
3
|
-
import { BEACON_COHORT_ADVERT } from '../constants.js';
|
|
4
|
-
/**
|
|
5
|
-
* Represents a message advertising a cohort to potential participants.
|
|
6
|
-
* @class BeaconCohortAdvertMessage
|
|
7
|
-
* @extends BaseMessage
|
|
8
|
-
* @type {BeaconCohortAdvertMessage}
|
|
9
|
-
*/
|
|
10
|
-
export class BeaconCohortAdvertMessage extends BaseMessage {
|
|
11
|
-
id;
|
|
12
|
-
constructor({ from, id, cohortId, cohortSize, beaconType, network }) {
|
|
13
|
-
const body = { cohortId, cohortSize, beaconType, network };
|
|
14
|
-
const type = BEACON_COHORT_ADVERT;
|
|
15
|
-
super({ from, body, type });
|
|
16
|
-
this.id = id || `${type}/${cohortId}`;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Initializes a BeaconCohortAdvertMessage from a possible CohortAdvertMessage object.
|
|
20
|
-
* @param {CohortAdvertMessage} data The CohortAdvertMessage object to initialize the BeaconCohortAdvertMessage.
|
|
21
|
-
* @returns {BeaconCohortAdvertMessage} The new BeaconCohortAdvertMessage.
|
|
22
|
-
*/
|
|
23
|
-
static fromJSON(data) {
|
|
24
|
-
const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
|
|
25
|
-
if (message.type !== BEACON_COHORT_ADVERT) {
|
|
26
|
-
throw new Error(`Invalid type: ${message.type}`);
|
|
27
|
-
}
|
|
28
|
-
return new BeaconCohortAdvertMessage(message);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=cohort-advert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cohort-advert.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAYvD;;;;;GAKG;AACH,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACjD,EAAE,CAAS;IAElB,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAuB;QACtF,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QAC3D,MAAM,IAAI,GAAG,oBAAoB,CAAC;QAClC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAgC;QACrD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,EAAC,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { JSONUtils } from '@did-btcr2/common';
|
|
2
|
-
import { BaseMessage } from '../base.js';
|
|
3
|
-
import { BEACON_COHORT_READY } from '../constants.js';
|
|
4
|
-
/**
|
|
5
|
-
* Represents a message indicating that a cohort has met the required conditions.
|
|
6
|
-
* @class BeaconCohortReadyMessage
|
|
7
|
-
* @extends BaseMessage
|
|
8
|
-
* @type {BeaconCohortReadyMessage}
|
|
9
|
-
*/
|
|
10
|
-
export class BeaconCohortReadyMessage extends BaseMessage {
|
|
11
|
-
constructor({ from, to, cohortId, beaconAddress, cohortKeys }) {
|
|
12
|
-
const body = { cohortId, beaconAddress, cohortKeys };
|
|
13
|
-
const type = BEACON_COHORT_READY;
|
|
14
|
-
super({ from, to, body, type });
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Initializes an BeaconCohortReadyMessage from a given OptIn object.
|
|
18
|
-
* @param {CohortReadyMessage} data The CohortReadyMessage object to initialize the BeaconCohortReadyMessage.
|
|
19
|
-
* @returns {BeaconCohortReadyMessage} The new BeaconCohortReadyMessage.
|
|
20
|
-
*/
|
|
21
|
-
static fromJSON(data) {
|
|
22
|
-
const message = JSONUtils.isParsable(data) ? JSON.parse(data) : data;
|
|
23
|
-
if (message.type !== BEACON_COHORT_READY) {
|
|
24
|
-
throw new Error(`Invalid type: ${message.type}`);
|
|
25
|
-
}
|
|
26
|
-
return new BeaconCohortReadyMessage(message);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=cohort-ready.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cohort-ready.js","sourceRoot":"","sources":["../../../../../../../../src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAWtD;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,WAAW;IACvD,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAsB;QAC/E,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,mBAAmB,CAAC;QACjC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,IAA+B;QACpD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF"}
|