Skip to main content

Text

The Text class represents textual data in the form of a Merkle tree. Each character of the text is converted to its ASCII code and stored as a leaf in the Merkle tree. The root of the tree can be used as a compact representation of the text data in cryptographic proofs.

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Text(text: string, height?: number): Text
  • Constructs a new Text instance by creating a Merkle tree from the given text string. Each character in the text is converted to its ASCII code and stored as a leaf in the tree.

    @throws

    Will throw an error if the text length exceeds the number of leaves in the Merkle tree.


    Parameters

    • text: string

      The text string to be represented.

    • height: number = TEXT_TREE_HEIGHT

      The height of the Merkle tree. Defaults to TEXT_TREE_HEIGHT.

    Returns Text

Properties

readonlyheight

height: number

The height of the Merkle tree.

readonlyroot

root: Field

The root of the Merkle tree representing the text data.

readonlysize

size: number

The length of the text.

readonlytext

text: string

The original text string.

Methods

publictoString

  • toString(): string
  • Returns the original text string.


    Returns string

    The text string.