Skip to content

Commit 97b0c61

Browse files
committed
Require CollisionResistance for ExpandMsgXof
1 parent 6c8b558 commit 97b0c61

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use super::{Domain, ExpandMsg, Expander};
44
use crate::{Error, Result};
55
use core::{fmt, num::NonZero, ops::Mul};
6-
use digest::{ExtendableOutput, HashMarker, Update, XofReader};
6+
use digest::{
7+
CollisionResistance, ExtendableOutput, HashMarker, Update, XofReader, typenum::IsGreaterOrEqual,
8+
};
79
use hybrid_array::{
810
ArraySize,
911
typenum::{IsLess, Prod, True, U2, U256},
@@ -40,6 +42,9 @@ where
4042
// If DST is larger than 255 bytes, the length of the computed DST is calculated by `K * 2`.
4143
// https://www.rfc-editor.org/rfc/rfc9380.html#section-5.3.1-2.1
4244
K: Mul<U2, Output: ArraySize + IsLess<U256, Output = True>>,
45+
// The collision resistance of `HashT` MUST be at least `K` bits.
46+
// https://www.rfc-editor.org/rfc/rfc9380.html#section-5.3.2-2.1
47+
HashT: CollisionResistance<CollisionResistance: IsGreaterOrEqual<K, Output = True>>,
4348
{
4449
type Expander<'dst> = Self;
4550

@@ -114,7 +119,11 @@ mod test {
114119
#[allow(clippy::panic_in_result_fn)]
115120
fn assert<HashT, L>(&self, dst: &'static [u8], domain: &Domain<'_, U32>) -> Result<()>
116121
where
117-
HashT: Default + ExtendableOutput + Update + HashMarker,
122+
HashT: Default
123+
+ ExtendableOutput
124+
+ Update
125+
+ HashMarker
126+
+ CollisionResistance<CollisionResistance: IsGreaterOrEqual<U16, Output = True>>,
118127
L: ArraySize,
119128
{
120129
assert_message(self.msg, domain, L::to_u16(), self.msg_prime);

0 commit comments

Comments
 (0)