Class: DidBtcr2 ​
Defined in: packages/method/src/did-btcr2.ts:57
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:61
Name of the DID method, as defined in the DID BTCR2 specification
Methods ​
create() ​
staticcreate(genesisBytes,options?):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 ​
string
Promise resolving to an identifier string.
Throws ​
if any of the checks fail
Example ​
const genesisBytes = SchnorrKeyPair.generate().publicKey.compressed;
const did = DidBtcr2.create(genesisBytes, { idType: 'KEY', network: 'regtest' });getSigningMethod() ​
staticgetSigningMethod(didDocument,methodId?):DidVerificationMethod
Defined in: packages/method/src/did-btcr2.ts:270
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?):Resolver
Defined in: packages/method/src/did-btcr2.ts:115
Entry point for section 7.2 Resolve.
Factory method that performs pure setup and returns a Resolver state machine. The caller drives resolution by calling resolver.resolve() and resolver.provide(). Analogous to Rust's Document::read().
Parameters ​
did ​
string
The did:btcr2 identifier to be resolved.
resolutionOptions? ​
ResolutionOptions = {}
Options used during the resolution process.
Returns ​
A sans-I/O state machine the caller drives to completion.
Example ​
const resolver = DidBtcr2.resolve(did, { sidecar });
let state = resolver.resolve();
while (state.status === 'action-required') {
for (const need of state.needs) { ... provide data ... }
state = resolver.resolve();
}
const { didDocument, metadata } = state.result;update() ​
staticupdate(params):Promise<SignedBTCR2Update>
Defined in: packages/method/src/did-btcr2.ts:160
Entry point for section 7.3 Update. See specification for the Resolve Process. See Update (class) for class implementation.
BTCR2 DID documents can be updated by anchoring BTCR2 Updates to Bitcoin transactions. These transactions MAY be published to the Bitcoin network. Any property in the DID document may be updated except the id. Doing so would invalidate the DID document.
Parameters ​
params ​
An object containing the parameters for the update operation.
beaconId ​
string
The beacon ID associated with the update.
bitcoin? ​
Optional Bitcoin network connection for announcing the update. If not provided, a default connection will be initialized.
patches ​
The array of JSON Patch operations to apply to the sourceDocument.
signingMaterial? ​
string | Bytes
Optional signing material (key bytes or hex string).
sourceDocument ​
The DID document being updated.
sourceVersionId ​
number
The version ID before applying the update.
verificationMethodId ​
string
The verificationMethod ID to sign the update with.
Returns ​
Promise<SignedBTCR2Update>
Promise resolving to the signed BTCR2 update.
Throws ​
if no verificationMethod, verificationMethod type is not Multikey or the publicKeyMultibase header is not zQ3s