@did-btcr2/method 0.23.0 → 0.25.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 +96 -50
- package/dist/browser.js +36332 -37280
- package/dist/browser.mjs +36331 -37279
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
- 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 +3 -4
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/cjs/core/beacon/beacon.js.map +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js +119 -7
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/factory.js +1 -1
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
- package/dist/cjs/core/beacon/singleton-beacon.js.map +1 -0
- 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 +1 -1
- package/dist/cjs/core/identifier.js.map +1 -1
- package/dist/{esm/core/resolve.js → cjs/core/resolver.js} +244 -92
- package/dist/cjs/core/resolver.js.map +1 -0
- package/dist/cjs/core/update.js +7 -7
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +34 -94
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/did-document.js +9 -19
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
- 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 +3 -4
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +119 -7
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/factory.js +1 -1
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -0
- 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 +1 -1
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/{cjs/core/resolve.js → esm/core/resolver.js} +244 -92
- package/dist/esm/core/resolver.js.map +1 -0
- package/dist/esm/core/update.js +7 -7
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +34 -94
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/did-document.js +9 -19
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +1 -0
- 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 +1 -0
- 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 +10 -4
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +27 -7
- 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 +1 -0
- package/dist/types/core/beacon/{singleton.d.ts → singleton-beacon.d.ts} +7 -5
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/smt-beacon.d.ts +5 -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 +1 -0
- package/dist/types/core/interfaces.d.ts +6 -15
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +167 -0
- package/dist/types/core/resolver.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +1 -0
- package/dist/types/core/update.d.ts +4 -3
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +17 -16
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- 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 +2 -6
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +1 -1
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +4 -3
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +4 -3
- 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 +3 -4
- package/src/core/beacon/beacon.ts +9 -5
- package/src/core/beacon/cas-beacon.ts +156 -10
- package/src/core/beacon/factory.ts +1 -1
- package/src/core/beacon/{singleton.ts → singleton-beacon.ts} +20 -36
- package/src/core/beacon/smt-beacon.ts +4 -3
- package/src/core/identifier.ts +1 -1
- package/src/core/interfaces.ts +5 -16
- package/src/core/resolver.ts +706 -0
- package/src/core/update.ts +9 -9
- package/src/did-btcr2.ts +37 -130
- package/src/index.ts +2 -3
- package/src/utils/did-document.ts +10 -18
- package/dist/cjs/core/beacon/singleton.js.map +0 -1
- package/dist/cjs/core/resolve.js.map +0 -1
- package/dist/cjs/utils/general.js +0 -195
- package/dist/cjs/utils/general.js.map +0 -1
- package/dist/esm/core/beacon/singleton.js.map +0 -1
- package/dist/esm/core/resolve.js.map +0 -1
- package/dist/esm/utils/general.js +0 -195
- package/dist/esm/utils/general.js.map +0 -1
- package/dist/types/core/beacon/singleton.d.ts.map +0 -1
- package/dist/types/core/resolve.d.ts +0 -92
- package/dist/types/core/resolve.d.ts.map +0 -1
- package/dist/types/utils/general.d.ts +0 -85
- package/dist/types/utils/general.d.ts.map +0 -1
- package/src/core/resolve.ts +0 -474
- package/src/utils/general.ts +0 -204
package/dist/types/index.d.ts
CHANGED
|
@@ -28,16 +28,16 @@ export * from './core/beacon/error.js';
|
|
|
28
28
|
export * from './core/beacon/factory.js';
|
|
29
29
|
export * from './core/beacon/interfaces.js';
|
|
30
30
|
export * from './core/beacon/signal-discovery.js';
|
|
31
|
-
export * from './core/beacon/singleton.js';
|
|
31
|
+
export * from './core/beacon/singleton-beacon.js';
|
|
32
32
|
export * from './core/beacon/smt-beacon.js';
|
|
33
33
|
export * from './core/beacon/utils.js';
|
|
34
34
|
export * from './core/identifier.js';
|
|
35
35
|
export * from './core/interfaces.js';
|
|
36
|
-
export * from './core/
|
|
36
|
+
export * from './core/resolver.js';
|
|
37
37
|
export * from './core/types.js';
|
|
38
38
|
export * from './core/update.js';
|
|
39
39
|
export * from './utils/appendix.js';
|
|
40
40
|
export * from './utils/did-document-builder.js';
|
|
41
41
|
export * from './utils/did-document.js';
|
|
42
|
-
export * from './utils/general.js';
|
|
43
42
|
export * from './did-btcr2.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAE3D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wDAAwD,CAAC;AACvE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,mEAAmE,CAAC;AAClF,cAAc,4DAA4D,CAAC;AAC3E,cAAc,oEAAoE,CAAC;AACnF,cAAc,yEAAyE,CAAC;AACxF,cAAc,sEAAsE,CAAC;AACrF,cAAc,qEAAqE,CAAC;AACpF,cAAc,2EAA2E,CAAC;AAE1F,cAAc,6DAA6D,CAAC;AAC5E,cAAc,0DAA0D,CAAC;AAEzE,cAAc,kDAAkD,CAAC;AACjE,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAE5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc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}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HashBytes, JSONObject, KeyBytes } from '@did-btcr2/common';
|
|
2
2
|
import { DidDocument as W3CDidDocument, DidVerificationMethod as W3CDidVerificationMethod } from '@web5/dids';
|
|
3
3
|
import { BeaconService } from '../core/beacon/interfaces.js';
|
|
4
|
+
export declare const BTCR2_DID_DOCUMENT_CONTEXT: string[];
|
|
4
5
|
export declare const ID_PLACEHOLDER_VALUE = "did:btcr2:_";
|
|
5
6
|
export declare const BECH32M_CHARS = "";
|
|
6
7
|
export declare const DID_REGEX: RegExp;
|
|
@@ -138,12 +139,6 @@ export declare class DidDocument implements Btcr2DidDocument {
|
|
|
138
139
|
* @returns {boolean} True if the id is valid.
|
|
139
140
|
*/
|
|
140
141
|
private static isValidId;
|
|
141
|
-
/**
|
|
142
|
-
* Validates that the controller exists and is correctly formatted.
|
|
143
|
-
* @param {Array<string>} controller The controller to validate.
|
|
144
|
-
* @returns {boolean} True if the controller is valid.
|
|
145
|
-
*/
|
|
146
|
-
private static isValidController;
|
|
147
142
|
/**
|
|
148
143
|
* Validates that verification methods exist and are correctly formatted.
|
|
149
144
|
* @private
|
|
@@ -233,3 +228,4 @@ export declare class GenesisDocument extends DidDocument {
|
|
|
233
228
|
*/
|
|
234
229
|
static toGenesisBytes(genesisDocument: GenesisDocumentLike): HashBytes;
|
|
235
230
|
}
|
|
231
|
+
//# sourceMappingURL=did-document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-document.d.ts","sourceRoot":"","sources":["../../../src/utils/did-document.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EAGT,UAAU,EAEV,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,qBAAqB,IAAI,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE9G,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK7D,eAAO,MAAM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AAe,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe;IAKxE;;;;;;OAMG;WACW,MAAM,CAClB,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAChD,aAAa,EAAE,yBAAyB,EACxC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAC5B,eAAe;IAIlB;;;;OAIG;WACW,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe;IA4BlF;;;;OAIG;WACW,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,eAAe;IAIrE;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,eAAe,EAAE,mBAAmB,GAAG,SAAS;CAGvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/method",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reference implementation for the did:btcr2 DID method written in TypeScript and JavaScript. did:btcr2 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. This is the core method implementation for the did-btcr2-js monorepo.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"multiformats": "^13.3.1",
|
|
84
84
|
"nostr-tools": "^2.15.0",
|
|
85
85
|
"tiny-secp256k1": "^2.2.3",
|
|
86
|
-
"@did-btcr2/bitcoin": "0.
|
|
87
|
-
"@did-btcr2/
|
|
88
|
-
"@did-btcr2/keypair": "0.
|
|
89
|
-
"@did-btcr2/
|
|
86
|
+
"@did-btcr2/bitcoin": "0.5.0",
|
|
87
|
+
"@did-btcr2/common": "8.0.0",
|
|
88
|
+
"@did-btcr2/keypair": "0.11.0",
|
|
89
|
+
"@did-btcr2/cryptosuite": "6.0.2"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@eslint/js": "^9.22.0",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NotImplementedError } from '@did-btcr2/common';
|
|
2
2
|
import { RawSchnorrKeyPair, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
3
3
|
import { Identifier } from '../../../../identifier.js';
|
|
4
4
|
import { AggregateBeaconMessageType } from '../../cohort/messages/index.js';
|
|
5
|
+
import { BaseMessage } from '../../cohort/messages/base.js';
|
|
5
6
|
import { CommunicationService, MessageHandler, ServiceAdapterConfig, ServiceAdapterIdentity } from '../service.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -101,13 +102,13 @@ export class DidCommAdapter implements CommunicationService {
|
|
|
101
102
|
/**
|
|
102
103
|
* Sends a message to a recipient using the Nostr protocol.
|
|
103
104
|
* This method is a placeholder and should be implemented with actual Nostr message sending logic.
|
|
104
|
-
* @param {
|
|
105
|
+
* @param {AggregateBeaconMessageType} _message The message to send, typically containing the content and metadata.
|
|
105
106
|
* @param {string} _recipient The public key or identifier of the recipient.
|
|
106
107
|
* @param {string} _sender The public key or identifier of the sender.
|
|
107
108
|
* @returns {Promise<void>} A promise that resolves when the message is sent.
|
|
108
109
|
*/
|
|
109
110
|
public async sendMessage(
|
|
110
|
-
_message:
|
|
111
|
+
_message: AggregateBeaconMessageType | BaseMessage,
|
|
111
112
|
_recipient: string,
|
|
112
113
|
_sender: string
|
|
113
114
|
): Promise<void | Promise<string>[]> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TODO: Finish nostr adapter implementation. Rethink patterns used.
|
|
2
2
|
|
|
3
|
-
import { Did
|
|
3
|
+
import { Did } from '@did-btcr2/common';
|
|
4
4
|
import { CompressedSecp256k1PublicKey, RawSchnorrKeyPair, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
5
5
|
import { nonceGen } from '@scure/btc-signer/musig2';
|
|
6
6
|
import { Event, EventTemplate, Filter, finalizeEvent, nip44 } from 'nostr-tools';
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
BEACON_COHORT_SIGNATURE_AUTHORIZATION
|
|
19
19
|
} from '../../cohort/messages/constants.js';
|
|
20
20
|
import { AggregateBeaconMessage, AggregateBeaconMessageType } from '../../cohort/messages/index.js';
|
|
21
|
+
import { BaseMessage } from '../../cohort/messages/base.js';
|
|
21
22
|
import { CommunicationAdapterError } from '../error.js';
|
|
22
23
|
import { CommunicationService, MessageHandler, ServiceAdapter, ServiceAdapterConfig, ServiceAdapterIdentity } from '../service.js';
|
|
23
24
|
|
|
@@ -190,12 +191,12 @@ export class NostrAdapter implements CommunicationService {
|
|
|
190
191
|
* TODO: Clean up and complete this method.
|
|
191
192
|
* Sends a message to a recipient using the Nostr protocol.
|
|
192
193
|
* This method is a placeholder and should be implemented with actual Nostr message sending logic.
|
|
193
|
-
* @param {
|
|
194
|
+
* @param {AggregateBeaconMessageType} message The message to send, typically containing the content and metadata.
|
|
194
195
|
* @param {Did} from The identifier of the sender.
|
|
195
196
|
* @param {Did} [to] The identifier of the recipient.
|
|
196
197
|
* @returns {Promise<void>} A promise that resolves when the message is sent.
|
|
197
198
|
*/
|
|
198
|
-
public async sendMessage(message:
|
|
199
|
+
public async sendMessage(message: AggregateBeaconMessageType | BaseMessage, from: Did, to?: Did): Promise<void | Promise<string>[]> {
|
|
199
200
|
// Check if the sender and recipient DIDs are valid identifiers
|
|
200
201
|
if(
|
|
201
202
|
[from, to]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Maybe } from '@did-btcr2/common';
|
|
2
1
|
import { AggregateBeaconMessageType } from '../cohort/messages/index.js';
|
|
2
|
+
import { BaseMessage } from '../cohort/messages/base.js';
|
|
3
3
|
import { RawSchnorrKeyPair } from '@did-btcr2/keypair';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -34,7 +34,7 @@ export interface CommunicationService {
|
|
|
34
34
|
setKeys(keys: ServiceAdapterIdentity<RawSchnorrKeyPair>): void;
|
|
35
35
|
registerMessageHandler(messageType: string, handler: MessageHandler): void;
|
|
36
36
|
sendMessage(
|
|
37
|
-
message:
|
|
37
|
+
message: AggregateBeaconMessageType | BaseMessage,
|
|
38
38
|
sender: string,
|
|
39
39
|
recipient?: string
|
|
40
40
|
): Promise<void | Promise<string>[]>;
|
|
@@ -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
|
}
|