SequenceHash: Multihashing Without Algorithmic Lock-In
According to Trail of Bits, SequenceHash and SequenceMAC are open-source specifications that provide hash-agnostic multihashing and message authentication.
Trail of Bits introduced SequenceHash and SequenceMAC under the Community Cryptography Specification Project (C2SP). According to the source, these specifications give developers a secure way to hash multiple inputs without binding their application to a single hashing algorithm.
Unlike NIST’s TupleHash, which works only with Keccak and SHA3, SequenceHash and SequenceMAC are hash-agnostic. The source reports that they support almost any secure cryptographic hash function, including the SHA2 family (SHA256, SHA384, SHA512), BLAKE, and RIPEMD. Initial implementations and test vectors have been released in Rust, Go, and Python.
How It Works
The core idea behind SequenceHash is unambiguous input encoding and a double-hash construction.
For example, when a developer concatenates two raw strings, "AB" and "C", the result is "ABC". However, "A" concatenated with "BC" also results in "ABC". Raw hash updates are vulnerable to this type of ambiguity. The source states that SequenceHash prevents this by using a length-suffix encoding scheme featuring a fixed-length 128-bit integer for inputs.
To prevent length-extension attacks, both constructs use a double-hash mechanism. Furthermore, the source notes they support optional customization strings up to $2^{128}-1$ bytes long, which are integrated into the outer layer of the double-hash to provide domain separation. For MAC construction, SequenceMAC explicitly incorporates key lengths into a header block during preprocessing.
Why Developers Might Care
According to the source, these specifications offer several practical benefits for engineering secure systems:
- Protocol Safety: Simple concatenation of hash inputs can introduce severe bugs, such as forgeries in zero-knowledge proofs via the Fiat-Shamir transform. SequenceHash ensures that inputs remain semantically distinct.
- Algorithm Flexibility: Systems constrained by regulatory standards—such as government contracts requiring SHA384 or SHA512 under CNSA 2.0—can perform multihashing without adopting SHA3 or Keccak.
- Performance Optimization: Because customization strings are added solely to the outer layer, developers can reuse the inner hash computation when hashing the same dataset across multiple distinct contexts.
- MAC Security: SequenceMAC avoids the key pseudocollision and key extension vulnerabilities found in standard HMAC implementations by including key lengths in its preprocessing header.
Limitations
The source outlines specific operational boundaries and security constraints:
- Underlying Primitive Dependency: SequenceHash and SequenceMAC inherit the security profile of the underlying hash function. The source notes they cannot fix broken primitives like MD4, SHA0, or CRC32.
- Missing XOF Support: The source states that unlike TupleHash, a corresponding SequenceXOF for extensible output functions has not yet been specified or implemented.
- MAC Output Mismatch: Using SequenceMAC with algorithms that yield outputs smaller than 256 bits, such as SHA224 or RIPEMD160, results in security levels that fail to match a 32-byte minimum key size requirement.
- Application-Layer Responsibility: The construct only secures the hash inputs provided. The source emphasizes that developers remain fully responsible for handling consistent string encodings, uniform field ordering (such as in JSON or XML), and including necessary protocol parameters to prevent logical vulnerabilities.
Source Link
Trail of Bits: SequenceHash: Multihashing for the rest of us