@did-btc1/method
    Preparing search index...

    Class Btc1Read

    Implements 4.2 Read. The read operation is executed by a resolver after a resolution request identifying a specific did:btc1 identifier is received from a client at Resolution Time. The request MAY contain a resolutionOptions object containing additional information to be used in resolution. The resolver then attempts to resolve the DID document of the identifier at a specific Target Time. The Target Time is either provided in resolutionOptions or is set to the Resolution Time of the request. To do so it executes the following algorithm:

    1. Let identifierComponents be the result of running the algorithm in Parse did:btc1 identifier, passing in the identifier.
    2. Set initialDocument to the result of running Resolve Initial Document passing identifier, identifierComponents and resolutionOptions.
    3. Set targetDocument to the result of running the algorithm in Resolve Target Document passing in initialDocument and resolutionOptions.
    4. Return targetDocument.

    Btc1Read

    Index

    Constructors

    Methods

    • Implements 4.2.3.6 Apply DID Update.

      This algorithm attempts to apply a DID Update to a DID document, it first verifies the proof on the update is a valid capabilityInvocation of the root authority over the DID being resolved. Then it applies the JSON patch transformation to the DID document, checks the transformed DID document matches the targetHash specified by the update and validates it is a conformant DID document before returning it. This algorithm takes inputs contemporaryDIDDocument and an update.

      Parameters

      • params: { contemporaryDIDDocument: Btc1DidDocument; update: DidUpdatePayload }

        Parameters for applyDidUpdate.

        • contemporaryDIDDocument: Btc1DidDocument

          The current DID Document to update.

        • update: DidUpdatePayload

          The DID Update Payload to apply.

      Returns Promise<Btc1DidDocument>

    • Implements 4.2.2.2.2 CAS Retrieval.

      The CAS Retrieval algorithm attempts to retrieve an initialDocument from a Content Addressable Storage (CAS) system by converting the bytes in the identifier into a Content Identifier (CID). It takes in an identifier and an identifierComponents object. It returns an initialDocument.

      Parameters

      Returns Promise<Btc1DidDocument>

      The resolved DID Document object

      if the DID Document content is invalid

    • Implements 4.2.3.5 Confirm Duplicate Update.

      The Confirm Duplicate Update algorithm takes in a DidUpdatePayload | DID Update Payload and verifies that the update is a duplicate against the hash history of previously applied updates. The algorithm takes in an update and an array of hashes, updateHashHistory. It throws an error if the update is not a duplicate, otherwise it returns.

      Parameters

      • params: { update: DidUpdatePayload; updateHashHistory: string[] }

        Parameters for confirmDuplicateUpdate.

        • update: DidUpdatePayload

          The DID Update Payload to confirm.

        • updateHashHistory: string[]

          The history of hashes for previously applied updates.

      Returns Promise<void>

      A promise that resolves if the update is a duplicate, otherwise throws an error.

      if the update hash does not match the historical hash.

    • Protected

      Implements 4.2.3.1 Determine Target Blockheight.

      The Determine Target Blockheight algorithm determines the targetted Bitcoin blockheight that the resolution algorithm should traverse the blockchain history up to looking for for Beacon Signals. It takes in network and targetTime. It returns a Bitcoin blockheight.

      Parameters

      • params: { network: BitcoinNetworkNames; targetTime?: number }

        The parameters for the determineTargetBlockHeight operation.

        • network: BitcoinNetworkNames

          The bitcoin network to connect to (mainnet, signet, testnet, regtest).

        • OptionaltargetTime?: number

          Unix timestamp used to find highest block height < targetTime. If not provided, finds the highest bitcoin block height where confirmations > DEFAULT_BLOCK_CONFIRMATIONS.

      Returns Promise<number>

      The target blockheight.

    • Implements 4.2.2.2 External Resolution.

      The External Resolution algorithm externally retrieves an intermediateDocumentRepresentation, either by retrieving it from Content Addressable Storage (CAS) or from the Sidecar Data provided as part of the resolution request. It takes in a did:btc1 identifier, a identifierComponents object and a resolutionOptions object. It returns an initialDocument, which is a conformant DID document validated against the identifier.

      Parameters

      Returns Promise<Btc1DidDocument>

      The resolved DID Document object

    • Implements 4.2.3.3 Find Next Signals.

      The Find Next Signals algorithm finds the next Bitcoin block containing Beacon Signals from one or more of the beacons and retuns all Beacon Signals within that block.

      It takes the following inputs:

      • contemporaryBlockhieght: The height of the block this function is looking for Beacon Signals in. An integer greater or equal to 0.
      • targetBlockheight: The height of the Bitcoin block that the resolution algorithm searches for Beacon Signals up to. An integer greater or equal to 0.
      • beacons: An array of Beacon services in the contemporary DID document. Each Beacon contains properties:
        • id: The id of the Beacon service in the DID document. A string.
        • type: The type of the Beacon service in the DID document. A string whose values MUST be either SingletonBeacon, CIDAggregateBeacon or SMTAggregateBeacon.
        • serviceEndpoint: A BIP21 URI representing a Bitcoin address.
        • address: The Bitcoin address decoded from the `serviceEndpoint value.
      • network: A string identifying the Bitcoin network of the did:btc1 identifier. This algorithm MUST query the Bitcoin blockchain identified by the network.

      It returns a nextSignals struct, containing the following properties:

      • blockheight: The Bitcoin blockheight for the block containing the Beacon Signals.
      • signals: An array of signals. Each signal is a struct containing the following:
        • beaconId: The id for the Beacon that the signal was announced by.
        • beaconType: The type of the Beacon that announced the signal.
        • tx: The Bitcoin transaction that is the Beacon Signal.

      Parameters

      • params: {
            beacons: BeaconServiceAddress[];
            contemporaryBlockHeight: number;
            network: BitcoinNetworkNames;
        }

        The parameters for the findNextSignals operation.

        • beacons: BeaconServiceAddress[]

          The beacons to look for in the block.

        • contemporaryBlockHeight: number
        • network: BitcoinNetworkNames

      Returns Promise<BeaconSignal>

      An array of BeaconSignal objects with blockHeight and signals.

    • Implements 4.2.3.4 Process Beacon Signals.

      The Process Beacon Signals algorithm processes each Beacon Signal by attempting to retrieve and validate an announce DID Update Payload for that signal according to the type of the Beacon.

      It takes as inputs

      • beaconSignals: An array of Beacon Signals retrieved from the Find Next Signals algorithm. Each signal contains:
        • beaconId: The id for the Beacon that the signal was announced by.
        • beaconType: The type of the Beacon that announced the signal.
        • tx: The Bitcoin transaction that is the Beacon Signal.
      • signalsMetadata: Maps Beacon Signal Bitcoin transaction ids to a SignalMetadata object containing:
        • updatePayload: A DID Update Payload which should match the update announced by the Beacon Signal. In the case of a SMT proof of non-inclusion, no DID Update Payload may be provided.
        • proofs: Sparse Merkle Tree proof used to verify that the updatePayload exists as the leaf indexed by the did:btc1 identifier being resolved.

      It returns an array of DID Update Payloads.

      Parameters

      • signals: Signal[]

        The beacon signals to process.

      • signalsMetadata: SignalsMetadata

        The sidecar data for the DID Document.

      Returns Promise<DidUpdatePayload[]>

      The updated DID Document object.

    • Protected

      TODO: Need to finish implementing the traverseBlockchainHistory method

      Implements 4.2.3.2 Traverse Blockchain History.

      The Traverse Blockchain History algorithm traverses Bitcoin blocks, starting from the block with the contemporaryBlockheight, to find beaconSignals emitted by Beacons within the contemporaryDIDDocument. Each beaconSignal is processed to retrieve a didUpdatePayload to the DID document. Each update is applied to the document and duplicates are ignored. If the algorithm reaches the block with the blockheight specified by a targetBlockheight, the contemporaryDIDDocument at that blockheight is returned assuming a single canonical history of the DID document has been constructed up to that point. It takes in contemporaryDIDDocument, contemporaryBlockHeight, currentVersionId, targetVersionId, targetBlockheight, updateHashHistory, signalsMetadata and network. It returns the contemporaryDIDDocument once either the targetBlockheight or targetVersionId have been reached.

      Parameters

      • params: {
            contemporaryBlockHeight: number;
            contemporaryDIDDocument: Btc1DidDocument;
            currentVersionId: number;
            network: BitcoinNetworkNames;
            signalsMetadata: SignalsMetadata;
            targetTime: number;
            targetVersionId?: number;
            updateHashHistory: string[];
        }

        The parameters for the traverseBlockchainHistory operation.

        • contemporaryBlockHeight: number

          The blockheight of the contemporaryDIDDocument.

        • contemporaryDIDDocument: Btc1DidDocument

          The DID Document at the contemporaryBlockheight.

        • currentVersionId: number

          The current versionId of the DID Document.

        • network: BitcoinNetworkNames

          The bitcoin network to connect to (mainnet, signet, testnet, regtest).

        • signalsMetadata: SignalsMetadata

          See SignalsMetadata for details.

        • targetTime: number

          The target blockheight to resolve the DID Document.

        • OptionaltargetVersionId?: number

          The target versionId of the DID Document.

        • updateHashHistory: string[]

          The hash history of the DID Document updates.

      Returns Promise<Btc1DidDocument>

      The resolved DID Document object with a validated single, canonical history.