Files
voprf-vx/src/ciphersuite.rs
T
breakingbread ffefd16b98
Rust CI / cargo fmt (pull_request) Successful in 3s
Rust CI / cargo clippy (pull_request) Successful in 28s
Rust CI / test (1.87.0 / no backend / no frontend) (pull_request) Successful in 1m24s
Rust CI / test (stable / no backend / no frontend) (pull_request) Successful in 1m21s
Rust CI / test (1.87.0 / no backend / --features danger) (pull_request) Successful in 1m24s
Rust CI / test (stable / no backend / --features danger) (pull_request) Successful in 1m21s
Rust CI / test (1.87.0 / no backend / --features serde) (pull_request) Successful in 1m30s
Rust CI / test (stable / no backend / --features serde) (pull_request) Successful in 1m23s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (pull_request) Successful in 1m33s
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (pull_request) Successful in 1m30s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (pull_request) Successful in 1m36s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (pull_request) Successful in 1m28s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (pull_request) Successful in 1m36s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (pull_request) Successful in 1m29s
Rust CI / cargo audit (pull_request) Successful in 4s
Rust CI / no-std (thumbv6m-none-eabi / no backend) (pull_request) Successful in 12s
Rust CI / no-std (wasm32-unknown-unknown / no backend) (pull_request) Successful in 13s
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (pull_request) Successful in 12s
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (pull_request) Successful in 15s
chore: bump to v1.0.0-rc.0, implement zeroize for deps and license fix
2026-07-02 14:47:47 +02:00

53 lines
2.0 KiB
Rust

// SPDX-License-Identifier: MIT OR Apache-2.0
// Copyright (c) VexaHub and contributors.
// Copyright (c) Meta Platforms, Inc. and affiliates.
//! Defines the CipherSuite trait to specify the underlying primitives for VOPRF
use crate::Group;
use digest::block_api::BlockSizeUser;
use digest::typenum::{IsLess, IsLessOrEqual, U256};
use digest::{FixedOutput, HashMarker, OutputSizeUser};
use hash2curve::{ExpandMsg, GroupDigest, MapToCurve, OprfParameters};
use hybrid_array::ArraySize;
use hybrid_array::typenum::{IsGreaterOrEqual, Prod, True, U2};
/// Configures the underlying primitives used in VOPRF
pub trait CipherSuite
where
<Self::Hash as OutputSizeUser>::OutputSize: ArraySize
+ IsLess<U256>
+ IsLessOrEqual<<Self::Hash as BlockSizeUser>::BlockSize, Output = True>
+ IsGreaterOrEqual<Prod<<Self::Group as Group>::SecurityLevel, U2>, Output = True>,
{
/// The ciphersuite identifier as dictated by
/// <https://www.rfc-editor.org/rfc/rfc9497>
const ID: &'static [u8];
/// A finite cyclic group along with a point representation that allows some
/// customization on how to hash an input to a curve point. See [`Group`].
type Group: Group;
/// The main hash function to use (for HKDF computations and hashing
/// transcripts).
type Hash: BlockSizeUser + Default + FixedOutput + HashMarker;
}
/// The hash function associated with a curve's OPRF `expand_message` implementation.
type OprfHash<T> =
<<T as GroupDigest>::ExpandMsg as ExpandMsg<<T as MapToCurve>::SecurityLevel>>::Hash;
impl<T: OprfParameters> CipherSuite for T
where
T: Group,
OprfHash<T>: BlockSizeUser + Default + FixedOutput + HashMarker,
<OprfHash<T> as OutputSizeUser>::OutputSize: ArraySize
+ IsLess<U256>
+ IsLessOrEqual<<OprfHash<T> 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 = OprfHash<T>;
}