aggregateSha3HashIntoSinglePoseidonRoot
Umbra SDK reference for Aggregate Sha3 Hash Into Single Poseidon Root.
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
A 32-byte SHA-3 hash (Sha3Hash) to aggregate.
Returns
A single PoseidonHash representing the aggregated SHA-3 commitment.
Remarks
The aggregation procedure:
- Validates that the input is a 32-byte
Uint8Array(Sha3Hash). - Reverses the byte order to match the endianness expected by the bit unpacking logic.
- Expands the 32 bytes into 256 bits (LSB-first per byte).
- Splits the 256 bits into 22 groups: 21 groups of 12 bits, followed by 1 group of 4 bits.
- For each group, computes an intermediate Poseidon hash over the bits (0/1 as field elements).
- 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.