@did-btcr2/method 0.34.0 → 0.36.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.
Files changed (64) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/browser.js +335 -167
  3. package/dist/browser.mjs +335 -167
  4. package/dist/cjs/index.js +275 -114
  5. package/dist/esm/core/aggregation/cohort.js +8 -2
  6. package/dist/esm/core/aggregation/cohort.js.map +1 -1
  7. package/dist/esm/core/aggregation/conditions.js +75 -0
  8. package/dist/esm/core/aggregation/conditions.js.map +1 -0
  9. package/dist/esm/core/aggregation/messages/base.js.map +1 -1
  10. package/dist/esm/core/aggregation/messages/bodies.js +16 -2
  11. package/dist/esm/core/aggregation/messages/bodies.js.map +1 -1
  12. package/dist/esm/core/aggregation/messages/factories.js.map +1 -1
  13. package/dist/esm/core/aggregation/participant.js +34 -15
  14. package/dist/esm/core/aggregation/participant.js.map +1 -1
  15. package/dist/esm/core/aggregation/runner/participant-runner.js +9 -1
  16. package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
  17. package/dist/esm/core/aggregation/runner/service-runner.js +12 -1
  18. package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
  19. package/dist/esm/core/aggregation/service.js +27 -7
  20. package/dist/esm/core/aggregation/service.js.map +1 -1
  21. package/dist/esm/core/aggregation/signer.js +33 -0
  22. package/dist/esm/core/aggregation/signer.js.map +1 -0
  23. package/dist/esm/core/aggregation/signing-session.js +34 -11
  24. package/dist/esm/core/aggregation/signing-session.js.map +1 -1
  25. package/dist/esm/core/aggregation/transport/in-memory.js +5 -2
  26. package/dist/esm/core/aggregation/transport/in-memory.js.map +1 -1
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
  30. package/dist/types/core/aggregation/conditions.d.ts +58 -0
  31. package/dist/types/core/aggregation/conditions.d.ts.map +1 -0
  32. package/dist/types/core/aggregation/messages/base.d.ts +2 -3
  33. package/dist/types/core/aggregation/messages/base.d.ts.map +1 -1
  34. package/dist/types/core/aggregation/messages/bodies.d.ts +2 -3
  35. package/dist/types/core/aggregation/messages/bodies.d.ts.map +1 -1
  36. package/dist/types/core/aggregation/messages/factories.d.ts +2 -3
  37. package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -1
  38. package/dist/types/core/aggregation/participant.d.ts +24 -8
  39. package/dist/types/core/aggregation/participant.d.ts.map +1 -1
  40. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
  41. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
  42. package/dist/types/core/aggregation/service.d.ts +18 -8
  43. package/dist/types/core/aggregation/service.d.ts.map +1 -1
  44. package/dist/types/core/aggregation/signer.d.ts +50 -0
  45. package/dist/types/core/aggregation/signer.d.ts.map +1 -0
  46. package/dist/types/core/aggregation/signing-session.d.ts +13 -5
  47. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
  48. package/dist/types/core/aggregation/transport/in-memory.d.ts.map +1 -1
  49. package/dist/types/index.d.ts +2 -0
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/package.json +4 -4
  52. package/src/core/aggregation/cohort.ts +8 -2
  53. package/src/core/aggregation/conditions.ts +116 -0
  54. package/src/core/aggregation/messages/base.ts +6 -3
  55. package/src/core/aggregation/messages/bodies.ts +18 -6
  56. package/src/core/aggregation/messages/factories.ts +2 -3
  57. package/src/core/aggregation/participant.ts +54 -23
  58. package/src/core/aggregation/runner/participant-runner.ts +9 -1
  59. package/src/core/aggregation/runner/service-runner.ts +13 -1
  60. package/src/core/aggregation/service.ts +51 -13
  61. package/src/core/aggregation/signer.ts +67 -0
  62. package/src/core/aggregation/signing-session.ts +34 -11
  63. package/src/core/aggregation/transport/in-memory.ts +7 -3
  64. package/src/index.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"participant.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/participant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AW,EAAE;IA+BzD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IAI/E;;;;;OAKG;IACI,YAAY,IAAI,IAAI;CAK5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpE,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEjC,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEzF,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE/F,MAAM,WAAW,mCAAmC;IAClD,4BAA4B;IAC5B,SAAS,EAAE,SAAS,CAAC;IAErB,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,4BAA6B,SAAQ,iBAAiB,CAAC,4BAA4B,CAAC;;IAC/F,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;gBAY7B,OAAO,EAAE,mCAAmC;IAYxD;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,8EAA8E;IAC9E,IAAI,IAAI,IAAI;IAwBZ;;;OAGG;WACU,SAAS,CACpB,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,mEAAmE;QACnE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,0FAA0F;QAC1F,QAAQ,CAAC,EAAE,kBAAkB,CAAC;KAC/B,CAAC;CAwNH"}
