Global

Methods

acceptCompositeClaims(expandedPresentation, rules) → {Promise.<Array.<Object>>}

Returns a list of all RDF statements proven by the presentation. DOES NOT VERIFY THE PRESENTATION. Verification must be performed for the results of this function to be trustworthy. The return value may contaim duplicate claims. This function throws an error if: a provided proof is not applicable given the ruleset, a provided proof makes unverified assumptions, a provided proof is malformed.
Parameters:
Name Type Description
expandedPresentation a VCDM presentation as expanded json-ld
rules ordered list of axioms which will be accepted within proofs of composite claims
Source:
Returns:
Type
Promise.<Array.<Object>>

adaptKey(key, msgCount)

Attempts to adapt supplied key for the `msgCount` messages. Throws an error if `msgCount` is greater than the supported message count.
Parameters:
Name Type Description
key *
msgCount *
Source:

adaptKey(key, _msgCount)

Adapts the provided public or secret key for the given message count.
Parameters:
Name Type Description
key *
_msgCount *
Source:

addAttributeToReveal(credentialIndex, attributes)

Species attributes to be revealed in the credential
Parameters:
Name Type Description
credentialIndex number
attributes Array.<string>
Source:

(async) addCredentialToPresent(credentialLD, options) → {Promise.<number>}

Adds a BBS+ JSON-LD credential to be presented
Parameters:
Name Type Description
credentialLD
options
Source:
Returns:
Type
Promise.<number>

addOwner(ownerDID)

Add a owner to the policy
Parameters:
Name Type Description
ownerDID string Owner's DID
Source:

