Blockchain Commons Components TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class Digest

    A type that can provide a single unique digest that characterizes its contents.

    Use Cases:

    • Data integrity verification
    • Unique identifier for an object based on its content
    • Content-addressable storage implementation
    • Comparing objects by their content rather than identity

    Implements

    Index

    Properties

    DIGEST_SIZE: 32 = SHA256_SIZE

    Methods

    • Create a Digest from data, validating the length. Alias for fromData for compatibility with Rust API.

      Parameters

      • data: Uint8Array

      Returns Digest

    • Compute SHA-256 digest from multiple data parts.

      The parts are concatenated and then hashed.

      Parameters

      • imageParts: Uint8Array<ArrayBufferLike>[]

        Array of byte arrays to concatenate and hash

      Returns Digest

    • Compute SHA-256 digest of data (legacy alias for fromImage).

      Parameters

      • data: Uint8Array

      Returns Digest

      Use fromImage instead

    • Get the first four bytes of the digest as a hexadecimal string. Useful for short descriptions.

      Returns string

    • Validate the digest against the given image.

      The image is hashed with SHA-256 and compared to this digest.

      Parameters

      • image: Uint8Array

      Returns boolean

      true if the digest matches the image.

    • Returns the CBOR tags associated with Digest.

      Returns Tag[]

    • Returns the untagged CBOR encoding (as a byte string).

      Returns Cbor

    • Returns the tagged CBOR encoding.

      Returns Cbor

    • Returns the tagged value in CBOR binary representation.

      Returns Uint8Array

    • Creates a Digest by decoding it from untagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Digest

    • Creates a Digest by decoding it from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Digest

    • Returns the UR representation of the Digest. Note: URs use untagged CBOR since the type is conveyed by the UR type itself.

      Returns UR

    • Returns the UR string representation.

      Returns string

    • Validate the given data against the digest, if any.

      Returns true if the digest is undefined or if the digest matches the image's digest. Returns false if the digest does not match.

      Parameters

      • image: Uint8Array
      • digest: Digest | undefined

      Returns boolean