Umbra SDK Docs

aggregateSha3HashIntoSinglePoseidonRoot

Umbra SDK reference for Aggregate Sha3 Hash Into Single Poseidon Root.

client


aggregateSha3HashIntoSinglePoseidonRoot(sha3Hash): U256LeBytes

Defined in: src/utils/hasher.ts:339

Aggregates a 32-byte SHA-3 hash into a single Poseidon root using a bit-level encoding compatible with Circom circuits.

Parameters

sha3Hash

U256LeBytes

A 32-byte SHA-3 hash (Sha3Hash) to aggregate.

Returns

U256LeBytes

A single PoseidonHash representing the aggregated SHA-3 commitment.

Remarks

The aggregation procedure:

  1. Validates that the input is a 32-byte Uint8Array (Sha3Hash).
  2. Reverses the byte order to match the endianness expected by the bit unpacking logic.
  3. Expands the 32 bytes into 256 bits (LSB-first per byte).
  4. Splits the 256 bits into 22 groups: 21 groups of 12 bits, followed by 1 group of 4 bits.
  5. For each group, computes an intermediate Poseidon hash over the bits (0/1 as field elements).
  6. Aggregates the 22 intermediate hashes with a two-level Poseidon tree:
    • firstBatchHash = Poseidon.hash(intermediate[0..10])
    • secondBatchHash = Poseidon.hash(intermediate[11..21])
    • root = Poseidon.hash([firstBatchHash, secondBatchHash])

This produces a single PoseidonHash that can be fed into Poseidon-based ZK circuits, while the original commitment is computed using SHA-3.

Throws

If the input is not a 32-byte Uint8Array.

Throws

PoseidonHasherError If any underlying Poseidon hashing operation fails.