(async) addParams(param, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Add new signature params.
Parameters:
Name Type Description
param The signature params to add.
signerDid Signer of the payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) addPositiveAccumulator(id, accumulated, publicKeyRef, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Add a positive (add-only) accumulator
Parameters:
Name Type Description
id Unique accumulator id
accumulated Current accumulated value.
publicKeyRef Reference to accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) addPublicKey(publicKey, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Add accumulator public key
Parameters:
Name Type Description
publicKey Accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) addPublicKey(publicKey, targetDid, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Add a public key
Parameters:
Name Type Description
publicKey public key to add.
targetDid The DID to which key is being added
signerDid The DID that is adding the key by signing the payload because it controls `targetDid`
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) addUniversalAccumulator(id, accumulated, publicKeyRef, maxSize, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Add universal (supports add/remove) accumulator
Parameters:
Name Type Description
id Unique accumulator id
accumulated Current accumulated value.
publicKeyRef Reference to accumulator public key
maxSize Maximum size of the accumulator
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

asDockAddress(addr, network)

Convert address to Dock appropriate network address.
Parameters:
Name Type Description
addr address to convert
network the network to use, allowed values are `main`, `test` and `dev` corresponding to mainnet, testnet and dev node
Source:

batchDocumentsInMerkleTree(documents) → {Array}

Batch multiple documents in binary merkle tree and return the root and proofs for each document
Parameters:
Name Type Description
documents
Source:
Returns:
- An 2 element array where 1st element is root and 2nd is an array with proofs for each document.
Type
Array

blobHexIdToQualified(hexId) → {string}

Return a fully qualified Dock Blob id, i.e. "blob:dock:"
Parameters:
Name Type Description
hexId string The hex blob id (without the qualifier)
Source:
Returns:
- The fully qualified Blob id
Type
string

buildDockCredentialStatus(registryId) → {Object}

Return `credentialStatus` according to W3C spec when the revocation status is checked on Dock
Parameters:
Name Type Description
registryId Revocation registry id
Source:
Returns:
Type
Object

bytesToWrappedBytes(bytes) → {Object}

Convert bytes to struct `WrappedBytes` expected by chain
Parameters:
Name Type Description
bytes
Source:
Returns:
Type
Object

checkCredential(credential)

Parameters:
Name Type Description
credential object An object that could be a VerifiableCredential.
Source:
Throws:
Error

checkCredentialJSONLD(credential)

Parameters:
Name Type Description
credential object An object that could be a VerifiableCredential.
Source:
Throws:
Error

checkCredentialOptional(credential)

Parameters:
Name Type Description
credential object An object that could be a VerifiableCredential.
Source:
Throws:
Error

checkCredentialRequired(credential)

Parameters:
Name Type Description
credential object An object that could be a VerifiableCredential.
Source:
Throws:
Error

checkRevocationStatus(credential, revocationApi) → {Promise.<({verified: boolean}|{verified: boolean, error: string})>}

Check if the credential is revoked or not.
Parameters:
Name Type Description
credential
revocationApi
Source:
Returns:
The returned object will have a key `verified` which is true if the credential is not revoked and false otherwise. The `error` will describe the error if any.
Type
Promise.<({verified: boolean}|{verified: boolean, error: string})>

claimgraphToStore(claimgraph) → {Store}

Converts a claimgraph JSON representation into an N3 RDF store
Parameters:
Name Type Description
claimgraph object JSON-LD RDF object
Source:
Returns:
Type
Store

controllerIds(ownerDID)

Returns list containing unique sorted owner DIDs.
Parameters:
Name Type Description
ownerDID string Owner's DID
Source:

convertToPresentation(document)

Converts a derived proof credential to the native presentation format
Parameters:
Name Type Description
document
Source:

(async) createAddParamsTx(params, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to add new BBS+ params.
Parameters:
Name Type Description
params The BBS+ params to add.
signerDid Signer of the payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createAddPositiveAccumulatorTx(id, accumulated, publicKeyRef, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create a transaction to add positive (add-only) accumulator
Parameters:
Name Type Description
id Unique accumulator id
accumulated Current accumulated value.
publicKeyRef Reference to accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createAddPublicKeyTx(publicKey, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to add accumulator public key
Parameters:
Name Type Description
publicKey Accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createAddPublicKeyTx(publicKey, targetDid, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to add a public key
Parameters:
Name Type Description
publicKey public key to add.
targetDid The DID to which key is being added
signerDid The DID that is adding the key by signing the payload because it controls `targetDid`
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createAddUniversalAccumulatorTx(id, accumulated, publicKeyRef, maxSize, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create a transaction to add universal (supports add/remove) accumulator
Parameters:
Name Type Description
id Unique accumulator id
accumulated Current accumulated value.
publicKeyRef Reference to accumulator public key
maxSize Maximum size of the accumulator
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

createDidKey(publicKey, verRel) → {object}

Returns a `DidKey` as expected by the Substrate node
Parameters:
Name Type Description
publicKey PublicKey The public key for the DID. The Keyring is intentionally avoided here as it may not be accessible always, like in case of hardware wallet
verRel VerificationRelationship
Source:
Returns:
- The object has structure and keys with same names as expected by the Substrate node
Type
object

createDidSig(did, keyId, sig) → {Object}

Parameters:
Name Type Description
did string DID as hex
keyId number -
sig Signature
Source:
Returns:
Type
Object

createNewDockBlobId() → {string}

Create and return a fully qualified Dock Blob id, i.e. "blob:dock:"
Source:
Returns:
- The Blob id
Type
string

createNewDockDID() → {string}

Create and return a fully qualified Dock DID, i.e. "did:dock:"
Source:
Returns:
- The DID
Type
string

createParamsObjFromChainResponse(params) → {Object}

Format an object received from the chain as a params object with keys `bytes`, `label` and `curveType`.
Parameters:
Name Type Description
params
Source:
Returns:
Type
Object

createPresentation(options) → {object}

Create BBS+ presentation
Parameters:
Name Type Description
options
Source:
Returns:
Type
object

createPublicKeyObjFromChainResponse(pk) → {Object}

Format an object received from the chain as a public key object with keys `bytes`, ` paramsRef` and `curveType`.
Parameters:
Name Type Description
pk
Source:
Returns:
Type
Object

createRandomRegistryId() → {string}

Generate a random revocation registry id.
Source:
Returns:
The id as a hex string
Type
string

(async) createRemovePublicKeyTx(removeKeyId, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to remove accumulator public key
Parameters:
Name Type Description
removeKeyId Index of the accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createRemovePublicKeyTx(removeKeyId, targetDid, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to remove public key
Parameters:
Name Type Description
removeKeyId The key index for key to remove.
targetDid The DID from which key is being removed
signerDid The DID that is removing the key by signing the payload because it controls `targetDid`
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) createVerifyData(options) → {Promise.<{Uint8Array}>}

Parameters:
Name Type Description
options object The options to use.
Properties
Name Type Description
document object The document to be signed/verified.
proof object The proof to be verified.
documentLoader function The document loader to use.
expansionMap function NOT SUPPORTED; do not use.
labelBytes bytes to be used for the params label
Source:
Returns:
.
Type
Promise.<{Uint8Array}>

(async) credsToEEClaimGraph(expandedCredentials) → {Promise.<Array.<Object>>}

Convert a list of expanded credentials which have already been verified into an RDF claim graph. The resulting claimgraph is in Explicit Ethos form.
Parameters:
Name Type Description
expandedCredentials A list of expanded credentials, each is expected to be a separate
Source:
Returns:
Type
Promise.<Array.<Object>>

(async) credToEECG() → {Promise.<Array.<Object>>}

Convert a single expanded credential which has already been verified into an RDF claim graph.
Source:
Returns:
Type
Promise.<Array.<Object>>

(async) deploy(anchor, waitForFinalization, params) → {Promise.<*>}

Write anchor on chain
Parameters:
Name Type Default Description
anchor
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

deployTx(anchor) → {object}

Prepare transaction to write anchor on chain
Parameters:
Name Type Description
anchor Uint8Array | string
Source:
Returns:
The extrinsic to sign and send.
Type
object

dereferenceFromIPFS(cid, ipfsClient, options) → {Promise.<string>}

Dereferences a CID from IPFS into a string, expects a running node to be connected to
Parameters:
Name Type Description
cid string IPFS document cid hash
ipfsClient object The IPFS HTTP Client
options object IPFS HTTP Client options passed to cat
Source:
Returns:
Type
Promise.<string>

documentLoader(resolveropt) → {loadDocument}

Takes a resolver and returns a function that returns a document or throws an error when the document cannot be found.
Parameters:
Name Type Attributes Default Description
resolver DIDResolver <optional>
null The resolver is optional but should be passed when DIDs need to be resolved.
Source:
Returns:
- the returned function
Type
loadDocument

encodeExtrinsicAsHash(api, tx) → {string}

Encodes an extrinsic as a blake2 hash
Parameters:
Name Type Description
api * API for creating Call type
tx * Extrinsic to encode
Source:
Returns:
Type
string

ensureArray(value)

Fail if the given value isn't an array
Parameters:
Name Type Description
value
Source:

ensureObject(value)

Fail if the given value isn't an object
Parameters:
Name Type Description
value
Source:

ensureObjectWithId(value, name)

Fail if the given value isn't an object with id property
Parameters:
Name Type Description
value
name string Name of the object. Used in constructing error.
Source:

ensureObjectWithKey(value, name, key)

Fail if the given value isn't an object with the given key as property
Parameters:
Name Type Description
value object object to check
name string Name of the object. Used in constructing error.
key string Property to look for
Source:

ensureString(value)

Fail if the given value isn't a string
Parameters:
Name Type Description
value
Source:

ensureURI(uri)

Fail if the given string isn't a URI
Parameters:
Name Type Description
uri
Source:

ensureValidDatetime(datetime)

Fail if the given datetime isn't valid.
Parameters:
Name Type Description
datetime
Source:

expandJSONLD(credential)

Helper method to ensure credential is valid according to the context
Parameters:
Name Type Description
credential
Source:

extractProof(expandedPresentation) → {Promise.<Array.<Object>>}

Extracts any included proofs of composite claims from a presentation. The presentation must be in expanded form. Returns the proofs, concatenated together.
Parameters:
Name Type Description
expandedPresentation a VCDM presentation as expanded json-ld
Source:
Returns:
Type
Promise.<Array.<Object>>

from(verificationMethod) → {EcdsaSecp256k1VerificationKey2019}

Construct the public key object from the verification method
Parameters:
Name Type Description
verificationMethod
Source:
Returns:
Type
EcdsaSecp256k1VerificationKey2019

from(verificationMethod) → {Ed25519VerificationKey2018}

Construct the public key object from the verification method
Parameters:
Name Type Description
verificationMethod
Source:
Returns:
Type
Ed25519VerificationKey2018

from(verificationMethod) → {Sr25519VerificationKey2020}

Construct the public key object from the verification method
Parameters:
Name Type Description
verificationMethod
Source:
Returns:
Type
Sr25519VerificationKey2020

fromHex(value) → {Signature}

Create SignatureEd25519 from given hex string
Parameters:
Name Type Description
value string Hex string
Source:
Returns:
Type
Signature

fromHex(value) → {Signature}

Create SignatureSecp256k1 from given hex string
Parameters:
Name Type Description
value string Hex string
Source:
Returns:
Type
Signature

fromHex(value) → {Signature}

Create SignatureSr25519 from given hex string
Parameters:
Name Type Description
value string Hex string
Source:
Returns:
Type
Signature

fromHex(value) → {Signature}

Creates a new DidSignature object. Validates the given value. Currently supported signature types only require validating the byte size.
Parameters:
Name Type Description
value string Value of the signature. This is validated
Source:
Returns:
The Signature object if the given value is valid.
Type
Signature

fromJsigProofValue(proofValue) → {*|string}

Json-ld signs prefix signatures with a specific character. Removes that character
Parameters:
Name Type Description
proofValue
Source:
Returns:
Type
* | string

fromKeyringPair(pair) → {PublicKeySecp256k1}

Returns a compressed public key for Secp256k1 curve. The name is intentionally kept same with the base export class to keep the API uniform
Parameters:
Name Type Description
pair object A KeyPair from elliptic library
Source:
Returns:
Type
PublicKeySecp256k1

fromKeyringPair(pair) → {PublicKey}

Extracts the public key from a pair. Assumes the KeyringPair is of the correct type. The `type` is intentionally not inspected to follow dependency inversion principle. generate the instance correct subclass
Parameters:
Name Type Description
pair object A polkadot-js KeyringPair.
Source:
Returns:
Type
PublicKey

fromPolkadotJSKeyringPair(message, signingPair)

Signs the given message and wraps it in the Signature
Parameters:
Name Type Description
message array The message to sign as bytearray
signingPair object The pair from Polkadot-js containing the signing key
Source:

generate(options)

Generates new keypair using provided options.
Parameters:
Name Type Description
options
Properties
Name Type Description
seed
params
controller
id
msgCount
Source:

generateEcdsaSecp256k1Keypair(persopt, entropyopt) → {object}

Generate keypair for Ecdsa over Secp256k1. Explicitly denying other options to keep the API simple
Parameters:
Name Type Attributes Description
pers string <optional>
A string
entropy array | string <optional>
A byte array or hex string
Source:
Returns:
A keypair
Type
object

(async) get(anchor, preHashed) → {Promise.<*>}

Query anchor from chain
Parameters:
Name Type Default Description
anchor
preHashed Boolean false If the anchor has already been hashed.
Source:
Returns:
- The promise will either successfully resolve to the block number where anchor was created or reject with an error.
Type
Promise.<*>

(async) get(id, dockApi) → {Promise.<object>}

Get schema from the chain using the given id, by querying the blob storage. Accepts a full blob id like blob:dock:0x... or just the hex identifier and the `DockAPI` object. The returned schema would be formatted as specified in the RFC (including author DID, schema id) or an error is returned if schema is not found on the chain or in JSON format.
Parameters:
Name Type Description
id string The Schema ID
dockApi object The Dock API
Source:
Returns:
Type
Promise.<object>

(async) getAccumulator(id, withKeyAndParams) → {Promise.<({created: *, lastModified: *}|null)>}

Get the accumulator as an object. The field `type` in object specifies whether it is "positive" or "universal". Fields `created` and `lastModified` are block nos where the accumulator was created and last updated respectively. Field `nonce` is the last accepted nonce by the chain, the next write to the accumulator should increment the nonce by 1. Field `accumulated` contains the current accumulated value.
Parameters:
Name Type Default Description
id
withKeyAndParams false
Source:
Returns:
Type
Promise.<({created: *, lastModified: *}|null)>

getAllEventsFromBlock(api, numberOrHash, formatted)

Given a block number or block hash, get all events.
Parameters:
Name Type Description
api *
numberOrHash *
formatted *
Source:

getAllExtrinsicsFromBlock(api, numberOrHash, includeAllExtrinsics)

Given a block number or block hash, get all extrinsics.
Parameters:
Name Type Description
api *
numberOrHash *
includeAllExtrinsics * If false, returns only successful extrinsics.
Source:

(async) getAllParamsByDid(did) → {Promise.<Array.<object>>}

Get all params written by a DID
Parameters:
Name Type Description
did
Source:
Returns:
Type
Promise.<Array.<object>>

(async) getAllParamsByDid(did) → {Promise.<Array.<object>>}

Get all params written by a DID
Parameters:
Name Type Description
did
Source:
Returns:
Type
Promise.<Array.<object>>

(async) getAllPublicKeysByDid(did, withParams) → {Promise.<Array.<object>>}

Get all public keys written by a DID
Parameters:
Name Type Default Description
did
withParams false
Source:
Returns:
Type
Promise.<Array.<object>>

getAndValidateSchemaIfPresent(credential, schemaApi, context, documentLoader) → {Promise.<void>}

Get schema and run validation on credential if it contains both a credentialSubject and credentialSchema
Parameters:
Name Type Description
credential object a verifiable credential JSON object
schemaApi object An object representing a map. "schema type -> schema API". The API is used to get a schema doc. For now, the object specifies the type as key and the value as the API, but the structure can change as we support more APIs there are more details associated with each API. Only Dock is supported as of now.
context object the context
documentLoader object the document loader
Source:
Returns:
Type
Promise.<void>

getBytesForStateChange(api, stateChange) → {array}

// TODO: Error handling when `stateChange` is not registered Helper function to return bytes of a `StateChange` enum. Updates like key change, DID removal, revocation, etc require the change to be wrapped in `StateChange` before serializing for signing.
Parameters:
Name Type Description
api object Promise API from polkadot-js
stateChange object A representation of a `StateChange` enum variant
Source:
Returns:
An array of Uint8
Type
array

getCredentialStatuses(expanded)

Checks if a credential has a credentialStatus property and it has the properties we expect
Parameters:
Name Type Description
expanded
Source:

getDockRevIdFromCredential(credential) → {*}

Generate the revocation id of a credential usable by Dock. It hashes the credential id to get the revocation id
Parameters:
Name Type Description
credential
Source:
Returns:
Type
*

getHexIdentifier() → {string}

Gets the hexadecimal value of the given string.
Source:
Returns:
Returns the hexadecimal representation of the ID.
Type
string

getHexIdentifierFromBlobID(id) → {string}

Gets the hexadecimal value of the given ID.
Parameters:
Name Type Description
id string The ID can be passed as fully qualified ID like `blob:dock:` or a 32 byte hex string
Source:
Returns:
Returns the hexadecimal representation of the ID.
Type
string

getHexIdentifierFromDID(did) → {string}

Gets the hexadecimal value of the given DID.
Parameters:
Name Type Description
did string The DID can be passed as fully qualified DID like `did:dock:` or a 32 byte hex string
Source:
Returns:
Returns the hexadecimal representation of the DID.
Type
string

getImplications(claimgraph, proof, rules) → {Array.<Object>}

Given a claimgraph of true assumptions, and the allowed logical rules, return the claims that are proven true by proof. If the proof is not applicable given the ruleset, or makes unverified assumptions, throw an error. The return value may contain duplicate claims.
Parameters:
Name Type Description
claimgraph known true assumptions (usually extracted from a presentation or a cred)
proof proof of composite claims (usually comes from calling proveh())
rules ordered list of axioms
Source:
Returns:
Type
Array.<Object>

(async) getJSONSchemaSpec(json) → {Promise.<object>}

Gets the JSON schema spec from given JSON. Will either return the stored JSON schema or get it using HTTP or will throw error if cannot get.
Parameters:
Name Type Description
json object
Source:
Returns:
Type
Promise.<object>

getKeyPairType(pair) → {string|*}

Return the type of signature from a given keypair
Parameters:
Name Type Description
pair object Can be a keypair from polkadot-js or elliptic library.
Source:
Returns:
Type
string | *

(async) getLastParamsWritten(did) → {Promise.<({bytes: string}|null)>}

Get last params written by this DID
Parameters:
Name Type Description
did
Source:
Returns:
Type
Promise.<({bytes: string}|null)>

(async) getLastParamsWritten(did) → {Promise.<({bytes: string}|null)>}

Get last params written by this DID
Parameters:
Name Type Description
did
Source:
Returns:
Type
Promise.<({bytes: string}|null)>

getNonce(hexDid, nonce, didModule) → {Promise.<(undefined|*)>}

Get the nonce to be used for sending the next transaction if not provided already.
Parameters:
Name Type Description
hexDid DID whose nonce is needed
nonce If provided, returned as it is.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<(undefined|*)>

(async) getPublicKey(did, keyId, withParams) → {Promise.<({bytes: string}|null)>}

Parameters:
Name Type Default Description
did
keyId
withParams false If true, return the params referenced by the public key. It will throw an error if paramsRef is null or params were not found on chain which can happen if they were deleted after this public key was added.
Source:
Returns:
Type
Promise.<({bytes: string}|null)>

getPublicKeyFromKeyringPair(pair) → {PublicKey}

Inspect the `type` of the `KeyringPair` to generate the correct kind of PublicKey.
Parameters:
Name Type Description
pair object A polkadot-js KeyringPair.
Source:
Returns:
An instance of the correct subclass of PublicKey
Type
PublicKey

getSignatureFromKeyringPair(pair, message) → {Signature}

Inspect the `type` of the `KeyringPair` to generate the correct kind of Signature.
Parameters:
Name Type Description
pair object A polkadot-js KeyringPair.
message array an array of bytes (Uint8)
Source:
Returns:
An instance of the correct subclass of Signature
Type
Signature

getSuiteFromKeyDoc(keyDoc) → {object}

Get signature suite from a keyDoc
Parameters:
Name Type Description
keyDoc object key document containing `id`, `controller`, `type`, `privateKeyBase58` and `publicKeyBase58`
Source:
Returns:
- signature suite.
Type
object

getTransferExtrinsicsFromBlock(api, numberOrHash, balanceFormatted, includeAllTransfers)

Given a block number or block hash, get all transfer extrinsics. Each returned extrinsic is in form `[sender, recipient, amount]`
Parameters:
Name Type Description
api *
numberOrHash *
balanceFormatted *
includeAllTransfers * If false, will only return successful transfer extrinsics
Source:

getUniqueElementsFromArray(a, filterCallback) → {*}

Get unique elements from an array as seen by the filterCallback function.
Parameters:
Name Type Description
a array Array to check for duplicates.
filterCallback function Elements will be fed to this function before comparison.
Source:
Returns:
Type
*

(async) getUpdatesFromBlock(accumulatorId, blockNoOrBlockHash) → {Promise.<Array.<object>>}

Fetch a block and get all accumulator updates made in that block's extrinsics corresponding to accumulator id `accumulatorId`
Parameters:
Name Type Description
accumulatorId
blockNoOrBlockHash
Source:
Returns:
- Resolves to an array of `update`s where each `update` is an object with keys `newAccumulated`, `additions`, `removals` and `witnessUpdateInfo`. The last keys have value null if they were not provided in the extrinsic.
Type
Promise.<Array.<object>>

(async) getVerificationMethod(document, proof, documentLoader)

Parameters:
Name Type Description
document object to be signed.
proof object
documentLoader function
Source:

(async) getVerificationMethod(document, proof, documentLoader, expansionMap)

Parameters:
Name Type Description
document object to be signed.
proof object
documentLoader function
expansionMap function
Source:

(async) getVerificationMethod(document, proof, documentLoader, expansionMap)

Parameters:
Name Type Description
document object to be signed.
proof object
documentLoader function
expansionMap function
Source:

(async) getVerificationMethod(document, proof, documentLoader, expansionMap)

Parameters:
Name Type Description
document object to be signed.
proof object
documentLoader function
expansionMap function
Source:

hasDockRevocation(status) → {Boolean}

Check if a credential status has a Dock specific revocation
Parameters:
Name Type Description
status
Source:
Returns:
Type
Boolean

hash(anchor) → {Uint8Array}

Hash given data using Blake2b
Parameters:
Name Type Description
anchor
Source:
Returns:
Type
Uint8Array

hexDIDToQualified(hexId) → {string}

Return a fully qualified Dock DID id, i.e. "did:dock:"
Parameters:
Name Type Description
hexId string The hex blob id (without the qualifier)
Source:
Returns:
- The fully qualified Blob id
Type
string

isHexWithGivenByteSize(value, byteSizeopt) → {Boolean}

Check if the given input is hexadecimal or not. Optionally checks for the byte size of the hex. Case-insensitive on hex chars
Parameters:
Name Type Attributes Description
value string Hexadecimal value
byteSize number <optional>
Expected byte size of the input.
Source:
Returns:
True if hex (with given size) else false
Type
Boolean

isObject(value) → {boolean}

Return true if a value is an object
Parameters:
Name Type Description
value
Source:
Returns:
Type
boolean

isRevocationCheckNeeded(credential, forceRevocationCheck, revocationApi) → {boolean}

Checks if the revocation check is needed. Will return true if `forceRevocationCheck` is true else will check the truthyness of revocationApi. Will return true even if revocationApi is an empty object.
Parameters:
Name Type Description
credential object The expanded credential to be checked.
forceRevocationCheck boolean Whether to force the revocation check. Warning, setting forceRevocationCheck to false can allow false positives when verifying revocable credentials.
revocationApi object See above verification methods for details on this parameter
Source:
Returns:
- Whether to check for revocation or not.
Type
boolean

isString(value) → {boolean}

Return true if the given value is a string.
Parameters:
Name Type Description
value
Source:
Returns:
Type
boolean

issueCredential(keyDoc, credential, compactProofopt, documentLoader, purpose, expansionMap, issuerObjectopt, addSuiteContextopt, typeopt) → {Promise.<object>}

Issue a Verifiable credential
Parameters:
Name Type Attributes Description
keyDoc object key document containing `id`, `controller`, `type`, `privateKeyBase58` and `publicKeyBase58`
credential object Credential to be signed.
compactProof Boolean <optional>
Whether to compact the JSON-LD or not.
documentLoader
purpose
expansionMap
issuerObject object <optional>
Optional issuer object to assign
addSuiteContext Boolean <optional>
Toggles the default behavior of each signature suite enforcing the presence of its own `@context` (if it is not present, it's added to the context list).
type jsonld | jwt | proofValue <optional>
Optional format/type of the credential (JSON-LD, JWT, proofValue)
Source:
Returns:
The signed credential object.
Type
Promise.<object>

isVerifiedCredential(credentialopt, paramsopt) → {Promise.<boolean>}

Check that credential is verified, i.e. the credential has VCDM compliant structure and the `proof` (signature by issuer) is correct.
Parameters:
Name Type Attributes Description
credential object <optional>
The credential to verify
params object <optional>
Verify parameters (TODO: add type info for this object)
Source:
Returns:
Returns promise that resolves to true if credential is valid and not revoked and false otherwise
Type
Promise.<boolean>

isVerifiedPresentation(paramsopt) → {Promise.<boolean>}

Check that presentation is verified, i.e. the presentation and credentials have VCDM compliant structure and the `proof` (signature by holder) is correct.
Parameters:
Name Type Attributes Description
params object <optional>
Verify parameters (TODO: add type info for this object)
Source:
Returns:
- Returns promise that resolves to true if the presentation is valid and all the credentials are valid and not revoked and false otherwise. The `error` will describe the error if any.
Type
Promise.<boolean>

normalizeToHex(data)

Normalizes the given input to hex. Expects a Uint8Array or a hex string
Parameters:
Name Type Description
data Uint8Array | string
Source:

parseEventAsAccumulatorUpdate(event) → {null|Array.<string>}

Accepts an event and returns the accumulator id and accumulated value if the event was `accumulator:AccumulatorUpdated`
Parameters:
Name Type Description
event The event. This is the `event` key in the `event` object, i.e. for the `event` object got in response of `api.query.system.events`, the argument to this function is `event.event`.
Source:
Returns:
- null if the event is not `accumulator:AccumulatorUpdated` else [accumulatorId, accumulated]
Type
null | Array.<string>

parseRDFDocument(document, parserOptions) → {*}

Parses an RDF document string and formats it according to rify requirements
Parameters:
Name Type Description
document string RDF document in turtle or other form
parserOptions object N3 Parser configuration object
Source:
Returns:
Type
*

parseRef(ref) → {Array.<any>}

Parse a reference to a param or a public key. A reference uniquely identifies a param or a public key and is a pair of a DID and a positive number starting from 1.
Parameters:
Name Type Description
ref
Source:
Returns:
Type
Array.<any>

prepareAddParameters(bytes, curveType, label) → {Object}

Create object to add new parameters on chain
Parameters:
Name Type Description
bytes
curveType
label
Source:
Returns:
Type
Object

prepareAddPublicKey(bytes, curveType, paramsRef) → {Object}

Create object to add new public key on chain
Parameters:
Name Type Description
bytes
curveType
paramsRef Provide if this public key was created using params present on chain.
Source:
Returns:
Type
Object

presentationToEEClaimGraph(expandedPresentation) → {Promise.<Array.<Object>>}

Returns a list of all RDF statements in the presentation. DOES NOT VERIFY THE PRESENTATION. Verification must be performed for the results of this function to be trustworthy.
Parameters:
Name Type Description
expandedPresentation a VCDM presentation as expanded json-ld
Source:
Returns:
Type
Promise.<Array.<Object>>

proveCompositeClaims(expandedPresentation, compositeClaims, rules) → {Promise.<Object>}

Given the assumptions encoded in the provided presentation, prove a list of composite claims. T return proof of composite claims as a jsonld json literal which can be attached directly to a presentation as {expandedLogicProperty} before [signing and ]submitting. This function throws an error if the requested composite claims are unprovable.
Parameters:
Name Type Description
expandedPresentation a VCDM presentation as expanded json-ld
compositeClaims claims to prove, provide in claimgraph format
rules ordered list of axioms which will be accepted within proofs of composite claims
Source:
Returns:
- proof is returned as a json literal
Type
Promise.<Object>

queryNextLookup(claimgraph, query, engine) → {array.<any>}

Queries a claimgraph object and returns all the bindings to the variable named `?lookupNext`
Parameters:
Name Type Description
claimgraph array.<object> A list of RDF quads
query string SPARQL query string
engine object RDF query engine
Source:
Returns:
Type
array.<any>

(async) removeAccumulator(id, id, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Remove the accumulator from chain. This frees up the id for reuse.
Parameters:
Name Type Description
id
id id to remove
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) removeAccumulatorTx(id, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<object>}

Create transaction to remove accumulator
Parameters:
Name Type Description
id id to remove
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<object>

(async) removeParams(index, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Remove existing BBS+ params.
Parameters:
Name Type Description
index Index to uniquely identify BBS+ params
signerDid Signer of the blob
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) removeParamsTx(index, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<*>}

Create transaction to remove existing BBS+ params.
Parameters:
Name Type Description
index Index to uniquely identify BBS+ params
signerDid Signer of the payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<*>

(async) removePublicKey(removeKeyId, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Remove a public key
Parameters:
Name Type Description
removeKeyId Index of the accumulator public key
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) removePublicKey(removeKeyId, targetDid, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<*>}

Remove public key
Parameters:
Name Type Description
removeKeyId The key index for key to remove.
targetDid The DID from which key is being removed
signerDid The DID that is removing the key by signing the payload because it controls `targetDid`
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<*>

(async) resolve(did) → {Promise.<object>}

Resolve a did:key DID. The DID is expected to be a fully qualified DID.
Parameters:
Name Type Description
did string The full DID
Source:
Returns:
Type
Promise.<object>

(async) resolve(did) → {Promise.<object>}

Resolve a Dock DID. The DID is expected to be a fully qualified DID.
Parameters:
Name Type Description
did string The full DID
Source:
Returns:
Type
Promise.<object>

(async) resolve(didUrl) → {Promise.<object>}

Resolve a Dock DID. The DID is expected to be a fully qualified DID.
Parameters:
Name Type Description
didUrl string The full DID
Source:
Returns:
Type
Promise.<object>

(async) resolve(did) → {Promise.<object>}

Resolve the given DID with the providers or try to fetch from the universal resolver if available.
Parameters:
Name Type Description
did string A full DID (with method, like did:dock:5....)
Source:
Returns:
Returns a promise to the DID document
Type
Promise.<object>

(async) resolve(did) → {Promise.<object>}

Fetch the DID from the universal resolver.
Parameters:
Name Type Description
did string A full DID (with method, like did:uport:2nQtiQG....)
Source:
Returns:
Type
Promise.<object>

(async) setJSONSchema(json)

Add the JSON schema to this object after checking that `json` is a valid JSON schema. Check if JSON is valid.
Parameters:
Name Type Description
json object the schema JSON
Source:

sign(pair, blobModule)

Serializes the object using `getSerializedBlob` and then signs it using the given polkadot-js pair. The object will be updated with key `signature`. Repeatedly calling it will keep resetting the `signature` key
Parameters:
Name Type Description
pair object Key pair to sign with
blobModule
Source:

(async) sign(options) → {Promise.<object>}

Adds a signature (proofValue) field to the proof object. Called by LinkedDataSignature.createProof().
Parameters:
Name Type Description
options object The options to use.
Properties
Name Type Description
verifyData Uint8Array Data to be signed (extracted from document, according to the suite's spec).
proof object Proof object (containing the proofPurpose, verificationMethod, etc).
Source:
Returns:
Resolves with the proof containing the signature value.
Type
Promise.<object>

(async) sign(options) → {Promise.<object>}

Adds a signature (proofValue) field to the proof object. Called by LinkedDataSignature.createProof().
Parameters:
Name Type Description
options object The options to use.
Properties
Name Type Description
verifyData Uint8Array Data to be signed (extracted from document, according to the suite's spec).
proof object Proof object (containing the proofPurpose, verificationMethod, etc).
Source:
Returns:
Resolves with the proof containing the signature value.
Type
Promise.<object>

signAddParams(keyPair, params) → {Signature}

Parameters:
Name Type Description
keyPair
params
Source:
Returns:
Type
Signature

signAddPublicKey(keyPair, pk) → {Signature}

Parameters:
Name Type Description
keyPair
pk
Source:
Returns:
Type
Signature

signer() → {Object}

Returns a signer object for use with jsonld-signatures.
Source:
Returns:
A signer for the json-ld block.
Type
Object

signerFactory(keypair, verificationMethod) → {object}

Generate object with `sign` method
Parameters:
Name Type Description
keypair
verificationMethod
Source:
Returns:
Type
object

signerFactory(keypair, verificationMethod) → {object}

Generate object with `sign` method
Parameters:
Name Type Description
keypair
verificationMethod
Source:
Returns:
Type
object

signerFactory(keypair, verificationMethod) → {object}

Generate object with `sign` method
Parameters:
Name Type Description
keypair
verificationMethod
Source:
Returns:
Type
object

signerFactory(keypair) → {object}

Generate object with `sign` method
Parameters:
Name Type Description
keypair
Source:
Returns:
Type
object

signerFactory(keypair, verificationMethod) → {object}

Generate object with `sign` method
Parameters:
Name Type Description
keypair
verificationMethod
Source:
Returns:
Type
object

signPrehashed(messageHash, signingPair) → {string}

Sign an already hashed message
Parameters:
Name Type Description
messageHash Hash of the message
signingPair
Source:
Returns:
Type
string

signPresentation(presentation, keyDoc, challenge, domain, resolveropt, compactProofopt, presentationPurposeopt) → {Promise.<VerifiablePresentation>}

Sign a Verifiable Presentation
Parameters:
Name Type Attributes Description
presentation object the one to be signed
keyDoc object key document containing `id`, `controller`, `type`, `privateKeyBase58` and `publicKeyBase58`
challenge string proof challenge Required.
domain string proof domain (optional)
resolver DIDResolver <optional>
Resolver for DIDs.
compactProof Boolean <optional>
Whether to compact the JSON-LD or not.
presentationPurpose object <optional>
Optional presentation purpose to override default AuthenticationProofPurpose
Source:
Returns:
A VerifiablePresentation with a proof.
Type
Promise.<VerifiablePresentation>

signRemoveParams(keyPair, ref) → {Signature}

Parameters:
Name Type Description
keyPair
ref
Source:
Returns:
Type
Signature

signRemovePublicKey(keyPair, ref) → {Signature}

Parameters:
Name Type Description
keyPair
ref
Source:
Returns:
Type
Signature

toBlob() → {object}

Serializes the schema to a blob object to send to the node
Source:
Returns:
Type
object

toJSON() → {object}

Serializes schema object to JSON
Source:
Returns:
Type
object

toJSON() → {Object}

Source:
Returns:
The PublicKey JSON variant Ed25519.
Type
Object

toJSON() → {Object}

Source:
Returns:
The PublicKey JSON variant Secp256k1.
Type
Object

toJSON() → {Object}

Source:
Returns:
The PublicKey JSON variant Sr25519.
Type
Object

toJSON() → {Object}

Source:
Returns:
The PublicKey JSON variant X25519.
Type
Object

toJSON() → {Object}

Source:
Returns:
The correct PublicKey JSON variant. The extending export class should implement it.
Type
Object

toJSON() → {Object}

Source:
Returns:
The DidSignature JSON variant Ed25519.
Type
Object

toJSON() → {Object}

Source:
Returns:
The DidSignature JSON variant Secp256k1.
Type
Object

toJSON() → {Object}

Source:
Returns:
The DidSignature JSON variant Sr25519.
Type
Object

toJSON() → {Object}

Source:
Returns:
The correct DidSignature JSON variant. The extending export class should implement it.
Type
Object

toJSON() → {object}

Converts policy to JSON object
Source:
Returns:
Type
object

toJSON() → {object}

Converts policy to JSON object
Source:
Returns:
Type
object

toJsonldjsNode(node) → {any}

Converts a a JSON-LD RDF object to N3 data type
Parameters:
Name Type Description
node object JSON-LD RDF representation object
Source:
Returns:
Type
any

transferDock(api, senderKeypair, recipAddr, amount, sendTxn) → {Promise.<*>}

Transfer tokens and return txn hash. Converts to mirco tokens first
Parameters:
Name Type Description
api
senderKeypair
recipAddr
amount Amount in tokens
sendTxn If true, will send the transaction and return transaction hash otherwise return the signed transaction
Source:
Returns:
Type
Promise.<*>

transferMicroDock(api, senderKeypair, recipAddr, amount, sendTxn) → {Promise.<*>}

Transfer micro tokens and return txn hash.
Parameters:
Name Type Description
api
senderKeypair
recipAddr
amount Amount in micro (10^-6) tokens
sendTxn If true, will send the transaction and return transaction hash otherwise return the signed transaction
Source:
Returns:
Type
Promise.<*>

(async) updateAccumulator(id, newAccumulated, additions, removals, witnessUpdateInfo, signerDid, keyPair, keyId, nonce, didModule, waitForFinalization, params) → {Promise.<object>}

Update existing accumulator
Parameters:
Name Type Description
id
newAccumulated Accumulated value after the update
additions
removals
witnessUpdateInfo
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
waitForFinalization
params
Source:
Returns:
Type
Promise.<object>

(async) updateAccumulatorTx(id, newAccumulated, additions, removals, witnessUpdateInfo, signerDid, keyPair, keyId, nonce, didModule) → {Promise.<object>}

Create a transaction to update accumulator
Parameters:
Name Type Description
id Unique accumulator id
newAccumulated Accumulated value after the update
additions
removals
witnessUpdateInfo
signerDid Signer of the transaction payload
keyPair Signer's keypair
keyId The key id used by the signer. This will be used by the verifier (node) to fetch the public key for verification
nonce The nonce to be used for sending this transaction. If not provided then `didModule` must be provided.
didModule Reference to the DID module. If nonce is not provided then the next nonce for the DID is fetched by using this
Source:
Returns:
Type
Promise.<object>

(async) validate(proof, options) → {Promise.<{valid: boolean, error: Error}>}

Validates the purpose of a proof. This method is called during proof verification, after the proof value has been checked against the given verification method (in the case of a digital signature, the signature has been cryptographically verified against the public key).
Parameters:
Name Type Description
proof object The proof to validate.
options object The options to use.
Properties
Name Type Attributes Description
document object The document whose signature is being verified.
suite object Signature suite used in the proof.
verificationMethod string Key id URL to the paired public key.
documentLoader object <optional>
A document loader.
expansionMap object <optional>
An expansion map.
Source:
Throws:
  • If verification method not authorized by controller.
    Type
    Error
  • If proof's created timestamp is out of range.
    Type
    Error
Returns:
Resolves on completion.
Type
Promise.<{valid: boolean, error: Error}>

validateAddress(address, network) → {boolean}

Return true if an address is valid according to the provided network, false otherwise.
Parameters:
Name Type Description
address string The address in SS58 format.
network string Address if from testnet or mainnet. Accepts only `test` and `main`.
Source:
Returns:
true if the address is valid, false otherwise.
Type
boolean

validateBlobIDHexIdentifier(identifier) → {void}

Check if the given identifier is 32 byte hex
Parameters:
Name Type Description
identifier string The identifier to check.
Source:
Returns:
Throws exception if invalid identifier
Type
void

validateByteSize()

Check that the given public key has the expected byte size. Assumes the public key is in hex.
Source:

validateByteSize()

Check that the given signature has the expected byte size. Assumes the signature is in hex.
Source:

validateCredentialSchema(credential, schema, context) → {Promise.<Boolean>}

The function uses `jsonschema` package to verify that the expanded `credential`'s subject `credentialSubject` has the JSON schema `schema`
Parameters:
Name Type Description
credential object The credential to use, must be expanded JSON-LD
schema object The schema to use
context
Source:
Returns:
- Returns promise to a boolean or throws error
Type
Promise.<Boolean>

validateDockDIDHexIdentifier(identifier) → {void}

Check if the given identifier is 32 byte hex
Parameters:
Name Type Description
identifier string The identifier to check.
Source:
Returns:
Throws exception if invalid identifier
Type
void

validateDockDIDSS58Identifier(identifier) → {void}

Check if the given identifier is 32 byte valid SS58 string
Parameters:
Name Type Description
identifier string The identifier to check.
Source:
Returns:
Throws exception if invalid identifier
Type
void

(async) validateSchema(json) → {Promise.<object>}

Check that the given JSON schema is compliant with JSON schema spec mentioned in RFC
Parameters:
Name Type Description
json object The JSON schema to validate
Source:
Returns:
- Returns promise to an object or throws error
Type
Promise.<object>

verifier() → {object}

Construct the verifier factory that has the verify method using the current public key
Source:
Returns:
Type
object

verifier() → {object}

Construct the verifier factory that has the verify method using the current public key
Source:
Returns:
Type
object

verifier() → {object}

Construct the verifier factory that has the verify method using the current public key
Source:
Returns:
Type
object

verifier() → {Object}

Returns a verifier object for use with jsonld-signatures.
Source:
Returns:
Used to verify jsonld-signatures.
Type
Object

verifierFactory(publicKey) → {object}

Verifier factory that returns the object with the verify method
Parameters:
Name Type Description
publicKey
Source:
Returns:
Type
object

verifierFactory(publicKey) → {object}

Verifier factory that returns the object with the verify method
Parameters:
Name Type Description
publicKey
Source:
Returns:
Type
object

verifierFactory(publicKey) → {object}

Verifier factory that returns the object with the verify method
Parameters:
Name Type Description
publicKey
Source:
Returns:
Type
object

verifierFactory(keypair) → {object}

Generate object with `verify` method
Parameters:
Name Type Description
keypair
Source:
Returns:
Type
object

verifyCredential(vcJSONorStringopt, options) → {Promise.<object>}

Verify a Verifiable Credential. Returns the verification status and error in an object
Parameters:
Name Type Attributes Description
vcJSONorString object <optional>
The VCDM Credential as JSON-LD or JWT string
options VerifiableParams Verify parameters, this object is passed down to jsonld-signatures calls
Source:
Returns:
verification result. The returned object will have a key `verified` which is true if the credential is valid and not revoked and false otherwise. The `error` will describe the error if any.
Type
Promise.<object>

verifyEcdsaSecp256k1Sig(message, signature, publicKey) → {boolean}

Verify a given signature on a given message
Parameters:
Name Type Description
message array Bytes of message. Its assumed that the message is not hashed already and hashed before verifying
signature SignatureSecp256k1 signature to verify
publicKey PublicKeySecp256k1 Secp256k1 public key for verification
Source:
Returns:
True when signature is valid, false otherwise
Type
boolean

verifyEcdsaSecp256k1SigPrehashed(messageHash, signature, publicKey) → {boolean}

Verify a given signature on a given message hash
Parameters:
Name Type Description
messageHash array Hash of the message. Its assumed that the message is hashed already
signature SignatureSecp256k1 signature to verify
publicKey PublicKeySecp256k1 Secp256k1 public key for verification
Source:
Returns:
True when signature is valid, false otherwise
Type
boolean

verifyMerkleProofOfDocument(document, proof, root) → {boolean}

Verify inclusion proof of document in a merkle tree with given root. The document is hashed to form a leaf first
Parameters:
Name Type Description
document
proof
root
Source:
Returns:
Type
boolean

verifyMerkleProofOfLeaf(leaf, proof, root) → {boolean}

Verify inclusion proof of leaf in a merkle tree with given root.
Parameters:
Name Type Description
leaf
proof
root
Source:
Returns:
Type
boolean

verifyPresentation(presentation, options) → {Promise.<object>}

Verify a Verifiable Presentation. Returns the verification status and error in an object
Parameters:
Name Type Description
presentation object The verifiable presentation
options VerifiableParams Verify parameters, this object is passed down to jsonld-signatures calls
Source:
Returns:
verification result. The returned object will have a key `verified` which is true if the presentation is valid and all the credentials are valid and not revoked and false otherwise. The `error` will describe the error if any.
Type
Promise.<object>

(async) verifySignature(options) → {Promise.<boolean>}

Verifies the proof signature against the given data.
Parameters:
Name Type Description
options object The options to use.
Properties
Name Type Description
verifyData Uint8Array Canonicalized hashed data.
verificationMethod object Key object.
proof object The proof to be verified.
Source:
Returns:
Resolves with the verification result.
Type
Promise.<boolean>

(async) verifySignature(options) → {Promise.<boolean>}

Verifies the proof signature against the given data.
Parameters:
Name Type Description
options object The options to use.
Properties
Name Type Description
verifyData Uint8Array Canonicalized hashed data.
verificationMethod object Key object.
proof object The proof to be verified.
Source:
Returns:
Resolves with the verification result.
Type
Promise.<boolean>

(async) writeToChain(dock, signerDid, keyPair, keyId, nonce, waitForFinalization, params) → {Promise.<object>}

Prepares a transaction to write this schema object to the dock chain using the blob module
Parameters:
Name Type Description
dock object The dock API
signerDid
keyPair
keyId
nonce
waitForFinalization
params
Source:
Returns:
The extrinsic to sign and send.
Type
Promise.<object>

Type Definitions

KeyDoc

The Options to use in the function createUser.
Type:
  • object
Properties:
Name Type Description
id string The key's ID
controller any The key's controller ste
type any the type of key, Sr25519VerificationKey2020 or Ed25519VerificationKey2018 or EcdsaSecp256k1VerificationKey2019
keypair object Keypair is generated by either using polkadot-js's keyring or utils
publicKey object The key's public key taken from the keypair
Source:

Options

The Options to use in the function DockAPI.
Type:
  • object
Properties:
Name Type Attributes Description
address string <optional>
The node address to connect to.
keyring object <optional>
PolkadotJS keyring
chainTypes object <optional>
Types for the chain
chainRpc object <optional>
RPC definitions for the chain
loadPoaModules Boolean <optional>
Whether to load PoA modules or not. Defaults to true
Source:

VerifiableCredentialVerificationResult

The credential verification result
Type:
  • object
Properties:
Name Type Attributes Description
verified Boolean Is this credential verified or not
results array Verification results
error any <optional>
Optional error
Source:

VerifiableParams

The Options to verify credentials and presentations.
Type:
  • object
Properties:
Name Type Attributes Description
challenge string <optional>
proof challenge Required.
domain string <optional>
proof domain (optional)
controller string <optional>
controller (optional)
resolver DIDResolver <optional>
Resolver to resolve the issuer DID (optional)
unsignedPresentation Boolean <optional>
Whether to verify the proof or not
compactProof Boolean <optional>
Whether to compact the JSON-LD or not.
forceRevocationCheck Boolean <optional>
Whether to force revocation check or not. Warning, setting forceRevocationCheck to false can allow false positives when verifying revocable credentials.
purpose object <optional>
A purpose other than the default CredentialIssuancePurpose
revocationApi object <optional>
An object representing a map. "revocation type -> revocation API". The API is used to check revocation status. For now, the object specifies the type as key and the value as the API, but the structure can change as we support more APIs there are more details associated with each API. Only Dock is supported as of now.
schemaApi object <optional>
An object representing a map. "schema type -> schema API". The API is used to get a schema doc. For now, the object specifies the type as key and the value as the API, but the structure can change as we support more APIs there are more details associated with each API. Only Dock is supported as of now.
documentLoader object <optional>
A document loader, can be null and use the default
Source:

VerifiableParams

The Options to verify credentials and presentations.
Type:
  • object
Properties:
Name Type Attributes Description
challenge string <optional>
proof challenge Required.
domain string <optional>
proof domain (optional)
controller string <optional>
controller (optional)
resolver DIDResolver <optional>
Resolver to resolve the issuer DID (optional)
unsignedPresentation Boolean <optional>
Whether to verify the proof or not
compactProof Boolean <optional>
Whether to compact the JSON-LD or not.
forceRevocationCheck Boolean <optional>
Whether to force revocation check or not. Warning, setting forceRevocationCheck to false can allow false positives when verifying revocable credentials.
presentationPurpose object <optional>
A purpose other than the default AuthenticationProofPurpose
revocationApi object <optional>
An object representing a map. "revocation type -> revocation API". The API is used to check revocation status. For now, the object specifies the type as key and the value as the API, but the structure can change as we support more APIs there are more details associated with each API. Only Dock is supported as of now.
schemaApi object <optional>
An object representing a map. "schema type -> schema API". The API is used to get a schema doc. For now, the object specifies the type as key and the value as the API, but the structure can change as we support more APIs there are more details associated with each API. Only Dock is supported as of now.
documentLoader object <optional>
A document loader, can be null and use the default
Source:

VerifiablePresentation

Representation of a Verifiable Presentation.
Type:
  • object
Source:

VerifiablePresentationVerificationResult

The presentation verification result
Type:
  • object
Properties:
Name Type Attributes Description
presentationResult object Is this presentqtion verified or not
credentialResults array Verification results
verified Boolean Is verified or not
error any <optional>
Optional error
Source: