pub fn keccak256(
builder: &CircuitBuilder,
message: &[Wire],
len_bytes: usize,
) -> [Wire; 4]Expand description
Computes the Keccak-256 hash of a fixed-length message.
This function creates a circuit that computes the Keccak-256 digest of a message with a known, fixed length at circuit construction time. It’s more efficient than the variable-length version as it doesn’t need runtime length checks or multiplexing.
§Arguments
builder- Circuit builder for constructing constraintsmessage- Input message as packed 64-bit words (8 bytes per wire)len_bytes- The exact length of the message in bytes
§Returns
[Wire; 4]- The Keccak-256 digest as 4 wires of 64 bits each
§Panics
- If
message.len()does not equal exactlylen_bytes.div_ceil(8)
§Example
ⓘ
use binius_circuits::keccak::fixed_length::keccak256;
use binius_frontend::CircuitBuilder;
let builder = CircuitBuilder::new();
// Create input wires for a 32-byte message
let message: Vec<_> = (0..4).map(|_| builder.add_witness()).collect();
// Compute Keccak-256 of the 32-byte message
let digest = keccak256(&builder, &message, 32);