Hash Functions
Leo provides three families of hash functions, each with different characteristics:
- BHP256 / BHP512 / BHP768 / BHP1024 - Bowe-Hopwood-Pedersen hashes. General-purpose, efficient inside circuits. Use BHP256 for most cases.
- Pedersen64 / Pedersen128 - Algebraic commitment-friendly hashes. Good when you need the output to be usable in further algebraic operations.
- Poseidon2 / Poseidon4 / Poseidon8 - Optimized for arithmetic circuits. Lowest constraint count when hashing multiple field elements.
leo
let h: field = BHP256::hash_to_field(input);
let c: field = Poseidon2::hash_to_field(a, b);
When choosing a hash function for your program, Poseidon is typically fastest inside proofs, BHP is the safest default, and Pedersen is best when the output needs algebraic properties.