@did-btcr2/method 0.26.0 → 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 -1
- package/dist/browser.js +24111 -20342
- package/dist/browser.mjs +24111 -20342
- package/dist/cjs/index.js +2463 -2174
- 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 +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/index.js +14 -24
- 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 +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 +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/index.d.ts +9 -24
- 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 +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 +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/index.ts +15 -29
- 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/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 -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
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import type { KeyBytes, Maybe } from '@did-btcr2/common';
|
|
2
|
-
import { HDKey } from '@scure/bip32';
|
|
3
|
-
import { AggregateBeaconCohort } from './cohort/index.js';
|
|
4
|
-
import type { CohortAdvertMessage } from './cohort/messages/keygen/cohort-advert.js';
|
|
5
|
-
import type { CohortReadyMessage } from './cohort/messages/keygen/cohort-ready.js';
|
|
6
|
-
import type { CohortAggregatedNonceMessage } from './cohort/messages/sign/aggregated-nonce.js';
|
|
7
|
-
import type { CohortAuthorizationRequestMessage } from './cohort/messages/sign/authorization-request.js';
|
|
8
|
-
import type { CommunicationService } from './communication/service.js';
|
|
9
|
-
import { BeaconCohortSigningSession } from './session/index.js';
|
|
10
|
-
type Seed = KeyBytes;
|
|
11
|
-
type Mnemonic = string;
|
|
12
|
-
type SessionId = string;
|
|
13
|
-
type ActiveSigningSessions = Map<SessionId, BeaconCohortSigningSession>;
|
|
14
|
-
type CohortId = string;
|
|
15
|
-
type KeyIndex = number;
|
|
16
|
-
type CohortKeyState = Map<CohortId, KeyIndex>;
|
|
17
|
-
type BeaconParticipantParams = {
|
|
18
|
-
ent: Seed | Mnemonic;
|
|
19
|
-
protocol?: CommunicationService;
|
|
20
|
-
did: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Represents a participant in the did:btc1 Beacon Aggregation protocol.
|
|
25
|
-
* @class BeaconParticipant
|
|
26
|
-
* @type {BeaconParticipant}
|
|
27
|
-
*/
|
|
28
|
-
export declare class BeaconParticipant {
|
|
29
|
-
/**
|
|
30
|
-
* The name of the BeaconParticipant service.
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
33
|
-
name: string;
|
|
34
|
-
/**
|
|
35
|
-
* The DID of the BeaconParticipant.
|
|
36
|
-
* @type {Array<string>}
|
|
37
|
-
*/
|
|
38
|
-
did: string;
|
|
39
|
-
/**
|
|
40
|
-
* The communication protocol used by the BeaconParticipant.
|
|
41
|
-
* @type {CommunicationService}
|
|
42
|
-
*/
|
|
43
|
-
protocol: CommunicationService;
|
|
44
|
-
/**
|
|
45
|
-
* The HD key used by the BeaconParticipant.
|
|
46
|
-
* @type {HDKey}
|
|
47
|
-
*/
|
|
48
|
-
hdKey: HDKey;
|
|
49
|
-
/**
|
|
50
|
-
* The current index for the beacon key.
|
|
51
|
-
* @type {number}
|
|
52
|
-
*/
|
|
53
|
-
beaconKeyIndex: number;
|
|
54
|
-
/**
|
|
55
|
-
* The coordinator DIDs that the participant is subscribed to.
|
|
56
|
-
* @type {Array<string>}
|
|
57
|
-
*/
|
|
58
|
-
coordinatorDids: Array<string>;
|
|
59
|
-
/**
|
|
60
|
-
* The cohorts that the participant is part of.
|
|
61
|
-
* @type {Array<AggregateBeaconCohort>}
|
|
62
|
-
*/
|
|
63
|
-
cohorts: Array<AggregateBeaconCohort>;
|
|
64
|
-
/**
|
|
65
|
-
* A mapping of Cohort IDs to HDKey indexes (CohortId => KeyIndex).
|
|
66
|
-
* @type {CohortKeyState}
|
|
67
|
-
*/
|
|
68
|
-
cohortKeyState: CohortKeyState;
|
|
69
|
-
/**
|
|
70
|
-
* A mapping of active Session IDs to their sessions (sessionId => BeaconCohortSigningSession).
|
|
71
|
-
* @type {ActiveSigningSessions}
|
|
72
|
-
*/
|
|
73
|
-
activeSigningSessions: ActiveSigningSessions;
|
|
74
|
-
/**
|
|
75
|
-
* Creates an instance of BeaconParticipant.
|
|
76
|
-
* @param {BeaconParticipantParams} params The parameters for the participant.
|
|
77
|
-
* @param {Seed | Mnemonic} params.ent The seed or mnemonic to derive the HD key.
|
|
78
|
-
* @param {CommunicationService} params.protocol The communication protocol to use.
|
|
79
|
-
* @param {string} params.did The DID of the participant.
|
|
80
|
-
* @param {string} [params.name] Optional name for the participant. If not provided, a random name will be generated.
|
|
81
|
-
*/
|
|
82
|
-
constructor({ ent, protocol, did, name }: BeaconParticipantParams);
|
|
83
|
-
/**
|
|
84
|
-
* Setup and start the BeaconParticipant communication protocol..
|
|
85
|
-
* @returns {void}
|
|
86
|
-
*/
|
|
87
|
-
start(): void;
|
|
88
|
-
/**
|
|
89
|
-
* Retrieves the HD key for a specific cohort based on its ID.
|
|
90
|
-
* @param {string} cohortId The ID of the cohort for which to retrieve the key.
|
|
91
|
-
* @returns {HDKey} The HD key for the cohort, or throws an error if not found.
|
|
92
|
-
* @throws {BeaconParticipantError} If the cohort key state is not found for the given cohort ID.
|
|
93
|
-
*/
|
|
94
|
-
getCohortKey(cohortId: string): HDKey;
|
|
95
|
-
/**
|
|
96
|
-
* Sets the state of the cohort key for a given cohort ID and key index.
|
|
97
|
-
* @param {string} cohortId The ID of the cohort for which to set the key state.
|
|
98
|
-
* @returns {void}
|
|
99
|
-
*/
|
|
100
|
-
setCohortKey(cohortId: string): void;
|
|
101
|
-
/**
|
|
102
|
-
* Finalizes the placeholder "__UNSET__" key and assigns it to the provided cohortId.
|
|
103
|
-
* If no "__UNSET__" entry exists, throws an error.
|
|
104
|
-
* If cohortId already exists, logs a warning and does nothing.
|
|
105
|
-
* @param {string} cohortId The ID of the cohort to finalize the unset key for.
|
|
106
|
-
* @throws {BeaconParticipantError} If no "__UNSET__" cohort key state is found.
|
|
107
|
-
* @returns {void}
|
|
108
|
-
*/
|
|
109
|
-
finalizeUnsetCohortKey(cohortId: string): void;
|
|
110
|
-
/**
|
|
111
|
-
* Handle subscription acceptance from a coordinator.
|
|
112
|
-
* @param {CohortOptInAcceptMessage} message The message containing the subscription acceptance.
|
|
113
|
-
* @returns {Promise<void>}
|
|
114
|
-
*/
|
|
115
|
-
private _handleSubscribeAccept;
|
|
116
|
-
/**
|
|
117
|
-
* Handles a cohort advertisement message.
|
|
118
|
-
* @param {Maybe<BeaconCohortAdvertMessage>} message The cohort advertisement message.
|
|
119
|
-
* @returns {Promise<void>}
|
|
120
|
-
*/
|
|
121
|
-
_handleCohortAdvert(message: Maybe<CohortAdvertMessage>): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Handles a cohort set message.
|
|
124
|
-
* @param {Maybe<CohortReadyMessage>} message The cohort set message.
|
|
125
|
-
* @returns {Promise<void>}
|
|
126
|
-
*/
|
|
127
|
-
_handleCohortReady(message: Maybe<CohortReadyMessage>): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Handles an authorization request message.
|
|
130
|
-
* @param {Maybe<CohortAuthorizationRequestMessage>} message The authorization request message.
|
|
131
|
-
* @returns {Promise<void>}
|
|
132
|
-
*/
|
|
133
|
-
_handleAuthorizationRequest(message: Maybe<CohortAuthorizationRequestMessage>): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Handles an aggregated nonce message.
|
|
136
|
-
* @param {Maybe<CohortAggregatedNonceMessage>} message The aggregated nonce message.
|
|
137
|
-
* @returns {Promise<void>}
|
|
138
|
-
*/
|
|
139
|
-
_handleAggregatedNonce(message: Maybe<CohortAggregatedNonceMessage>): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Subscribes to a coordinator's messages.
|
|
142
|
-
* @param {string} coordinatorDid The DID of the coordinator to subscribe to.
|
|
143
|
-
* @returns {Promise<void>}
|
|
144
|
-
*/
|
|
145
|
-
subscribeToCoordinator(coordinatorDid: string): Promise<any>;
|
|
146
|
-
/**
|
|
147
|
-
* Joins a cohort with the given ID and coordinator DID.
|
|
148
|
-
* @param {string} cohortId The ID of the cohort to join.
|
|
149
|
-
* @param {string} coordinatorDid The DID of the cohort coordinator.
|
|
150
|
-
* @returns {Promise<void>}
|
|
151
|
-
*/
|
|
152
|
-
joinCohort(cohortId: string, coordinatorDid: string): Promise<void>;
|
|
153
|
-
/**
|
|
154
|
-
* Requests a signature for the given cohort and data.
|
|
155
|
-
* @param {string} cohortId The ID of the cohort for which to request a signature.
|
|
156
|
-
* @param {string} data The data for which to request a signature.
|
|
157
|
-
* @returns {Promise<boolean>} Whether the signature request was successful.
|
|
158
|
-
*/
|
|
159
|
-
requestCohortSignature(cohortId: string, data: string): Promise<boolean>;
|
|
160
|
-
/**
|
|
161
|
-
* Generates a nonce contribution for the given cohort and session.
|
|
162
|
-
* @param {AggregateBeaconCohort} cohort The cohort for which to generate the nonce contribution.
|
|
163
|
-
* @param {BeaconCohortSigningSession} session The session for which to generate the nonce contribution.
|
|
164
|
-
* @returns {Promise<string[]>} An array of nonce points in hexadecimal format.
|
|
165
|
-
*/
|
|
166
|
-
generateNonceContribution(cohort: AggregateBeaconCohort, session: BeaconCohortSigningSession): Uint8Array;
|
|
167
|
-
/**
|
|
168
|
-
* Sends a nonce contribution message to the cohort coordinator.
|
|
169
|
-
* @param {AggregateBeaconCohort} cohort The cohort to which the nonce contribution is sent.
|
|
170
|
-
* @param {Uint8Array} nonceContribution The nonce contribution points in hexadecimal format.
|
|
171
|
-
* @param {BeaconCohortSigningSession} session The session associated with the nonce contribution.
|
|
172
|
-
*/
|
|
173
|
-
sendNonceContribution(cohort: AggregateBeaconCohort, nonceContribution: Uint8Array, session: BeaconCohortSigningSession): Promise<void>;
|
|
174
|
-
/**
|
|
175
|
-
* Sends a partial signature for the given session.
|
|
176
|
-
* @param {BeaconCohortSigningSession} session The session for which the partial signature is sent.
|
|
177
|
-
* @param {Uint8Array} partialSig The partial signature to send.
|
|
178
|
-
* @returns {Promise<void>}
|
|
179
|
-
*/
|
|
180
|
-
sendPartialSignature(session: BeaconCohortSigningSession, partialSig: Uint8Array): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Initializes a new BeaconParticipant instance.
|
|
183
|
-
* @param {Seed | Mnemonic} ent The secret key used for signing.
|
|
184
|
-
* @param {CommunicationService} protocol The communication protocol used by the participant.
|
|
185
|
-
* @param {string} [name] The name of the participant.
|
|
186
|
-
* @param {string} [did] The decentralized identifier (DID) of the participant.
|
|
187
|
-
* @returns {BeaconParticipant} A new instance of BeaconParticipant.
|
|
188
|
-
*/
|
|
189
|
-
static initialize(ent: Seed | Mnemonic, protocol: CommunicationService, did: string, name?: string): BeaconParticipant;
|
|
190
|
-
}
|
|
191
|
-
export {};
|
|
192
|
-
//# sourceMappingURL=participant.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"participant.d.ts","sourceRoot":"","sources":["../../../../../src/core/beacon/aggregation/participant.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import * as musig2 from '@scure/btc-signer/musig2';
|
|
2
|
-
import { Transaction } from 'bitcoinjs-lib';
|
|
3
|
-
import type { AggregateBeaconCohort } from '../cohort/index.js';
|
|
4
|
-
import { BeaconCohortAuthorizationRequestMessage } from '../cohort/messages/sign/authorization-request.js';
|
|
5
|
-
import type { SIGNING_SESSION_STATUS_TYPE } from './status.js';
|
|
6
|
-
/**
|
|
7
|
-
* Convert a big-endian byte array into a bigint.
|
|
8
|
-
* @param bytes - The input Uint8Array representing a big-endian integer.
|
|
9
|
-
* @returns The integer value as a bigint.
|
|
10
|
-
*/
|
|
11
|
-
export declare function bigEndianToInt(bytes: Uint8Array): bigint;
|
|
12
|
-
/**
|
|
13
|
-
* Convert a bigint to a big-endian Uint8Array of specified length.
|
|
14
|
-
* @param xInit - The bigint to convert.
|
|
15
|
-
* @param length - The desired length of the output array in bytes.
|
|
16
|
-
* @returns A Uint8Array representing the bigint in big-endian form.
|
|
17
|
-
*/
|
|
18
|
-
export declare function intToBigEndian(xInit: bigint, length: number): Uint8Array;
|
|
19
|
-
type PublicKeyHex = string;
|
|
20
|
-
type Nonce = Uint8Array;
|
|
21
|
-
type NonceContributions = Map<PublicKeyHex, Nonce>;
|
|
22
|
-
type PartialSignatures = Map<string, Uint8Array>;
|
|
23
|
-
type ProcessedRequests = Record<string, string>;
|
|
24
|
-
export interface SigningSession {
|
|
25
|
-
id?: string;
|
|
26
|
-
cohort: AggregateBeaconCohort;
|
|
27
|
-
pendingTx: Transaction;
|
|
28
|
-
nonceContributions?: NonceContributions;
|
|
29
|
-
aggregatedNonce?: Uint8Array;
|
|
30
|
-
partialSignatures?: PartialSignatures;
|
|
31
|
-
signature?: Uint8Array;
|
|
32
|
-
status?: SIGNING_SESSION_STATUS_TYPE;
|
|
33
|
-
processedRequests?: ProcessedRequests;
|
|
34
|
-
nonceSecrets?: bigint;
|
|
35
|
-
}
|
|
36
|
-
export declare class BeaconCohortSigningSession implements SigningSession {
|
|
37
|
-
/**
|
|
38
|
-
* Unique identifier for the signing session.
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
id: string;
|
|
42
|
-
/**
|
|
43
|
-
* DID of the coordinator.
|
|
44
|
-
* @type {AggregateBeaconCohort}
|
|
45
|
-
*/
|
|
46
|
-
cohort: AggregateBeaconCohort;
|
|
47
|
-
/**
|
|
48
|
-
* Pending transaction to be signed.
|
|
49
|
-
* @type {Transaction}
|
|
50
|
-
*/
|
|
51
|
-
pendingTx: Transaction;
|
|
52
|
-
/**
|
|
53
|
-
* Map of nonce contributions from participants.
|
|
54
|
-
* @type {Map<PublicKeyHex, Nonce>}
|
|
55
|
-
*/
|
|
56
|
-
nonceContributions: Map<PublicKeyHex, Nonce>;
|
|
57
|
-
/**
|
|
58
|
-
* Aggregated nonce from all participants.
|
|
59
|
-
* @type {Uint8Array}
|
|
60
|
-
*/
|
|
61
|
-
aggregatedNonce?: Uint8Array;
|
|
62
|
-
/**
|
|
63
|
-
* Map of partial signatures from participants.
|
|
64
|
-
* @type {Map<string, Uint8Array>}
|
|
65
|
-
*/
|
|
66
|
-
partialSignatures: Map<string, Uint8Array>;
|
|
67
|
-
/**
|
|
68
|
-
* Final signature for the transaction.
|
|
69
|
-
* @type {Uint8Array}
|
|
70
|
-
*/
|
|
71
|
-
signature?: Uint8Array;
|
|
72
|
-
/**
|
|
73
|
-
* Current status of the signing session.
|
|
74
|
-
* @type {SIGNING_SESSION_STATUS_TYPE}
|
|
75
|
-
*/
|
|
76
|
-
status: SIGNING_SESSION_STATUS_TYPE;
|
|
77
|
-
/**
|
|
78
|
-
* Map of processed requests from participants.
|
|
79
|
-
* @type {Record<string, string>}
|
|
80
|
-
*/
|
|
81
|
-
processedRequests: Record<string, string>;
|
|
82
|
-
/**
|
|
83
|
-
* Secrets for nonces contributed by participants.
|
|
84
|
-
* @type {Array<bigint>}
|
|
85
|
-
*/
|
|
86
|
-
nonceSecrets?: bigint;
|
|
87
|
-
/**
|
|
88
|
-
* Musig2 session for signing operations.
|
|
89
|
-
* @type {musig2.Session}
|
|
90
|
-
*/
|
|
91
|
-
musig2Session?: musig2.Session;
|
|
92
|
-
/**
|
|
93
|
-
* Creates a new instance of BeaconCohortSigningSession.
|
|
94
|
-
* @param {SigningSession} params Parameters to initialize the signing session.
|
|
95
|
-
* @param {Transaction} params.pendingTx The pending transaction to be signed.
|
|
96
|
-
* @param {string} [params.id] Optional unique identifier for the signing session. If not provided, a new UUID will be generated.
|
|
97
|
-
* @param {AggregateBeaconCohort} [params.cohort] The cohort associated with the signing session.
|
|
98
|
-
* @param {Record<string, string>} [params.processedRequests] Map of processed requests from participants.
|
|
99
|
-
* @param {SIGNING_SESSION_STATUS_TYPE} [params.status] The current status of the signing session. Defaults to AWAITING_NONCE_CONTRIBUTIONS.
|
|
100
|
-
*/
|
|
101
|
-
constructor({ id, cohort, pendingTx, processedRequests, status }: SigningSession);
|
|
102
|
-
/**
|
|
103
|
-
* Gets the authorization request message for a participant.
|
|
104
|
-
* @param {string} to The public key of the participant to whom the request is sent.
|
|
105
|
-
* @param {string} from The public key of the participant sending the request.
|
|
106
|
-
* @returns {AuthorizationRequest} The authorization request message.
|
|
107
|
-
*/
|
|
108
|
-
getAuthorizationRequest(to: string, from: string): BeaconCohortAuthorizationRequestMessage;
|
|
109
|
-
/**
|
|
110
|
-
* Adds a nonce contribution from a participant to the session.
|
|
111
|
-
* @param {string} from The public key of the participant contributing the nonce.
|
|
112
|
-
* @param {Array<string>} nonceContribution The nonce contribution from the participant.
|
|
113
|
-
* @throws {Error} If the session is not awaiting nonce contributions or if the contribution is invalid.
|
|
114
|
-
*/
|
|
115
|
-
addNonceContribution(from: string, nonceContribution: Uint8Array): void;
|
|
116
|
-
/**
|
|
117
|
-
* Generates the aggregated nonce from all nonce contributions for the session.
|
|
118
|
-
* @returns {Uint8Array} The aggregated nonce.
|
|
119
|
-
* @throws {AggregateBeaconError} If not all nonce contributions have been received.
|
|
120
|
-
*/
|
|
121
|
-
generateAggregatedNonce(): Uint8Array;
|
|
122
|
-
/**
|
|
123
|
-
* Adds a partial signature from a participant to the session.
|
|
124
|
-
* @param {string} from The public key of the participant contributing the partial signature.
|
|
125
|
-
* @param {Uint8Array} partialSignature The partial signature from the participant.
|
|
126
|
-
*/
|
|
127
|
-
addPartialSignature(from: string, partialSignature: Uint8Array): void;
|
|
128
|
-
/**
|
|
129
|
-
* Generates the final signature from all partial signatures.
|
|
130
|
-
* @returns {Uint8Array} The final aggregated signature.
|
|
131
|
-
*/
|
|
132
|
-
generateFinalSignature(): Promise<Uint8Array>;
|
|
133
|
-
/**
|
|
134
|
-
* Generates a partial signature for the session using the participant's secret key.
|
|
135
|
-
* @param {Uint8Array} participantSk The secret key of the participant.
|
|
136
|
-
* @returns {Uint8Array} The partial signature generated by the participant.
|
|
137
|
-
*/
|
|
138
|
-
generatePartialSignature(participantSk: Uint8Array): Uint8Array;
|
|
139
|
-
/**
|
|
140
|
-
* Converts the signing session instance to a JSON object representation.
|
|
141
|
-
* @returns {BeaconCohortSigningSession} The JSON object representation of the signing session.
|
|
142
|
-
*/
|
|
143
|
-
toJSON(): Partial<BeaconCohortSigningSession>;
|
|
144
|
-
/**
|
|
145
|
-
* Checks if the signing session is a completed state.
|
|
146
|
-
* @returns {boolean} True if the session is complete, false otherwise.
|
|
147
|
-
*/
|
|
148
|
-
isComplete(): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Checks if the signing session is in a failed state.
|
|
151
|
-
* @returns {boolean} True if the session has failed, false otherwise.
|
|
152
|
-
*/
|
|
153
|
-
isFailed(): boolean;
|
|
154
|
-
}
|
|
155
|
-
export {};
|
|
156
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/session/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type SIGNING_SESSION_STATUS_TYPE = 'AWAITING_NONCE_CONTRIBUTIONS' | 'NONCE_CONTRIBUTION_SENT' | 'NONCE_CONTRIBUTIONS_RECEIVED' | 'AWAITING_PARTIAL_SIGNATURES' | 'PARTIAL_SIGNATURES_RECEIVED' | 'SIGNATURE_COMPLETE' | 'FAILED';
|
|
2
|
-
export declare enum SIGNING_SESSION_STATUS {
|
|
3
|
-
AWAITING_NONCE_CONTRIBUTIONS = "AWAITING_NONCE_CONTRIBUTIONS",
|
|
4
|
-
NONCE_CONTRIBUTION_SENT = "NONCE_CONTRIBUTION_SENT",
|
|
5
|
-
NONCE_CONTRIBUTIONS_RECEIVED = "NONCE_CONTRIBUTIONS_RECEIVED",
|
|
6
|
-
AWAITING_PARTIAL_SIGNATURES = "AWAITING_PARTIAL_SIGNATURES",
|
|
7
|
-
PARTIAL_SIGNATURES_RECEIVED = "PARTIAL_SIGNATURES_RECEIVED",
|
|
8
|
-
SIGNATURE_COMPLETE = "SIGNATURE_COMPLETE",
|
|
9
|
-
FAILED = "FAILED"
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../../src/core/beacon/aggregation/session/status.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACjC,8BAA8B,GAC9B,yBAAyB,GACzB,8BAA8B,GAC9B,6BAA6B,GAC7B,6BAA6B,GAC7B,oBAAoB,GACpB,QAAQ,CAAA;AAEd,oBAAY,sBAAsB;IAC9B,4BAA4B,iCAAiC;IAC7D,uBAAuB,4BAA4B;IACnD,4BAA4B,iCAAiC;IAC7D,2BAA2B,gCAAgC;IAC3D,2BAA2B,gCAAgC;IAC3D,kBAAkB,uBAAuB;IACzC,MAAM,WAAW;CACpB"}
|
|
@@ -1,305 +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 type { BeaconCohortRequestSignatureMessage } from './messages/sign/request-signature.js';
|
|
8
|
-
import type { COHORT_STATUS_TYPE } from './status.js';
|
|
9
|
-
import { COHORT_STATUS } from './status.js';
|
|
10
|
-
|
|
11
|
-
export type Musig2CohortObject = {
|
|
12
|
-
id?: string;
|
|
13
|
-
coordinatorDid?: string;
|
|
14
|
-
minParticipants?: number;
|
|
15
|
-
status?: COHORT_STATUS_TYPE;
|
|
16
|
-
network: string;
|
|
17
|
-
beaconType?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface BeaconCohort {
|
|
21
|
-
id?: string;
|
|
22
|
-
coordinatorDid: string;
|
|
23
|
-
minParticipants: number;
|
|
24
|
-
status: COHORT_STATUS_TYPE;
|
|
25
|
-
network: string;
|
|
26
|
-
pendingSignatureRequests?: Record<string, string>;
|
|
27
|
-
participants?: Array<string>;
|
|
28
|
-
cohortKeys?: Array<Uint8Array>;
|
|
29
|
-
trMerkleRoot?: Uint8Array;
|
|
30
|
-
beaconAddress?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class AggregateBeaconCohort implements BeaconCohort {
|
|
34
|
-
/**
|
|
35
|
-
* Unique identifier for the cohort.
|
|
36
|
-
* @type {string}
|
|
37
|
-
*/
|
|
38
|
-
public id: string;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* DID of the coordinator.
|
|
42
|
-
* @type {string}
|
|
43
|
-
*/
|
|
44
|
-
public coordinatorDid: string;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Minimum number of participants required to finalize the cohort.
|
|
48
|
-
* @type {number}
|
|
49
|
-
*/
|
|
50
|
-
public minParticipants: number;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Status of the cohort.
|
|
54
|
-
* @type {string}
|
|
55
|
-
*/
|
|
56
|
-
public status: COHORT_STATUS_TYPE;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Network on which the cohort operates (e.g., 'mainnet', 'testnet').
|
|
60
|
-
* @type {string}
|
|
61
|
-
*/
|
|
62
|
-
public network: string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Pending signature requests, mapping participant DIDs to their pending signatures.
|
|
66
|
-
* @type {Record<string, string>}
|
|
67
|
-
*/
|
|
68
|
-
public pendingSignatureRequests: Record<string, string> = {};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* List of participant DIDs.
|
|
72
|
-
* @type {Array<string>}
|
|
73
|
-
*/
|
|
74
|
-
public participants: Array<string> = new Array<string>();
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* List of cohort keys.
|
|
78
|
-
* @type {Array<Uint8Array>}
|
|
79
|
-
*/
|
|
80
|
-
public _cohortKeys: Array<Uint8Array> = new Array<Uint8Array>();
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Taproot Merkle root for the cohort.
|
|
84
|
-
* @type {Uint8Array}
|
|
85
|
-
*/
|
|
86
|
-
public trMerkleRoot: Uint8Array = new Uint8Array();
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Beacon address for the cohort, calculated from the Taproot multisig.
|
|
90
|
-
* @type {string}
|
|
91
|
-
*/
|
|
92
|
-
public beaconAddress: string = '';
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Type of beacon used in the cohort (default is 'SMTBeacon').
|
|
96
|
-
* @type {string}
|
|
97
|
-
*/
|
|
98
|
-
public beaconType: string;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Creates a new Musig2Cohort instance.
|
|
102
|
-
* @param {Musig2CohortObject} params Parameters for initializing the cohort.
|
|
103
|
-
* @param {string} [params.id] Optional unique identifier for the cohort. If not provided, a random UUID will be generated.
|
|
104
|
-
* @param {number} params.minParticipants Minimum number of participants required to finalize the cohort.
|
|
105
|
-
* @param {string} [params.coordinatorDid] DID of the coordinator managing the cohort.
|
|
106
|
-
* @param {string} params.status Initial status of the cohort (e.g., 'PENDING', 'COHORT_SET').
|
|
107
|
-
* @param {string} params.network Network on which the cohort operates (e.g., 'mainnet', 'testnet').
|
|
108
|
-
*/
|
|
109
|
-
constructor({ id, minParticipants, coordinatorDid, status, network, beaconType }: Musig2CohortObject) {
|
|
110
|
-
this.id = id || crypto.randomUUID();
|
|
111
|
-
this.minParticipants = minParticipants || 2;
|
|
112
|
-
this.coordinatorDid = coordinatorDid || '';
|
|
113
|
-
this.status = status as COHORT_STATUS_TYPE || COHORT_STATUS.COHORT_ADVERTISED;
|
|
114
|
-
this.network = network;
|
|
115
|
-
this.beaconType = beaconType || 'SMTBeacon';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
set cohortKeys(keys: Array<Uint8Array>) {
|
|
119
|
-
this.cohortKeys = sortKeys(keys);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public validateCohort(participantKeys: Array<string>, cohortKeys: Array<string>, beaconAddress: string): void {
|
|
123
|
-
for(const key of participantKeys){
|
|
124
|
-
if(!cohortKeys.includes(key)) {
|
|
125
|
-
this.status = COHORT_STATUS.COHORT_FAILED;
|
|
126
|
-
throw new BeaconCoordinatorError(
|
|
127
|
-
`Participant key ${key} not found in cohort ${this.id}.`,
|
|
128
|
-
'COHORT_VALIDATION_ERROR',
|
|
129
|
-
{
|
|
130
|
-
cohortId : this.id,
|
|
131
|
-
participantKeys : participantKeys,
|
|
132
|
-
cohortKeys : cohortKeys,
|
|
133
|
-
beaconAddress : beaconAddress
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
this.cohortKeys = cohortKeys.map(key => hexToBytes(key));
|
|
139
|
-
const calculatedAddress = this.calulateBeaconAddress();
|
|
140
|
-
if (calculatedAddress !== beaconAddress) {
|
|
141
|
-
this.status = COHORT_STATUS.COHORT_FAILED;
|
|
142
|
-
throw new BeaconCoordinatorError(
|
|
143
|
-
`Calculated beacon address ${calculatedAddress} does not match provided address ${beaconAddress}.`,
|
|
144
|
-
'COHORT_ADDRESS_MISMATCH_ERROR',
|
|
145
|
-
{
|
|
146
|
-
cohortId : this.id,
|
|
147
|
-
calculatedAddress,
|
|
148
|
-
providedAddress : beaconAddress
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
this.beaconAddress = beaconAddress;
|
|
153
|
-
this.status = COHORT_STATUS.COHORT_SET_STATUS;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Finalizes the cohort by checking if the minimum number of participants is met.
|
|
158
|
-
* If the minimum is met, it sets the status to 'COHORT_SET_STATUS' and calculates the beacon address.
|
|
159
|
-
* @throws {BeaconCoordinatorError} If the number of participants is less than the minimum required.
|
|
160
|
-
* @returns {void}
|
|
161
|
-
*/
|
|
162
|
-
public finalize(): void {
|
|
163
|
-
if(this.participants.length < this.minParticipants) {
|
|
164
|
-
throw new BeaconCoordinatorError(
|
|
165
|
-
'Not enough participants to finalize the cohort',
|
|
166
|
-
'FINALIZE_COHORT_ERROR',
|
|
167
|
-
{
|
|
168
|
-
cohortId : this.id,
|
|
169
|
-
participants : this.participants,
|
|
170
|
-
minParticipants : this.minParticipants
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
this.status = COHORT_STATUS.COHORT_SET_STATUS;
|
|
175
|
-
this.beaconAddress = this.calulateBeaconAddress();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Calculates the beacon Taproot multisig address for the cohort using participant keys.
|
|
180
|
-
* @returns {string} The Taproot address for the cohort.
|
|
181
|
-
* @throws {BeaconCoordinatorError} If the Taproot address cannot be calculated.
|
|
182
|
-
*/
|
|
183
|
-
public calulateBeaconAddress(): string {
|
|
184
|
-
const keyAggContext = keyAggregate(this.cohortKeys);
|
|
185
|
-
const aggPubkey = keyAggExport(keyAggContext);
|
|
186
|
-
const payment = payments.p2tr({ internalPubkey: aggPubkey });
|
|
187
|
-
if(!payment.hash) {
|
|
188
|
-
throw new BeaconCoordinatorError(
|
|
189
|
-
'Failed to calculate Taproot Merkle root',
|
|
190
|
-
'CALCULATE_BEACON_MERKLE_ROOT_ERROR',
|
|
191
|
-
{
|
|
192
|
-
cohortId : this.id,
|
|
193
|
-
cohortKeys : this.cohortKeys,
|
|
194
|
-
minParticipants : this.minParticipants
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
this.trMerkleRoot = payment.hash;
|
|
199
|
-
if(!payment.address) {
|
|
200
|
-
throw new BeaconCoordinatorError(
|
|
201
|
-
'Failed to calculate Taproot address',
|
|
202
|
-
'CALCULATE_BEACON_ADDRESS_ERROR',
|
|
203
|
-
{
|
|
204
|
-
cohortId : this.id,
|
|
205
|
-
cohortKeys : this.cohortKeys,
|
|
206
|
-
minParticipants : this.minParticipants
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
return payment.address;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Generates a CohortReadyMessage to be sent to participants when the cohort is set.
|
|
215
|
-
* @param {string} to The DID of the participant to whom the message is sent.
|
|
216
|
-
* @param {string} from The DID of the coordinator sending the message.
|
|
217
|
-
* @returns {BeaconCohortReadyMessage} The CohortReadyMessage containing the cohort details.
|
|
218
|
-
*/
|
|
219
|
-
public getCohortReadyMessage(to: string, from: string): BeaconCohortReadyMessage {
|
|
220
|
-
if(this.status !== COHORT_STATUS.COHORT_SET_STATUS) {
|
|
221
|
-
throw new BeaconCoordinatorError('Cohort status not "COHORT_SET".');
|
|
222
|
-
}
|
|
223
|
-
return new BeaconCohortReadyMessage({
|
|
224
|
-
to,
|
|
225
|
-
from,
|
|
226
|
-
cohortId : this.id,
|
|
227
|
-
beaconAddress : this.beaconAddress,
|
|
228
|
-
cohortKeys : this.cohortKeys,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Adds a signature request to the pending requests for the cohort.
|
|
234
|
-
* @param {BeaconCohortRequestSignatureMessage} message The signature request message to add.
|
|
235
|
-
* @throws {Error} If a signature request from the same participant already exists.
|
|
236
|
-
*/
|
|
237
|
-
public addSignatureRequest(message: BeaconCohortRequestSignatureMessage): void {
|
|
238
|
-
if(!this.validateSignatureRequest(message)) {
|
|
239
|
-
throw new BeaconCoordinatorError(`No signature request from ${message.from} in cohort ${this.id}.`);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if(!message.body?.data) {
|
|
243
|
-
throw new BeaconCoordinatorError(`No signature data in request from ${message.from} in cohort ${this.id}.`);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
this.pendingSignatureRequests[message.from] = message.body.data;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Validates a signature request message to ensure it is from a participant in the cohort.
|
|
251
|
-
* @param {BeaconCohortRequestSignatureMessage} message The signature request message to validate.
|
|
252
|
-
* @returns {boolean} True if the message is valid, false otherwise.
|
|
253
|
-
*/
|
|
254
|
-
public validateSignatureRequest(message: BeaconCohortRequestSignatureMessage): boolean {
|
|
255
|
-
const cohortId = message.body?.cohortId;
|
|
256
|
-
if(cohortId !== this.id) {
|
|
257
|
-
console.info(`Signature request for wrong cohort: ${cohortId}.`);
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if(!this.participants.includes(message.from)) {
|
|
262
|
-
console.info(`Participant ${message.from} not in cohort ${this.id}.`);
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Starts a signing session for the cohort.
|
|
271
|
-
* @returns {BeaconCohortSigningSession} The request signature message for the signing session.
|
|
272
|
-
*/
|
|
273
|
-
public startSigningSession(): BeaconCohortSigningSession {
|
|
274
|
-
console.debug(`Starting signing session for cohort ${this.id} with status ${this.status}`);
|
|
275
|
-
if(this.status !== COHORT_STATUS.COHORT_SET_STATUS) {
|
|
276
|
-
throw new BeaconCoordinatorError(`Cohort ${this.id} is not set.`);
|
|
277
|
-
}
|
|
278
|
-
// const smtRootBytes = new Uint8Array(32).map(() => Math.floor(Math.random() * 256));
|
|
279
|
-
const cohort = new AggregateBeaconCohort(this);
|
|
280
|
-
return new BeaconCohortSigningSession({
|
|
281
|
-
cohort,
|
|
282
|
-
pendingTx : new Transaction(),
|
|
283
|
-
processedRequests : this.pendingSignatureRequests,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Converts the cohort instance to a JSON object representation.
|
|
289
|
-
* @returns {BeaconCohort} The JSON object representation of the cohort.
|
|
290
|
-
*/
|
|
291
|
-
public toJSON(): BeaconCohort {
|
|
292
|
-
return {
|
|
293
|
-
id : this.id,
|
|
294
|
-
coordinatorDid : this.coordinatorDid,
|
|
295
|
-
minParticipants : this.minParticipants,
|
|
296
|
-
status : this.status,
|
|
297
|
-
network : this.network,
|
|
298
|
-
pendingSignatureRequests : this.pendingSignatureRequests,
|
|
299
|
-
participants : this.participants,
|
|
300
|
-
cohortKeys : this.cohortKeys,
|
|
301
|
-
trMerkleRoot : this.trMerkleRoot,
|
|
302
|
-
beaconAddress : this.beaconAddress,
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
}
|