pub fn ripemd160_fixed(
builder: &CircuitBuilder,
message: &[Wire],
len_bytes: usize,
) -> [Wire; 5]Expand description
Computes RIPEMD-160 hash of a fixed-length message.
This function creates a subcircuit that computes the RIPEMD-160 hash of a message with a compile-time known length. Unlike a variable-length RIPEMD-160 implementation, this function is optimized for fixed-length inputs where the length is known at circuit construction time.
See Pseudo-code for RIPEMD-160 for reference.
§Arguments
builder- Circuit builder for constructing constraintsmessage- Input message as 32-bit words (4 bytes per wire) in little-endian format. Each wire must have the high 32 bits set to zero (precondition).len_bytes- The fixed length of the message in bytes (known at compile time)
§Returns
[Wire; 5]- The RIPEMD-160 digest as 5 wires, each containing a 32-bit word in the low 32 bits (high 32 bits are zero) in little-endian order
§Panics
- If
message.len()does not equal exactlylen_bytes.div_ceil(4) - If the message length in bits cannot fit in 32 bits
§Preconditions
- The caller must constrain the
messagewires to have their high 32 bits set to zero.
§Example
ⓘ
use binius_circuits::ripemd::ripemd160_fixed;
use binius_frontend::compiler::CircuitBuilder;
let mut builder = CircuitBuilder::new();
// Create input wires for a 32-byte message (8 32-bit words)
let message: Vec<_> = (0..8).map(|_| builder.add_witness()).collect();
// Compute RIPEMD-160 of the 32-byte message
let digest = ripemd160_fixed(&builder, &message, 32);