@did-btcr2/method 0.33.0 → 0.35.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/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +371 -119
- package/dist/browser.mjs +371 -119
- package/dist/cjs/index.js +326 -81
- package/dist/esm/core/aggregation/cohort.js +5 -1
- package/dist/esm/core/aggregation/cohort.js.map +1 -1
- package/dist/esm/core/aggregation/participant.js +25 -8
- package/dist/esm/core/aggregation/participant.js.map +1 -1
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +66 -0
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/index.js +1 -0
- package/dist/esm/core/aggregation/runner/index.js.map +1 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js +9 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
- package/dist/esm/core/aggregation/runner/service-runner.js +4 -1
- package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
- package/dist/esm/core/aggregation/service.js +4 -4
- package/dist/esm/core/aggregation/service.js.map +1 -1
- package/dist/esm/core/aggregation/signer.js +33 -0
- package/dist/esm/core/aggregation/signer.js.map +1 -0
- package/dist/esm/core/aggregation/signing-session.js +34 -11
- package/dist/esm/core/aggregation/signing-session.js.map +1 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +149 -0
- package/dist/esm/core/aggregation/transport/in-memory.js.map +1 -0
- package/dist/esm/core/aggregation/transport/index.js +1 -0
- package/dist/esm/core/aggregation/transport/index.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js +10 -8
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +4 -4
- 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/singleton-beacon.js +4 -4
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +4 -4
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
- package/dist/types/core/aggregation/participant.d.ts +17 -4
- package/dist/types/core/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +56 -0
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/service.d.ts +10 -4
- package/dist/types/core/aggregation/service.d.ts.map +1 -1
- package/dist/types/core/aggregation/signer.d.ts +50 -0
- package/dist/types/core/aggregation/signer.d.ts.map +1 -0
- package/dist/types/core/aggregation/signing-session.d.ts +13 -5
- package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +64 -0
- package/dist/types/core/aggregation/transport/in-memory.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +12 -10
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +4 -4
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +3 -3
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +4 -4
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +4 -4
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/core/aggregation/cohort.ts +5 -1
- package/src/core/aggregation/participant.ts +38 -12
- package/src/core/aggregation/runner/aggregation-runner.ts +96 -0
- package/src/core/aggregation/runner/index.ts +1 -0
- package/src/core/aggregation/runner/participant-runner.ts +9 -1
- package/src/core/aggregation/runner/service-runner.ts +4 -1
- package/src/core/aggregation/service.ts +12 -6
- package/src/core/aggregation/signer.ts +67 -0
- package/src/core/aggregation/signing-session.ts +34 -11
- package/src/core/aggregation/transport/in-memory.ts +178 -0
- package/src/core/aggregation/transport/index.ts +1 -0
- package/src/core/beacon/beacon.ts +12 -10
- package/src/core/beacon/cas-beacon.ts +4 -4
- package/src/core/beacon/factory.ts +3 -3
- package/src/core/beacon/singleton-beacon.ts +4 -4
- package/src/core/beacon/smt-beacon.ts +4 -4
- package/src/core/resolver.ts +1 -1
- package/src/index.ts +1 -0
|
@@ -89,7 +89,7 @@ export function deriveSingletonAddress(
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Options accepted by {@link
|
|
92
|
+
* Options accepted by {@link SinglePartyBeacon.buildSignAndBroadcast} and related helpers.
|
|
93
93
|
*/
|
|
94
94
|
export interface BroadcastOptions {
|
|
95
95
|
/** Fee estimator for computing the transaction fee. Defaults to {@link DEFAULT_FEE_ESTIMATOR}. */
|
|
@@ -115,14 +115,14 @@ export interface BeaconTxPlan {
|
|
|
115
115
|
feeSats: bigint;
|
|
116
116
|
/**
|
|
117
117
|
* Singleton beacon script kind, when applicable. Drives the signing dispatch
|
|
118
|
-
* in {@link
|
|
118
|
+
* in {@link SinglePartyBeacon.signSinglePartyTx}. Aggregation plans set this to `'p2tr'`.
|
|
119
119
|
*/
|
|
120
120
|
scriptKind: SingletonScriptKind;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Build an OP_RETURN script carrying a 32-byte beacon signal.
|
|
125
|
-
* Exported as a utility so callers building txs outside
|
|
125
|
+
* Exported as a utility so callers building txs outside SinglePartyBeacon (e.g., the aggregation
|
|
126
126
|
* `onProvideTxData` callback) can produce identical output.
|
|
127
127
|
*
|
|
128
128
|
* Uses the opcode *string* `'RETURN'` rather than the numeric `OP.RETURN`
|
|
@@ -168,7 +168,7 @@ async function fetchSpendableUtxo(
|
|
|
168
168
|
* Returns the unsigned Transaction + prev-output metadata that an aggregation service's
|
|
169
169
|
* signing session consumes (via {@link SigningTxData}).
|
|
170
170
|
*
|
|
171
|
-
* This is the reusable counterpart to {@link
|
|
171
|
+
* This is the reusable counterpart to {@link SinglePartyBeacon.buildSignAndBroadcast}'s internal
|
|
172
172
|
* construction step — the aggregation path must produce an unsigned tx because the
|
|
173
173
|
* signature comes from a MuSig2 round, not a local secret key.
|
|
174
174
|
*
|
|
@@ -311,9 +311,11 @@ async function signSingletonInput(
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
|
-
* Abstract base class
|
|
315
|
-
*
|
|
316
|
-
*
|
|
314
|
+
* Abstract base class providing the single-party broadcast machinery shared by
|
|
315
|
+
* all BTCR2 beacon types: one party holds one key and broadcasts one 32-byte
|
|
316
|
+
* signal (P2PKH / P2WPKH / P2TR key-path). The aggregation (cohort of N >= 1)
|
|
317
|
+
* broadcast mode is the orthogonal axis, handled by the AggregationService and
|
|
318
|
+
* {@link buildAggregationBeaconTx}, not by this class hierarchy. See ADR 037.
|
|
317
319
|
*
|
|
318
320
|
* Beacons are lightweight typed wrappers around a {@link BeaconService} configuration.
|
|
319
321
|
* Dependencies (signals, sidecar data, bitcoin connection) are passed as method
|
|
@@ -322,10 +324,10 @@ async function signSingletonInput(
|
|
|
322
324
|
* Use {@link BeaconFactory.establish} to create typed instances from service config.
|
|
323
325
|
*
|
|
324
326
|
* @abstract
|
|
325
|
-
* @class
|
|
326
|
-
* @type {
|
|
327
|
+
* @class SinglePartyBeacon
|
|
328
|
+
* @type {SinglePartyBeacon}
|
|
327
329
|
*/
|
|
328
|
-
export abstract class
|
|
330
|
+
export abstract class SinglePartyBeacon {
|
|
329
331
|
/**
|
|
330
332
|
* The Beacon service configuration parsed from the DID Document.
|
|
331
333
|
*/
|
|
@@ -5,7 +5,7 @@ import type { Signer } from '@did-btcr2/keypair';
|
|
|
5
5
|
import type { BeaconProcessResult, DataNeed } from '../resolver.js';
|
|
6
6
|
import type { SidecarData } from '../types.js';
|
|
7
7
|
import type { BroadcastOptions } from './beacon.js';
|
|
8
|
-
import {
|
|
8
|
+
import { SinglePartyBeacon } from './beacon.js';
|
|
9
9
|
import type { BeaconService, BeaconSignal, BlockMetadata, CasPublishFn } from './interfaces.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -28,9 +28,9 @@ export interface CASBroadcastOptions extends BroadcastOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* @class CASBeacon
|
|
30
30
|
* @type {CASBeacon}
|
|
31
|
-
* @extends {
|
|
31
|
+
* @extends {SinglePartyBeacon}
|
|
32
32
|
*/
|
|
33
|
-
export class CASBeacon extends
|
|
33
|
+
export class CASBeacon extends SinglePartyBeacon {
|
|
34
34
|
/**
|
|
35
35
|
* Creates an instance of CASBeacon.
|
|
36
36
|
* @param {BeaconService} service The service of the Beacon.
|
|
@@ -115,7 +115,7 @@ export class CASBeacon extends Beacon {
|
|
|
115
115
|
* Creates a CAS Announcement mapping the DID to the update hash, broadcasts the hash of the
|
|
116
116
|
* announcement via OP_RETURN, and optionally publishes the announcement off-chain via the
|
|
117
117
|
* supplied `casPublish` callback. UTXO selection, PSBT construction, fee estimation, signing,
|
|
118
|
-
* and broadcast are delegated to {@link
|
|
118
|
+
* and broadcast are delegated to {@link SinglePartyBeacon.buildSignAndBroadcast}.
|
|
119
119
|
*
|
|
120
120
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
121
121
|
* @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MethodError } from '@did-btcr2/common';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SinglePartyBeacon } from './beacon.js';
|
|
3
3
|
import { CASBeacon } from './cas-beacon.js';
|
|
4
4
|
import type { BeaconService } from './interfaces.js';
|
|
5
5
|
import { SingletonBeacon } from './singleton-beacon.js';
|
|
@@ -14,9 +14,9 @@ export class BeaconFactory {
|
|
|
14
14
|
/**
|
|
15
15
|
* Establish a Beacon instance based on the provided service and optional sidecar data.
|
|
16
16
|
* @param {BeaconService} service The beacon service configuration.
|
|
17
|
-
* @returns {
|
|
17
|
+
* @returns {SinglePartyBeacon} The established Beacon instance.
|
|
18
18
|
*/
|
|
19
|
-
static establish(service: BeaconService):
|
|
19
|
+
static establish(service: BeaconService): SinglePartyBeacon {
|
|
20
20
|
switch (service.type) {
|
|
21
21
|
case 'SingletonBeacon':
|
|
22
22
|
return new SingletonBeacon(service);
|
|
@@ -5,16 +5,16 @@ import type { Signer } from '@did-btcr2/keypair';
|
|
|
5
5
|
import type { BeaconProcessResult, DataNeed } from '../resolver.js';
|
|
6
6
|
import type { SidecarData } from '../types.js';
|
|
7
7
|
import type { BroadcastOptions } from './beacon.js';
|
|
8
|
-
import {
|
|
8
|
+
import { SinglePartyBeacon } from './beacon.js';
|
|
9
9
|
import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
|
|
13
13
|
* @class SingletonBeacon
|
|
14
14
|
* @type {SingletonBeacon}
|
|
15
|
-
* @extends {
|
|
15
|
+
* @extends {SinglePartyBeacon}
|
|
16
16
|
*/
|
|
17
|
-
export class SingletonBeacon extends
|
|
17
|
+
export class SingletonBeacon extends SinglePartyBeacon {
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Creates an instance of SingletonBeacon.
|
|
@@ -64,7 +64,7 @@ export class SingletonBeacon extends Beacon {
|
|
|
64
64
|
*
|
|
65
65
|
* The signal bytes embedded in OP_RETURN are the SHA-256 canonical hash of the signed update.
|
|
66
66
|
* UTXO selection, PSBT construction, fee estimation, signing, and broadcast are delegated to
|
|
67
|
-
* {@link
|
|
67
|
+
* {@link SinglePartyBeacon.buildSignAndBroadcast}.
|
|
68
68
|
*
|
|
69
69
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
70
70
|
* @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
|
|
@@ -7,7 +7,7 @@ import { randomBytes } from '@noble/hashes/utils';
|
|
|
7
7
|
import type { BeaconProcessResult, DataNeed } from '../resolver.js';
|
|
8
8
|
import type { SidecarData } from '../types.js';
|
|
9
9
|
import type { BroadcastOptions } from './beacon.js';
|
|
10
|
-
import {
|
|
10
|
+
import { SinglePartyBeacon } from './beacon.js';
|
|
11
11
|
import { SMTBeaconError } from './error.js';
|
|
12
12
|
import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
|
|
13
13
|
|
|
@@ -21,9 +21,9 @@ import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js
|
|
|
21
21
|
*
|
|
22
22
|
* @class SMTBeacon
|
|
23
23
|
* @type {SMTBeacon}
|
|
24
|
-
* @extends {
|
|
24
|
+
* @extends {SinglePartyBeacon}
|
|
25
25
|
*/
|
|
26
|
-
export class SMTBeacon extends
|
|
26
|
+
export class SMTBeacon extends SinglePartyBeacon {
|
|
27
27
|
/**
|
|
28
28
|
* Creates an instance of SMTBeacon.
|
|
29
29
|
* @param {BeaconService} service The Beacon service.
|
|
@@ -127,7 +127,7 @@ export class SMTBeacon extends Beacon {
|
|
|
127
127
|
* Builds a single-entry Sparse Merkle Tree from the signed update, then broadcasts the tree's
|
|
128
128
|
* root hash via OP_RETURN. For multi-party aggregation, use the {@link AggregationService}
|
|
129
129
|
* subsystem directly instead of this method. UTXO selection, PSBT construction, fee estimation,
|
|
130
|
-
* signing, and broadcast are delegated to {@link
|
|
130
|
+
* signing, and broadcast are delegated to {@link SinglePartyBeacon.buildSignAndBroadcast}.
|
|
131
131
|
*
|
|
132
132
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
133
133
|
* @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
|
package/src/core/resolver.ts
CHANGED
|
@@ -102,7 +102,7 @@ export type ResolverState =
|
|
|
102
102
|
| { status: 'resolved'; result: DidResolutionResponse };
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Return type from {@link
|
|
105
|
+
* Return type from {@link SinglePartyBeacon.processSignals}.
|
|
106
106
|
* Contains successfully resolved updates and any data needs that must be
|
|
107
107
|
* satisfied before the remaining signals can be processed.
|
|
108
108
|
*/
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Aggregation
|
|
2
2
|
export * from './core/aggregation/service.js';
|
|
3
3
|
export * from './core/aggregation/participant.js';
|
|
4
|
+
export * from './core/aggregation/signer.js';
|
|
4
5
|
export * from './core/aggregation/cohort.js';
|
|
5
6
|
export * from './core/aggregation/signing-session.js';
|
|
6
7
|
export * from './core/aggregation/phases.js';
|