Class: Identifier ​
Defined in: packages/method/dist/types/core/identifier.d.ts:30
Implements 3 Syntax. A did:btcr2 DID consists of a did:btcr2 prefix, followed by an id-bech32 value, which is a Bech32m encoding of:
- the specification version;
- the Bitcoin network identifier; and
- either:
- a key-value representing a secp256k1 public key; or
- a hash-value representing the hash of an initiating external DID document. Identifier
Constructors ​
Constructor ​
new Identifier():
Identifier
Returns ​
Identifier
Methods ​
decode() ​
staticdecode(identifier):DidComponents
Defined in: packages/method/dist/types/core/identifier.d.ts:62
Implements 3.3 did:btcr2 Identifier Decoding.
Parameters ​
identifier ​
string
The BTCR2 DID to be parsed
Returns ​
The parsed identifier components. See DidComponents for details.
Throws ​
if an error occurs while parsing the identifier
Throws ​
if identifier is invalid
Throws ​
if the method is not supported
encode() ​
staticencode(params):string
Defined in: packages/method/dist/types/core/identifier.d.ts:48
Implements 3.2 did:btcr2 Identifier Encoding.
A did:btcr2 DID consists of a did:btcr2 prefix, followed by an id-bech32 value, which is a Bech32m encoding of:
- the specification version;
- the Bitcoin network identifier; and
- either:
- a key-value representing a secp256k1 public key; or
- a hash-value representing the hash of an initiating external DID document.
Parameters ​
params ​
See DidComponents for details.
genesisBytes ​
Public key or an intermediate document bytes.
idType ​
string
Identifier type (key or external).
network ​
string
Bitcoin network name.
version ​
number
Identifier version.
Returns ​
string
The new did:btcr2 identifier.
generate() ​
staticgenerate():object
Defined in: packages/method/dist/types/core/identifier.d.ts:67
Generates a new did:btcr2 identifier based on a newly generated key pair.
Returns ​
object
The new did:btcr2 identifier.
identifier ​
identifier:
object
identifier.controller ​
controller:
string
identifier.id ​
id:
string
keys ​
keys:
SchnorrKeyPair
isValid() ​
staticisValid(identifier):boolean
Defined in: packages/method/dist/types/core/identifier.d.ts:79
Validates a did:btcr2 identifier.
Parameters ​
identifier ​
string
The did:btcr2 identifier to validate.
Returns ​
boolean
True if the identifier is valid, false otherwise.