@did-btcr2/method 0.37.0 → 0.39.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 +47868 -34771
- package/dist/browser.mjs +47867 -34770
- package/dist/cjs/index.js +462 -6060
- package/dist/esm/core/beacon/beacon.js +101 -10
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/fee-estimator.js +12 -27
- package/dist/esm/core/beacon/fee-estimator.js.map +1 -1
- package/dist/esm/core/did-sender-resolver.js +26 -0
- package/dist/esm/core/did-sender-resolver.js.map +1 -0
- package/dist/esm/index.js +3 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +59 -3
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/fee-estimator.d.ts +10 -37
- package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -1
- package/dist/types/core/did-sender-resolver.d.ts +14 -0
- package/dist/types/core/did-sender-resolver.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -16
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/core/beacon/beacon.ts +131 -12
- package/src/core/beacon/fee-estimator.ts +15 -49
- package/src/core/did-sender-resolver.ts +25 -0
- package/src/index.ts +3 -17
- package/dist/esm/core/aggregation/beacon-strategy.js +0 -76
- package/dist/esm/core/aggregation/beacon-strategy.js.map +0 -1
- package/dist/esm/core/aggregation/cohort.js +0 -316
- package/dist/esm/core/aggregation/cohort.js.map +0 -1
- package/dist/esm/core/aggregation/conditions.js +0 -102
- package/dist/esm/core/aggregation/conditions.js.map +0 -1
- package/dist/esm/core/aggregation/errors.js +0 -22
- package/dist/esm/core/aggregation/errors.js.map +0 -1
- package/dist/esm/core/aggregation/fallback-spend.js +0 -132
- package/dist/esm/core/aggregation/fallback-spend.js.map +0 -1
- package/dist/esm/core/aggregation/logger.js +0 -15
- package/dist/esm/core/aggregation/logger.js.map +0 -1
- package/dist/esm/core/aggregation/messages/base.js +0 -36
- package/dist/esm/core/aggregation/messages/base.js.map +0 -1
- package/dist/esm/core/aggregation/messages/bodies.js +0 -149
- package/dist/esm/core/aggregation/messages/bodies.js.map +0 -1
- package/dist/esm/core/aggregation/messages/constants.js +0 -37
- package/dist/esm/core/aggregation/messages/constants.js.map +0 -1
- package/dist/esm/core/aggregation/messages/factories.js +0 -139
- package/dist/esm/core/aggregation/messages/factories.js.map +0 -1
- package/dist/esm/core/aggregation/messages/guards.js +0 -40
- package/dist/esm/core/aggregation/messages/guards.js.map +0 -1
- package/dist/esm/core/aggregation/messages/index.js +0 -6
- package/dist/esm/core/aggregation/messages/index.js.map +0 -1
- package/dist/esm/core/aggregation/participant.js +0 -588
- package/dist/esm/core/aggregation/participant.js.map +0 -1
- package/dist/esm/core/aggregation/phases.js +0 -45
- package/dist/esm/core/aggregation/phases.js.map +0 -1
- package/dist/esm/core/aggregation/recovery-policy.js +0 -156
- package/dist/esm/core/aggregation/recovery-policy.js.map +0 -1
- package/dist/esm/core/aggregation/recovery-spend.js +0 -106
- package/dist/esm/core/aggregation/recovery-spend.js.map +0 -1
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +0 -74
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/events.js +0 -2
- package/dist/esm/core/aggregation/runner/events.js.map +0 -1
- package/dist/esm/core/aggregation/runner/index.js +0 -6
- package/dist/esm/core/aggregation/runner/index.js.map +0 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js +0 -407
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/service-runner.js +0 -694
- package/dist/esm/core/aggregation/runner/service-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/typed-emitter.js +0 -80
- package/dist/esm/core/aggregation/runner/typed-emitter.js.map +0 -1
- package/dist/esm/core/aggregation/service.js +0 -774
- package/dist/esm/core/aggregation/service.js.map +0 -1
- package/dist/esm/core/aggregation/signer.js +0 -33
- package/dist/esm/core/aggregation/signer.js.map +0 -1
- package/dist/esm/core/aggregation/signing-session.js +0 -195
- package/dist/esm/core/aggregation/signing-session.js.map +0 -1
- package/dist/esm/core/aggregation/transport/didcomm.js +0 -41
- package/dist/esm/core/aggregation/transport/didcomm.js.map +0 -1
- package/dist/esm/core/aggregation/transport/error.js +0 -12
- package/dist/esm/core/aggregation/transport/error.js.map +0 -1
- package/dist/esm/core/aggregation/transport/factory.js +0 -29
- package/dist/esm/core/aggregation/transport/factory.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/client.js +0 -350
- package/dist/esm/core/aggregation/transport/http/client.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/envelope.js +0 -126
- package/dist/esm/core/aggregation/transport/http/envelope.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/errors.js +0 -11
- package/dist/esm/core/aggregation/transport/http/errors.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +0 -45
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/index.js +0 -12
- package/dist/esm/core/aggregation/transport/http/index.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js +0 -38
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/protocol.js +0 -28
- package/dist/esm/core/aggregation/transport/http/protocol.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js +0 -45
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/request-auth.js +0 -100
- package/dist/esm/core/aggregation/transport/http/request-auth.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/server.js +0 -481
- package/dist/esm/core/aggregation/transport/http/server.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/sse-stream.js +0 -110
- package/dist/esm/core/aggregation/transport/http/sse-stream.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/sse-writer.js +0 -25
- package/dist/esm/core/aggregation/transport/http/sse-writer.js.map +0 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +0 -149
- package/dist/esm/core/aggregation/transport/in-memory.js.map +0 -1
- package/dist/esm/core/aggregation/transport/index.js +0 -8
- package/dist/esm/core/aggregation/transport/index.js.map +0 -1
- package/dist/esm/core/aggregation/transport/nostr.js +0 -491
- package/dist/esm/core/aggregation/transport/nostr.js.map +0 -1
- package/dist/esm/core/aggregation/transport/transport.js +0 -2
- package/dist/esm/core/aggregation/transport/transport.js.map +0 -1
- package/dist/types/core/aggregation/beacon-strategy.d.ts +0 -56
- package/dist/types/core/aggregation/beacon-strategy.d.ts.map +0 -1
- package/dist/types/core/aggregation/cohort.d.ts +0 -182
- package/dist/types/core/aggregation/cohort.d.ts.map +0 -1
- package/dist/types/core/aggregation/conditions.d.ts +0 -86
- package/dist/types/core/aggregation/conditions.d.ts.map +0 -1
- package/dist/types/core/aggregation/errors.d.ts +0 -14
- package/dist/types/core/aggregation/errors.d.ts.map +0 -1
- package/dist/types/core/aggregation/fallback-spend.d.ts +0 -94
- package/dist/types/core/aggregation/fallback-spend.d.ts.map +0 -1
- package/dist/types/core/aggregation/logger.d.ts +0 -22
- package/dist/types/core/aggregation/logger.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/base.d.ts +0 -58
- package/dist/types/core/aggregation/messages/base.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/bodies.d.ts +0 -177
- package/dist/types/core/aggregation/messages/bodies.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/constants.d.ts +0 -31
- package/dist/types/core/aggregation/messages/constants.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/factories.d.ts +0 -217
- package/dist/types/core/aggregation/messages/factories.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/guards.d.ts +0 -11
- package/dist/types/core/aggregation/messages/guards.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/index.d.ts +0 -6
- package/dist/types/core/aggregation/messages/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/participant.d.ts +0 -162
- package/dist/types/core/aggregation/participant.d.ts.map +0 -1
- package/dist/types/core/aggregation/phases.d.ts +0 -55
- package/dist/types/core/aggregation/phases.d.ts.map +0 -1
- package/dist/types/core/aggregation/recovery-policy.d.ts +0 -132
- package/dist/types/core/aggregation/recovery-policy.d.ts.map +0 -1
- package/dist/types/core/aggregation/recovery-spend.d.ts +0 -94
- package/dist/types/core/aggregation/recovery-spend.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +0 -66
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/events.d.ts +0 -147
- package/dist/types/core/aggregation/runner/events.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/index.d.ts +0 -6
- package/dist/types/core/aggregation/runner/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +0 -122
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/service-runner.d.ts +0 -211
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts +0 -41
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +0 -1
- package/dist/types/core/aggregation/service.d.ts +0 -177
- package/dist/types/core/aggregation/service.d.ts.map +0 -1
- package/dist/types/core/aggregation/signer.d.ts +0 -50
- package/dist/types/core/aggregation/signer.d.ts.map +0 -1
- package/dist/types/core/aggregation/signing-session.d.ts +0 -81
- package/dist/types/core/aggregation/signing-session.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/didcomm.d.ts +0 -23
- package/dist/types/core/aggregation/transport/didcomm.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/error.d.ts +0 -8
- package/dist/types/core/aggregation/transport/error.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/factory.d.ts +0 -28
- package/dist/types/core/aggregation/transport/factory.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/client.d.ts +0 -48
- package/dist/types/core/aggregation/transport/http/client.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/envelope.d.ts +0 -64
- package/dist/types/core/aggregation/transport/http/envelope.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/errors.d.ts +0 -9
- package/dist/types/core/aggregation/transport/http/errors.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +0 -32
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/index.d.ts +0 -12
- package/dist/types/core/aggregation/transport/http/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +0 -26
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/protocol.d.ts +0 -53
- package/dist/types/core/aggregation/transport/http/protocol.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +0 -41
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts +0 -50
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/server.d.ts +0 -110
- package/dist/types/core/aggregation/transport/http/server.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +0 -34
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +0 -12
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +0 -64
- package/dist/types/core/aggregation/transport/in-memory.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/index.d.ts +0 -8
- package/dist/types/core/aggregation/transport/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/nostr.d.ts +0 -153
- package/dist/types/core/aggregation/transport/nostr.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/transport.d.ts +0 -62
- package/dist/types/core/aggregation/transport/transport.d.ts.map +0 -1
- package/src/core/aggregation/beacon-strategy.ts +0 -142
- package/src/core/aggregation/cohort.ts +0 -415
- package/src/core/aggregation/conditions.ts +0 -172
- package/src/core/aggregation/errors.ts +0 -25
- package/src/core/aggregation/fallback-spend.ts +0 -223
- package/src/core/aggregation/logger.ts +0 -33
- package/src/core/aggregation/messages/base.ts +0 -80
- package/src/core/aggregation/messages/bodies.ts +0 -328
- package/src/core/aggregation/messages/constants.ts +0 -40
- package/src/core/aggregation/messages/factories.ts +0 -297
- package/src/core/aggregation/messages/guards.ts +0 -61
- package/src/core/aggregation/messages/index.ts +0 -5
- package/src/core/aggregation/participant.ts +0 -779
- package/src/core/aggregation/phases.ts +0 -91
- package/src/core/aggregation/recovery-policy.ts +0 -237
- package/src/core/aggregation/recovery-spend.ts +0 -192
- package/src/core/aggregation/runner/aggregation-runner.ts +0 -118
- package/src/core/aggregation/runner/events.ts +0 -129
- package/src/core/aggregation/runner/index.ts +0 -5
- package/src/core/aggregation/runner/participant-runner.ts +0 -488
- package/src/core/aggregation/runner/service-runner.ts +0 -866
- package/src/core/aggregation/runner/typed-emitter.ts +0 -87
- package/src/core/aggregation/service.ts +0 -1000
- package/src/core/aggregation/signer.ts +0 -67
- package/src/core/aggregation/signing-session.ts +0 -290
- package/src/core/aggregation/transport/didcomm.ts +0 -59
- package/src/core/aggregation/transport/error.ts +0 -13
- package/src/core/aggregation/transport/factory.ts +0 -65
- package/src/core/aggregation/transport/http/client.ts +0 -409
- package/src/core/aggregation/transport/http/envelope.ts +0 -204
- package/src/core/aggregation/transport/http/errors.ts +0 -11
- package/src/core/aggregation/transport/http/inbox-buffer.ts +0 -53
- package/src/core/aggregation/transport/http/index.ts +0 -11
- package/src/core/aggregation/transport/http/nonce-cache.ts +0 -43
- package/src/core/aggregation/transport/http/protocol.ts +0 -57
- package/src/core/aggregation/transport/http/rate-limiter.ts +0 -75
- package/src/core/aggregation/transport/http/request-auth.ts +0 -164
- package/src/core/aggregation/transport/http/server.ts +0 -615
- package/src/core/aggregation/transport/http/sse-stream.ts +0 -121
- package/src/core/aggregation/transport/http/sse-writer.ts +0 -23
- package/src/core/aggregation/transport/in-memory.ts +0 -178
- package/src/core/aggregation/transport/index.ts +0 -7
- package/src/core/aggregation/transport/nostr.ts +0 -576
- package/src/core/aggregation/transport/transport.ts +0 -79
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
2
|
-
import { canonicalHash, canonicalize, hash } from '@did-btcr2/common';
|
|
3
|
-
import { BTCR2MerkleTree } from '@did-btcr2/smt';
|
|
4
|
-
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
5
|
-
import { concatBytes, hexToBytes, randomBytes } from '@noble/hashes/utils';
|
|
6
|
-
import { p2tr } from '@scure/btc-signer';
|
|
7
|
-
import { keyAggExport, keyAggregate, sortKeys } from '@scure/btc-signer/musig2';
|
|
8
|
-
import { AggregationCohortError } from './errors.js';
|
|
9
|
-
import { DEFAULT_FUNDING_MODEL, buildRecoveryLeaves, resolveFallbackThreshold } from './recovery-policy.js';
|
|
10
|
-
/**
|
|
11
|
-
* Represents an Aggregation Cohort: a set of Aggregation Participants who
|
|
12
|
-
* submitted cryptographic material to an Aggregation Service to coordinate
|
|
13
|
-
* signing of a shared n-of-n MuSig2 Bitcoin transaction.
|
|
14
|
-
*
|
|
15
|
-
* This is a pure data class: it holds cohort state and provides computation
|
|
16
|
-
* helpers (key aggregation, CAS Announcement building, SMT tree building).
|
|
17
|
-
* It performs no I/O and emits no messages. Both AggregationService and
|
|
18
|
-
* AggregationParticipant create their own AggregationCohort instances to
|
|
19
|
-
* track their respective views of the cohort state.
|
|
20
|
-
*
|
|
21
|
-
* @class AggregationCohort
|
|
22
|
-
*/
|
|
23
|
-
export class AggregationCohort {
|
|
24
|
-
/** Unique identifier for the cohort. */
|
|
25
|
-
id;
|
|
26
|
-
/** DID of the Aggregation Service managing this cohort. */
|
|
27
|
-
serviceDid;
|
|
28
|
-
/** Minimum number of participants required to finalize the cohort. */
|
|
29
|
-
minParticipants;
|
|
30
|
-
/** Network on which the cohort operates (mainnet, mutinynet, etc.). */
|
|
31
|
-
network;
|
|
32
|
-
/** Type of beacon used in the cohort: 'CASBeacon' or 'SMTBeacon'. */
|
|
33
|
-
beaconType;
|
|
34
|
-
/** List of participant DIDs that have been accepted into the cohort. */
|
|
35
|
-
participants = [];
|
|
36
|
-
/**
|
|
37
|
-
* Mapping from participant DID to their compressed secp256k1 public key.
|
|
38
|
-
* Distinct from {@link cohortKeys} (which is sorted per BIP-327): this lets
|
|
39
|
-
* callers look up a participant's key without knowing their position in the
|
|
40
|
-
* sorted array. Populated by the service at `acceptParticipant` time.
|
|
41
|
-
*/
|
|
42
|
-
participantKeys = new Map();
|
|
43
|
-
/** Sorted list of cohort participants' compressed public keys. */
|
|
44
|
-
#cohortKeys = [];
|
|
45
|
-
/**
|
|
46
|
-
* BIP-341 TapTweak scalar: `taggedHash("TapTweak", internalPubkey || tapMerkleRoot)`.
|
|
47
|
-
* The beacon output is an internal key (the MuSig2 aggregate) plus a script
|
|
48
|
-
* tree (the recovery leaves), so the tweak commits to the tree's Merkle root.
|
|
49
|
-
* The MuSig2 signing session applies this as an x-only tweak; a value that does
|
|
50
|
-
* not match the root the funded address was derived from silently yields an
|
|
51
|
-
* invalid key-path signature.
|
|
52
|
-
*/
|
|
53
|
-
tapTweak = new Uint8Array();
|
|
54
|
-
/** The n-of-n MuSig2 aggregate internal key, x-only (32 bytes), set by computeBeaconAddress(). */
|
|
55
|
-
internalKey = new Uint8Array();
|
|
56
|
-
/** BIP-341 Taproot Merkle root of the recovery script tree, set by computeBeaconAddress(). */
|
|
57
|
-
tapMerkleRoot = new Uint8Array();
|
|
58
|
-
/** Operator recovery key, x-only (32 bytes). Used to build the CSV recovery leaf. */
|
|
59
|
-
recoveryKey;
|
|
60
|
-
/** Relative-timelock (BIP-68 nSequence) before the recovery leaf is spendable. */
|
|
61
|
-
recoverySequence;
|
|
62
|
-
/** Funding model governing the recovery leaves (default 'operator-funded'). */
|
|
63
|
-
fundingModel;
|
|
64
|
-
/**
|
|
65
|
-
* Advertised k of the k-of-n fallback leaf, or undefined to default to n-1 at
|
|
66
|
-
* address computation. Read the resolved value via {@link effectiveFallbackThreshold}.
|
|
67
|
-
*/
|
|
68
|
-
fallbackThreshold;
|
|
69
|
-
/** The Taproot beacon address: key path is the MuSig2 aggregate, script path is fallback + recovery. */
|
|
70
|
-
beaconAddress = '';
|
|
71
|
-
/** Pending DID updates submitted by participants, keyed by DID. */
|
|
72
|
-
pendingUpdates = new Map();
|
|
73
|
-
/**
|
|
74
|
-
* Participant DIDs that explicitly declined to submit an update this round
|
|
75
|
-
* (cooperative non-inclusion). A decliner is absent from the CAS Announcement
|
|
76
|
-
* Map and carries a non-inclusion leaf in the SMT, yet still signs. Kept
|
|
77
|
-
* disjoint from {@link pendingUpdates} so CAS correctness holds by construction.
|
|
78
|
-
*/
|
|
79
|
-
nonIncluded = new Set();
|
|
80
|
-
/** CAS Beacon Announcement Map (DID to updateHash), set by buildCASAnnouncement(). */
|
|
81
|
-
casAnnouncement;
|
|
82
|
-
/** Per-participant SMT proofs, set by buildSMTTree(). */
|
|
83
|
-
smtProofs;
|
|
84
|
-
/** Signal bytes (32 bytes) for OP_RETURN: SHA-256 of CAS announcement OR SMT root. */
|
|
85
|
-
signalBytes;
|
|
86
|
-
/** Set of participant DIDs that have approved the aggregated data. */
|
|
87
|
-
validationAcks = new Set();
|
|
88
|
-
/** Set of participant DIDs that have rejected the aggregated data. */
|
|
89
|
-
validationRejections = new Set();
|
|
90
|
-
constructor({ id, minParticipants, serviceDid, network, beaconType, recoveryKey, recoverySequence, fundingModel, fallbackThreshold }) {
|
|
91
|
-
this.id = id || crypto.randomUUID();
|
|
92
|
-
// `?? 2` (not `|| 2`) so a deliberately-passed 0 is preserved rather than
|
|
93
|
-
// silently coerced; the service rejects an invalid count at createCohort.
|
|
94
|
-
this.minParticipants = minParticipants ?? 2;
|
|
95
|
-
this.serviceDid = serviceDid || '';
|
|
96
|
-
this.network = network;
|
|
97
|
-
this.beaconType = beaconType || 'CASBeacon';
|
|
98
|
-
this.recoveryKey = recoveryKey;
|
|
99
|
-
this.recoverySequence = recoverySequence;
|
|
100
|
-
this.fundingModel = fundingModel ?? DEFAULT_FUNDING_MODEL;
|
|
101
|
-
this.fallbackThreshold = fallbackThreshold;
|
|
102
|
-
}
|
|
103
|
-
/** Sorted cohort keys (sorted on assignment per BIP-327). */
|
|
104
|
-
get cohortKeys() {
|
|
105
|
-
return this.#cohortKeys;
|
|
106
|
-
}
|
|
107
|
-
set cohortKeys(keys) {
|
|
108
|
-
this.#cohortKeys = sortKeys(keys);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* The resolved k of the k-of-n fallback leaf: the advertised
|
|
112
|
-
* {@link fallbackThreshold}, or n-1 (floored at 1) when unadvertised, where n is
|
|
113
|
-
* the current cohort size. This is the value the beacon address commits to and
|
|
114
|
-
* the spend builders must reproduce. Returns 0 before any cohort keys are set.
|
|
115
|
-
*/
|
|
116
|
-
get effectiveFallbackThreshold() {
|
|
117
|
-
if (this.#cohortKeys.length === 0)
|
|
118
|
-
return 0;
|
|
119
|
-
return resolveFallbackThreshold(this.fallbackThreshold, this.#cohortKeys.length);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Computes the Taproot beacon address from the cohort keys and recovery params.
|
|
123
|
-
*
|
|
124
|
-
* The output's key path is the n-of-n MuSig2 aggregate of the cohort keys; its
|
|
125
|
-
* script path is the recovery tree (a CSV recovery leaf so a missing signer
|
|
126
|
-
* cannot permanently lock the UTXO). Sets `internalKey`, `tapMerkleRoot`, and
|
|
127
|
-
* the `tapTweak` the MuSig2 session must apply for the key-path spend.
|
|
128
|
-
*
|
|
129
|
-
* The tweak is derived from the Merkle root the address was built with (read
|
|
130
|
-
* back from the payment), never recomputed by hand, so the MuSig2 key-path
|
|
131
|
-
* signature is guaranteed to validate against the funded address.
|
|
132
|
-
*/
|
|
133
|
-
computeBeaconAddress() {
|
|
134
|
-
if (this.#cohortKeys.length === 0) {
|
|
135
|
-
throw new AggregationCohortError('Cannot compute beacon address: no cohort keys.', 'NO_COHORT_KEYS', { cohortId: this.id });
|
|
136
|
-
}
|
|
137
|
-
if (!this.recoveryKey || this.recoveryKey.length === 0 || this.recoverySequence === undefined) {
|
|
138
|
-
throw new AggregationCohortError('Cannot compute beacon address: missing recovery key or sequence.', 'NO_RECOVERY_PARAMS', { cohortId: this.id });
|
|
139
|
-
}
|
|
140
|
-
const keyAggContext = keyAggregate(this.#cohortKeys);
|
|
141
|
-
const aggPubkey = keyAggExport(keyAggContext);
|
|
142
|
-
// The beacon output commits to the script tree (k-of-n fallback leaf + CSV
|
|
143
|
-
// recovery leaf) alongside the MuSig2 internal key. Derive the address for
|
|
144
|
-
// the cohort's network. Without the network arg p2tr defaults to mainnet, so
|
|
145
|
-
// a mutinynet/signet/regtest cohort would otherwise advertise a `bc1p...`
|
|
146
|
-
// address that no participant can fund.
|
|
147
|
-
const leaves = buildRecoveryLeaves(this.fundingModel, {
|
|
148
|
-
recoveryKey: this.recoveryKey,
|
|
149
|
-
recoverySequence: this.recoverySequence,
|
|
150
|
-
cohortKeys: this.#cohortKeys,
|
|
151
|
-
fallbackThreshold: resolveFallbackThreshold(this.fallbackThreshold, this.#cohortKeys.length),
|
|
152
|
-
});
|
|
153
|
-
// allowUnknownOutputs: the CSV recovery leaf is a custom script, not one of
|
|
154
|
-
// p2tr's recognized templates (tr_ns/tr_ms), so the template check must be
|
|
155
|
-
// waived. The leaf hash (and thus the address) is computed from the raw
|
|
156
|
-
// script bytes regardless.
|
|
157
|
-
const payment = p2tr(aggPubkey, leaves, getNetwork(this.network), true);
|
|
158
|
-
// BIP-341: the key-path tweak commits to the script tree's Merkle root.
|
|
159
|
-
// taggedHash("TapTweak", internalPubkey || tapMerkleRoot). Use the root the
|
|
160
|
-
// library committed to (payment.tapMerkleRoot) so the tweak matches the
|
|
161
|
-
// funded address byte-for-byte.
|
|
162
|
-
this.internalKey = aggPubkey;
|
|
163
|
-
this.tapMerkleRoot = payment.tapMerkleRoot;
|
|
164
|
-
this.tapTweak = schnorr.utils.taggedHash('TapTweak', concatBytes(aggPubkey, payment.tapMerkleRoot));
|
|
165
|
-
if (!payment.address) {
|
|
166
|
-
throw new AggregationCohortError('Failed to compute Taproot address', 'BEACON_ADDRESS_ERROR', { cohortId: this.id });
|
|
167
|
-
}
|
|
168
|
-
this.beaconAddress = payment.address;
|
|
169
|
-
return payment.address;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Validates that the participant's key is in the cohort and the beacon address
|
|
173
|
-
* matches the locally-computed one. Used by participants to verify cohort ready
|
|
174
|
-
* messages from the service.
|
|
175
|
-
*/
|
|
176
|
-
validateMembership(participantPkHex, cohortKeysHex, expectedBeaconAddress) {
|
|
177
|
-
if (!cohortKeysHex.includes(participantPkHex)) {
|
|
178
|
-
throw new AggregationCohortError(`Participant key not found in cohort ${this.id}.`, 'COHORT_VALIDATION_ERROR', { cohortId: this.id, participantPkHex });
|
|
179
|
-
}
|
|
180
|
-
this.cohortKeys = cohortKeysHex.map(k => hexToBytes(k));
|
|
181
|
-
const computed = this.computeBeaconAddress();
|
|
182
|
-
if (computed !== expectedBeaconAddress) {
|
|
183
|
-
throw new AggregationCohortError(`Computed beacon address ${computed} does not match expected ${expectedBeaconAddress}.`, 'BEACON_ADDRESS_MISMATCH', { cohortId: this.id, computed, expected: expectedBeaconAddress });
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Returns the position of a participant's public key in the sorted
|
|
188
|
-
* {@link cohortKeys} array, or -1 if the participant is not in the cohort.
|
|
189
|
-
* Required by MuSig2 partial-sig verification which indexes by signer position.
|
|
190
|
-
*/
|
|
191
|
-
indexOfParticipant(did) {
|
|
192
|
-
const pk = this.participantKeys.get(did);
|
|
193
|
-
if (!pk)
|
|
194
|
-
return -1;
|
|
195
|
-
return this.#cohortKeys.findIndex(k => k.length === pk.length && k.every((b, i) => b === pk[i]));
|
|
196
|
-
}
|
|
197
|
-
addUpdate(participantDid, signedUpdate) {
|
|
198
|
-
if (!this.participants.includes(participantDid)) {
|
|
199
|
-
throw new AggregationCohortError(`Participant ${participantDid} is not in cohort ${this.id}.`, 'UNKNOWN_PARTICIPANT', { cohortId: this.id, participantDid });
|
|
200
|
-
}
|
|
201
|
-
this.pendingUpdates.set(participantDid, signedUpdate);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Record that a participant declined to submit an update this round
|
|
205
|
-
* (cooperative non-inclusion). The member stays in the cohort and still signs.
|
|
206
|
-
*/
|
|
207
|
-
addNonInclusion(participantDid) {
|
|
208
|
-
if (!this.participants.includes(participantDid)) {
|
|
209
|
-
throw new AggregationCohortError(`Participant ${participantDid} is not in cohort ${this.id}.`, 'UNKNOWN_PARTICIPANT', { cohortId: this.id, participantDid });
|
|
210
|
-
}
|
|
211
|
-
// A DID cannot both submit and decline. The service guards re-submission, but
|
|
212
|
-
// keep the invariant local so the response gate and builders stay consistent.
|
|
213
|
-
if (this.pendingUpdates.has(participantDid)) {
|
|
214
|
-
throw new AggregationCohortError(`Participant ${participantDid} already submitted an update; cannot also decline.`, 'CONFLICTING_RESPONSE', { cohortId: this.id, participantDid });
|
|
215
|
-
}
|
|
216
|
-
this.nonIncluded.add(participantDid);
|
|
217
|
-
}
|
|
218
|
-
hasAllUpdates() {
|
|
219
|
-
return this.pendingUpdates.size === this.participants.length;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* True when every participant has responded for this round, either with an
|
|
223
|
-
* update or with an explicit non-inclusion. This is the aggregation gate when
|
|
224
|
-
* non-inclusion is in play; it generalizes {@link hasAllUpdates} the same way
|
|
225
|
-
* {@link hasAllValidationResponses} generalizes a unanimous ack.
|
|
226
|
-
*/
|
|
227
|
-
hasAllResponses() {
|
|
228
|
-
return this.pendingUpdates.size + this.nonIncluded.size === this.participants.length;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Builds a CAS Announcement Map from collected updates.
|
|
232
|
-
* Maps each participant DID to base64url canonical hash of their signed update.
|
|
233
|
-
* Computes signal bytes as SHA-256 of canonicalized announcement.
|
|
234
|
-
*
|
|
235
|
-
* Members who declined (cooperative non-inclusion) are naturally absent from
|
|
236
|
-
* the map: the body iterates {@link pendingUpdates}, which never holds a
|
|
237
|
-
* decliner. Absence from the map is exactly the CAS non-inclusion signal.
|
|
238
|
-
*/
|
|
239
|
-
buildCASAnnouncement() {
|
|
240
|
-
if (!this.hasAllResponses()) {
|
|
241
|
-
throw new AggregationCohortError('Cannot build CAS Announcement: not all participants have responded.', 'INCOMPLETE_RESPONSES', { cohortId: this.id, updates: this.pendingUpdates.size, declined: this.nonIncluded.size, total: this.participants.length });
|
|
242
|
-
}
|
|
243
|
-
const announcement = {};
|
|
244
|
-
for (const [did, signedUpdate] of this.pendingUpdates) {
|
|
245
|
-
announcement[did] = canonicalHash(signedUpdate);
|
|
246
|
-
}
|
|
247
|
-
this.casAnnouncement = announcement;
|
|
248
|
-
this.signalBytes = hash(canonicalize(announcement));
|
|
249
|
-
return announcement;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Builds an SMT tree with one leaf per participant.
|
|
253
|
-
*
|
|
254
|
-
* A member who submitted an update gets an inclusion leaf
|
|
255
|
-
* (SHA-256(SHA-256(nonce) || SHA-256(update))); a member who declined gets a
|
|
256
|
-
* non-inclusion leaf (SHA-256(SHA-256(nonce)), the `signedUpdate` entry field
|
|
257
|
-
* omitted). The cohort mints each member's nonce and returns it inside that
|
|
258
|
-
* member's serialized proof, so a decliner can self-validate its own
|
|
259
|
-
* non-inclusion slot and the resolver can recompute the leaf. Stores
|
|
260
|
-
* per-participant proofs and the SMT root as signalBytes.
|
|
261
|
-
*/
|
|
262
|
-
buildSMTTree() {
|
|
263
|
-
if (!this.hasAllResponses()) {
|
|
264
|
-
throw new AggregationCohortError('Cannot build SMT tree: not all participants have responded.', 'INCOMPLETE_RESPONSES', { cohortId: this.id, updates: this.pendingUpdates.size, declined: this.nonIncluded.size, total: this.participants.length });
|
|
265
|
-
}
|
|
266
|
-
const tree = new BTCR2MerkleTree();
|
|
267
|
-
const entries = [];
|
|
268
|
-
const encoder = new TextEncoder();
|
|
269
|
-
// Slot every participant: an inclusion leaf for submitters, a non-inclusion
|
|
270
|
-
// leaf (signedUpdate omitted) for decliners.
|
|
271
|
-
for (const did of this.participants) {
|
|
272
|
-
const nonce = randomBytes(32);
|
|
273
|
-
const signedUpdate = this.pendingUpdates.get(did);
|
|
274
|
-
if (signedUpdate) {
|
|
275
|
-
entries.push({ did, nonce, signedUpdate: encoder.encode(canonicalize(signedUpdate)) });
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
entries.push({ did, nonce });
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
tree.addEntries(entries);
|
|
282
|
-
tree.finalize();
|
|
283
|
-
this.signalBytes = tree.rootHash;
|
|
284
|
-
this.smtProofs = new Map();
|
|
285
|
-
for (const did of this.participants) {
|
|
286
|
-
this.smtProofs.set(did, tree.proof(did));
|
|
287
|
-
}
|
|
288
|
-
return this.smtProofs;
|
|
289
|
-
}
|
|
290
|
-
addValidation(participantDid, approved) {
|
|
291
|
-
if (!this.participants.includes(participantDid)) {
|
|
292
|
-
throw new AggregationCohortError(`Unknown participant ${participantDid} in cohort ${this.id}.`, 'UNKNOWN_PARTICIPANT', { cohortId: this.id, participantDid });
|
|
293
|
-
}
|
|
294
|
-
if (approved) {
|
|
295
|
-
this.validationAcks.add(participantDid);
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
this.validationRejections.add(participantDid);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* True when every participant has either approved or rejected the aggregated data.
|
|
303
|
-
*/
|
|
304
|
-
hasAllValidationResponses() {
|
|
305
|
-
return this.validationAcks.size + this.validationRejections.size === this.participants.length;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* True when all participants approved. Note: differs from {@link hasAllValidationResponses},
|
|
309
|
-
* this returns false if any participant rejected, even if all responses are in.
|
|
310
|
-
*/
|
|
311
|
-
isFullyValidated() {
|
|
312
|
-
return this.validationRejections.size === 0
|
|
313
|
-
&& this.validationAcks.size === this.participants.length;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
//# sourceMappingURL=cohort.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cohort.js","sourceRoot":"","sources":["../../../../src/core/aggregation/cohort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAkB5G;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAiB;IAC5B,w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EAC7D,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,cAAc,EAAE,CAC7D,CAAC;QACJ,CAAC;QACD,IAAG,QAAQ,EAAE,CAAC;YACZ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;OAEG;IACI,yBAAyB;QAC9B,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IAChG,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC;eACtC,IAAI,CAAC,cAAc,CAAC,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cohort conditions: the constraints an Aggregation Service advertises for a
|
|
3
|
-
* cohort (did:btcr2 spec, "Step 1: Create Aggregation Cohort"). See ADR 039.
|
|
4
|
-
*
|
|
5
|
-
* The spec frames these as an optional menu ("the Aggregation Service can define
|
|
6
|
-
* conditions such as ..."), so only `beaconType` and `minParticipants` are
|
|
7
|
-
* required here; every other condition is optional and, when absent, means
|
|
8
|
-
* unconstrained.
|
|
9
|
-
*
|
|
10
|
-
* Enforcement is staged (ADR 039): `beaconType` and the participant bounds are
|
|
11
|
-
* enforced by the state machine now; DIDs-per-participant, timing/cadence, and
|
|
12
|
-
* the pending-update trigger are modeled and advertised here but enforced when
|
|
13
|
-
* the multi-cohort (AGG-4) and non-inclusion (AGG-5) tracks land. The two cost
|
|
14
|
-
* conditions are advertised metadata only - the protocol performs no payment or
|
|
15
|
-
* settlement (consistent with ADR 008).
|
|
16
|
-
*/
|
|
17
|
-
import { MAX_RECOVERY_SEQUENCE } from './recovery-policy.js';
|
|
18
|
-
/** Beacon types that support aggregation (singleton is single-party only, per ADR 037). */
|
|
19
|
-
export const KNOWN_BEACON_TYPES = ['CASBeacon', 'SMTBeacon'];
|
|
20
|
-
/** Funding models an operator may advertise. Only 'operator-funded' is implemented (ADR 042). */
|
|
21
|
-
export const KNOWN_FUNDING_MODELS = ['operator-funded', 'participant-funded'];
|
|
22
|
-
/** Validate an optional [min, max] integer pair. */
|
|
23
|
-
function checkPair(problems, label, min, max) {
|
|
24
|
-
if (min !== undefined && (!Number.isInteger(min) || min < 0)) {
|
|
25
|
-
problems.push(`min${label} must be an integer >= 0`);
|
|
26
|
-
}
|
|
27
|
-
if (max !== undefined && (!Number.isInteger(max) || max < 0)) {
|
|
28
|
-
problems.push(`max${label} must be an integer >= 0`);
|
|
29
|
-
}
|
|
30
|
-
if (min !== undefined && max !== undefined && Number.isInteger(min) && Number.isInteger(max) && max < min) {
|
|
31
|
-
problems.push(`max${label} must be >= min${label}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/** Validate an optional advertised cost. */
|
|
35
|
-
function checkCost(problems, label, cost) {
|
|
36
|
-
if (cost === undefined)
|
|
37
|
-
return;
|
|
38
|
-
if (typeof cost.amount !== 'number' || !Number.isFinite(cost.amount) || cost.amount < 0) {
|
|
39
|
-
problems.push(`${label}.amount must be a finite number >= 0`);
|
|
40
|
-
}
|
|
41
|
-
if (typeof cost.unit !== 'string' || cost.unit.length === 0) {
|
|
42
|
-
problems.push(`${label}.unit must be a non-empty string`);
|
|
43
|
-
}
|
|
44
|
-
if (cost.basis !== undefined && cost.basis !== 'per-did' && cost.basis !== 'per-participant') {
|
|
45
|
-
problems.push(`${label}.basis must be 'per-did' or 'per-participant'`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Validate a set of cohort conditions. Returns a list of human-readable problems
|
|
50
|
-
* (empty when valid) so the caller can decide how to surface them. Used by
|
|
51
|
-
* `createCohort()` to fail fast instead of discovering invalidity at finalize.
|
|
52
|
-
*/
|
|
53
|
-
export function validateCohortConditions(c) {
|
|
54
|
-
const problems = [];
|
|
55
|
-
if (!KNOWN_BEACON_TYPES.includes(c.beaconType)) {
|
|
56
|
-
problems.push(`beaconType must be one of ${KNOWN_BEACON_TYPES.join(', ')}`);
|
|
57
|
-
}
|
|
58
|
-
if (!Number.isInteger(c.minParticipants) || c.minParticipants < 1) {
|
|
59
|
-
problems.push('minParticipants must be an integer >= 1');
|
|
60
|
-
}
|
|
61
|
-
if (c.maxParticipants !== undefined) {
|
|
62
|
-
if (!Number.isInteger(c.maxParticipants) || c.maxParticipants < 1) {
|
|
63
|
-
problems.push('maxParticipants must be an integer >= 1');
|
|
64
|
-
}
|
|
65
|
-
else if (Number.isInteger(c.minParticipants) && c.maxParticipants < c.minParticipants) {
|
|
66
|
-
problems.push('maxParticipants must be >= minParticipants');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
checkPair(problems, 'DidsPerParticipant', c.minDidsPerParticipant, c.maxDidsPerParticipant);
|
|
70
|
-
checkPair(problems, 'SecondsBetweenAnnouncements', c.minSecondsBetweenAnnouncements, c.maxSecondsBetweenAnnouncements);
|
|
71
|
-
if (c.pendingUpdateTrigger !== undefined && (!Number.isInteger(c.pendingUpdateTrigger) || c.pendingUpdateTrigger < 1)) {
|
|
72
|
-
problems.push('pendingUpdateTrigger must be an integer >= 1');
|
|
73
|
-
}
|
|
74
|
-
// Fallback threshold (k of the k-of-n fallback leaf). Optional; when advertised
|
|
75
|
-
// it must be a positive integer and cannot exceed maxParticipants (the binding
|
|
76
|
-
// upper bound against the actual cohort size n is checked at keygen, where n is
|
|
77
|
-
// known). See ADR 042.
|
|
78
|
-
if (c.fallbackThreshold !== undefined) {
|
|
79
|
-
if (!Number.isInteger(c.fallbackThreshold) || c.fallbackThreshold < 1) {
|
|
80
|
-
problems.push('fallbackThreshold must be an integer >= 1');
|
|
81
|
-
}
|
|
82
|
-
else if (c.maxParticipants !== undefined && Number.isInteger(c.maxParticipants) && c.fallbackThreshold > c.maxParticipants) {
|
|
83
|
-
problems.push('fallbackThreshold must be <= maxParticipants');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
checkCost(problems, 'costOfEnrollment', c.costOfEnrollment);
|
|
87
|
-
checkCost(problems, 'costPerAnnouncement', c.costPerAnnouncement);
|
|
88
|
-
// Recovery params: the beacon output's CSV recovery leaf. Required so a
|
|
89
|
-
// missing signer can never permanently lock the funded UTXO (ADR 042). The
|
|
90
|
-
// key is an x-only (32-byte) Schnorr public key, carried as 64 hex chars.
|
|
91
|
-
if (typeof c.recoveryKey !== 'string' || !/^[0-9a-fA-F]{64}$/.test(c.recoveryKey)) {
|
|
92
|
-
problems.push('recoveryKey must be a 64-character hex string (x-only public key)');
|
|
93
|
-
}
|
|
94
|
-
if (!Number.isInteger(c.recoverySequence) || c.recoverySequence < 1 || c.recoverySequence > MAX_RECOVERY_SEQUENCE) {
|
|
95
|
-
problems.push(`recoverySequence must be a block-based BIP-68 relative timelock in [1, ${MAX_RECOVERY_SEQUENCE}]`);
|
|
96
|
-
}
|
|
97
|
-
if (c.fundingModel !== undefined && !KNOWN_FUNDING_MODELS.includes(c.fundingModel)) {
|
|
98
|
-
problems.push(`fundingModel must be one of ${KNOWN_FUNDING_MODELS.join(', ')}`);
|
|
99
|
-
}
|
|
100
|
-
return problems;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=conditions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../../../src/core/aggregation/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,E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0E;IAC1E,IAAG,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;QACjF,QAAQ,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,gBAAgB,GAAG,CAAC,IAAI,CAAC,CAAC,gBAAgB,GAAG,qBAAqB,EAAE,CAAC;QACjH,QAAQ,CAAC,IAAI,CAAC,0EAA0E,qBAAqB,GAAG,CAAC,CAAC;IACpH,CAAC;IACD,IAAG,CAAC,CAAC,YAAY,KAAK,SAAS,IAAI,CAAE,oBAA0C,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;QACzG,QAAQ,CAAC,IAAI,CAAC,+BAA+B,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MethodError } from '@did-btcr2/common';
|
|
2
|
-
export class AggregationServiceError extends MethodError {
|
|
3
|
-
constructor(message, type = 'AggregationServiceError', data) {
|
|
4
|
-
super(message, type, data);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export class AggregationParticipantError extends MethodError {
|
|
8
|
-
constructor(message, type = 'AggregationParticipantError', data) {
|
|
9
|
-
super(message, type, data);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class AggregationCohortError extends MethodError {
|
|
13
|
-
constructor(message, type = 'AggregationCohortError', data) {
|
|
14
|
-
super(message, type, data);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class SigningSessionError extends MethodError {
|
|
18
|
-
constructor(message, type = 'SigningSessionError', data) {
|
|
19
|
-
super(message, type, data);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/core/aggregation/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACtD,YAAY,OAAe,EAAE,OAAe,yBAAyB,EAAE,IAA0B;QAC/F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,2BAA4B,SAAQ,WAAW;IAC1D,YAAY,OAAe,EAAE,OAAe,6BAA6B,EAAE,IAA0B;QACnG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,OAAe,wBAAwB,EAAE,IAA0B;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YAAY,OAAe,EAAE,OAAe,qBAAqB,EAAE,IAA0B;QAC3F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fallback spend builder for aggregate beacon outputs.
|
|
3
|
-
*
|
|
4
|
-
* An aggregate beacon UTXO is a Taproot output whose key path is the cohort's
|
|
5
|
-
* n-of-n MuSig2 aggregate key and whose script path carries a k-of-n fallback
|
|
6
|
-
* leaf (`p2tr_ms` CHECKSIGADD) plus a CSV recovery leaf (see
|
|
7
|
-
* {@link ./recovery-policy.ts} and ADR 042). When the optimistic n-of-n key path
|
|
8
|
-
* stalls (a missing or defecting signer), the cohort can still push the SAME
|
|
9
|
-
* announcement transaction through the fallback leaf with any k members'
|
|
10
|
-
* signatures, instead of abandoning the round or waiting out the recovery
|
|
11
|
-
* timelock.
|
|
12
|
-
*
|
|
13
|
-
* Unlike the MuSig2 key path, the fallback is a plain k-of-n script-path spend:
|
|
14
|
-
* each signer produces a standalone BIP-340 signature over the script-path
|
|
15
|
-
* sighash (no nonce round), and the coordinator assembles k of them into the
|
|
16
|
-
* witness. The coordinator never holds a participant secret - it injects the
|
|
17
|
-
* collected signatures and finalizes.
|
|
18
|
-
*
|
|
19
|
-
* This module is pure with respect to the network: it takes the beacon
|
|
20
|
-
* transaction, the cohort and recovery parameters, the spent output, and the
|
|
21
|
-
* collected signatures, and returns a finalized {@link Transaction}.
|
|
22
|
-
* Broadcasting is the caller's concern.
|
|
23
|
-
*/
|
|
24
|
-
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
25
|
-
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
26
|
-
import { SigHash, p2tr } from '@scure/btc-signer';
|
|
27
|
-
import { keyAggExport, keyAggregate, sortKeys } from '@scure/btc-signer/musig2';
|
|
28
|
-
import { AggregationCohortError } from './errors.js';
|
|
29
|
-
import { DEFAULT_FUNDING_MODEL, TAPROOT_LEAF_VERSION, buildFallbackLeaf, buildRecoveryLeaves, resolveFallbackThreshold, tapLeafHash, } from './recovery-policy.js';
|
|
30
|
-
function bytesEqual(a, b) {
|
|
31
|
-
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Compute the BIP-341 script-path sighash a cohort member must sign to authorize
|
|
35
|
-
* the fallback spend. The leaf is the k-of-n fallback leaf; signers produce a
|
|
36
|
-
* standalone BIP-340 signature over this digest with SIGHASH_DEFAULT.
|
|
37
|
-
*/
|
|
38
|
-
export function fallbackSighash(tx, inputIndex, prevOutScript, prevOutValue, fallbackLeafScript) {
|
|
39
|
-
return tx.preimageWitnessV1(inputIndex, [prevOutScript], SigHash.DEFAULT, [prevOutValue], undefined, fallbackLeafScript, TAPROOT_LEAF_VERSION);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Assemble and finalize a k-of-n fallback spend of an aggregate beacon UTXO.
|
|
43
|
-
*
|
|
44
|
-
* Reconstructs the funded Taproot output (MuSig2 internal key + fallback/recovery
|
|
45
|
-
* script tree), verifies each collected signature against the script-path
|
|
46
|
-
* sighash and a cohort key, injects exactly k distinct valid signatures into the
|
|
47
|
-
* fallback leaf, and finalizes the witness. The returned transaction is the same
|
|
48
|
-
* announcement the optimistic path would have produced, signed via the script
|
|
49
|
-
* path instead of the key path.
|
|
50
|
-
*
|
|
51
|
-
* @throws {AggregationCohortError} when there are no cohort keys, the spent
|
|
52
|
-
* script does not match the reconstructed tree output, or fewer than k valid
|
|
53
|
-
* distinct signatures were supplied.
|
|
54
|
-
*/
|
|
55
|
-
export function buildFallbackSpend(params) {
|
|
56
|
-
const { pendingTx, cohortKeys, recoveryKey, recoverySequence, fundingModel, network, prevOutScript, prevOutValue, signatures, } = params;
|
|
57
|
-
const inputIndex = params.inputIndex ?? 0;
|
|
58
|
-
if (cohortKeys.length === 0) {
|
|
59
|
-
throw new AggregationCohortError('Cannot build fallback spend: no cohort keys.', 'NO_COHORT_KEYS');
|
|
60
|
-
}
|
|
61
|
-
// Resolve k the same way the cohort did, so the reconstructed leaf matches.
|
|
62
|
-
const fallbackThreshold = resolveFallbackThreshold(params.fallbackThreshold, cohortKeys.length);
|
|
63
|
-
// Reconstruct the funded output the same way the cohort derived its address.
|
|
64
|
-
const internalKey = keyAggExport(keyAggregate(sortKeys(cohortKeys)));
|
|
65
|
-
const leaves = buildRecoveryLeaves(fundingModel ?? DEFAULT_FUNDING_MODEL, {
|
|
66
|
-
recoveryKey, recoverySequence, cohortKeys, fallbackThreshold,
|
|
67
|
-
});
|
|
68
|
-
const net = getNetwork(network);
|
|
69
|
-
// allowUnknownOutputs: the CSV recovery leaf is a custom script (see cohort.ts).
|
|
70
|
-
const payment = p2tr(internalKey, leaves, net, true);
|
|
71
|
-
// The output we are spending must be the cohort's funded beacon output; if the
|
|
72
|
-
// reconstructed tree script differs, the witness would not match the chain.
|
|
73
|
-
if (!bytesEqual(payment.script, prevOutScript)) {
|
|
74
|
-
throw new AggregationCohortError('Reconstructed beacon output script does not match the spent prevout script.', 'PREVOUT_SCRIPT_MISMATCH');
|
|
75
|
-
}
|
|
76
|
-
const fallbackLeaf = buildFallbackLeaf({ cohortKeys, fallbackThreshold });
|
|
77
|
-
// Locate the fallback leaf's tapLeafScript entry: each entry is
|
|
78
|
-
// [controlBlock, script || leafVersion]; strip the trailing version byte to
|
|
79
|
-
// compare the script.
|
|
80
|
-
const leafEntry = payment.tapLeafScript?.find(([, scriptVer]) => {
|
|
81
|
-
const script = scriptVer.slice(0, scriptVer.length - 1);
|
|
82
|
-
return bytesEqual(script, fallbackLeaf);
|
|
83
|
-
});
|
|
84
|
-
if (!leafEntry) {
|
|
85
|
-
throw new AggregationCohortError('Could not locate the fallback leaf in the reconstructed beacon output.', 'FALLBACK_LEAF_NOT_FOUND');
|
|
86
|
-
}
|
|
87
|
-
// Validate the collected signatures against the script-path sighash. The leaf
|
|
88
|
-
// is keyed by x-only cohort keys, so a valid signature must verify against one
|
|
89
|
-
// of them. Keep only distinct, valid signatures (first occurrence per key).
|
|
90
|
-
const cohortXOnly = sortKeys(cohortKeys).map(k => k.slice(1));
|
|
91
|
-
const tx = pendingTx;
|
|
92
|
-
const sighash = fallbackSighash(tx, inputIndex, prevOutScript, prevOutValue, fallbackLeaf);
|
|
93
|
-
const leafHash = tapLeafHash(fallbackLeaf);
|
|
94
|
-
const accepted = new Map(); // x-only hex to signature
|
|
95
|
-
for (const { pubKey, signature } of signatures) {
|
|
96
|
-
if (pubKey.length !== 32 || signature.length !== 64)
|
|
97
|
-
continue;
|
|
98
|
-
const isCohortKey = cohortXOnly.some(k => bytesEqual(k, pubKey));
|
|
99
|
-
if (!isCohortKey)
|
|
100
|
-
continue;
|
|
101
|
-
const hex = Array.from(pubKey, b => b.toString(16).padStart(2, '0')).join('');
|
|
102
|
-
if (accepted.has(hex))
|
|
103
|
-
continue;
|
|
104
|
-
let ok = false;
|
|
105
|
-
try {
|
|
106
|
-
ok = schnorr.verify(signature, sighash, pubKey);
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
ok = false;
|
|
110
|
-
}
|
|
111
|
-
if (ok)
|
|
112
|
-
accepted.set(hex, signature);
|
|
113
|
-
}
|
|
114
|
-
if (accepted.size < fallbackThreshold) {
|
|
115
|
-
throw new AggregationCohortError(`Not enough valid fallback signatures: have ${accepted.size}, need ${fallbackThreshold}.`, 'NOT_ENOUGH_FALLBACK_SIGNATURES', { have: accepted.size, need: fallbackThreshold });
|
|
116
|
-
}
|
|
117
|
-
// A k-of-n CHECKSIGADD leaf demands EXACTLY k satisfied signatures (the final
|
|
118
|
-
// <k> NUMEQUAL fails if the running count differs), so inject exactly k.
|
|
119
|
-
const chosen = cohortXOnly
|
|
120
|
-
.filter(k => accepted.has(Array.from(k, b => b.toString(16).padStart(2, '0')).join('')))
|
|
121
|
-
.slice(0, fallbackThreshold);
|
|
122
|
-
tx.updateInput(inputIndex, {
|
|
123
|
-
tapLeafScript: [leafEntry],
|
|
124
|
-
tapScriptSig: chosen.map(pubKey => {
|
|
125
|
-
const hex = Array.from(pubKey, b => b.toString(16).padStart(2, '0')).join('');
|
|
126
|
-
return [{ pubKey, leafHash }, accepted.get(hex)];
|
|
127
|
-
}),
|
|
128
|
-
});
|
|
129
|
-
tx.finalize();
|
|
130
|
-
return tx;
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=fallback-spend.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-spend.js","sourceRoot":"","sources":["../../../../src/core/aggregation/fallback-spend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE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QAAQ,CAAC,GAAG,CAAC,GAAG,CAAE,CAAE,CAAC;QACtD,CAAC,CAAC;KACH,CAAC,CAAC;IACH,EAAE,CAAC,QAAQ,EAAE,CAAC;IACd,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** Console-backed logger. Default for runners and transports. */
|
|
2
|
-
export const CONSOLE_LOGGER = {
|
|
3
|
-
debug: (msg, ...args) => console.debug(msg, ...args),
|
|
4
|
-
info: (msg, ...args) => console.info(msg, ...args),
|
|
5
|
-
warn: (msg, ...args) => console.warn(msg, ...args),
|
|
6
|
-
error: (msg, ...args) => console.error(msg, ...args),
|
|
7
|
-
};
|
|
8
|
-
/** No-op logger. Useful for tests and production environments with own logging pipeline. */
|
|
9
|
-
export const SILENT_LOGGER = {
|
|
10
|
-
debug: () => { },
|
|
11
|
-
info: () => { },
|
|
12
|
-
warn: () => { },
|
|
13
|
-
error: () => { },
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/core/aggregation/logger.ts"],"names":[],"mappings":"AAkBA,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,KAAK,EAAG,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,EAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACpD,IAAI,EAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACpD,KAAK,EAAG,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAG,GAAG,EAAE,GAAE,CAAC;IAChB,IAAI,EAAI,GAAG,EAAE,GAAE,CAAC;IAChB,IAAI,EAAI,GAAG,EAAE,GAAE,CAAC;IAChB,KAAK,EAAG,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC"}
|