@did-btcr2/method 0.26.0 → 0.28.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 +118 -236
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +27665 -23764
- package/dist/browser.mjs +27665 -23764
- package/dist/cjs/index.js +2661 -2239
- 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 +286 -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/core/updater.js +269 -0
- package/dist/esm/core/updater.js.map +1 -0
- package/dist/esm/did-btcr2.js +30 -42
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +16 -25
- 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 +111 -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/core/updater.d.ts +178 -0
- package/dist/types/core/updater.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +23 -23
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -25
- 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 +364 -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/core/updater.ts +415 -0
- package/src/did-btcr2.ts +36 -66
- package/src/index.ts +17 -30
- 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/esm/core/update.js +0 -112
- package/dist/esm/core/update.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/dist/types/core/update.d.ts +0 -52
- package/dist/types/core/update.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/src/core/update.ts +0 -158
package/README.md
CHANGED
|
@@ -1,275 +1,157 @@
|
|
|
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
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### CLI Reference
|
|
43
|
-
|
|
10
|
+
pnpm add @did-btcr2/method
|
|
44
11
|
```
|
|
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
|
|
60
12
|
|
|
61
|
-
|
|
62
|
-
|------|--------|---------|------------|-------------|
|
|
63
|
-
| `--type` | `key`, `external` | `key` | `create`, `list` | DID identifier type |
|
|
64
|
-
| `--network` | `regtest`, `bitcoin`, `mutinynet`, etc. | `regtest` | `create`, `list` | Bitcoin network |
|
|
65
|
-
| `--genesis` | hex string | prompt / auto-generate | `create` | Genesis bytes hex (see below) |
|
|
66
|
-
| `--hash` | 8-char short hash | — | `update`, `fund`, `announce`, `resolve` | Vector identifier (required) |
|
|
67
|
-
| `--interactive` | flag (no value) | off | `update` | Enable interactive patch builder |
|
|
68
|
-
| `--amount` | BTC amount | `0.001` | `fund` | BTC amount to send to each beacon address |
|
|
69
|
-
| `--offline` | flag (no value) | off | `update`, `resolve` | Skip on-chain announcement or live resolution |
|
|
13
|
+
## What's in the Box
|
|
70
14
|
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
| Update a DID (sans-I/O state machine) | `DidBtcr2.update()` → `Updater` |
|
|
20
|
+
| Update utilities (construct, sign, announce) | `Updater.construct()`, `Updater.sign()`, `Updater.announce()` |
|
|
21
|
+
| Beacon types (Singleton, CAS, SMT) | `SingletonBeacon`, `CASBeacon`, `SMTBeacon` |
|
|
22
|
+
| Fee estimation (pluggable) | `FeeEstimator`, `StaticFeeEstimator` |
|
|
23
|
+
| Multi-party aggregation (MuSig2) | `AggregationServiceRunner`, `AggregationParticipantRunner` |
|
|
24
|
+
| Transport abstraction (Nostr, DIDComm stub) | `Transport`, `NostrTransport` |
|
|
25
|
+
| DID document types and builders | `Btcr2DidDocument`, `DidDocumentBuilder` |
|
|
73
26
|
|
|
74
|
-
|
|
27
|
+
## Quick Start
|
|
75
28
|
|
|
76
|
-
|
|
29
|
+
### Create a DID
|
|
77
30
|
|
|
78
|
-
|
|
31
|
+
```typescript
|
|
32
|
+
import { DidBtcr2 } from '@did-btcr2/method';
|
|
33
|
+
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
79
34
|
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Outputs:**
|
|
35
|
+
// Deterministic (k-type) — the identifier IS the public key
|
|
36
|
+
const keys = SchnorrKeyPair.generate();
|
|
37
|
+
const did = DidBtcr2.create(keys.publicKey.compressed, {
|
|
38
|
+
idType : 'KEY',
|
|
39
|
+
network : 'mutinynet',
|
|
40
|
+
});
|
|
41
|
+
// did:btcr2:k1q5p...
|
|
94
42
|
```
|
|
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
43
|
|
|
105
|
-
|
|
44
|
+
### Resolve a DID
|
|
106
45
|
|
|
107
|
-
|
|
46
|
+
`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
47
|
|
|
109
|
-
|
|
48
|
+
```typescript
|
|
49
|
+
import { DidBtcr2 } from '@did-btcr2/method';
|
|
110
50
|
|
|
111
|
-
|
|
51
|
+
const resolver = DidBtcr2.resolve(did, { sidecar });
|
|
52
|
+
let state = resolver.resolve();
|
|
112
53
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
```
|
|
132
|
-
|
|
133
|
-
#### `fund`
|
|
134
|
-
|
|
135
|
-
Funds all beacon service addresses in the DID document via RPC `sendtoaddress`, then mines blocks to confirm the funding transaction(s). **Requires a live Bitcoin node with a loaded wallet.**
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
source .env
|
|
139
|
-
pnpm generate:vector fund --hash <hash>
|
|
140
|
-
pnpm generate:vector fund --hash <hash> --amount 0.01
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
> Requires `BITCOIN_NETWORK_CONFIG` to be set with connection info
|
|
144
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
145
|
-
|
|
146
|
-
#### `announce`
|
|
54
|
+
while (state.status === 'action-required') {
|
|
55
|
+
for (const need of state.needs) {
|
|
56
|
+
const data = await fetchData(need); // your I/O goes here
|
|
57
|
+
resolver.provide(need, data);
|
|
58
|
+
}
|
|
59
|
+
state = resolver.resolve();
|
|
60
|
+
}
|
|
147
61
|
|
|
148
|
-
|
|
62
|
+
const { didDocument, metadata } = state.result;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
See [`src/core/resolver.ts`](./src/core/resolver.ts) for the full `DataNeed` union and phase transitions.
|
|
66
|
+
|
|
67
|
+
### Update a DID
|
|
68
|
+
|
|
69
|
+
`DidBtcr2.update()` returns a sans-I/O state machine — the counterpart to the Resolver. The caller drives the update by fulfilling typed data needs (signing key, funding confirmation, broadcast).
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { DidBtcr2, Updater } from '@did-btcr2/method';
|
|
73
|
+
|
|
74
|
+
const updater = DidBtcr2.update({
|
|
75
|
+
sourceDocument,
|
|
76
|
+
patches : [{ op: 'add', path: '/service/-', value: newService }],
|
|
77
|
+
sourceVersionId : 1,
|
|
78
|
+
verificationMethodId : '#initialKey',
|
|
79
|
+
beaconId : '#beacon-0',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
let state = updater.advance();
|
|
83
|
+
while (state.status === 'action-required') {
|
|
84
|
+
for (const need of state.needs) {
|
|
85
|
+
switch (need.kind) {
|
|
86
|
+
case 'NeedSigningKey':
|
|
87
|
+
updater.provide(need, secretKeyBytes);
|
|
88
|
+
break;
|
|
89
|
+
case 'NeedFunding':
|
|
90
|
+
// Check UTXOs at need.beaconAddress, fund if needed
|
|
91
|
+
updater.provide(need);
|
|
92
|
+
break;
|
|
93
|
+
case 'NeedBroadcast':
|
|
94
|
+
await Updater.announce(need.beaconService, need.signedUpdate, secretKey, bitcoin);
|
|
95
|
+
updater.provide(need);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
state = updater.advance();
|
|
100
|
+
}
|
|
149
101
|
|
|
150
|
-
|
|
151
|
-
source .env
|
|
152
|
-
pnpm generate:vector announce --hash <hash>
|
|
102
|
+
const { signedUpdate } = state.result;
|
|
153
103
|
```
|
|
154
104
|
|
|
155
|
-
|
|
156
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
105
|
+
See [`src/core/updater.ts`](./src/core/updater.ts) for the full `UpdaterDataNeed` union and phase transitions.
|
|
157
106
|
|
|
158
|
-
|
|
107
|
+
### Update Aggregation (Multi-Party MuSig2)
|
|
159
108
|
|
|
160
|
-
|
|
109
|
+
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:
|
|
161
110
|
|
|
162
|
-
|
|
111
|
+
```typescript
|
|
112
|
+
import { AggregationServiceRunner, NostrTransport } from '@did-btcr2/method';
|
|
163
113
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
pnpm generate:vector resolve --hash <hash>
|
|
114
|
+
const transport = new NostrTransport({ relays: ['wss://relay.damus.io'] });
|
|
115
|
+
transport.registerActor(serviceDid, serviceKeys);
|
|
116
|
+
transport.start();
|
|
168
117
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
118
|
+
const runner = new AggregationServiceRunner({
|
|
119
|
+
transport,
|
|
120
|
+
did : serviceDid,
|
|
121
|
+
keys : serviceKeys,
|
|
122
|
+
config : { minParticipants: 2, network: 'mutinynet', beaconType: 'CASBeacon' },
|
|
123
|
+
onProvideTxData: async ({ beaconAddress, signalBytes }) => buildBeaconTx(beaconAddress, signalBytes),
|
|
124
|
+
});
|
|
172
125
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
lib/data/{network}/{type}/{hash}/
|
|
176
|
-
resolve/input.json # { did, resolutionOptions: { sidecar } }
|
|
177
|
-
resolve/output.json # { didDocument, didResolutionMetadata, didDocumentMetadata } (live only)
|
|
126
|
+
runner.on('signing-complete', (result) => console.log('done'));
|
|
127
|
+
const result = await runner.run();
|
|
178
128
|
```
|
|
179
129
|
|
|
180
|
-
|
|
181
|
-
> for the DID's network. Source your `.env` file or export it directly.
|
|
130
|
+
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).
|
|
182
131
|
|
|
183
|
-
|
|
132
|
+
## Architecture Principles
|
|
184
133
|
|
|
185
|
-
|
|
134
|
+
- **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.
|
|
135
|
+
- **Layered APIs.** High-level facades (like `AggregationServiceRunner`) encapsulate boilerplate; low-level state machines stay available for tests, custom transports, and fine-grained control.
|
|
136
|
+
- **Pluggable transport.** The `Transport` interface decouples protocol logic from the wire format. Ships with `NostrTransport`; add your own for DIDComm, libp2p, or anything else.
|
|
137
|
+
- **Browser-compatible.** All code targets both Node.js (>= 22) and modern browsers. No Node-only APIs in the core.
|
|
186
138
|
|
|
187
|
-
|
|
188
|
-
pnpm generate:vector list
|
|
189
|
-
pnpm generate:vector list --network regtest --type key
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Interactive Mode
|
|
193
|
-
|
|
194
|
-
Pass `--interactive` to the `update` step to build custom patches. The tool detects common patch targets and auto-generates values.
|
|
139
|
+
## Build & Test
|
|
195
140
|
|
|
196
141
|
```bash
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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..."}}
|
|
142
|
+
# From packages/method/
|
|
143
|
+
pnpm build # Compile ESM + CJS + browser bundle
|
|
144
|
+
pnpm build:tests # Compile tests to tests/compiled/
|
|
145
|
+
pnpm test # Run the test suite with coverage
|
|
146
|
+
pnpm lint # ESLint (zero warnings tolerated)
|
|
237
147
|
```
|
|
238
148
|
|
|
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.
|
|
149
|
+
Tests run from compiled JS, so run `pnpm build:tests` before `pnpm test` after any test changes.
|
|
242
150
|
|
|
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
|
|
151
|
+
## Documentation
|
|
262
152
|
|
|
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
|
-
```
|
|
153
|
+
- **Package docs on btcr2.dev** — [btcr2.dev/impls/ts](https://btcr2.dev/impls/ts)
|
|
154
|
+
- **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)** — Beacon architecture, Singleton / CAS / SMT behavior, signal discovery
|
|
155
|
+
- **[`docs/aggregation.md`](./docs/aggregation.md)** — Multi-party aggregation protocol, Runner and state machine APIs, e2e examples
|
|
156
|
+
- **[`docs/test-vectors.md`](./docs/test-vectors.md)** — CLI tool for generating did:btcr2 test vectors via a stepped workflow
|
|
157
|
+
- **Source reference** — See JSDoc comments on public classes; the most important entry points are `DidBtcr2` (facade), `Resolver` (read path), `Updater` (write path), and the aggregation runners.
|