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

    Class Canonicalization

    Canonicalization class provides methods for canonicalizing JSON objects and hashing them using SHA-256. It supports different canonicalization algorithms and encoding formats (hex and base58). Canonicalization

    Index

    Constructors

    Accessors

    Methods

    • Step 3.2: Encodes HashBytes (Uint8Array) to a base58btc string.

      Parameters

      • hashBytes: Bytes

        The hash as a Uint8Array.

      Returns string

      The hash as a hex string.

    • Canonicalizes an object, hashes it and returns it as hash bytes. Step 1-2: Canonicalize → Hash.

      Parameters

      Returns Promise<Bytes>

      The final SHA-256 hash bytes.

    • Step 1: Uses this.algorithm to determine the method (JCS/RDFC).

      Parameters

      Returns Promise<string>

      The canonicalized object.

    • Step 3: Encodes SHA-256 hashed, canonicalized object as a hex or base58 string.

      Parameters

      • canonicalizedhash: Bytes

        The canonicalized object to encode.

      • encoding: string = 'hex'

        The encoding format ('hex' or 'base58').

      Returns string

      The encoded string.

      If the encoding format is not supported.

    • Step 2: SHA-256 hashes a canonicalized object.

      Parameters

      • canonicalized: string

        The canonicalized object.

      Returns Bytes

      The SHA-256 HashBytes (Uint8Array).

    • Computes the SHA-256 hashes of canonicalized object and encodes it as a base58 string. Step 2-3: Hash → Encode(base58).

      Parameters

      • canonicalized: string

        The canonicalized object to hash.

      Returns string

      The SHA-256 hash as a base58 string.

    • Computes the SHA-256 hash of a canonicalized object and encodes it as a hex string. Step 2-3: Hash → Encode(Hex).

      Parameters

      • canonicalized: string

        The canonicalized object to hash.

      Returns string

      The SHA-256 hash as a hex string.

    • Step 3.1: Encodes HashBytes (Uint8Array) to a hex string.

      Parameters

      • hashBytes: Bytes

        The hash as a Uint8Array.

      Returns string

      The hash as a hex string.

    • Step 1: Canonicalizes an object using JCS (JSON Canonicalization Scheme).

      Parameters

      Returns any

      The canonicalized object.

    • Implements 9.2 JSON Canonicalization and Hash.

      A macro function that takes in a JSON document, document, and canonicalizes it following the JSON Canonicalization Scheme. The function returns the canonicalizedBytes.

      Optionally encodes a sha256 hashed canonicalized JSON object. Step 1 Canonicalize (JCS/RDFC) → Step 2 Hash (SHA256) → Step 3 Encode (Hex/Base58).

      Parameters

      • object: JSONObject

        The object to process.

      • encoding: string = 'hex'

        The encoding format ('hex' or 'base58').

      Returns Promise<string>

      The final SHA-256 hash bytes as a hex string.

    • Step 1: Canonicalizes an object using RDF Canonicalization (RDFC).

      Parameters

      Returns Promise<string>

      The canonicalized object.