Skip to content

Commit ec34342

Browse files
committed
Loosen Hash constraints further
1 parent fec3022 commit ec34342

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/ciphersuite.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use digest::core_api::BlockSizeUser;
1212
use digest::{FixedOutput, HashMarker, OutputSizeUser};
1313
use elliptic_curve::VoprfParameters;
1414
use elliptic_curve::hash2curve::{ExpandMsg, ExpandMsgXmd};
15-
use hybrid_array::typenum::{IsLess, IsLessOrEqual, U256};
15+
use hybrid_array::typenum::{IsLess, IsLessOrEqual, U256, U65536};
1616

1717
use crate::Group;
1818

1919
/// Configures the underlying primitives used in VOPRF
2020
pub trait CipherSuite
2121
where
22-
<Self::Hash as OutputSizeUser>::OutputSize: IsLess<U256>,
22+
<Self::Hash as OutputSizeUser>::OutputSize: IsLess<U65536>,
2323
{
2424
/// The ciphersuite identifier as dictated by
2525
/// <https://www.rfc-editor.org/rfc/rfc9497>
@@ -43,7 +43,7 @@ where
4343
T: Group,
4444
T::Hash: BlockSizeUser + Default + FixedOutput + HashMarker,
4545
<T::Hash as OutputSizeUser>::OutputSize:
46-
IsLess<U256> + IsLessOrEqual<<T::Hash as BlockSizeUser>::BlockSize>,
46+
IsLess<U256> + IsLess<U65536> + IsLessOrEqual<<T::Hash as BlockSizeUser>::BlockSize>,
4747
{
4848
const ID: &'static str = T::ID;
4949

src/common.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::ops::Add;
1313

1414
use derive_where::derive_where;
1515
use digest::{Digest, Output};
16-
use hybrid_array::typenum::{IsLess, U9, U256, Unsigned};
16+
use hybrid_array::typenum::{IsLess, U9, U65536, Unsigned};
1717
use hybrid_array::{Array, ArrayN, ArraySize};
1818
use rand_core::{TryCryptoRng, TryRngCore};
1919
use subtle::ConstantTimeEq;
@@ -441,7 +441,7 @@ pub(crate) fn server_evaluate_hash_input<CS: CipherSuite>(
441441
.chain_update(info.as_ref());
442442
}
443443
Ok(hash
444-
.chain_update(i2osp_2(issued_element.len()).map_err(|_| Error::Input)?)
444+
.chain_update(i2osp_2_array(&issued_element))
445445
.chain_update(issued_element)
446446
.chain_update(STR_FINALIZE)
447447
.finalize())
@@ -515,6 +515,6 @@ pub(crate) fn i2osp_2(input: usize) -> Result<[u8; 2], InternalError> {
515515
.map_err(|_| InternalError::I2osp)
516516
}
517517

518-
pub(crate) fn i2osp_2_array<L: ArraySize + IsLess<U256>>(_: &Array<u8, L>) -> ArrayN<u8, 2> {
518+
pub(crate) fn i2osp_2_array<L: ArraySize + IsLess<U65536>>(_: &Array<u8, L>) -> ArrayN<u8, 2> {
519519
L::U16.to_be_bytes().into()
520520
}

src/group/elliptic_curve.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use elliptic_curve::sec1::{FromEncodedPoint, ModulusSize, ToEncodedPoint};
1414
use elliptic_curve::{
1515
AffinePoint, Field, FieldBytesSize, Group as _, ProjectivePoint, PublicKey, Scalar, SecretKey,
1616
};
17-
use hybrid_array::typenum::Sum;
17+
use hybrid_array::typenum::{IsLess, Sum, U65536};
1818
use hybrid_array::{Array, ArraySize};
1919
use rand_core::{TryCryptoRng, TryRngCore};
2020

@@ -28,6 +28,7 @@ impl<C> Group for C
2828
where
2929
C: GroupDigest,
3030
ProjectivePoint<Self>: CofactorGroup + ToEncodedPoint<Self>,
31+
ElemLen<Self>: IsLess<U65536>,
3132
ScalarLen<Self>: ModulusSize,
3233
AffinePoint<Self>: FromEncodedPoint<Self> + ToEncodedPoint<Self>,
3334
Scalar<Self>: FromOkm,

src/group/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::{Add, Mul, Sub};
2121
use ::elliptic_curve::hash2curve::ExpandMsg;
2222
#[cfg(feature = "decaf448")]
2323
pub use decaf::Decaf448;
24-
use hybrid_array::typenum::Sum;
24+
use hybrid_array::typenum::{IsLess, Sum, U65536};
2525
use hybrid_array::{Array, ArraySize};
2626
use rand_core::{TryCryptoRng, TryRngCore};
2727
#[cfg(feature = "ristretto255")]
@@ -50,7 +50,7 @@ where
5050
+ for<'a> Mul<&'a Self::Scalar, Output = Self::Elem>;
5151

5252
/// The byte length necessary to represent group elements
53-
type ElemLen: ArraySize + 'static;
53+
type ElemLen: ArraySize + IsLess<U65536> + 'static;
5454

5555
/// The type of base field scalars
5656
type Scalar: ConstantTimeEq

0 commit comments

Comments
 (0)