diff --git a/plonky2/src/hash/hashing.rs b/plonky2/src/hash/hashing.rs index 75b35a93d6..7a2c4fb725 100644 --- a/plonky2/src/hash/hashing.rs +++ b/plonky2/src/hash/hashing.rs @@ -11,6 +11,19 @@ use crate::plonk::circuit_builder::CircuitBuilder; use crate::plonk::config::AlgebraicHasher; impl, const D: usize> CircuitBuilder { + /// Pad the message using the `pad10*1` rule, then hash it. + /// + /// This is circuit version of + /// [`crate::plonk::config::Hasher::hash_pad`] + pub fn hash_pad>(&mut self, inputs: Vec) -> HashOutTarget { + let mut padded_input = inputs; + padded_input.push(self.one()); + while (padded_input.len() + 1) % H::Permutation::RATE != 0 { + padded_input.push(self.zero()); + } + padded_input.push(self.one()); + self.hash_n_to_hash_no_pad::(padded_input) + } pub fn hash_or_noop>(&mut self, inputs: Vec) -> HashOutTarget { let zero = self.zero(); if inputs.len() <= NUM_HASH_OUT_ELTS {