Class PoseidonHasher

A helper class encapsulating Poseidon hash functionality.

Implements

  • Hasher

Constructors

Methods

  • Compresses two 32-byte hashes.

    Parameters

    • lhs: Field

      The first hash.

    • rhs: Field

      The second hash.

    Returns Field

    The new 32-byte hash.

  • Compresses an array of buffers.

    Parameters

    • inputs: Field[]

      The array of buffers to compress.

    Returns Field

    The resulting 32-byte hash.

  • Given a buffer containing 32 byte poseidon leaves, return a new buffer containing the leaves and all pairs of nodes that define a merkle tree.

    E.g. Input: [1][2][3][4] Output: [1][2][3][4][compress(1,2)][compress(3,4)][compress(5,6)].

    Parameters

    • leaves: Field[]

      The 32 byte poseidon leaves.

    Returns Promise<Field[]>

    A tree represented by an array.