Skip to main content
Module

x/json_hash/mod.ts>MerkleHash

JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes
Latest
class MerkleHash
Re-export
import { MerkleHash } from "https://deno.land/x/json_hash@0.2.0/mod.ts";

Represents a hash of a Merkle tree.

Constructors

new
MerkleHash(
algorithm: T & DigestAlgorithmType,
hashBuffer: ArrayBuffer | Uint8Array | number[],
_moveFromInternalBuffer?: unknown,
)

Creates a new MerkleHash from a Uint8Array.

Properties

readonly
algorithm: T & DigestAlgorithmType

The hash algorithm used to create this digest.

readonly
base85: string

Shows the base85 (RFC 1924) representation of the hash.

readonly
hex: string

Shows the hexadecimal representation of the hash.

Methods

compareTo(other: MerkleHash<T>): number

Compares two MerkleHash objects. The comparison is done by comparing the hashes in byte order, that is, it's lexicographic.

equals(other: MerkleHash<T>): boolean

Checks if two MerkleHash objects are equal.

toString(): string

Shows the algorithm and hexadecimal representation of the hash.

toUint8Array(): Uint8Array

Returns the Uint8Array representation of the hash.

Static Methods

deriveFrom<T extends DigestAlgorithmType>(algorithm: T & DigestAlgorithmType, data: BufferSource | AsyncIterable<BufferSource> | Iterable<BufferSource>): Promise<MerkleHash<T>>

Derives a MerkleHash from input data.

fromHex<T extends DigestAlgorithmType>(algorithm: T & DigestAlgorithmType, hex: string): MerkleHash<T>

Converts a hexadecimal string into a MerkleHash.