Class: DidBtcr2 ​
Defined in: packages/method/src/did-btcr2.ts:64
Implements did:btcr2 DID Method Specification. did:btcr2 is a censorship-resistant Decentralized Identifier (DID) method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. It supports zero-cost off-chain DID creation; aggregated updates for scalable on-chain update costs; long-term identifiers that can support frequent updates; private communication of the DID document; private DID resolution; and non-repudiation.
DidBtcr2
Implements ​
Implements ​
DidMethod
Constructors ​
Constructor ​
new DidBtcr2():
DidBtcr2
Returns ​
DidBtcr2
Properties ​
methodName ​
staticmethodName:string='btcr2'
Defined in: packages/method/src/did-btcr2.ts:66
Methods ​
create() ​
staticcreate(genesisBytes,options?):Promise<string>
Defined in: packages/method/src/did-btcr2.ts:79
Implements section 7.1 Create.
Parameters ​
genesisBytes ​
The bytes used to create the genesis document for a did:btcr2 identifier. This can be either the bytes of the genesis document itself or the bytes of a key that will be used to create the genesis document.
options? ​
Options for creating the identifier, including the idType (key or external), version, and network.
Returns ​
Promise<string>
Promise resolving to a Btcr2Identifier string.
Throws ​
if any of the checks fail
getSigningMethod() ​
staticgetSigningMethod(didDocument,methodId?):DidVerificationMethod
Defined in: packages/method/src/did-btcr2.ts:322
Given the W3C DID Document of a did:btcr2 identifier, return the signing verification method that will be used for signing messages and credentials. If given, the methodId parameter is used to select the verification method. If not given, the Identity Key's verification method with an ID fragment of '#initialKey' is used.
Parameters ​
didDocument ​
The DID Document of the did:btcr2 identifier.
methodId? ​
string
Optional verification method ID to be used for signing.
Returns ​
Promise resolving to the DidVerificationMethod object used for signing.
Throws ​
if the parsed did method does not match btcr2 or signing method could not be determined.
resolve() ​
staticresolve(did,resolutionOptions?):Promise<DidResolutionResult>
Defined in: packages/method/src/did-btcr2.ts:122
Entry point for section 7.2 Resolve. See specification for the Resolve Process. See Resolve (class) for class implementation.
Resolving a did:btcr2 identifier iteratively builds a DID document by applying BTCR2 Updates to an Initial DID Document that have been committed to the Bitcoin blockchain by Authorized Beacon Signals. The Initial DID Document is either deterministically created from the DID or provided by Sidecar Data.
Parameters ​
did ​
string
a valid did:btcr2 identifier to be resolved
resolutionOptions? ​
ResolutionOptions = ...
Returns ​
Promise<DidResolutionResult>
Promise resolving to a DID Resolution Result containing the targetDocument
Throws ​
if the resolution fails for any reason
Throws ​
InvalidDid if the identifier is invalid
Example ​
const resolution = await DidBtcr2.resolve(
'did:btcr2:k1q0dygyp3gz969tp46dychzy4q78c2k3js68kvyr0shanzg67jnuez2cfplh'
)update() ​
staticupdate(params):Promise<SidecarData>
Defined in: packages/method/src/did-btcr2.ts:250
Entry point for section 4.3 Update. See Update for implementation details.
An update to a did:btcr2 document is an invoked capability using the ZCAP-LD data format, signed by a verificationMethod that has the authority to make the update as specified in the previous DID document. Capability invocations for updates MUST be authorized using Data Integrity following the bip340-jcs-2025 cryptosuite with a proofPurpose of capabilityInvocation.
The Update algorithm takes as inputs a Identifier, sourceDocument, sourceVersionId, documentPatch, a verificationMethodId and an array of beaconIds. The sourceDocument is the DID document being updated. The documentPatch is a JSON Patch object containing a set of transformations to be applied to the sourceDocument. The result of these transformations MUST produce a DID document conformant to the DID Core specification. The verificationMethodId is an identifier for a verificationMethod within the sourceDocument. The verificationMethod identified MUST be a BIP340 Multikey. The beaconIds MUST identify service endpoints with one of the three Beacon Types SingletonBeacon, CASBeacon, and SMTBeacon.
Parameters ​
params ​
Required parameters for the update operation.
beaconIds ​
string[]
The beacon IDs to announce the update
identifier ​
string
The btcr2 identifier to be updated.
patch ​
sourceDocument ​
The DID document being updated.
sourceVersionId ​
number
The versionId of the source document.
verificationMethodId ​
string
The verificationMethod ID to sign the update
Returns ​
Promise<SidecarData>
Promise resolving to void
Throws ​
if the verificationMethod type is not Multikey or the publicKeyMultibase header is not zQ3s