Skip to content

Commit

Permalink
Update ff/src/fields/field_hashers/expander/mod.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Pratyush Mishra <[email protected]>
  • Loading branch information
burdges and Pratyush authored Sep 12, 2023
1 parent a3ab30a commit 14bb2a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ff/src/fields/field_hashers/expander/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ pub struct DST(arrayvec::ArrayVec<u8, MAX_DST_LENGTH>);

impl DST {
pub fn new_xmd<H: FixedOutputReset + Default>(dst: &[u8]) -> DST {
DST(if dst.len() > MAX_DST_LENGTH {
let array = if dst.len() > MAX_DST_LENGTH {
let mut long = H::default();
long.update(&LONG_DST_PREFIX[..]);
long.update(&dst);
ArrayVec::try_from(long.finalize_fixed().as_ref()).unwrap()
(long.finalize_fixed().as_ref()).try_into()
} else {
ArrayVec::try_from(dst).unwrap()
})
dst.try_into()
};
DST(array.unwrap())
}

pub fn new_xof<H: ExtendableOutput + Default>(dst: &[u8], k: usize) -> DST {
Expand Down

0 comments on commit 14bb2a3

Please sign in to comment.