chore: implemented Hash back into CipherSuite via hash2curve ExpandMsg (#3)
Rust CI / cargo fmt (push) Successful in 4s
Rust CI / cargo clippy (push) Successful in 26s
Rust CI / test (1.87.0 / no backend / no frontend) (push) Successful in 1m25s
Rust CI / test (stable / no backend / no frontend) (push) Successful in 1m18s
Rust CI / test (1.87.0 / no backend / --features danger) (push) Successful in 1m24s
Rust CI / test (stable / no backend / --features danger) (push) Successful in 1m18s
Rust CI / test (1.87.0 / no backend / --features serde) (push) Successful in 1m23s
Rust CI / test (stable / no backend / --features serde) (push) Successful in 1m19s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (push) Successful in 1m34s
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (push) Successful in 1m27s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (push) Successful in 1m34s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (push) Successful in 1m29s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (push) Successful in 1m33s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (push) Successful in 1m29s
Rust CI / cargo audit (push) Successful in 3s
Rust CI / no-std (thumbv6m-none-eabi / no backend) (push) Successful in 13s
Rust CI / no-std (wasm32-unknown-unknown / no backend) (push) Successful in 14s
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (push) Successful in 12s
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (push) Successful in 15s

Reviewed-on: vexahub/voprf-vexahub#3
Co-authored-by: UneBaguette <[email protected]>
Co-committed-by: UneBaguette <[email protected]>
This commit was merged in pull request #3.
This commit is contained in:
2026-06-28 18:16:42 +02:00
committed by breakingbread
parent 405c1901ef
commit 9f9dc23aa1
8 changed files with 146 additions and 142 deletions
+28 -19
View File
@@ -13,7 +13,7 @@ use core::ops::Mul;
use digest::block_api::BlockSizeUser;
use digest::typenum::{IsLess, IsLessOrEqual, U256};
use digest::{Digest, FixedOutput, HashMarker, OutputSizeUser};
use hash2curve::OprfParameters;
use hash2curve::{ExpandMsg, GroupDigest, OprfParameters};
use hybrid_array::ArraySize;
use hybrid_array::typenum::{IsGreaterOrEqual, Prod, True, U2};
@@ -39,22 +39,31 @@ where
type Hash: Digest + BlockSizeUser + Default + FixedOutput + HashMarker;
}
/// A generic [`CipherSuite`] implementation for any compatible (Group, Hash) pair
#[allow(dead_code)]
#[derive(Debug)]
pub struct Suite<G, H>(core::marker::PhantomData<(G, H)>);
impl<G, H> CipherSuite for Suite<G, H>
where
G: Group + OprfParameters,
H: BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser,
<G as Group>::SecurityLevel: Mul<U2>,
<H as OutputSizeUser>::OutputSize: ArraySize
+ IsLess<U256>
+ IsLessOrEqual<<H as BlockSizeUser>::BlockSize, Output = True>
+ IsGreaterOrEqual<Prod<<G as Group>::SecurityLevel, U2>, Output = True>,
{
const ID: &'static [u8] = G::ID;
type Group = G;
type Hash = H;
/// Trait associating a hash to an elliptic curve for OPRF usage.
pub trait OprfCipherSuite: OprfParameters + Group {
type Hash: Digest + BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser;
}
impl<T> OprfCipherSuite for T
where
T: OprfParameters + Group,
<T as GroupDigest>::ExpandMsg: ExpandMsg<<T as Group>::SecurityLevel>,
<<T as GroupDigest>::ExpandMsg as ExpandMsg<<T as Group>::SecurityLevel>>::Hash:
Digest + BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser,
{
type Hash = <<T as GroupDigest>::ExpandMsg as ExpandMsg<<T as Group>::SecurityLevel>>::Hash;
}
impl<T: OprfCipherSuite> CipherSuite for T
where
T: Group,
<T as Group>::SecurityLevel: Mul<U2>,
<<T as OprfCipherSuite>::Hash as OutputSizeUser>::OutputSize: ArraySize
+ IsLess<U256>
+ IsLessOrEqual<<<T as OprfCipherSuite>::Hash as BlockSizeUser>::BlockSize, Output = True>
+ IsGreaterOrEqual<Prod<<T as Group>::SecurityLevel, U2>, Output = True>,
{
const ID: &'static [u8] = T::ID;
type Group = T;
type Hash = <T as OprfCipherSuite>::Hash;
}