@did-btcr2/method 0.22.0 → 0.24.1
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 +96 -50
- package/dist/browser.js +35708 -37764
- package/dist/browser.mjs +35707 -37763
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +13 -2
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +7 -2
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +6 -11
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +5 -8
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +40 -44
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +35 -38
- package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +18 -7
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/signal-discovery.js +6 -6
- package/dist/cjs/core/beacon/signal-discovery.js.map +1 -1
- package/dist/cjs/core/beacon/singleton.js +18 -17
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
- package/dist/cjs/core/identifier.js +11 -13
- package/dist/cjs/core/identifier.js.map +1 -1
- package/dist/cjs/core/resolve.js +25 -22
- package/dist/cjs/core/resolve.js.map +1 -1
- package/dist/cjs/core/update.js +4 -4
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +11 -16
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/did-document.js +22 -21
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/index.js +13 -2
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +7 -2
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +6 -11
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +5 -8
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +40 -44
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js +35 -38
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +18 -7
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +1 -1
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/signal-discovery.js +6 -6
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
- package/dist/esm/core/beacon/singleton.js +18 -17
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +1 -1
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/identifier.js +11 -13
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolve.js +25 -22
- package/dist/esm/core/resolve.js.map +1 -1
- package/dist/esm/core/update.js +4 -4
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +11 -16
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/did-document.js +22 -21
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +2 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +2 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -3
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +5 -3
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/error.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -2
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +2 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/status.d.ts +1 -0
- package/dist/types/core/beacon/beacon.d.ts +4 -3
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +4 -3
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +1 -0
- package/dist/types/core/beacon/factory.d.ts +1 -0
- package/dist/types/core/beacon/interfaces.d.ts +1 -0
- package/dist/types/core/beacon/signal-discovery.d.ts +6 -5
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton.d.ts +4 -4
- package/dist/types/core/beacon/singleton.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +4 -3
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts +1 -0
- package/dist/types/core/identifier.d.ts +18 -21
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +3 -2
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolve.d.ts +4 -3
- package/dist/types/core/resolve.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +1 -0
- package/dist/types/core/update.d.ts +3 -2
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +5 -4
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +1 -0
- package/dist/types/utils/did-document-builder.d.ts +1 -0
- package/dist/types/utils/did-document.d.ts +5 -7
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/core/beacon/aggregation/cohort/index.ts +13 -2
- package/src/core/beacon/aggregation/cohort/messages/base.ts +7 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +1 -1
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +9 -15
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +9 -11
- package/src/core/beacon/aggregation/communication/service.ts +2 -2
- package/src/core/beacon/aggregation/coordinator.ts +40 -44
- package/src/core/beacon/aggregation/participant.ts +38 -40
- package/src/core/beacon/aggregation/session/index.ts +18 -7
- package/src/core/beacon/beacon.ts +3 -3
- package/src/core/beacon/cas-beacon.ts +3 -3
- package/src/core/beacon/signal-discovery.ts +9 -9
- package/src/core/beacon/singleton.ts +20 -20
- package/src/core/beacon/smt-beacon.ts +3 -3
- package/src/core/identifier.ts +31 -28
- package/src/core/interfaces.ts +2 -2
- package/src/core/resolve.ts +32 -26
- package/src/core/update.ts +6 -6
- package/src/did-btcr2.ts +21 -21
- package/src/index.ts +0 -1
- package/src/utils/did-document.ts +24 -20
- package/dist/cjs/utils/general.js +0 -195
- package/dist/cjs/utils/general.js.map +0 -1
- package/dist/esm/utils/general.js +0 -195
- package/dist/esm/utils/general.js.map +0 -1
- package/dist/types/utils/general.d.ts +0 -85
- package/dist/types/utils/general.d.ts.map +0 -1
- package/src/utils/general.ts +0 -204
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Maybe } from '@did-btcr2/common';
|
|
2
2
|
import { RawSchnorrKeyPair } from '@did-btcr2/keypair';
|
|
3
3
|
import { BeaconCoordinatorError } from '../error.js';
|
|
4
4
|
import { AggregateBeaconCohort } from './cohort/index.js';
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
BEACON_COHORT_ADVERT,
|
|
7
7
|
BEACON_COHORT_NONCE_CONTRIBUTION,
|
|
8
8
|
BEACON_COHORT_OPT_IN,
|
|
9
|
-
BEACON_COHORT_OPT_IN_ACCEPT,
|
|
10
9
|
BEACON_COHORT_REQUEST_SIGNATURE,
|
|
11
10
|
BEACON_COHORT_SIGNATURE_AUTHORIZATION
|
|
12
11
|
} from './cohort/messages/constants.js';
|
|
13
12
|
import { BeaconCohortAdvertMessage } from './cohort/messages/keygen/cohort-advert.js';
|
|
14
13
|
import { BeaconCohortReadyMessage } from './cohort/messages/keygen/cohort-ready.js';
|
|
14
|
+
import { BeaconCohortOptInAcceptMessage } from './cohort/messages/keygen/opt-in-accept.js';
|
|
15
15
|
import { BeaconCohortOptInMessage, CohortOptInMessage } from './cohort/messages/keygen/opt-in.js';
|
|
16
16
|
import { BeaconCohortAggregatedNonceMessage } from './cohort/messages/sign/aggregated-nonce.js';
|
|
17
17
|
import { BeaconCohortNonceContributionMessage, CohortNonceContributionMessage } from './cohort/messages/sign/nonce-contribution.js';
|
|
@@ -98,7 +98,7 @@ export class BeaconCoordinator {
|
|
|
98
98
|
* @returns {void}
|
|
99
99
|
*/
|
|
100
100
|
start(): void {
|
|
101
|
-
|
|
101
|
+
console.info(`Setting up BeaconCoordinator ${this.name} (${this.did}) on ${this.protocol.name} ...`);
|
|
102
102
|
this.protocol.registerMessageHandler(BEACON_COHORT_OPT_IN, this.#handleOptIn.bind(this));
|
|
103
103
|
this.protocol.registerMessageHandler(BEACON_COHORT_REQUEST_SIGNATURE, this.#handleRequestSignature.bind(this));
|
|
104
104
|
this.protocol.registerMessageHandler(BEACON_COHORT_NONCE_CONTRIBUTION, this.#handleNonceContribution.bind(this));
|
|
@@ -117,7 +117,7 @@ export class BeaconCoordinator {
|
|
|
117
117
|
const participant = optIn.from;
|
|
118
118
|
const participantPk = optIn.body?.participantPk;
|
|
119
119
|
if(!cohortId || !participant || !participantPk) {
|
|
120
|
-
|
|
120
|
+
console.warn(`Invalid opt-in message from ${participant}: missing cohortId, participant or participantPk`);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
@@ -142,16 +142,16 @@ export class BeaconCoordinator {
|
|
|
142
142
|
const signatureRequest = BeaconCohortRequestSignatureMessage.fromJSON(message);
|
|
143
143
|
const cohortId = signatureRequest.body?.cohortId;
|
|
144
144
|
if (!cohortId) {
|
|
145
|
-
|
|
145
|
+
console.warn(`Signature request missing cohort ID from ${signatureRequest.from}`);
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
149
149
|
if (!cohort) {
|
|
150
|
-
|
|
150
|
+
console.error(`Cohort with ID ${cohortId} not found.`);
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
cohort.addSignatureRequest(signatureRequest);
|
|
154
|
-
|
|
154
|
+
console.info(`Received signature request from ${signatureRequest.from} for cohort ${cohortId}.`);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -164,12 +164,12 @@ export class BeaconCoordinator {
|
|
|
164
164
|
const nonceContribMessage = BeaconCohortNonceContributionMessage.fromJSON(message);
|
|
165
165
|
const cohortId = nonceContribMessage.body?.cohortId;
|
|
166
166
|
if (!cohortId) {
|
|
167
|
-
|
|
167
|
+
console.warn(`Nonce contribution message missing cohort ID from ${nonceContribMessage.from}`);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
const sessionId = nonceContribMessage.body?.sessionId;
|
|
171
171
|
if (!sessionId) {
|
|
172
|
-
|
|
172
|
+
console.warn(`Nonce contribution message missing session ID from ${nonceContribMessage.from}`);
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
// Get the signing session using the cohort ID from the message.
|
|
@@ -177,7 +177,7 @@ export class BeaconCoordinator {
|
|
|
177
177
|
|
|
178
178
|
// If the signing session does not exist, log an error and return.
|
|
179
179
|
if(!signingSession) {
|
|
180
|
-
|
|
180
|
+
console.error(`Session ${cohortId || sessionId} not found.`);
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -190,12 +190,12 @@ export class BeaconCoordinator {
|
|
|
190
190
|
}
|
|
191
191
|
const nonceContribution = nonceContribMessage.body?.nonceContribution;
|
|
192
192
|
if(!nonceContribution) {
|
|
193
|
-
|
|
193
|
+
console.warn(`Nonce contribution message missing nonce contribution from ${nonceContribMessage.from}`);
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
// Add the nonce contribution to the signing session.
|
|
197
197
|
signingSession.addNonceContribution(nonceContribMessage.from, nonceContribution);
|
|
198
|
-
|
|
198
|
+
console.info(`Nonce contribution received from ${nonceContribMessage.from} for session ${sessionId}.`);
|
|
199
199
|
|
|
200
200
|
if (signingSession.status !== SIGNING_SESSION_STATUS.NONCE_CONTRIBUTIONS_RECEIVED) {
|
|
201
201
|
await this.sendAggregatedNonce(signingSession);
|
|
@@ -211,17 +211,17 @@ export class BeaconCoordinator {
|
|
|
211
211
|
const sigAuthMessage = BeaconCohortSignatureAuthorizationMessage.fromJSON(message);
|
|
212
212
|
const cohortId = sigAuthMessage.body?.cohortId;
|
|
213
213
|
if (!cohortId) {
|
|
214
|
-
|
|
214
|
+
console.warn(`Signature authorization message missing cohort ID from ${sigAuthMessage.from}`);
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
const sessionId = sigAuthMessage.body?.sessionId;
|
|
218
218
|
if (!sessionId) {
|
|
219
|
-
|
|
219
|
+
console.warn(`Signature authorization message missing session ID from ${sigAuthMessage.from}`);
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
const signingSession = this.activeSigningSessions.get(cohortId || sessionId);
|
|
223
223
|
if (!signingSession) {
|
|
224
|
-
|
|
224
|
+
console.error(`Session ${sessionId} not found.`);
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -240,12 +240,12 @@ export class BeaconCoordinator {
|
|
|
240
240
|
}
|
|
241
241
|
const partialSignature = sigAuthMessage.body?.partialSignature;
|
|
242
242
|
if (!partialSignature) {
|
|
243
|
-
|
|
243
|
+
console.warn(`Signature authorization message missing partial signature from ${sigAuthMessage.from}`);
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
// Add the signature authorization to the signing session.
|
|
247
247
|
signingSession.addPartialSignature(sigAuthMessage.from, partialSignature);
|
|
248
|
-
|
|
248
|
+
console.info(`Received partial signature from ${sigAuthMessage.from} for session ${sessionId}.`);
|
|
249
249
|
|
|
250
250
|
if(signingSession.partialSignatures.size === signingSession.cohort.participants.length) {
|
|
251
251
|
signingSession.status = SIGNING_SESSION_STATUS.PARTIAL_SIGNATURES_RECEIVED;
|
|
@@ -253,7 +253,7 @@ export class BeaconCoordinator {
|
|
|
253
253
|
|
|
254
254
|
if (signingSession.status === SIGNING_SESSION_STATUS.PARTIAL_SIGNATURES_RECEIVED) {
|
|
255
255
|
const signature = await signingSession.generateFinalSignature();
|
|
256
|
-
|
|
256
|
+
console.info(`Final signature ${Buffer.from(signature).toString('hex')} generated for session ${signingSession.id}`);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
@@ -263,14 +263,14 @@ export class BeaconCoordinator {
|
|
|
263
263
|
* @returns {Promise<void>}
|
|
264
264
|
*/
|
|
265
265
|
private async _startKeyGeneration(cohort: AggregateBeaconCohort): Promise<void> {
|
|
266
|
-
|
|
266
|
+
console.info(`Starting key generation for cohort ${cohort.id} with participants: ${cohort.participants.join(', ')}`);
|
|
267
267
|
cohort.finalize();
|
|
268
268
|
for(const participant of cohort.participants) {
|
|
269
269
|
const message = cohort.getCohortReadyMessage(participant, this.did);
|
|
270
|
-
|
|
270
|
+
console.info(`Sending BEACON_COHORT_READY message to ${participant}`);
|
|
271
271
|
await this.protocol.sendMessage(message, participant, this.did);
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
console.info(`Finished sending BEACON_COHORT_READY message to ${cohort.participants.length} participants`);
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
@@ -279,12 +279,8 @@ export class BeaconCoordinator {
|
|
|
279
279
|
* @returns {Promise<void>}
|
|
280
280
|
*/
|
|
281
281
|
async acceptSubscription(participant: string): Promise<void> {
|
|
282
|
-
|
|
283
|
-
const message = {
|
|
284
|
-
type : BEACON_COHORT_OPT_IN_ACCEPT,
|
|
285
|
-
to : participant,
|
|
286
|
-
from : this.did
|
|
287
|
-
};
|
|
282
|
+
console.info(`Accepting subscription from ${participant}`);
|
|
283
|
+
const message = new BeaconCohortOptInAcceptMessage({ to: participant, from: this.did });
|
|
288
284
|
await this.protocol.sendMessage(message, this.did, participant);
|
|
289
285
|
}
|
|
290
286
|
|
|
@@ -295,7 +291,7 @@ export class BeaconCoordinator {
|
|
|
295
291
|
*/
|
|
296
292
|
async sendAggregatedNonce(session: BeaconCohortSigningSession): Promise<void> {
|
|
297
293
|
const aggregatedNonce = session.generateAggregatedNonce();
|
|
298
|
-
|
|
294
|
+
console.info(`Aggregated Nonces for session ${session.id}:`, aggregatedNonce);
|
|
299
295
|
|
|
300
296
|
session.status = SIGNING_SESSION_STATUS.AWAITING_PARTIAL_SIGNATURES;
|
|
301
297
|
for (const participant of session.cohort.participants) {
|
|
@@ -306,10 +302,10 @@ export class BeaconCoordinator {
|
|
|
306
302
|
sessionId : session.id,
|
|
307
303
|
aggregatedNonce : aggregatedNonce
|
|
308
304
|
});
|
|
309
|
-
|
|
305
|
+
console.info(`Sending AGGREGATED_NONCE message to ${participant}`);
|
|
310
306
|
await this.protocol.sendMessage(message, participant, this.did);
|
|
311
307
|
}
|
|
312
|
-
|
|
308
|
+
console.info(`Successfully sent aggregated nonce message to all participants in session ${session.id}.`);
|
|
313
309
|
}
|
|
314
310
|
|
|
315
311
|
/**
|
|
@@ -325,7 +321,7 @@ export class BeaconCoordinator {
|
|
|
325
321
|
beaconType: string = 'SMTBeacon'
|
|
326
322
|
): Promise<AggregateBeaconCohort> {
|
|
327
323
|
const cohort = new AggregateBeaconCohort({ minParticipants, network, beaconType });
|
|
328
|
-
|
|
324
|
+
console.info(`Advertising new cohort ${cohort.id} ...`);
|
|
329
325
|
this.cohorts.push(cohort);
|
|
330
326
|
const message = new BeaconCohortAdvertMessage({
|
|
331
327
|
from : this.did,
|
|
@@ -334,9 +330,9 @@ export class BeaconCoordinator {
|
|
|
334
330
|
network : cohort.network,
|
|
335
331
|
beaconType
|
|
336
332
|
});
|
|
337
|
-
|
|
333
|
+
console.info(`Sending ${BEACON_COHORT_ADVERT} message to network ...`, message);
|
|
338
334
|
await this.protocol.sendMessage(message, this.did);
|
|
339
|
-
|
|
335
|
+
console.info(`Cohort ${cohort.id} advertised successfully.`);
|
|
340
336
|
return cohort;
|
|
341
337
|
}
|
|
342
338
|
|
|
@@ -349,13 +345,13 @@ export class BeaconCoordinator {
|
|
|
349
345
|
async announceCohortReady(cohortId: string): Promise<AggregateBeaconCohort> {
|
|
350
346
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
351
347
|
if (!cohort) {
|
|
352
|
-
|
|
348
|
+
console.error(`Cohort with ID ${cohortId} not found.`);
|
|
353
349
|
throw new BeaconCoordinatorError(
|
|
354
350
|
`Cohort with ID ${cohortId} not found.`,
|
|
355
351
|
'COHORT_NOT_FOUND', { cohortId }
|
|
356
352
|
);
|
|
357
353
|
}
|
|
358
|
-
|
|
354
|
+
console.info(`Announcing cohort ${cohort.id} to ${cohort.participants.length} subscribers...`);
|
|
359
355
|
this.cohorts.push(cohort);
|
|
360
356
|
for (const participant of cohort.participants) {
|
|
361
357
|
const message = new BeaconCohortReadyMessage({
|
|
@@ -365,7 +361,7 @@ export class BeaconCoordinator {
|
|
|
365
361
|
beaconAddress : cohort.beaconAddress,
|
|
366
362
|
cohortKeys : cohort.cohortKeys,
|
|
367
363
|
});
|
|
368
|
-
|
|
364
|
+
console.info(`Sending ${BEACON_COHORT_ADVERT} message to ${participant}`);
|
|
369
365
|
|
|
370
366
|
await this.protocol.sendMessage(message, this.did, participant);
|
|
371
367
|
}
|
|
@@ -379,24 +375,24 @@ export class BeaconCoordinator {
|
|
|
379
375
|
* @throws {BeaconCoordinatorError} If the cohort with the given ID is not found.
|
|
380
376
|
*/
|
|
381
377
|
async startSigningSession(cohortId: string): Promise<BeaconCohortSigningSession> {
|
|
382
|
-
|
|
378
|
+
console.info(`Attempting to start signing session for cohort ${cohortId}`);
|
|
383
379
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
384
380
|
if (!cohort) {
|
|
385
|
-
|
|
381
|
+
console.error(`Cohort with ID ${cohortId} not found.`);
|
|
386
382
|
throw new BeaconCoordinatorError(`Cohort with ID ${cohortId} not found.`, 'COHORT_NOT_FOUND');
|
|
387
383
|
}
|
|
388
|
-
|
|
384
|
+
console.info(`Cohort ${cohortId} found. Starting signing session.`);
|
|
389
385
|
const signingSession = cohort.startSigningSession();
|
|
390
|
-
|
|
386
|
+
console.info(`Starting signing session ${signingSession.id} for cohort ${cohortId}`);
|
|
391
387
|
for (const participant of cohort.participants) {
|
|
392
388
|
const msg = signingSession.getAuthorizationRequest(participant, this.did);
|
|
393
|
-
|
|
389
|
+
console.info(`Sending authorization request to ${participant}`);
|
|
394
390
|
await this.protocol.sendMessage(msg, this.did, participant).catch(error => {
|
|
395
|
-
|
|
391
|
+
console.error(`Error sending authorization request to ${participant}: ${error.message}`);
|
|
396
392
|
});
|
|
397
393
|
}
|
|
398
394
|
this.activeSigningSessions.set(cohortId, signingSession);
|
|
399
|
-
|
|
395
|
+
console.info(`Signing session ${signingSession.id} started for cohort ${cohortId}`);
|
|
400
396
|
return signingSession;
|
|
401
397
|
}
|
|
402
398
|
|
|
@@ -412,7 +408,7 @@ export class BeaconCoordinator {
|
|
|
412
408
|
did : service.did,
|
|
413
409
|
keys : service.keys,
|
|
414
410
|
});
|
|
415
|
-
|
|
411
|
+
console.info(`BeaconCoordinator ${coordinator.name} initialized with DID ${coordinator.did}. Run .start() to listen for messages`);
|
|
416
412
|
return coordinator;
|
|
417
413
|
}
|
|
418
414
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyBytes,
|
|
1
|
+
import { KeyBytes, Maybe } from '@did-btcr2/common';
|
|
2
2
|
import { HDKey } from '@scure/bip32';
|
|
3
3
|
import { mnemonicToSeedSync } from '@scure/bip39';
|
|
4
4
|
import * as musig2 from '@scure/btc-signer/musig2';
|
|
@@ -130,7 +130,7 @@ export class BeaconParticipant {
|
|
|
130
130
|
this.protocol = protocol || new NostrAdapter();
|
|
131
131
|
this.protocol.setKeys({ public: pk, secret });
|
|
132
132
|
this.cohortKeyState.set('__UNSET__', this.beaconKeyIndex);
|
|
133
|
-
|
|
133
|
+
console.debug(`BeaconParticipant initialized with DID: ${this.did}, Name: ${this.name}, Key Index: ${this.beaconKeyIndex}`);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
@@ -138,7 +138,7 @@ export class BeaconParticipant {
|
|
|
138
138
|
* @returns {void}
|
|
139
139
|
*/
|
|
140
140
|
public start(): void {
|
|
141
|
-
|
|
141
|
+
console.info(`Setting up BeaconParticipant ${this.name} (${this.did}) on ${this.protocol.name} ...`);
|
|
142
142
|
this.protocol.registerMessageHandler(BEACON_COHORT_ADVERT, this._handleCohortAdvert.bind(this));
|
|
143
143
|
this.protocol.registerMessageHandler(BEACON_COHORT_OPT_IN_ACCEPT, this._handleSubscribeAccept.bind(this));
|
|
144
144
|
this.protocol.registerMessageHandler(BEACON_COHORT_READY, this._handleCohortReady.bind(this));
|
|
@@ -171,10 +171,10 @@ export class BeaconParticipant {
|
|
|
171
171
|
this.beaconKeyIndex = this.cohortKeyState.size + 1;
|
|
172
172
|
}
|
|
173
173
|
if(this.cohortKeyState.has(cohortId)) {
|
|
174
|
-
|
|
174
|
+
console.warn(`Cohort key state for cohort ${cohortId} already exists. Updating key index.`);
|
|
175
175
|
}
|
|
176
176
|
this.cohortKeyState.set(cohortId, this.beaconKeyIndex);
|
|
177
|
-
|
|
177
|
+
console.info(`Cohort key state updated. Next beacon key index: ${this.beaconKeyIndex + 1}`);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
@@ -196,7 +196,7 @@ export class BeaconParticipant {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
if (this.cohortKeyState.has(cohortId)) {
|
|
199
|
-
|
|
199
|
+
console.warn(`Cohort key state already exists for ${cohortId}. Skipping migration from '__UNSET__'.`);
|
|
200
200
|
this.cohortKeyState.delete(unsetKey);
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
@@ -204,7 +204,7 @@ export class BeaconParticipant {
|
|
|
204
204
|
this.setCohortKey(cohortId);
|
|
205
205
|
this.cohortKeyState.delete(unsetKey);
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
console.info(`Finalized '__UNSET__' CohortKeyState with ${cohortId} for ${this.did}`);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
/**
|
|
@@ -226,25 +226,25 @@ export class BeaconParticipant {
|
|
|
226
226
|
* @returns {Promise<void>}
|
|
227
227
|
*/
|
|
228
228
|
public async _handleCohortAdvert(message: Maybe<CohortAdvertMessage>): Promise<void> {
|
|
229
|
-
|
|
229
|
+
console.debug('_handleCohortAdvert', message);
|
|
230
230
|
const cohortAdvertMessage = BeaconCohortAdvertMessage.fromJSON(message);
|
|
231
|
-
|
|
231
|
+
console.info(`Received new cohort announcement from ${cohortAdvertMessage.from}`, cohortAdvertMessage);
|
|
232
232
|
|
|
233
233
|
const cohortId = cohortAdvertMessage.body?.cohortId;
|
|
234
234
|
if (!cohortId) {
|
|
235
|
-
|
|
235
|
+
console.warn('Received malformed cohort advert message: missing cohortId', cohortAdvertMessage);
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
const network = cohortAdvertMessage.body?.network;
|
|
240
240
|
if (!network) {
|
|
241
|
-
|
|
241
|
+
console.warn('Received malformed cohort advert message: missing network', cohortAdvertMessage);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
const minParticipants = cohortAdvertMessage.body?.cohortSize;
|
|
246
246
|
if (!cohortId || !network || !minParticipants) {
|
|
247
|
-
|
|
247
|
+
console.warn('Received malformed cohort advert message: missing minParticipants', cohortAdvertMessage);
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -271,30 +271,30 @@ export class BeaconParticipant {
|
|
|
271
271
|
const cohortId = cohortSetMessage.body?.cohortId;
|
|
272
272
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
273
273
|
if (!cohortId || !cohort) {
|
|
274
|
-
|
|
274
|
+
console.warn(`Cohort with ID ${cohortId} not found or not joined by participant ${this.did}.`);
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
277
|
this.finalizeUnsetCohortKey(cohortId);
|
|
278
278
|
const participantPkBytes = this.getCohortKey(cohortId).publicKey;
|
|
279
279
|
if(!participantPkBytes) {
|
|
280
|
-
|
|
280
|
+
console.error(`Failed to derive public key for cohort ${cohortId}`);
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
const participantPk = Buffer.from(participantPkBytes).toString('hex');
|
|
284
284
|
const beaconAddress = cohortSetMessage.body?.beaconAddress;
|
|
285
285
|
if(!beaconAddress) {
|
|
286
|
-
|
|
286
|
+
console.error(`Beacon address not provided in cohort set message for ${cohortId}`);
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
289
|
const cohortKeys = cohortSetMessage.body?.cohortKeys;
|
|
290
290
|
if(!cohortKeys) {
|
|
291
|
-
|
|
291
|
+
console.error(`Cohort keys not provided in cohort set message for ${cohortId}`);
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
294
|
const keys = cohortKeys.map(key => Buffer.from(key).toString('hex'));
|
|
295
295
|
cohort.validateCohort([participantPk], keys, beaconAddress);
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
console.info(`BeaconParticipant w/ pk ${participantPk} successfully joined cohort ${cohortId} with beacon address ${beaconAddress}.`);
|
|
297
|
+
console.info(`Cohort status: ${cohort.status}`);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
/**
|
|
@@ -306,17 +306,17 @@ export class BeaconParticipant {
|
|
|
306
306
|
const authRequest = BeaconCohortAuthorizationRequestMessage.fromJSON(message);
|
|
307
307
|
const cohort = this.cohorts.find(c => c.id === authRequest.body?.cohortId);
|
|
308
308
|
if (!cohort) {
|
|
309
|
-
|
|
309
|
+
console.warn(`Authorization request for unknown cohort ${authRequest.body?.cohortId} from ${authRequest.from}`);
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
312
|
const id = authRequest.body?.sessionId;
|
|
313
313
|
if (!id) {
|
|
314
|
-
|
|
314
|
+
console.warn(`Authorization request missing session ID from ${authRequest.from}`);
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
const pendingTx = authRequest.body?.pendingTx;
|
|
318
318
|
if (!pendingTx) {
|
|
319
|
-
|
|
319
|
+
console.warn(`Authorization request missing pending transaction from ${authRequest.from}`);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
const session = new BeaconCohortSigningSession({
|
|
@@ -338,23 +338,23 @@ export class BeaconParticipant {
|
|
|
338
338
|
const aggNonceMessage = BeaconCohortAggregatedNonceMessage.fromJSON(message);
|
|
339
339
|
const sessionId = aggNonceMessage.body?.sessionId;
|
|
340
340
|
if (!sessionId) {
|
|
341
|
-
|
|
341
|
+
console.warn(`Aggregated nonce message missing session ID from ${aggNonceMessage.from}`);
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
344
344
|
const session = this.activeSigningSessions.get(sessionId);
|
|
345
345
|
if (!session) {
|
|
346
|
-
|
|
346
|
+
console.warn(`Aggregated nonce message received for unknown session ${sessionId}`);
|
|
347
347
|
return;
|
|
348
348
|
}
|
|
349
349
|
const aggregatedNonce = aggNonceMessage.body?.aggregatedNonce;
|
|
350
350
|
if (!aggregatedNonce) {
|
|
351
|
-
|
|
351
|
+
console.warn(`Aggregated nonce message missing aggregated nonce from ${aggNonceMessage.from}`);
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
354
|
session.aggregatedNonce = aggregatedNonce;
|
|
355
355
|
const participantSk = this.getCohortKey(session.cohort.id).privateKey;
|
|
356
356
|
if(!participantSk) {
|
|
357
|
-
|
|
357
|
+
console.error(`Failed to derive secret key for cohort ${session.cohort.id}`);
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
360
|
const partialSig = session.generatePartialSignature(participantSk);
|
|
@@ -368,7 +368,7 @@ export class BeaconParticipant {
|
|
|
368
368
|
*/
|
|
369
369
|
public async subscribeToCoordinator(coordinatorDid: string): Promise<any> {
|
|
370
370
|
if(this.coordinatorDids.includes(coordinatorDid)) {
|
|
371
|
-
|
|
371
|
+
console.info(`Already subscribed to coordinator ${coordinatorDid}`);
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
374
|
const subMessage = new BeaconCohortSubscribeMessage({ to: coordinatorDid, from: this.did });
|
|
@@ -382,16 +382,16 @@ export class BeaconParticipant {
|
|
|
382
382
|
* @returns {Promise<void>}
|
|
383
383
|
*/
|
|
384
384
|
public async joinCohort(cohortId: string, coordinatorDid: string): Promise<void> {
|
|
385
|
-
|
|
385
|
+
console.info(`BeaconParticipant ${this.did} joining cohort ${cohortId} with coordinator ${coordinatorDid}`);
|
|
386
386
|
this.finalizeUnsetCohortKey(cohortId);
|
|
387
387
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
388
388
|
if (!cohort) {
|
|
389
|
-
|
|
389
|
+
console.warn(`Cohort with ID ${cohortId} not found.`);
|
|
390
390
|
return;
|
|
391
391
|
}
|
|
392
392
|
const pk = this.getCohortKey(cohortId).publicKey;
|
|
393
393
|
if(!pk) {
|
|
394
|
-
|
|
394
|
+
console.error(`Failed to derive public key for cohort ${cohortId} at index ${this.beaconKeyIndex}`);
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
397
|
this.setCohortKey(cohortId);
|
|
@@ -415,11 +415,11 @@ export class BeaconParticipant {
|
|
|
415
415
|
public async requestCohortSignature(cohortId: string, data: string): Promise<boolean> {
|
|
416
416
|
const cohort = this.cohorts.find(c => c.id === cohortId);
|
|
417
417
|
if (!cohort) {
|
|
418
|
-
|
|
418
|
+
console.warn(`Cohort with ID ${cohortId} not found.`);
|
|
419
419
|
return false;
|
|
420
420
|
}
|
|
421
421
|
if(cohort.status !== COHORT_STATUS.COHORT_SET_STATUS) {
|
|
422
|
-
|
|
422
|
+
console.warn(`Cohort ${cohortId} not in a set state. Current status: ${cohort.status}`);
|
|
423
423
|
return false;
|
|
424
424
|
}
|
|
425
425
|
const reqSigMessage = new BeaconCohortRequestSignatureMessage({
|
|
@@ -469,16 +469,14 @@ export class BeaconParticipant {
|
|
|
469
469
|
session: BeaconCohortSigningSession
|
|
470
470
|
): Promise<void> {
|
|
471
471
|
const nonceContributionMessage = BeaconCohortNonceContributionMessage.fromJSON({
|
|
472
|
-
to
|
|
473
|
-
from
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
nonceContribution
|
|
478
|
-
}
|
|
472
|
+
to : cohort.coordinatorDid,
|
|
473
|
+
from : this.did,
|
|
474
|
+
sessionId : session.id,
|
|
475
|
+
cohortId : cohort.id,
|
|
476
|
+
nonceContribution
|
|
479
477
|
});
|
|
480
478
|
await this.protocol.sendMessage(nonceContributionMessage, this.did, cohort.coordinatorDid);
|
|
481
|
-
|
|
479
|
+
console.info(`Nonce contribution sent for session ${session.id} in cohort ${cohort.id} by participant ${this.did}`);
|
|
482
480
|
}
|
|
483
481
|
|
|
484
482
|
/**
|
|
@@ -496,7 +494,7 @@ export class BeaconParticipant {
|
|
|
496
494
|
partialSignature : partialSig,
|
|
497
495
|
});
|
|
498
496
|
await this.protocol.sendMessage(sigAuthMessage, this.did, session.cohort.coordinatorDid);
|
|
499
|
-
|
|
497
|
+
console.info(`Partial signature sent for session ${session.id} in cohort ${session.cohort.id} by participant ${this.did}`);
|
|
500
498
|
}
|
|
501
499
|
|
|
502
500
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Logger } from '@did-btcr2/common';
|
|
2
1
|
import * as musig2 from '@scure/btc-signer/musig2';
|
|
3
2
|
import { Transaction } from 'bitcoinjs-lib';
|
|
4
3
|
import { AggregateBeaconError } from '../../error.js';
|
|
@@ -166,7 +165,7 @@ export class BeaconCohortSigningSession implements SigningSession {
|
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
if (this.nonceContributions.get(from)) {
|
|
169
|
-
|
|
168
|
+
console.warn(`WARNING: Nonce contribution already received from ${from}.`);
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
this.nonceContributions.set(from, nonceContribution);
|
|
@@ -188,7 +187,7 @@ export class BeaconCohortSigningSession implements SigningSession {
|
|
|
188
187
|
`Missing ${missing} nonce contributions. ` +
|
|
189
188
|
`Received ${this.cohort?.participants.length} of ${this.nonceContributions.size} nonce contributions. ` +
|
|
190
189
|
`Current status: ${this.status}`,
|
|
191
|
-
'NONCE_CONTRIBUTION_ERROR', this.
|
|
190
|
+
'NONCE_CONTRIBUTION_ERROR', this.toJSON()
|
|
192
191
|
);
|
|
193
192
|
}
|
|
194
193
|
const sortedPubkeys = musig2.sortKeys(this.cohort.cohortKeys);
|
|
@@ -210,7 +209,7 @@ export class BeaconCohortSigningSession implements SigningSession {
|
|
|
210
209
|
}
|
|
211
210
|
|
|
212
211
|
if(this.partialSignatures.get(from)) {
|
|
213
|
-
|
|
212
|
+
console.warn(`WARNING: Partial signature already received from ${from}.`);
|
|
214
213
|
}
|
|
215
214
|
|
|
216
215
|
this.partialSignatures.set(from, partialSignature);
|
|
@@ -236,7 +235,7 @@ export class BeaconCohortSigningSession implements SigningSession {
|
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
const sigSum = [...this.partialSignatures.values()].reduce((sum, sig) => sum + bigEndianToInt(sig), 0n);
|
|
239
|
-
|
|
238
|
+
console.info(`Aggregated Signature computed: ${sigSum}`);
|
|
240
239
|
|
|
241
240
|
this.aggregatedNonce ??= this.generateAggregatedNonce();
|
|
242
241
|
|
|
@@ -267,8 +266,20 @@ export class BeaconCohortSigningSession implements SigningSession {
|
|
|
267
266
|
* Converts the signing session instance to a JSON object representation.
|
|
268
267
|
* @returns {BeaconCohortSigningSession} The JSON object representation of the signing session.
|
|
269
268
|
*/
|
|
270
|
-
public
|
|
271
|
-
return
|
|
269
|
+
public toJSON(): Partial<BeaconCohortSigningSession> {
|
|
270
|
+
return {
|
|
271
|
+
id : this.id,
|
|
272
|
+
cohort : this.cohort,
|
|
273
|
+
pendingTx : this.pendingTx,
|
|
274
|
+
nonceContributions : this.nonceContributions,
|
|
275
|
+
aggregatedNonce : this.aggregatedNonce,
|
|
276
|
+
partialSignatures : this.partialSignatures,
|
|
277
|
+
signature : this.signature,
|
|
278
|
+
status : this.status,
|
|
279
|
+
processedRequests : this.processedRequests,
|
|
280
|
+
nonceSecrets : this.nonceSecrets,
|
|
281
|
+
musig2Session : this.musig2Session
|
|
282
|
+
};
|
|
272
283
|
}
|
|
273
284
|
|
|
274
285
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyBytes } from '@did-btcr2/common';
|
|
2
|
-
import {
|
|
2
|
+
import { BitcoinConnection } from '@did-btcr2/bitcoin';
|
|
3
3
|
import { SignedBTCR2Update } from '../../../../cryptosuite/dist/types/data-integrity-proof/interface.js';
|
|
4
4
|
import { SidecarData } from '../types.js';
|
|
5
5
|
import { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
|
|
@@ -47,12 +47,12 @@ export abstract class Beacon {
|
|
|
47
47
|
* Used during the update path.
|
|
48
48
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
49
49
|
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
51
51
|
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
52
52
|
*/
|
|
53
53
|
abstract broadcastSignal(
|
|
54
54
|
signedUpdate: SignedBTCR2Update,
|
|
55
55
|
secretKey: KeyBytes,
|
|
56
|
-
bitcoin:
|
|
56
|
+
bitcoin: BitcoinConnection
|
|
57
57
|
): Promise<SignedBTCR2Update>;
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BitcoinConnection } from '@did-btcr2/bitcoin';
|
|
2
2
|
import { KeyBytes } from '@did-btcr2/common';
|
|
3
3
|
import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
|
|
4
4
|
import { SidecarData } from '../types.js';
|
|
@@ -39,14 +39,14 @@ export class CASBeacon extends Beacon {
|
|
|
39
39
|
* Broadcast CAS Beacon signal to the Bitcoin network.
|
|
40
40
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
41
41
|
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
42
|
-
* @param {
|
|
42
|
+
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
43
43
|
* @return {Promise<SignedBTCR2Update>} The signed update that was broadcasted.
|
|
44
44
|
* @throws {CASBeaconError} if broadcasting fails.
|
|
45
45
|
*/
|
|
46
46
|
async broadcastSignal(
|
|
47
47
|
signedUpdate: SignedBTCR2Update,
|
|
48
48
|
secretKey: KeyBytes,
|
|
49
|
-
bitcoin:
|
|
49
|
+
bitcoin: BitcoinConnection
|
|
50
50
|
): Promise<SignedBTCR2Update> {
|
|
51
51
|
throw new CASBeaconError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, {signedUpdate, secretKey, bitcoin});
|
|
52
52
|
}
|