@circom:field.hash
Hash hex bytes with keccak256 and reduce the digest into the BN254 scalar field, the standard way to map addresses, strings or arbitrary data into a circuit input.
⚗️ Experimental — available at next.evmcrispr.com.
Returns: number
Syntax
Section titled “Syntax”@circom:field.hash(data)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
data | bytes | Hex bytes to hash (compose multiple values with @abi.encodePacked) |
Examples
Section titled “Examples”# Map an address into a field element (e.g. as a tree leaf)print "Leaf:" @circom:field.hash(@me)- Computes
keccak256(data) mod p. This is the common way to map addresses, strings and other non-field data into circuit inputs, but note that many protocols define their own mapping — check the circuit before assuming this one. - The result is uniform enough for commitments but is NOT the Poseidon hash; use @circom:poseidon when the circuit hashes with Poseidon.
See Also
Section titled “See Also”- @circom:field — reduction without hashing
- @circom:poseidon — the in-circuit hash