@did-btcr2/method 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -233
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +24111 -20342
- package/dist/browser.mjs +24111 -20342
- package/dist/cjs/index.js +2463 -2174
- package/dist/esm/core/aggregation/cohort.js +178 -0
- package/dist/esm/core/aggregation/cohort.js.map +1 -0
- package/dist/esm/core/aggregation/errors.js +22 -0
- package/dist/esm/core/aggregation/errors.js.map +1 -0
- package/dist/esm/core/{beacon/aggregation/cohort → aggregation}/messages/base.js +0 -1
- package/dist/esm/core/aggregation/messages/base.js.map +1 -0
- package/dist/esm/core/aggregation/messages/constants.js +26 -0
- package/dist/esm/core/aggregation/messages/constants.js.map +1 -0
- package/dist/esm/core/aggregation/messages/factories.js +113 -0
- package/dist/esm/core/aggregation/messages/factories.js.map +1 -0
- package/dist/esm/core/aggregation/messages/guards.js +37 -0
- package/dist/esm/core/aggregation/messages/guards.js.map +1 -0
- package/dist/esm/core/aggregation/messages/index.js +5 -0
- package/dist/esm/core/aggregation/messages/index.js.map +1 -0
- package/dist/esm/core/aggregation/participant.js +376 -0
- package/dist/esm/core/aggregation/participant.js.map +1 -0
- package/dist/esm/core/aggregation/phases.js +39 -0
- package/dist/esm/core/aggregation/phases.js.map +1 -0
- package/dist/esm/core/aggregation/runner/events.js +2 -0
- package/dist/esm/core/aggregation/runner/events.js.map +1 -0
- package/dist/esm/core/aggregation/runner/index.js +5 -0
- package/dist/esm/core/aggregation/runner/index.js.map +1 -0
- package/dist/esm/core/aggregation/runner/participant-runner.js +282 -0
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/service-runner.js +290 -0
- package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/typed-emitter.js +80 -0
- package/dist/esm/core/aggregation/runner/typed-emitter.js.map +1 -0
- package/dist/esm/core/aggregation/service.js +416 -0
- package/dist/esm/core/aggregation/service.js.map +1 -0
- package/dist/esm/core/aggregation/signing-session.js +133 -0
- package/dist/esm/core/aggregation/signing-session.js.map +1 -0
- package/dist/esm/core/aggregation/transport/didcomm.js +32 -0
- package/dist/esm/core/aggregation/transport/didcomm.js.map +1 -0
- package/dist/esm/core/aggregation/transport/error.js +12 -0
- package/dist/esm/core/aggregation/transport/error.js.map +1 -0
- package/dist/esm/core/aggregation/transport/factory.js +20 -0
- package/dist/esm/core/aggregation/transport/factory.js.map +1 -0
- package/dist/esm/core/aggregation/transport/index.js +6 -0
- package/dist/esm/core/aggregation/transport/index.js.map +1 -0
- package/dist/esm/core/aggregation/transport/nostr.js +262 -0
- package/dist/esm/core/aggregation/transport/nostr.js.map +1 -0
- package/dist/esm/core/aggregation/transport/transport.js +2 -0
- package/dist/esm/core/aggregation/transport/transport.js.map +1 -0
- package/dist/esm/core/beacon/beacon.js +80 -0
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +15 -56
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/error.js +0 -10
- package/dist/esm/core/beacon/error.js.map +1 -1
- package/dist/esm/core/beacon/fee-estimator.js +30 -0
- package/dist/esm/core/beacon/fee-estimator.js.map +1 -0
- package/dist/esm/core/beacon/singleton-beacon.js +10 -53
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +85 -9
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/identifier.js +13 -0
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +9 -0
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/index.js +14 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/aggregation/cohort.d.ts +94 -0
- package/dist/types/core/aggregation/cohort.d.ts.map +1 -0
- package/dist/types/core/aggregation/errors.d.ts +14 -0
- package/dist/types/core/aggregation/errors.d.ts.map +1 -0
- package/dist/types/core/{beacon/aggregation/cohort → aggregation}/messages/base.d.ts +7 -1
- package/dist/types/core/aggregation/messages/base.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/constants.d.ts +23 -0
- package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/factories.d.ts +177 -0
- package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/guards.d.ts +11 -0
- package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -0
- package/dist/types/core/aggregation/messages/index.d.ts +5 -0
- package/dist/types/core/aggregation/messages/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/participant.d.ts +101 -0
- package/dist/types/core/aggregation/participant.d.ts.map +1 -0
- package/dist/types/core/aggregation/phases.d.ts +49 -0
- package/dist/types/core/aggregation/phases.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/events.d.ts +89 -0
- package/dist/types/core/aggregation/runner/events.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts +5 -0
- package/dist/types/core/aggregation/runner/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +107 -0
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/service-runner.d.ts +102 -0
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts +41 -0
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +1 -0
- package/dist/types/core/aggregation/service.d.ts +112 -0
- package/dist/types/core/aggregation/service.d.ts.map +1 -0
- package/dist/types/core/aggregation/signing-session.d.ts +69 -0
- package/dist/types/core/aggregation/signing-session.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/didcomm.d.ts +20 -0
- package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -0
- package/dist/types/core/{beacon/aggregation/communication → aggregation/transport}/error.d.ts +2 -2
- package/dist/types/core/aggregation/transport/error.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/factory.d.ts +13 -0
- package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts +6 -0
- package/dist/types/core/aggregation/transport/index.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/nostr.d.ts +55 -0
- package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/transport.d.ts +37 -0
- package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -0
- package/dist/types/core/beacon/beacon.d.ts +37 -2
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +19 -7
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +0 -6
- package/dist/types/core/beacon/error.d.ts.map +1 -1
- package/dist/types/core/beacon/fee-estimator.d.ts +40 -0
- package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -0
- package/dist/types/core/beacon/interfaces.d.ts +8 -0
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +9 -2
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +27 -7
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts +8 -0
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +2 -2
- package/dist/types/core/resolver.d.ts +11 -1
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -24
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +31 -30
- package/src/core/aggregation/cohort.ts +247 -0
- package/src/core/aggregation/errors.ts +25 -0
- package/src/core/{beacon/aggregation/cohort → aggregation}/messages/base.ts +8 -3
- package/src/core/aggregation/messages/constants.ts +28 -0
- package/src/core/aggregation/messages/factories.ts +240 -0
- package/src/core/aggregation/messages/guards.ts +55 -0
- package/src/core/aggregation/messages/index.ts +4 -0
- package/src/core/aggregation/participant.ts +510 -0
- package/src/core/aggregation/phases.ts +82 -0
- package/src/core/aggregation/runner/events.ts +77 -0
- package/src/core/aggregation/runner/index.ts +4 -0
- package/src/core/aggregation/runner/participant-runner.ts +360 -0
- package/src/core/aggregation/runner/service-runner.ts +365 -0
- package/src/core/aggregation/runner/typed-emitter.ts +87 -0
- package/src/core/aggregation/service.ts +547 -0
- package/src/core/aggregation/signing-session.ts +209 -0
- package/src/core/aggregation/transport/didcomm.ts +42 -0
- package/src/core/aggregation/transport/error.ts +13 -0
- package/src/core/aggregation/transport/factory.ts +29 -0
- package/src/core/aggregation/transport/index.ts +5 -0
- package/src/core/aggregation/transport/nostr.ts +333 -0
- package/src/core/aggregation/transport/transport.ts +46 -0
- package/src/core/beacon/beacon.ts +122 -2
- package/src/core/beacon/cas-beacon.ts +28 -76
- package/src/core/beacon/error.ts +0 -12
- package/src/core/beacon/fee-estimator.ts +52 -0
- package/src/core/beacon/interfaces.ts +10 -1
- package/src/core/beacon/singleton-beacon.ts +14 -75
- package/src/core/beacon/smt-beacon.ts +109 -11
- package/src/core/identifier.ts +17 -0
- package/src/core/interfaces.ts +2 -2
- package/src/core/resolver.ts +25 -2
- package/src/index.ts +15 -29
- package/dist/esm/core/beacon/aggregation/cohort/index.js +0 -237
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js +0 -11
- package/dist/esm/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js +0 -98
- package/dist/esm/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/cohort/status.js +0 -8
- package/dist/esm/core/beacon/aggregation/cohort/status.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +0 -245
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/error.js +0 -12
- package/dist/esm/core/beacon/aggregation/communication/error.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/factory.js +0 -21
- package/dist/esm/core/beacon/aggregation/communication/factory.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/communication/service.js +0 -2
- package/dist/esm/core/beacon/aggregation/communication/service.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +0 -343
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/participant.js +0 -435
- package/dist/esm/core/beacon/aggregation/participant.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +0 -244
- package/dist/esm/core/beacon/aggregation/session/index.js.map +0 -1
- package/dist/esm/core/beacon/aggregation/session/status.js +0 -11
- package/dist/esm/core/beacon/aggregation/session/status.js.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +0 -136
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +0 -11
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +0 -65
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +0 -29
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +0 -24
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +0 -20
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +0 -25
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +0 -25
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +0 -26
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +0 -27
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts +0 -8
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +0 -89
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +0 -103
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/error.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +0 -10
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +0 -36
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +0 -116
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +0 -192
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +0 -156
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +0 -1
- package/dist/types/core/beacon/aggregation/session/status.d.ts +0 -11
- package/dist/types/core/beacon/aggregation/session/status.d.ts.map +0 -1
- package/src/core/beacon/aggregation/cohort/index.ts +0 -305
- package/src/core/beacon/aggregation/cohort/messages/constants.ts +0 -12
- package/src/core/beacon/aggregation/cohort/messages/index.ts +0 -143
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +0 -44
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +0 -35
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +0 -34
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +0 -36
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +0 -39
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +0 -40
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +0 -41
- package/src/core/beacon/aggregation/cohort/status.ts +0 -7
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +0 -148
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +0 -323
- package/src/core/beacon/aggregation/communication/error.ts +0 -13
- package/src/core/beacon/aggregation/communication/factory.ts +0 -25
- package/src/core/beacon/aggregation/communication/service.ts +0 -42
- package/src/core/beacon/aggregation/coordinator.ts +0 -419
- package/src/core/beacon/aggregation/participant.ts +0 -517
- package/src/core/beacon/aggregation/session/index.ts +0 -301
- package/src/core/beacon/aggregation/session/status.ts +0 -18
package/README.md
CHANGED
|
@@ -1,275 +1,128 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @did-btcr2/method
|
|
2
2
|
|
|
3
|
-
TypeScript implementation of [did:btcr2 DID Method](https://dcdpr.github.io/did-btcr2/).
|
|
3
|
+
TypeScript reference implementation of the [did:btcr2 DID Method](https://dcdpr.github.io/did-btcr2/) — a censorship-resistant Decentralized Identifier method using Bitcoin as a verifiable data registry.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Visit [btcr2.dev](https://btcr2.dev/impls/ts) to learn more about how to use [@did-btcr2/method](https://www.npmjs.com/package/@did-btcr2/method).
|
|
8
|
-
|
|
9
|
-
## Test Vector Generator
|
|
10
|
-
|
|
11
|
-
An incremental CLI tool for generating did:btcr2 test vectors through a stepped workflow: `create` → `update` (offline) → `fund` → `announce` → `resolve`. It produces JSON files under `lib/data/`.
|
|
12
|
-
|
|
13
|
-
The first positional argument is the action. `create` runs offline. All subsequent actions only need `--hash` — the type and network are derived from the DID itself.
|
|
5
|
+
This package is the core of the `did-btcr2-js` monorepo. It implements DID create/resolve/update operations, the three beacon types (Singleton, CAS, SMT), multi-party aggregation over MuSig2, and a pluggable transport layer for peer-to-peer coordination.
|
|
14
6
|
|
|
15
|
-
|
|
7
|
+
## Installation
|
|
16
8
|
|
|
17
9
|
```bash
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# 1. Create a new DID (only action that takes --type and --network)
|
|
21
|
-
pnpm generate:vector create
|
|
22
|
-
pnpm generate:vector create --type external --network mutinynet
|
|
23
|
-
|
|
24
|
-
# 2. Construct and sign an update offline (use the hash printed by step 1)
|
|
25
|
-
pnpm generate:vector update --hash <hash> --offline
|
|
26
|
-
|
|
27
|
-
# 3. Fund the beacon address(es)
|
|
28
|
-
source .env
|
|
29
|
-
pnpm generate:vector fund --hash <hash>
|
|
30
|
-
|
|
31
|
-
# 4. Announce the signed update on-chain
|
|
32
|
-
pnpm generate:vector announce --hash <hash>
|
|
33
|
-
|
|
34
|
-
# 5. Resolve the DID against a live Bitcoin node
|
|
35
|
-
pnpm generate:vector resolve --hash <hash>
|
|
36
|
-
|
|
37
|
-
# List existing vectors
|
|
38
|
-
pnpm generate:vector list
|
|
39
|
-
pnpm generate:vector list --network regtest --type key
|
|
10
|
+
pnpm add @did-btcr2/method
|
|
40
11
|
```
|
|
41
12
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
pnpm generate:vector <action> [options]
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
#### Actions
|
|
49
|
-
|
|
50
|
-
| Action | Description |
|
|
51
|
-
|--------|-------------|
|
|
52
|
-
| `create` | Create a new DID and initial test vector files |
|
|
53
|
-
| `update` | Construct and sign an update (optionally announce) |
|
|
54
|
-
| `fund` | Fund beacon address(es) via RPC `sendtoaddress` + mine a block |
|
|
55
|
-
| `announce` | Announce a previously signed update on-chain |
|
|
56
|
-
| `resolve` | Resolve a DID against a live Bitcoin node |
|
|
57
|
-
| `list` | Show existing test vectors |
|
|
58
|
-
|
|
59
|
-
#### Options
|
|
13
|
+
## What's in the Box
|
|
60
14
|
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
15
|
+
| Feature | Entry point |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Create a DID (offline, deterministic or external) | `DidBtcr2.create()` |
|
|
18
|
+
| Resolve a DID (sans-I/O state machine) | `DidBtcr2.resolve()` |
|
|
19
|
+
| Construct, sign, and announce updates | `Update.construct()`, `Update.sign()`, `Update.announce()` |
|
|
20
|
+
| Beacon types (Singleton, CAS, SMT) | `SingletonBeacon`, `CASBeacon`, `SMTBeacon` |
|
|
21
|
+
| Fee estimation (pluggable) | `FeeEstimator`, `StaticFeeEstimator` |
|
|
22
|
+
| Multi-party aggregation (MuSig2) | `AggregationServiceRunner`, `AggregationParticipantRunner` |
|
|
23
|
+
| Transport abstraction (Nostr, DIDComm stub) | `Transport`, `NostrTransport` |
|
|
24
|
+
| DID document types and builders | `Btcr2DidDocument`, `DidDocumentBuilder` |
|
|
70
25
|
|
|
71
|
-
|
|
72
|
-
> automatically and derives the type and network from the stored DID.
|
|
26
|
+
## Quick Start
|
|
73
27
|
|
|
74
|
-
###
|
|
28
|
+
### Create a DID
|
|
75
29
|
|
|
76
|
-
|
|
30
|
+
```typescript
|
|
31
|
+
import { DidBtcr2 } from '@did-btcr2/method';
|
|
32
|
+
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
77
33
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
pnpm generate:vector create
|
|
86
|
-
pnpm generate:vector create --type external --network regtest
|
|
87
|
-
|
|
88
|
-
# Bring your own genesis bytes
|
|
89
|
-
pnpm generate:vector create --type key --genesis 02abc...def
|
|
90
|
-
pnpm generate:vector create --type external --network regtest --genesis 82830a78...f83a99
|
|
34
|
+
// Deterministic (k-type) — the identifier IS the public key
|
|
35
|
+
const keys = SchnorrKeyPair.generate();
|
|
36
|
+
const did = DidBtcr2.create(keys.publicKey.compressed, {
|
|
37
|
+
idType : 'KEY',
|
|
38
|
+
network : 'mutinynet',
|
|
39
|
+
});
|
|
40
|
+
// did:btcr2:k1q5p...
|
|
91
41
|
```
|
|
92
42
|
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
lib/data/{network}/{type}/{hash}/
|
|
96
|
-
create/input.json # { idType, version, network, genesisBytes }
|
|
97
|
-
create/output.json # { did }
|
|
98
|
-
other.json # { genesisKeys: { secret, public }, genesisDocument? }
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
The `--hash` for subsequent steps is printed to the console.
|
|
102
|
-
|
|
103
|
-
#### `update`
|
|
104
|
-
|
|
105
|
-
Reads back the create output, rebuilds the source document, constructs and signs an update.
|
|
43
|
+
### Resolve a DID
|
|
106
44
|
|
|
107
|
-
|
|
45
|
+
`DidBtcr2.resolve()` returns a sans-I/O state machine. The caller drives resolution by fulfilling typed data needs (beacon signals, CAS announcements, signed updates).
|
|
108
46
|
|
|
109
|
-
|
|
47
|
+
```typescript
|
|
48
|
+
import { DidBtcr2 } from '@did-btcr2/method';
|
|
110
49
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
**Without `--offline`:** also announces the update on-chain immediately (requires a funded beacon address and `BITCOIN_NETWORK_CONFIG`).
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Recommended: sign offline, then fund and announce separately
|
|
117
|
-
pnpm generate:vector update --hash <hash> --offline
|
|
118
|
-
pnpm generate:vector update --hash <hash> --offline --interactive
|
|
119
|
-
|
|
120
|
-
# Or sign and announce in one step (beacon must already be funded)
|
|
121
|
-
source .env
|
|
122
|
-
pnpm generate:vector update --hash <hash>
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
**Outputs:**
|
|
126
|
-
```
|
|
127
|
-
lib/data/{network}/{type}/{hash}/
|
|
128
|
-
update/input.json # { sourceDocument, patches, sourceVersionId, ... }
|
|
129
|
-
update/output.json # { signedUpdate }
|
|
130
|
-
other.json # (updated with generated keys)
|
|
131
|
-
```
|
|
50
|
+
const resolver = DidBtcr2.resolve(did, { sidecar });
|
|
51
|
+
let state = resolver.resolve();
|
|
132
52
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
53
|
+
while (state.status === 'action-required') {
|
|
54
|
+
for (const need of state.needs) {
|
|
55
|
+
const data = await fetchData(need); // your I/O goes here
|
|
56
|
+
resolver.provide(need, data);
|
|
57
|
+
}
|
|
58
|
+
state = resolver.resolve();
|
|
59
|
+
}
|
|
136
60
|
|
|
137
|
-
|
|
138
|
-
source .env
|
|
139
|
-
pnpm generate:vector fund --hash <hash>
|
|
140
|
-
pnpm generate:vector fund --hash <hash> --amount 0.01
|
|
61
|
+
const { didDocument, metadata } = state.result;
|
|
141
62
|
```
|
|
142
63
|
|
|
143
|
-
|
|
144
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
64
|
+
See [`src/core/resolver.ts`](./src/core/resolver.ts) for the full `DataNeed` union and phase transitions.
|
|
145
65
|
|
|
146
|
-
|
|
66
|
+
### Construct and Sign an Update
|
|
147
67
|
|
|
148
|
-
|
|
68
|
+
```typescript
|
|
69
|
+
import { Update, Resolver } from '@did-btcr2/method';
|
|
149
70
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
71
|
+
const doc = Resolver.deterministic({ genesisBytes: keys.publicKey.compressed, /* ... */ });
|
|
72
|
+
const unsigned = await Update.construct(doc, [
|
|
73
|
+
{ op: 'add', path: '/service/-', value: { /* new service */ } },
|
|
74
|
+
], 1);
|
|
75
|
+
const signed = Update.sign(did, unsigned, doc.verificationMethod![0], keys.raw.secret!);
|
|
153
76
|
```
|
|
154
77
|
|
|
155
|
-
|
|
156
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
78
|
+
### Update Aggregation (Multi-Party MuSig2)
|
|
157
79
|
|
|
158
|
-
|
|
80
|
+
Aggregation lets multiple DID controllers coordinate a single Bitcoin transaction that announces all of their updates at once, signed n-of-n with MuSig2. The high-level `Runner` API hides the message routing and decision plumbing:
|
|
159
81
|
|
|
160
|
-
|
|
82
|
+
```typescript
|
|
83
|
+
import { AggregationServiceRunner, NostrTransport } from '@did-btcr2/method';
|
|
161
84
|
|
|
162
|
-
|
|
85
|
+
const transport = new NostrTransport({ relays: ['wss://relay.damus.io'] });
|
|
86
|
+
transport.registerActor(serviceDid, serviceKeys);
|
|
87
|
+
transport.start();
|
|
163
88
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
89
|
+
const runner = new AggregationServiceRunner({
|
|
90
|
+
transport,
|
|
91
|
+
did : serviceDid,
|
|
92
|
+
keys : serviceKeys,
|
|
93
|
+
config : { minParticipants: 2, network: 'mutinynet', beaconType: 'CASBeacon' },
|
|
94
|
+
onProvideTxData: async ({ beaconAddress, signalBytes }) => buildBeaconTx(beaconAddress, signalBytes),
|
|
95
|
+
});
|
|
168
96
|
|
|
169
|
-
|
|
170
|
-
|
|
97
|
+
runner.on('signing-complete', (result) => console.log('done'));
|
|
98
|
+
const result = await runner.run();
|
|
171
99
|
```
|
|
172
100
|
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
lib/data/{network}/{type}/{hash}/
|
|
176
|
-
resolve/input.json # { did, resolutionOptions: { sidecar } }
|
|
177
|
-
resolve/output.json # { didDocument, didResolutionMetadata, didDocumentMetadata } (live only)
|
|
178
|
-
```
|
|
101
|
+
The full step-by-step protocol walkthrough — service flow, participant flow, decision callbacks, events, the low-level state machine API, and production deployment notes — is in [`docs/aggregation.md`](./docs/aggregation.md).
|
|
179
102
|
|
|
180
|
-
|
|
181
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
103
|
+
## Architecture Principles
|
|
182
104
|
|
|
183
|
-
|
|
105
|
+
- **Sans-I/O core.** Resolver, Updater, and aggregation state machines perform zero I/O. They compute state transitions and emit typed needs or messages. Callers handle all network operations.
|
|
106
|
+
- **Layered APIs.** High-level facades (like `AggregationServiceRunner`) encapsulate boilerplate; low-level state machines stay available for tests, custom transports, and fine-grained control.
|
|
107
|
+
- **Pluggable transport.** The `Transport` interface decouples protocol logic from the wire format. Ships with `NostrTransport`; add your own for DIDComm, libp2p, or anything else.
|
|
108
|
+
- **Browser-compatible.** All code targets both Node.js (>= 22) and modern browsers. No Node-only APIs in the core.
|
|
184
109
|
|
|
185
|
-
|
|
110
|
+
## Build & Test
|
|
186
111
|
|
|
187
112
|
```bash
|
|
188
|
-
|
|
189
|
-
pnpm
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Pass `--interactive` to the `update` step to build custom patches. The tool detects common patch targets and auto-generates values.
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
pnpm generate:vector update --hash <hash> --interactive
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
#### Service patches (`/service/<n>`)
|
|
201
|
-
|
|
202
|
-
When `add` or `replace` targets a path like `/service/0`, the tool:
|
|
203
|
-
|
|
204
|
-
1. Prompts for **address type** (`p2pkh`, `p2wpkh`, `p2tr`) — defaults to `p2pkh`
|
|
205
|
-
2. Prompts for **pubkey hex** — leave empty to auto-generate a new keypair
|
|
206
|
-
3. Derives the Bitcoin address and builds the complete service object
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
--- Add a JSON Patch operation ---
|
|
210
|
-
op: add
|
|
211
|
-
path: /service/1
|
|
212
|
-
Detected service patch — auto-generating value.
|
|
213
|
-
address type (p2pkh | p2wpkh | p2tr) [p2pkh]: p2wpkh
|
|
214
|
-
pubkey hex (leave empty to auto-generate):
|
|
215
|
-
Auto-generated keypair (stored as "service-service-1")
|
|
216
|
-
Added: {"op":"add","path":"/service/1","value":{"id":"did:btcr2:...#service-1","type":"SingletonBeacon","serviceEndpoint":"bitcoin:bcrt1q..."}}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
#### Verification method patches (`/verificationMethod/<n>`)
|
|
220
|
-
|
|
221
|
-
When `add` or `replace` targets a path like `/verificationMethod/1`, the tool:
|
|
222
|
-
|
|
223
|
-
1. Prompts for an **id fragment** (e.g. `someNewId` or `#someNewId`) — defaults to `key-1`, `key-2`, etc.
|
|
224
|
-
2. Validates the id is unique against existing verification methods
|
|
225
|
-
3. Prompts for **pubkey hex** — leave empty to auto-generate
|
|
226
|
-
4. Builds the complete verification method object with `publicKeyMultibase`
|
|
227
|
-
|
|
228
|
-
```
|
|
229
|
-
--- Add a JSON Patch operation ---
|
|
230
|
-
op: add
|
|
231
|
-
path: /verificationMethod/1
|
|
232
|
-
Detected verificationMethod patch — auto-generating value.
|
|
233
|
-
id fragment (e.g. "someNewId" or "#someNewId") [key-1]: recoveryKey
|
|
234
|
-
pubkey hex (leave empty to auto-generate):
|
|
235
|
-
Auto-generated keypair (stored as "verificationMethod-verificationMethod-1")
|
|
236
|
-
Added: {"op":"add","path":"/verificationMethod/1","value":{"id":"did:btcr2:...#recoveryKey","type":"Multikey","controller":"did:btcr2:...","publicKeyMultibase":"zQ3sh..."}}
|
|
113
|
+
# From packages/method/
|
|
114
|
+
pnpm build # Compile ESM + CJS + browser bundle
|
|
115
|
+
pnpm build:tests # Compile tests to tests/compiled/
|
|
116
|
+
pnpm test # Run the test suite with coverage
|
|
117
|
+
pnpm lint # ESLint (zero warnings tolerated)
|
|
237
118
|
```
|
|
238
119
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
For any path not matching the above patterns, or for operations like `remove`, `move`, `copy`, the tool falls back to manual JSON value input.
|
|
120
|
+
Tests run from compiled JS, so run `pnpm build:tests` before `pnpm test` after any test changes.
|
|
242
121
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
All generated and user-provided keys are persisted in `other.json` for later reuse:
|
|
246
|
-
|
|
247
|
-
- **Auto-generated keys** include both `secret` and `public` hex values
|
|
248
|
-
- **User-provided keys** store the `public` hex with an empty `secret` field for you to fill in if needed
|
|
249
|
-
|
|
250
|
-
```json
|
|
251
|
-
{
|
|
252
|
-
"genesisKeys": { "secret": "...", "public": "..." },
|
|
253
|
-
"newBeaconKeys": { "secret": "...", "public": "..." },
|
|
254
|
-
"generatedKeys": {
|
|
255
|
-
"service-service-1": { "secret": "...", "public": "..." },
|
|
256
|
-
"verificationMethod-verificationMethod-1": { "secret": "", "public": "..." }
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
### Output Directory Structure
|
|
122
|
+
## Documentation
|
|
262
123
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
update/
|
|
269
|
-
input.json
|
|
270
|
-
output.json
|
|
271
|
-
resolve/
|
|
272
|
-
input.json
|
|
273
|
-
output.json # (live mode only)
|
|
274
|
-
other.json
|
|
275
|
-
```
|
|
124
|
+
- **Package docs on btcr2.dev** — [btcr2.dev/impls/ts](https://btcr2.dev/impls/ts)
|
|
125
|
+
- **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)** — Beacon architecture, Singleton / CAS / SMT behavior, signal discovery
|
|
126
|
+
- **[`docs/aggregation.md`](./docs/aggregation.md)** — Multi-party aggregation protocol, Runner and state machine APIs, e2e examples
|
|
127
|
+
- **[`docs/test-vectors.md`](./docs/test-vectors.md)** — CLI tool for generating did:btcr2 test vectors via a stepped workflow
|
|
128
|
+
- **Source reference** — See JSDoc comments on public classes; the most important entry points are `DidBtcr2` (facade), `Resolver` (read path), `Update` (write path), and the aggregation runners.
|