mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-05-23 10:19:27 +00:00
from_partial (non-target) now takes in a slice
- Doesn't need to take in a `Vec`.
This commit is contained in:
parent
fe89fa949e
commit
adf5444f3f
@ -31,14 +31,12 @@ impl<F: Field> HashOut<F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_partial(mut elements: Vec<F>) -> Self {
|
pub fn from_partial(elements_in: &[F]) -> Self {
|
||||||
debug_assert!(elements.len() <= 4);
|
debug_assert!(elements_in.len() <= 4);
|
||||||
while elements.len() < 4 {
|
|
||||||
elements.push(F::ZERO);
|
let mut elements = [F::ZERO; 4];
|
||||||
}
|
elements[0..elements_in.len()].copy_from_slice(elements_in);
|
||||||
Self {
|
Self { elements }
|
||||||
elements: [elements[0], elements[1], elements[2], elements[3]],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rand_from_rng<R: Rng>(rng: &mut R) -> Self {
|
pub fn rand_from_rng<R: Rng>(rng: &mut R) -> Self {
|
||||||
|
|||||||
@ -14,11 +14,11 @@ pub const SPONGE_WIDTH: usize = SPONGE_RATE + SPONGE_CAPACITY;
|
|||||||
|
|
||||||
/// Hash the vector if necessary to reduce its length to ~256 bits. If it already fits, this is a
|
/// Hash the vector if necessary to reduce its length to ~256 bits. If it already fits, this is a
|
||||||
/// no-op.
|
/// no-op.
|
||||||
pub fn hash_or_noop<F: RichField, P: PlonkyPermutation<F>>(inputs: Vec<F>) -> HashOut<F> {
|
pub fn hash_or_noop<F: RichField, P: PlonkyPermutation<F>>(inputs: &[F]) -> HashOut<F> {
|
||||||
if inputs.len() <= 4 {
|
if inputs.len() <= 4 {
|
||||||
HashOut::from_partial(inputs)
|
HashOut::from_partial(inputs)
|
||||||
} else {
|
} else {
|
||||||
hash_n_to_hash_no_pad::<F, P>(&inputs)
|
hash_n_to_hash_no_pad::<F, P>(inputs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user