1
+ {"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,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,+BAA+B;IAiCpD;;;;;OAKG;IACH,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAiGjC;;;OAGG;IACH,IAAI,IAAI,IAAI;CAqQb"}
1
+ {"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAUzD,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kEAAkE;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEtF,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAErC,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;CACzB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAE7B,MAAM,WAAW,+BAA+B;IAC9C,kEAAkE;IAClE,SAAS,EAAE,SAAS,CAAC;IAErB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;IAErB,4BAA4B;IAC5B,MAAM,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC;;;OAGG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,0FAA0F;AAC1F,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,wBAAwB,CAAC;;IACvF,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBA8BzB,OAAO,EAAE,+BAA+B;IAoCpD;;;;;OAKG;IACH,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAiGjC;;;OAGG;IACH,IAAI,IAAI,IAAI;CA8Qb"}
@@ -1,14 +1,18 @@
1
1
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
2
- import type { SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ import type { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
3
3
  import type { Transaction } from '@scure/btc-signer';
4
4
  import { AggregationCohort } from './cohort.js';
5
+ import { type CohortConditions } from './conditions.js';
5
6
  import type { BaseMessage } from './messages/base.js';
6
7
  import type { ServiceCohortPhaseType } from './phases.js';
7
- /** Cohort configuration set by the service operator. */
8
- export interface CohortConfig {
9
- minParticipants: number;
8
+ /**
9
+ * Cohort configuration set by the service operator: the advertised cohort
10
+ * {@link CohortConditions} plus the Bitcoin network. `beaconType` and
11
+ * `minParticipants` are required; the other conditions are optional (absent =
12
+ * unconstrained). See ADR 039.
13
+ */
14
+ export interface CohortConfig extends CohortConditions {
10
15
  network: string;
11
- beaconType: string;
12
16
  }
13
17
  /** Pending opt-in awaiting service operator approval. */
14
18
  export interface PendingOptIn {
@@ -51,7 +55,13 @@ export interface Rejection {
51
55
  export declare const DEFAULT_MAX_UPDATE_SIZE_BYTES: number;
52
56
  export interface AggregationServiceParams {
53
57
  did: string;
54
- keys: SchnorrKeyPair;
58
+ /**
59
+ * The service's compressed communication public key (placed in cohort adverts).
60
+ * The coordinator never signs - it aggregates public nonces and partial
61
+ * signatures - so it is given a public key only, never a secret-bearing
62
+ * keypair (see ADR 038).
63
+ */
64
+ publicKey: CompressedSecp256k1PublicKey;
55
65
  /**
56
66
  * Maximum canonicalized byte-length of a signed update body accepted by the
57
67
  * service. Submissions above this cap are silently dropped and surfaced as
@@ -73,9 +83,9 @@ export interface AggregationServiceParams {
73
83
  export declare class AggregationService {
74
84
  #private;
75
85
  readonly did: string;
76
- readonly keys: SchnorrKeyPair;
86
+ readonly publicKey: CompressedSecp256k1PublicKey;
77
87
  readonly maxUpdateSizeBytes: number;
78
- constructor({ did, keys, maxUpdateSizeBytes }: AggregationServiceParams);
88
+ constructor({ did, publicKey, maxUpdateSizeBytes }: AggregationServiceParams);
79
89
  receive(message: BaseMessage): void;
80
90
  /**
81
91
  * Drain the rejection log for a cohort. Used by runners to surface silent
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,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AQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzD,IAAI,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAE9C;IAED;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAGrC"}
@@ -0,0 +1,50 @@
1
+ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
2
+ /**
3
+ * A signing capability for MuSig2 aggregation.
4
+ *
5
+ * MuSig2 (BIP-327) cannot be driven through a generic `sign(message)` primitive:
6
+ * both nonce generation and partial signing need the raw 32-byte secret scalar
7
+ * (see ADR 038). Rather than hand that scalar around as a long-lived field, the
8
+ * participant holds an `AggregationSigner` and materializes the secret only for
9
+ * the duration of a single operation via {@link AggregationSigner.withSecret},
10
+ * which is responsible for wiping its working copy afterward.
11
+ *
12
+ * This is the seam a non-extractable / KMS-backed signer (or a session-scoped
13
+ * signer that destroys its key after the cohort completes) plugs into without
14
+ * changing the participant state machine.
15
+ *
16
+ * @interface AggregationSigner
17
+ */
18
+ export interface AggregationSigner {
19
+ /** Compressed 33-byte public key. Not secret; always available. */
20
+ readonly publicKey: Uint8Array;
21
+ /**
22
+ * Materialize the raw 32-byte secret key, pass it to `fn`, and zeroize the
23
+ * working copy before returning - even if `fn` throws. The secret must not
24
+ * escape the callback.
25
+ *
26
+ * @typeParam T The callback's return type (e.g. a nonce contribution or partial signature).
27
+ * @param {(secretKey: Uint8Array) => T} fn Operation that needs the raw secret for its duration.
28
+ * @returns {T} Whatever `fn` returns.
29
+ */
30
+ withSecret<T>(fn: (secretKey: Uint8Array) => T): T;
31
+ }
32
+ /**
33
+ * {@link AggregationSigner} backed by an in-memory {@link SchnorrKeyPair}.
34
+ *
35
+ * The keypair is held privately (never exposed as a public field) and each
36
+ * `withSecret` call pulls a fresh copy of the secret bytes, hands it to the
37
+ * callback, and wipes that copy on return. The underlying keypair is the
38
+ * caller's to own and destroy; this signer never mutates or destroys it.
39
+ *
40
+ * @class KeyPairAggregationSigner
41
+ * @implements {AggregationSigner}
42
+ */
43
+ export declare class KeyPairAggregationSigner implements AggregationSigner {
44
+ #private;
45
+ readonly publicKey: Uint8Array;
46
+ /** @param {SchnorrKeyPair} keys The keypair whose secret backs this signer. */
47
+ constructor(keys: SchnorrKeyPair);
48
+ withSecret<T>(fn: (secretKey: Uint8Array) => T): T;
49
+ }
50
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAE/B;;;;;;;;OAQG;IACH,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;;IAChE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAG/B,+EAA+E;gBACnE,IAAI,EAAE,cAAc;IAKhC,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC;CAUnD"}
@@ -21,6 +21,7 @@ export interface SigningSessionParams {
21
21
  * @class BeaconSigningSession
22
22
  */
23
23
  export declare class BeaconSigningSession {
24
+ #private;
24
25
  /** Unique identifier for this signing session. */
25
26
  id: string;
26
27
  /** The cohort this session signs for. */
@@ -41,8 +42,6 @@ export declare class BeaconSigningSession {
41
42
  signature?: Uint8Array;
42
43
  /** Current signing session phase. */
43
44
  phase: SigningSessionPhaseType;
44
- /** Participant's secret nonce (held only by the participant during signing). */
45
- secretNonce?: Uint8Array;
46
45
  constructor({ id, cohort, pendingTx, prevOutScripts, prevOutValues }: SigningSessionParams);
47
46
  /**
48
47
  * Computes the Taproot sighash (BIP-341) for the first input.
@@ -61,11 +60,20 @@ export declare class BeaconSigningSession {
61
60
  * Generates a partial signature using the participant's secret key + secret nonce.
62
61
  * Requires the aggregated nonce to have been set first (via the service).
63
62
  *
64
- * Zeros the stored `secretNonce` after use. JS cannot truly erase memory (GC
65
- * and immutable strings), but overwriting the bytes shortens the exposure
66
- * window and prevents accidental reuse or serialization of a spent nonce.
63
+ * Clears the stored secret nonce after use on every path (success or throw)
64
+ * via {@link clearSecrets}. JS cannot truly erase memory (GC may relocate
65
+ * buffers), but overwriting the bytes shortens the exposure window and
66
+ * prevents accidental reuse or serialization of a spent nonce - reuse of a
67
+ * MuSig2 nonce leaks the secret key.
67
68
  */
68
69
  generatePartialSignature(participantSecretKey: Uint8Array): Uint8Array;
70
+ /**
71
+ * Zeroize any retained secret nonce. Safe to call repeatedly and on any path
72
+ * (completion, failure, or teardown of an abandoned session). Callers that
73
+ * drop a session before it reaches a partial signature should invoke this so
74
+ * the secret nonce does not linger on the live object.
75
+ */
76
+ clearSecrets(): void;
69
77
  isComplete(): boolean;
70
78
  isFailed(): boolean;
71
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,CAAC,EAAE,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AK5F,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAKrE,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ5B,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1F,gBAAgB,CACd,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,IAAI;IAcb,wFAAwF;IAClF,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtE,8EAA8E;IACxE,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAI5F"}
@@ -1,5 +1,7 @@
1
1
  export * from './core/aggregation/service.js';
2
2
  export * from './core/aggregation/participant.js';
3
+ export * from './core/aggregation/signer.js';
4
+ export * from './core/aggregation/conditions.js';
3
5
  export * from './core/aggregation/cohort.js';
4
6
  export * from './core/aggregation/signing-session.js';
5
7
  export * from './core/aggregation/phases.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AAGnD,cAAc,yBAAyB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AC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-btcr2/method",
3
- "version": "0.34.0",
3
+ "version": "0.36.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",
@@ -82,9 +82,9 @@
82
82
  "nostr-tools": "^2.23.3",
83
83
  "@did-btcr2/smt": "^0.3.0",
84
84
  "@did-btcr2/common": "^9.1.0",
85
- "@did-btcr2/bitcoin": "^0.6.0",
86
- "@did-btcr2/keypair": "^0.13.0",
87
- "@did-btcr2/cryptosuite": "^8.0.0"
85
+ "@did-btcr2/keypair": "^0.13.1",
86
+ "@did-btcr2/cryptosuite": "^8.0.0",
87
+ "@did-btcr2/bitcoin": "^0.6.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@eslint/js": "^9.39.4",
@@ -1,3 +1,4 @@
1
+ import { getNetwork } from '@did-btcr2/bitcoin';
1
2
  import { canonicalHash, canonicalize, hash } from '@did-btcr2/common';
2
3
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
4
  import type { SerializedSMTProof, TreeEntry } from '@did-btcr2/smt';
@@ -90,7 +91,9 @@ export class AggregationCohort {
90
91
 
91
92
  constructor({ id, minParticipants, serviceDid, network, beaconType }: AggregationCohortParams) {
92
93
  this.id = id || crypto.randomUUID();
93
- this.minParticipants = minParticipants || 2;
94
+ // `?? 2` (not `|| 2`) so a deliberately-passed 0 is preserved rather than
95
+ // silently coerced; the service rejects an invalid count at createCohort.
96
+ this.minParticipants = minParticipants ?? 2;
94
97
  this.serviceDid = serviceDid || '';
95
98
  this.network = network;
96
99
  this.beaconType = beaconType || 'CASBeacon';
@@ -118,7 +121,10 @@ export class AggregationCohort {
118
121
  }
119
122
  const keyAggContext = keyAggregate(this.#cohortKeys);
120
123
  const aggPubkey = keyAggExport(keyAggContext);
121
- const payment = p2tr(aggPubkey);
124
+ // Derive the address for the cohort's network. Without the network arg
125
+ // p2tr defaults to mainnet, so a mutinynet/signet/regtest cohort would
126
+ // otherwise advertise a `bc1p...` address that no participant can fund.
127
+ const payment = p2tr(aggPubkey, undefined, getNetwork(this.network));
122
128
 
123
129
  // BIP-341: key-path-only P2TR has no script tree. Compute the tweak:
124
130
  // taggedHash("TapTweak", internalPubkey).
@@ -0,0 +1,116 @@
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
+
18
+ /** Beacon types that support aggregation (singleton is single-party only, per ADR 037). */
19
+ export const KNOWN_BEACON_TYPES = ['CASBeacon', 'SMTBeacon'] as const;
20
+
21
+ /**
22
+ * An advertised price. `unit` is operator-defined (the spec does not specify a
23
+ * currency); `basis` distinguishes a per-DID from a per-participant charge for
24
+ * "cost per announcement". Advertised only - never settled by the protocol.
25
+ */
26
+ export interface CohortCost {
27
+ amount: number;
28
+ unit: string;
29
+ basis?: 'per-did' | 'per-participant';
30
+ }
31
+
32
+ /** The seven spec cohort conditions. Only beaconType + minParticipants are required. */
33
+ export interface CohortConditions {
34
+ /** 1. Beacon mechanism: 'CASBeacon' or 'SMTBeacon'. Enforced. */
35
+ beaconType: string;
36
+ /** 2. Lower bound on cohort size. Enforced (finalize floor). */
37
+ minParticipants: number;
38
+ /** 2. Upper bound on cohort size. Enforced (accept/finalize ceiling). */
39
+ maxParticipants?: number;
40
+ /** 3. Lower bound on DIDs a participant may register. Advertised; enforcement staged (AGG-5). */
41
+ minDidsPerParticipant?: number;
42
+ /** 3. Upper bound on DIDs a participant may register. Advertised; enforcement staged (AGG-5). */
43
+ maxDidsPerParticipant?: number;
44
+ /** 4. One-time enrollment price. Advertised only - no settlement. */
45
+ costOfEnrollment?: CohortCost;
46
+ /** 5. Recurring per-announcement price. Advertised only - no settlement. */
47
+ costPerAnnouncement?: CohortCost;
48
+ /** 6. Floor on time between announcements (seconds). Advertised; enforcement staged (AGG-4/5). */
49
+ minSecondsBetweenAnnouncements?: number;
50
+ /** 6. Ceiling on time between announcements (seconds). Advertised; enforcement staged - generalizes the ADR 027 Cohort TTL. */
51
+ maxSecondsBetweenAnnouncements?: number;
52
+ /** 7. Pending-update count that triggers an announcement. Advertised; enforcement staged (AGG-5) - generalizes hasAllUpdates(). */
53
+ pendingUpdateTrigger?: number;
54
+ }
55
+
56
+ /** Validate an optional [min, max] integer pair. */
57
+ function checkPair(problems: string[], label: string, min?: number, max?: number): void {
58
+ if(min !== undefined && (!Number.isInteger(min) || min < 0)) {
59
+ problems.push(`min${label} must be an integer >= 0`);
60
+ }
61
+ if(max !== undefined && (!Number.isInteger(max) || max < 0)) {
62
+ problems.push(`max${label} must be an integer >= 0`);
63
+ }
64
+ if(min !== undefined && max !== undefined && Number.isInteger(min) && Number.isInteger(max) && max < min) {
65
+ problems.push(`max${label} must be >= min${label}`);
66
+ }
67
+ }
68
+
69
+ /** Validate an optional advertised cost. */
70
+ function checkCost(problems: string[], label: string, cost?: CohortCost): void {
71
+ if(cost === undefined) return;
72
+ if(typeof cost.amount !== 'number' || !Number.isFinite(cost.amount) || cost.amount < 0) {
73
+ problems.push(`${label}.amount must be a finite number >= 0`);
74
+ }
75
+ if(typeof cost.unit !== 'string' || cost.unit.length === 0) {
76
+ problems.push(`${label}.unit must be a non-empty string`);
77
+ }
78
+ if(cost.basis !== undefined && cost.basis !== 'per-did' && cost.basis !== 'per-participant') {
79
+ problems.push(`${label}.basis must be 'per-did' or 'per-participant'`);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Validate a set of cohort conditions. Returns a list of human-readable problems
85
+ * (empty when valid) so the caller can decide how to surface them. Used by
86
+ * `createCohort()` to fail fast instead of discovering invalidity at finalize.
87
+ */
88
+ export function validateCohortConditions(c: CohortConditions): string[] {
89
+ const problems: string[] = [];
90
+
91
+ if(!(KNOWN_BEACON_TYPES as readonly string[]).includes(c.beaconType)) {
92
+ problems.push(`beaconType must be one of ${KNOWN_BEACON_TYPES.join(', ')}`);
93
+ }
94
+ if(!Number.isInteger(c.minParticipants) || c.minParticipants < 1) {
95
+ problems.push('minParticipants must be an integer >= 1');
96
+ }
97
+ if(c.maxParticipants !== undefined) {
98
+ if(!Number.isInteger(c.maxParticipants) || c.maxParticipants < 1) {
99
+ problems.push('maxParticipants must be an integer >= 1');
100
+ } else if(Number.isInteger(c.minParticipants) && c.maxParticipants < c.minParticipants) {
101
+ problems.push('maxParticipants must be >= minParticipants');
102
+ }
103
+ }
104
+
105
+ checkPair(problems, 'DidsPerParticipant', c.minDidsPerParticipant, c.maxDidsPerParticipant);
106
+ checkPair(problems, 'SecondsBetweenAnnouncements', c.minSecondsBetweenAnnouncements, c.maxSecondsBetweenAnnouncements);
107
+
108
+ if(c.pendingUpdateTrigger !== undefined && (!Number.isInteger(c.pendingUpdateTrigger) || c.pendingUpdateTrigger < 1)) {
109
+ problems.push('pendingUpdateTrigger must be an integer >= 1');
110
+ }
111
+
112
+ checkCost(problems, 'costOfEnrollment', c.costOfEnrollment);
113
+ checkCost(problems, 'costPerAnnouncement', c.costPerAnnouncement);
114
+
115
+ return problems;
116
+ }
@@ -1,3 +1,5 @@
1
+ import type { CohortConditions } from '../conditions.js';
2
+
1
3
  /**
2
4
  * Current on-the-wire protocol version.
3
5
  *
@@ -7,9 +9,11 @@
7
9
  */
8
10
  export const AGGREGATION_WIRE_VERSION = 1;
9
11
 
10
- export type BaseBody = {
12
+ // Cohort conditions (beaconType, minParticipants, maxParticipants, ...) ride on
13
+ // the wire as flat optional body fields, supplied via `Partial<CohortConditions>`
14
+ // below so the bag stays a single source of truth for the advertised conditions.
15
+ export type BaseBody = Partial<CohortConditions> & {
11
16
  cohortId: string;
12
- cohortSize?: number;
13
17
  network?: string;
14
18
  participantPk?: Uint8Array;
15
19
  beaconAddress?: string;
@@ -23,7 +27,6 @@ export type BaseBody = {
23
27
  prevOutScriptHex?: string;
24
28
  prevOutValue?: string;
25
29
  communicationPk?: Uint8Array;
26
- beaconType?: string;
27
30
  data?: string;
28
31
  signedUpdate?: Record<string, unknown>;
29
32
  casAnnouncement?: Record<string, string>;
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import type { SerializedSMTProof } from '@did-btcr2/smt';
15
+ import type { CohortConditions } from '../conditions.js';
15
16
  import type { BaseMessage } from './base.js';
16
17
  import {
17
18
  AGGREGATED_NONCE,
@@ -29,10 +30,8 @@ import {
29
30
 
30
31
  // ── Cohort formation (Step 1) ─────────────────────────────────────────────
31
32
 
32
- export interface CohortAdvertBody {
33
+ export interface CohortAdvertBody extends CohortConditions {
33
34
  cohortId: string;
34
- cohortSize: number;
35
- beaconType: string;
36
35
  network: string;
37
36
  communicationPk: Uint8Array;
38
37
  }
@@ -135,8 +134,16 @@ export type AggregationMessage =
135
134
 
136
135
  const hasStr = (b: unknown, k: string): boolean =>
137
136
  !!b && typeof (b as Record<string, unknown>)[k] === 'string';
138
- const hasNum = (b: unknown, k: string): boolean =>
139
- !!b && typeof (b as Record<string, unknown>)[k] === 'number';
137
+ /** Present, an integer, and >= min. */
138
+ const hasIntMin = (b: unknown, k: string, min: number): boolean => {
139
+ const v = b ? (b as Record<string, unknown>)[k] : undefined;
140
+ return typeof v === 'number' && Number.isInteger(v) && v >= min;
141
+ };
142
+ /** Absent, or present as an integer >= min. */
143
+ const optIntMin = (b: unknown, k: string, min: number): boolean => {
144
+ const v = b ? (b as Record<string, unknown>)[k] : undefined;
145
+ return v === undefined || (typeof v === 'number' && Number.isInteger(v) && v >= min);
146
+ };
140
147
  const hasBool = (b: unknown, k: string): boolean =>
141
148
  !!b && typeof (b as Record<string, unknown>)[k] === 'boolean';
142
149
  const hasBytes = (b: unknown, k: string): boolean =>
@@ -147,9 +154,14 @@ const hasBytesArray = (b: unknown, k: string): boolean => {
147
154
  };
148
155
 
149
156
  export function isCohortAdvertMessage(m: BaseMessage): m is CohortAdvertMessage {
157
+ // Range-check the participant bounds so a malformed advert (missing or
158
+ // zero/negative minParticipants) is rejected rather than silently accepted as
159
+ // a zero-floor cohort. The service does the full cross-field validation at
160
+ // createCohort (see validateCohortConditions); here we guard the wire shape.
150
161
  return m.type === COHORT_ADVERT
151
162
  && hasStr(m.body, 'cohortId')
152
- && hasNum(m.body, 'cohortSize')
163
+ && hasIntMin(m.body, 'minParticipants', 1)
164
+ && optIntMin(m.body, 'maxParticipants', 1)
153
165
  && hasStr(m.body, 'beaconType')
154
166
  && hasStr(m.body, 'network')
155
167
  && hasBytes(m.body, 'communicationPk');
@@ -1,3 +1,4 @@
1
+ import type { CohortConditions } from '../conditions.js';
1
2
  import { BaseMessage } from './base.js';
2
3
  import {
3
4
  AGGREGATED_NONCE,
@@ -18,11 +19,9 @@ import {
18
19
  * Factory functions for creating messages related to the cohort formation step, where cohorts are
19
20
  * formed and participants opt in to join the cohort.
20
21
  */
21
- type CohortAdvertMessage = {
22
+ type CohortAdvertMessage = CohortConditions & {
22
23
  from: string;
23
24
  cohortId: string;
24
- cohortSize: number;
25
- beaconType: string;
26
25
  network: string;
27
26
  communicationPk: Uint8Array;
28
27
  };