@did-btcr2/method 0.26.0 → 0.28.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 +118 -236
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +27665 -23764
- package/dist/browser.mjs +27665 -23764
- package/dist/cjs/index.js +2661 -2239
- 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 +286 -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 +15 -56
- 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/singleton-beacon.js +10 -53
- 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/identifier.js +13 -0
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +9 -0
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/updater.js +269 -0
- package/dist/esm/core/updater.js.map +1 -0
- package/dist/esm/did-btcr2.js +30 -42
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +16 -25
- package/dist/esm/index.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 +111 -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 +37 -2
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +19 -7
- 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/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 +8 -0
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +9 -2
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +27 -7
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts +8 -0
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +2 -2
- package/dist/types/core/resolver.d.ts +11 -1
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/dist/types/core/updater.d.ts +178 -0
- package/dist/types/core/updater.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +23 -23
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -25
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +31 -30
- 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 +364 -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 +122 -2
- package/src/core/beacon/cas-beacon.ts +28 -76
- package/src/core/beacon/error.ts +0 -12
- package/src/core/beacon/fee-estimator.ts +52 -0
- package/src/core/beacon/interfaces.ts +10 -1
- package/src/core/beacon/singleton-beacon.ts +14 -75
- package/src/core/beacon/smt-beacon.ts +109 -11
- package/src/core/identifier.ts +17 -0
- package/src/core/interfaces.ts +2 -2
- package/src/core/resolver.ts +25 -2
- package/src/core/updater.ts +415 -0
- package/src/did-btcr2.ts +36 -66
- package/src/index.ts +17 -30
- 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 -245
- 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/esm/core/update.js +0 -112
- package/dist/esm/core/update.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/dist/types/core/update.d.ts +0 -52
- package/dist/types/core/update.d.ts.map +0 -1
- package/src/core/beacon/aggregation/cohort/index.ts +0 -305
- 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 -44
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -35
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -34
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -36
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -41
- package/src/core/beacon/aggregation/cohort/status.ts +0 -7
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -148
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -323
- 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 -419
- package/src/core/beacon/aggregation/participant.ts +0 -517
- package/src/core/beacon/aggregation/session/index.ts +0 -301
- package/src/core/beacon/aggregation/session/status.ts +0 -18
- package/src/core/update.ts +0 -158
package/src/did-btcr2.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { BitcoinConnection } from '@did-btcr2/bitcoin';
|
|
2
1
|
import type {
|
|
3
2
|
DocumentBytes,
|
|
4
|
-
HexString,
|
|
5
3
|
KeyBytes,
|
|
6
4
|
PatchOperation} from '@did-btcr2/common';
|
|
7
5
|
import {
|
|
@@ -12,7 +10,6 @@ import {
|
|
|
12
10
|
MethodError,
|
|
13
11
|
UpdateError
|
|
14
12
|
} from '@did-btcr2/common';
|
|
15
|
-
import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
16
13
|
import type {
|
|
17
14
|
DidMethod} from '@web5/dids';
|
|
18
15
|
import {
|
|
@@ -21,13 +18,12 @@ import {
|
|
|
21
18
|
DidErrorCode
|
|
22
19
|
} from '@web5/dids';
|
|
23
20
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
24
|
-
import { hexToBytes } from '@noble/hashes/utils';
|
|
25
21
|
import { initEccLib } from 'bitcoinjs-lib';
|
|
26
22
|
import type { BeaconService } from './core/beacon/interfaces.js';
|
|
27
23
|
import { Identifier } from './core/identifier.js';
|
|
28
24
|
import type { ResolutionOptions } from './core/interfaces.js';
|
|
29
25
|
import { Resolver } from './core/resolver.js';
|
|
30
|
-
import {
|
|
26
|
+
import { Updater } from './core/updater.js';
|
|
31
27
|
import { Appendix } from './utils/appendix.js';
|
|
32
28
|
import type { Btcr2DidDocument, DidVerificationMethod } from './utils/did-document.js';
|
|
33
29
|
|
|
@@ -140,55 +136,41 @@ export class DidBtcr2 implements DidMethod {
|
|
|
140
136
|
}
|
|
141
137
|
|
|
142
138
|
/**
|
|
143
|
-
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#
|
|
144
|
-
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
145
|
-
* See {@link Update | Update (class)} for class implementation.
|
|
139
|
+
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#update | 7.3 Update}.
|
|
146
140
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
141
|
+
* Factory method that validates the update parameters and returns a sans-I/O
|
|
142
|
+
* {@link Updater} state machine. The caller drives the updater through its
|
|
143
|
+
* phases (Construct → Sign → Broadcast → Complete) by calling `advance()` and
|
|
144
|
+
* `provide()`. The method package performs **zero I/O** — signing key retrieval
|
|
145
|
+
* (or KMS delegation) and the on-chain broadcast are the caller's responsibility.
|
|
146
|
+
*
|
|
147
|
+
* For a fully-wired version with Bitcoin broadcast and key handling, see
|
|
148
|
+
* `DidMethodApi.update()` in `@did-btcr2/api`.
|
|
149
|
+
*
|
|
150
|
+
* @param params Update construction parameters.
|
|
151
151
|
* @param {Btcr2DidDocument} params.sourceDocument The DID document being updated.
|
|
152
|
-
* @param {PatchOperation[]} params.patches The
|
|
153
|
-
* @param {
|
|
154
|
-
* @param {string} params.verificationMethodId The
|
|
155
|
-
* @param {string} params.beaconId The beacon ID
|
|
156
|
-
* @
|
|
157
|
-
* @
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* header is not `zQ3s`
|
|
152
|
+
* @param {PatchOperation[]} params.patches The JSON Patch operations to apply.
|
|
153
|
+
* @param {number} params.sourceVersionId The version ID before applying the update.
|
|
154
|
+
* @param {string} params.verificationMethodId The verification method ID to sign with.
|
|
155
|
+
* @param {string} params.beaconId The beacon service ID to broadcast through.
|
|
156
|
+
* @returns {Updater} A sans-I/O state machine for driving the update.
|
|
157
|
+
* @throws {UpdateError} If the verification method is not authorized, not found,
|
|
158
|
+
* not of type `Multikey`, or does not have a `zQ3s` publicKeyMultibase prefix.
|
|
159
|
+
* Also throws if the beacon service is not found.
|
|
161
160
|
*/
|
|
162
|
-
static
|
|
161
|
+
static update({
|
|
163
162
|
sourceDocument,
|
|
164
163
|
patches,
|
|
165
164
|
sourceVersionId,
|
|
166
165
|
verificationMethodId,
|
|
167
166
|
beaconId,
|
|
168
|
-
signingMaterial,
|
|
169
|
-
bitcoin,
|
|
170
167
|
}: {
|
|
171
168
|
sourceDocument: Btcr2DidDocument;
|
|
172
169
|
patches: PatchOperation[];
|
|
173
170
|
sourceVersionId: number;
|
|
174
171
|
verificationMethodId: string;
|
|
175
172
|
beaconId: string;
|
|
176
|
-
|
|
177
|
-
bitcoin?: BitcoinConnection;
|
|
178
|
-
}): Promise<SignedBTCR2Update> {
|
|
179
|
-
// If no signingMaterial provided, throw an UpdateError with INVALID_DID_UPDATE.
|
|
180
|
-
if (!signingMaterial) {
|
|
181
|
-
throw new UpdateError(
|
|
182
|
-
'Missing signing material for update',
|
|
183
|
-
INVALID_DID_UPDATE, {signingMaterial}
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Convert signingMaterial to bytes if it's a hex string
|
|
188
|
-
const secretKey = typeof signingMaterial === 'string'
|
|
189
|
-
? hexToBytes(signingMaterial)
|
|
190
|
-
: signingMaterial;
|
|
191
|
-
|
|
173
|
+
}): Updater {
|
|
192
174
|
// Validate that the verificationMethodId is authorized for capabilityInvocation
|
|
193
175
|
if(!sourceDocument.capabilityInvocation?.some(vr => vr === verificationMethodId)) {
|
|
194
176
|
throw new UpdateError(
|
|
@@ -201,15 +183,15 @@ export class DidBtcr2 implements DidMethod {
|
|
|
201
183
|
const verificationMethod = this.getSigningMethod(sourceDocument, verificationMethodId);
|
|
202
184
|
|
|
203
185
|
// Validate the verificationMethod exists in the sourceDocument
|
|
204
|
-
if
|
|
186
|
+
if(!verificationMethod) {
|
|
205
187
|
throw new UpdateError(
|
|
206
188
|
'Invalid verificationMethod: not found in source document',
|
|
207
|
-
INVALID_DID_DOCUMENT, {sourceDocument, verificationMethodId}
|
|
189
|
+
INVALID_DID_DOCUMENT, { sourceDocument, verificationMethodId }
|
|
208
190
|
);
|
|
209
191
|
}
|
|
210
192
|
|
|
211
193
|
// Validate the verificationMethod is of type 'Multikey'
|
|
212
|
-
if
|
|
194
|
+
if(verificationMethod.type !== 'Multikey') {
|
|
213
195
|
throw new UpdateError(
|
|
214
196
|
'Invalid verificationMethod: verificationMethod.type must be "Multikey"',
|
|
215
197
|
INVALID_DID_DOCUMENT, verificationMethod
|
|
@@ -217,46 +199,34 @@ export class DidBtcr2 implements DidMethod {
|
|
|
217
199
|
}
|
|
218
200
|
|
|
219
201
|
// Validate the publicKeyMultibase prefix is 'zQ3s'
|
|
220
|
-
if
|
|
202
|
+
if(verificationMethod.publicKeyMultibase?.slice(0, 4) !== 'zQ3s') {
|
|
221
203
|
throw new UpdateError(
|
|
222
204
|
'Invalid verificationMethodId: publicKeyMultibase prefix must start with "zQ3s"',
|
|
223
205
|
INVALID_DID_DOCUMENT, verificationMethod
|
|
224
206
|
);
|
|
225
207
|
}
|
|
226
208
|
|
|
227
|
-
//
|
|
228
|
-
const update = Update.construct(sourceDocument, patches, sourceVersionId);
|
|
229
|
-
|
|
230
|
-
// Sign the unsigned update using the specified verification method
|
|
231
|
-
const signed = Update.sign(sourceDocument.id, update, verificationMethod, secretKey);
|
|
232
|
-
|
|
233
|
-
// Filter sourceDocument services to get beaconServices matching beaconIds
|
|
209
|
+
// Find the beacon service matching the given beaconId
|
|
234
210
|
const beaconService = sourceDocument.service
|
|
235
211
|
.filter((service: BeaconService) => service.id === beaconId)
|
|
236
212
|
.filter((service: BeaconService): service is BeaconService => !!service)
|
|
237
213
|
.shift();
|
|
238
214
|
|
|
239
|
-
// If no matching beacon service found, throw an UpdateError with INVALID_DID_UPDATE.
|
|
240
215
|
if(!beaconService) {
|
|
241
216
|
throw new UpdateError(
|
|
242
217
|
'No beacon service found for provided beaconId',
|
|
243
|
-
INVALID_DID_UPDATE, {sourceDocument, beaconId}
|
|
218
|
+
INVALID_DID_UPDATE, { sourceDocument, beaconId }
|
|
244
219
|
);
|
|
245
220
|
}
|
|
246
|
-
// Require an explicit bitcoin connection — no silent env-var fallback
|
|
247
|
-
if (!bitcoin) {
|
|
248
|
-
throw new UpdateError(
|
|
249
|
-
'Bitcoin connection required for update. Pass a configured `bitcoin` parameter '
|
|
250
|
-
+ 'or use DidBtcr2Api which injects it automatically.',
|
|
251
|
-
INVALID_DID_UPDATE, { beaconId }
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Announce the signed update to the blockchain using the specified beacon(s)
|
|
256
|
-
await Update.announce(beaconService, signed, secretKey, bitcoin);
|
|
257
221
|
|
|
258
|
-
// Return
|
|
259
|
-
return
|
|
222
|
+
// Return a sans-I/O state machine the caller will drive
|
|
223
|
+
return new Updater({
|
|
224
|
+
sourceDocument,
|
|
225
|
+
patches,
|
|
226
|
+
sourceVersionId,
|
|
227
|
+
verificationMethod,
|
|
228
|
+
beaconService,
|
|
229
|
+
});
|
|
260
230
|
}
|
|
261
231
|
|
|
262
232
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,50 +1,37 @@
|
|
|
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';
|
|
33
16
|
export * from './core/beacon/factory.js';
|
|
17
|
+
export * from './core/beacon/fee-estimator.js';
|
|
34
18
|
export * from './core/beacon/interfaces.js';
|
|
35
19
|
export * from './core/beacon/signal-discovery.js';
|
|
36
20
|
export * from './core/beacon/singleton-beacon.js';
|
|
37
21
|
export * from './core/beacon/smt-beacon.js';
|
|
38
22
|
export * from './core/beacon/utils.js';
|
|
39
23
|
|
|
24
|
+
// Core
|
|
40
25
|
export * from './core/identifier.js';
|
|
41
26
|
export * from './core/interfaces.js';
|
|
42
27
|
export * from './core/resolver.js';
|
|
43
28
|
export * from './core/types.js';
|
|
44
|
-
export * from './core/
|
|
29
|
+
export * from './core/updater.js';
|
|
45
30
|
|
|
31
|
+
// Utils
|
|
46
32
|
export * from './utils/appendix.js';
|
|
47
33
|
export * from './utils/did-document-builder.js';
|
|
48
34
|
export * from './utils/did-document.js';
|
|
49
35
|
|
|
36
|
+
// Facade
|
|
50
37
|
export * from './did-btcr2.js';
|
|
@@ -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,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwB5C,MAAM,OAAO,qBAAqB;IAChC;;;OAGG;IACI,EAAE,CAAS;IAElB;;;OAGG;IACI,cAAc,CAAS;IAE9B;;;OAGG;IACI,eAAe,CAAS;IAE/B;;;OAGG;IACI,MAAM,CAAqB;IAElC;;;OAGG;IACI,OAAO,CAAS;IAEvB;;;OAGG;IACI,wBAAwB,GAA2B,EAAE,CAAC;IAE7D;;;OAGG;IACI,YAAY,GAAkB,IAAI,KAAK,EAAU,CAAC;IAEzD;;;OAGG;IACI,WAAW,GAAsB,IAAI,KAAK,EAAc,CAAC;IAEhE;;;OAGG;IACI,YAAY,GAAe,IAAI,UAAU,EAAE,CAAC;I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AGG;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 +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,mB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