chore: implemented Hash back into CipherSuite via hash2curve ExpandMsg
Rust CI / cargo fmt (push) Successful in 3s
Rust CI / cargo clippy (push) Successful in 28s
Rust CI / test (1.87.0 / no backend / no frontend) (push) Successful in 1m26s
Rust CI / test (stable / no backend / no frontend) (push) Successful in 1m19s
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 1m19s
Rust CI / test (1.87.0 / no backend / --features serde) (push) Successful in 1m26s
Rust CI / test (stable / no backend / --features serde) (push) Successful in 1m20s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (push) Successful in 1m36s
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (push) Successful in 1m29s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (push) Successful in 1m36s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (push) Successful in 1m27s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (push) Successful in 1m36s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (push) Successful in 1m27s
Rust CI / cargo audit (push) Successful in 4s
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (push) Successful in 15s
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (push) Successful in 11s
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 13s
Rust CI / cargo fmt (pull_request) Successful in 2s
Rust CI / cargo clippy (pull_request) Successful in 25s
Rust CI / test (1.87.0 / no backend / no frontend) (pull_request) Successful in 1m25s
Rust CI / test (stable / no backend / no frontend) (pull_request) Successful in 1m17s
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 1m18s
Rust CI / test (1.87.0 / no backend / --features serde) (pull_request) Successful in 1m26s
Rust CI / test (stable / no backend / --features serde) (pull_request) Successful in 1m17s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (pull_request) Successful in 1m34s
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (pull_request) Successful in 1m27s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (pull_request) Successful in 1m35s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (pull_request) Successful in 1m27s
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (pull_request) Successful in 1m35s
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (pull_request) Successful in 1m29s
Rust CI / cargo audit (pull_request) Successful in 5s
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (pull_request) Successful in 14s
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 11s
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (pull_request) Successful in 11s

This commit is contained in:
2026-06-28 17:32:20 +02:00
parent 405c1901ef
commit cb76820f52
8 changed files with 146 additions and 142 deletions
-1
View File
@@ -2,7 +2,6 @@
## 0.7.0-pre.0 (June 28, 2026) ## 0.7.0-pre.0 (June 28, 2026)
* MSRV bumped to 1.87 * MSRV bumped to 1.87
* `CipherSuite` no longer has a blanket impl via `VoprfParameters`; use `Suite<G, H>` instead (breaking change)
* Migrated from `elliptic-curve 0.13` to `0.14` * Migrated from `elliptic-curve 0.13` to `0.14`
* Replaced `generic-array` with `hybrid-array` * Replaced `generic-array` with `hybrid-array`
* Updated `digest` dependency to 0.11 * Updated `digest` dependency to 0.11
+28 -19
View File
@@ -13,7 +13,7 @@ use core::ops::Mul;
use digest::block_api::BlockSizeUser; use digest::block_api::BlockSizeUser;
use digest::typenum::{IsLess, IsLessOrEqual, U256}; use digest::typenum::{IsLess, IsLessOrEqual, U256};
use digest::{Digest, FixedOutput, HashMarker, OutputSizeUser}; use digest::{Digest, FixedOutput, HashMarker, OutputSizeUser};
use hash2curve::OprfParameters; use hash2curve::{ExpandMsg, GroupDigest, OprfParameters};
use hybrid_array::ArraySize; use hybrid_array::ArraySize;
use hybrid_array::typenum::{IsGreaterOrEqual, Prod, True, U2}; use hybrid_array::typenum::{IsGreaterOrEqual, Prod, True, U2};
@@ -39,22 +39,31 @@ where
type Hash: Digest + BlockSizeUser + Default + FixedOutput + HashMarker; type Hash: Digest + BlockSizeUser + Default + FixedOutput + HashMarker;
} }
/// A generic [`CipherSuite`] implementation for any compatible (Group, Hash) pair /// Trait associating a hash to an elliptic curve for OPRF usage.
#[allow(dead_code)] pub trait OprfCipherSuite: OprfParameters + Group {
#[derive(Debug)] type Hash: Digest + BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser;
pub struct Suite<G, H>(core::marker::PhantomData<(G, H)>); }
impl<G, H> CipherSuite for Suite<G, H> impl<T> OprfCipherSuite for T
where where
G: Group + OprfParameters, T: OprfParameters + Group,
H: BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser, <T as GroupDigest>::ExpandMsg: ExpandMsg<<T as Group>::SecurityLevel>,
<G as Group>::SecurityLevel: Mul<U2>, <<T as GroupDigest>::ExpandMsg as ExpandMsg<<T as Group>::SecurityLevel>>::Hash:
<H as OutputSizeUser>::OutputSize: ArraySize Digest + BlockSizeUser + Default + FixedOutput + HashMarker + OutputSizeUser,
+ IsLess<U256> {
+ IsLessOrEqual<<H as BlockSizeUser>::BlockSize, Output = True> type Hash = <<T as GroupDigest>::ExpandMsg as ExpandMsg<<T as Group>::SecurityLevel>>::Hash;
+ IsGreaterOrEqual<Prod<<G as Group>::SecurityLevel, U2>, Output = True>, }
{
const ID: &'static [u8] = G::ID; impl<T: OprfCipherSuite> CipherSuite for T
type Group = G; where
type Hash = H; 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;
} }
+15 -19
View File
@@ -53,7 +53,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! use rand::rngs::SysRng; //! use rand::rngs::SysRng;
//! use rand::Rng; //! use rand::Rng;
//! use voprf_vexahub::OprfServer; //! use voprf_vexahub::OprfServer;
@@ -73,7 +73,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! use rand::rngs::SysRng; //! use rand::rngs::SysRng;
//! use rand::Rng; //! use rand::Rng;
//! use voprf_vexahub::OprfClient; //! use voprf_vexahub::OprfClient;
@@ -94,7 +94,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::OprfClient; //! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -119,7 +119,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::OprfClient; //! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -152,7 +152,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::OprfClient; //! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -199,7 +199,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! use rand::rngs::SysRng; //! use rand::rngs::SysRng;
//! use rand::Rng; //! use rand::Rng;
//! use voprf_vexahub::VoprfServer; //! use voprf_vexahub::VoprfServer;
@@ -226,7 +226,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! use rand::rngs::SysRng; //! use rand::rngs::SysRng;
//! use rand::Rng; //! use rand::Rng;
//! use voprf_vexahub::VoprfClient; //! use voprf_vexahub::VoprfClient;
@@ -248,7 +248,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::{VoprfServerEvaluateResult, VoprfClient}; //! # use voprf_vexahub::{VoprfServerEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -275,7 +275,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::VoprfClient; //! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -316,7 +316,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::VoprfClient; //! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -370,7 +370,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::VoprfClient; //! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -394,7 +394,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateFinishResult, VoprfClient}; //! # use voprf_vexahub::{VoprfServerBatchEvaluateFinishResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -428,7 +428,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient}; //! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -462,7 +462,7 @@
//! # #[cfg(feature = "ristretto255")] //! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf_vexahub::Ristretto255; //! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))] //! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = voprf_vexahub::P256CipherSuite; //! # type CipherSuite = p256::NistP256;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient}; //! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng}; //! # use rand::{rngs::SysRng, Rng};
//! # //! #
@@ -566,13 +566,9 @@ mod voprf;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
/// A [`CipherSuite`] using P-256 and SHA-256, exposed for doctests.
#[cfg(feature = "doctest")]
pub type P256CipherSuite = Suite<p256::NistP256, sha2::Sha256>;
// Exports // Exports
pub use crate::ciphersuite::{CipherSuite, Suite}; pub use crate::ciphersuite::CipherSuite;
#[cfg(feature = "danger")] #[cfg(feature = "danger")]
pub use crate::common::derive_key; pub use crate::common::derive_key;
pub use crate::common::{ pub use crate::common::{
+16 -16
View File
@@ -271,8 +271,8 @@ mod tests {
use rand::rngs::SysRng; use rand::rngs::SysRng;
use super::*; use super::*;
use crate::Group;
use crate::common::{Dst, STR_HASH_TO_GROUP}; use crate::common::{Dst, STR_HASH_TO_GROUP};
use crate::{Group, Suite};
fn prf<CS: CipherSuite>( fn prf<CS: CipherSuite>(
input: &[u8], input: &[u8],
@@ -393,26 +393,26 @@ mod tests {
zeroize_oprf_server::<Ristretto255>(); zeroize_oprf_server::<Ristretto255>();
} }
base_retrieval::<Suite<NistP256, sha2::Sha256>>(); base_retrieval::<NistP256>();
base_inversion_unsalted::<Suite<NistP256, sha2::Sha256>>(); base_inversion_unsalted::<NistP256>();
server_evaluate::<Suite<NistP256, sha2::Sha256>>(); server_evaluate::<NistP256>();
zeroize_oprf_client::<Suite<NistP256, sha2::Sha256>>(); zeroize_oprf_client::<NistP256>();
zeroize_oprf_server::<Suite<NistP256, sha2::Sha256>>(); zeroize_oprf_server::<NistP256>();
base_retrieval::<Suite<NistP384, sha2::Sha384>>(); base_retrieval::<NistP384>();
base_inversion_unsalted::<Suite<NistP384, sha2::Sha384>>(); base_inversion_unsalted::<NistP384>();
server_evaluate::<Suite<NistP384, sha2::Sha384>>(); server_evaluate::<NistP384>();
zeroize_oprf_client::<Suite<NistP384, sha2::Sha384>>(); zeroize_oprf_client::<NistP384>();
zeroize_oprf_server::<Suite<NistP384, sha2::Sha384>>(); zeroize_oprf_server::<NistP384>();
base_retrieval::<Suite<NistP521, sha2::Sha512>>(); base_retrieval::<NistP521>();
base_inversion_unsalted::<Suite<NistP521, sha2::Sha512>>(); base_inversion_unsalted::<NistP521>();
server_evaluate::<Suite<NistP521, sha2::Sha512>>(); server_evaluate::<NistP521>();
zeroize_oprf_client::<Suite<NistP521, sha2::Sha512>>(); zeroize_oprf_client::<NistP521>();
zeroize_oprf_server::<Suite<NistP521, sha2::Sha512>>(); zeroize_oprf_server::<NistP521>();
Ok(()) Ok(())
} }
+16 -16
View File
@@ -736,8 +736,8 @@ mod tests {
use rand::rngs::SysRng; use rand::rngs::SysRng;
use super::*; use super::*;
use crate::Group;
use crate::common::STR_HASH_TO_GROUP; use crate::common::STR_HASH_TO_GROUP;
use crate::{Group, Suite};
fn prf<CS: CipherSuite>( fn prf<CS: CipherSuite>(
input: &[u8], input: &[u8],
@@ -895,26 +895,26 @@ mod tests {
zeroize_verifiable_server::<Ristretto255>(); zeroize_verifiable_server::<Ristretto255>();
} }
verifiable_retrieval::<Suite<NistP256, sha2::Sha256>>(); verifiable_retrieval::<NistP256>();
verifiable_bad_public_key::<Suite<NistP256, sha2::Sha256>>(); verifiable_bad_public_key::<NistP256>();
verifiable_server_evaluate::<Suite<NistP256, sha2::Sha256>>(); verifiable_server_evaluate::<NistP256>();
zeroize_verifiable_client::<Suite<NistP256, sha2::Sha256>>(); zeroize_verifiable_client::<NistP256>();
zeroize_verifiable_server::<Suite<NistP256, sha2::Sha256>>(); zeroize_verifiable_server::<NistP256>();
verifiable_retrieval::<Suite<NistP384, sha2::Sha384>>(); verifiable_retrieval::<NistP384>();
verifiable_bad_public_key::<Suite<NistP384, sha2::Sha384>>(); verifiable_bad_public_key::<NistP384>();
verifiable_server_evaluate::<Suite<NistP384, sha2::Sha384>>(); verifiable_server_evaluate::<NistP384>();
zeroize_verifiable_client::<Suite<NistP384, sha2::Sha384>>(); zeroize_verifiable_client::<NistP384>();
zeroize_verifiable_server::<Suite<NistP384, sha2::Sha384>>(); zeroize_verifiable_server::<NistP384>();
verifiable_retrieval::<Suite<NistP521, sha2::Sha512>>(); verifiable_retrieval::<NistP521>();
verifiable_bad_public_key::<Suite<NistP521, sha2::Sha512>>(); verifiable_bad_public_key::<NistP521>();
verifiable_server_evaluate::<Suite<NistP521, sha2::Sha512>>(); verifiable_server_evaluate::<NistP521>();
zeroize_verifiable_client::<Suite<NistP521, sha2::Sha512>>(); zeroize_verifiable_client::<NistP521>();
zeroize_verifiable_server::<Suite<NistP521, sha2::Sha512>>(); zeroize_verifiable_server::<NistP521>();
Ok(()) Ok(())
} }
+3 -3
View File
@@ -328,9 +328,9 @@ mod test {
let _ = $item::<crate::Ristretto255>::deserialize(&$bytes[..]); let _ = $item::<crate::Ristretto255>::deserialize(&$bytes[..]);
} }
let _ = $item::<crate::Suite<p256::NistP256, sha2::Sha256>>::deserialize(&$bytes[..]); let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]);
let _ = $item::<crate::Suite<p384::NistP384, sha2::Sha384>>::deserialize(&$bytes[..]); let _ = $item::<p384::NistP384>::deserialize(&$bytes[..]);
let _ = $item::<crate::Suite<p521::NistP521, sha2::Sha512>>::deserialize(&$bytes[..]); let _ = $item::<p521::NistP521>::deserialize(&$bytes[..]);
}; };
} }
+46 -46
View File
@@ -17,7 +17,7 @@ use crate::tests::parser::*;
use crate::{ use crate::{
BlindedElement, CipherSuite, EvaluationElement, Group, OprfClient, OprfServer, PoprfClient, BlindedElement, CipherSuite, EvaluationElement, Group, OprfClient, OprfServer, PoprfClient,
PoprfServer, PoprfServerBatchEvaluateFinishResult, PoprfServerBatchEvaluatePrepareResult, PoprfServer, PoprfServerBatchEvaluateFinishResult, PoprfServerBatchEvaluatePrepareResult,
Proof, Result, Suite, VoprfClient, VoprfServer, VoprfServerBatchEvaluateFinishResult, Proof, Result, VoprfClient, VoprfServer, VoprfServerBatchEvaluateFinishResult,
}; };
#[derive(Debug)] #[derive(Debug)]
@@ -133,83 +133,83 @@ fn test_vectors() -> Result<()> {
let p256_oprf_tvs = let p256_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("OPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("OPRF"));
assert_ne!(p256_oprf_tvs.len(), 0); assert_ne!(p256_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<Suite<NistP256, sha2::Sha256>>(&p256_oprf_tvs)?; test_oprf_seed_to_key::<NistP256>(&p256_oprf_tvs)?;
test_oprf_blind::<Suite<NistP256, sha2::Sha256>>(&p256_oprf_tvs)?; test_oprf_blind::<NistP256>(&p256_oprf_tvs)?;
test_oprf_blind_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_oprf_tvs)?; test_oprf_blind_evaluate::<NistP256>(&p256_oprf_tvs)?;
test_oprf_finalize::<Suite<NistP256, sha2::Sha256>>(&p256_oprf_tvs)?; test_oprf_finalize::<NistP256>(&p256_oprf_tvs)?;
test_oprf_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_oprf_tvs)?; test_oprf_evaluate::<NistP256>(&p256_oprf_tvs)?;
let p256_voprf_tvs = let p256_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("VOPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("VOPRF"));
assert_ne!(p256_voprf_tvs.len(), 0); assert_ne!(p256_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<Suite<NistP256, sha2::Sha256>>(&p256_voprf_tvs)?; test_voprf_seed_to_key::<NistP256>(&p256_voprf_tvs)?;
test_voprf_blind::<Suite<NistP256, sha2::Sha256>>(&p256_voprf_tvs)?; test_voprf_blind::<NistP256>(&p256_voprf_tvs)?;
test_voprf_blind_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_voprf_tvs)?; test_voprf_blind_evaluate::<NistP256>(&p256_voprf_tvs)?;
test_voprf_finalize::<Suite<NistP256, sha2::Sha256>>(&p256_voprf_tvs)?; test_voprf_finalize::<NistP256>(&p256_voprf_tvs)?;
test_voprf_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_voprf_tvs)?; test_voprf_evaluate::<NistP256>(&p256_voprf_tvs)?;
let p256_poprf_tvs = let p256_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("POPRF")); json_to_test_vectors!(rfc, String::from("P256-SHA256"), String::from("POPRF"));
assert_ne!(p256_poprf_tvs.len(), 0); assert_ne!(p256_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<Suite<NistP256, sha2::Sha256>>(&p256_poprf_tvs)?; test_poprf_seed_to_key::<NistP256>(&p256_poprf_tvs)?;
test_poprf_blind::<Suite<NistP256, sha2::Sha256>>(&p256_poprf_tvs)?; test_poprf_blind::<NistP256>(&p256_poprf_tvs)?;
test_poprf_blind_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_poprf_tvs)?; test_poprf_blind_evaluate::<NistP256>(&p256_poprf_tvs)?;
test_poprf_finalize::<Suite<NistP256, sha2::Sha256>>(&p256_poprf_tvs)?; test_poprf_finalize::<NistP256>(&p256_poprf_tvs)?;
test_poprf_evaluate::<Suite<NistP256, sha2::Sha256>>(&p256_poprf_tvs)?; test_poprf_evaluate::<NistP256>(&p256_poprf_tvs)?;
let p384_oprf_tvs = let p384_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("OPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("OPRF"));
assert_ne!(p384_oprf_tvs.len(), 0); assert_ne!(p384_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<Suite<NistP384, sha2::Sha384>>(&p384_oprf_tvs)?; test_oprf_seed_to_key::<NistP384>(&p384_oprf_tvs)?;
test_oprf_blind::<Suite<NistP384, sha2::Sha384>>(&p384_oprf_tvs)?; test_oprf_blind::<NistP384>(&p384_oprf_tvs)?;
test_oprf_blind_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_oprf_tvs)?; test_oprf_blind_evaluate::<NistP384>(&p384_oprf_tvs)?;
test_oprf_finalize::<Suite<NistP384, sha2::Sha384>>(&p384_oprf_tvs)?; test_oprf_finalize::<NistP384>(&p384_oprf_tvs)?;
test_oprf_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_oprf_tvs)?; test_oprf_evaluate::<NistP384>(&p384_oprf_tvs)?;
let p384_voprf_tvs = let p384_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("VOPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("VOPRF"));
assert_ne!(p384_voprf_tvs.len(), 0); assert_ne!(p384_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<Suite<NistP384, sha2::Sha384>>(&p384_voprf_tvs)?; test_voprf_seed_to_key::<NistP384>(&p384_voprf_tvs)?;
test_voprf_blind::<Suite<NistP384, sha2::Sha384>>(&p384_voprf_tvs)?; test_voprf_blind::<NistP384>(&p384_voprf_tvs)?;
test_voprf_blind_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_voprf_tvs)?; test_voprf_blind_evaluate::<NistP384>(&p384_voprf_tvs)?;
test_voprf_finalize::<Suite<NistP384, sha2::Sha384>>(&p384_voprf_tvs)?; test_voprf_finalize::<NistP384>(&p384_voprf_tvs)?;
test_voprf_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_voprf_tvs)?; test_voprf_evaluate::<NistP384>(&p384_voprf_tvs)?;
let p384_poprf_tvs = let p384_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("POPRF")); json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("POPRF"));
assert_ne!(p384_poprf_tvs.len(), 0); assert_ne!(p384_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<Suite<NistP384, sha2::Sha384>>(&p384_poprf_tvs)?; test_poprf_seed_to_key::<NistP384>(&p384_poprf_tvs)?;
test_poprf_blind::<Suite<NistP384, sha2::Sha384>>(&p384_poprf_tvs)?; test_poprf_blind::<NistP384>(&p384_poprf_tvs)?;
test_poprf_blind_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_poprf_tvs)?; test_poprf_blind_evaluate::<NistP384>(&p384_poprf_tvs)?;
test_poprf_finalize::<Suite<NistP384, sha2::Sha384>>(&p384_poprf_tvs)?; test_poprf_finalize::<NistP384>(&p384_poprf_tvs)?;
test_poprf_evaluate::<Suite<NistP384, sha2::Sha384>>(&p384_poprf_tvs)?; test_poprf_evaluate::<NistP384>(&p384_poprf_tvs)?;
let p521_oprf_tvs = let p521_oprf_tvs =
json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("OPRF")); json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("OPRF"));
assert_ne!(p521_oprf_tvs.len(), 0); assert_ne!(p521_oprf_tvs.len(), 0);
test_oprf_seed_to_key::<Suite<NistP521, sha2::Sha512>>(&p521_oprf_tvs)?; test_oprf_seed_to_key::<NistP521>(&p521_oprf_tvs)?;
test_oprf_blind::<Suite<NistP521, sha2::Sha512>>(&p521_oprf_tvs)?; test_oprf_blind::<NistP521>(&p521_oprf_tvs)?;
test_oprf_blind_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_oprf_tvs)?; test_oprf_blind_evaluate::<NistP521>(&p521_oprf_tvs)?;
test_oprf_finalize::<Suite<NistP521, sha2::Sha512>>(&p521_oprf_tvs)?; test_oprf_finalize::<NistP521>(&p521_oprf_tvs)?;
test_oprf_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_oprf_tvs)?; test_oprf_evaluate::<NistP521>(&p521_oprf_tvs)?;
let p521_voprf_tvs = let p521_voprf_tvs =
json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("VOPRF")); json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("VOPRF"));
assert_ne!(p521_voprf_tvs.len(), 0); assert_ne!(p521_voprf_tvs.len(), 0);
test_voprf_seed_to_key::<Suite<NistP521, sha2::Sha512>>(&p521_voprf_tvs)?; test_voprf_seed_to_key::<NistP521>(&p521_voprf_tvs)?;
test_voprf_blind::<Suite<NistP521, sha2::Sha512>>(&p521_voprf_tvs)?; test_voprf_blind::<NistP521>(&p521_voprf_tvs)?;
test_voprf_blind_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_voprf_tvs)?; test_voprf_blind_evaluate::<NistP521>(&p521_voprf_tvs)?;
test_voprf_finalize::<Suite<NistP521, sha2::Sha512>>(&p521_voprf_tvs)?; test_voprf_finalize::<NistP521>(&p521_voprf_tvs)?;
test_voprf_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_voprf_tvs)?; test_voprf_evaluate::<NistP521>(&p521_voprf_tvs)?;
let p521_poprf_tvs = let p521_poprf_tvs =
json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("POPRF")); json_to_test_vectors!(rfc, String::from("P521-SHA512"), String::from("POPRF"));
assert_ne!(p521_poprf_tvs.len(), 0); assert_ne!(p521_poprf_tvs.len(), 0);
test_poprf_seed_to_key::<Suite<NistP521, sha2::Sha512>>(&p521_poprf_tvs)?; test_poprf_seed_to_key::<NistP521>(&p521_poprf_tvs)?;
test_poprf_blind::<Suite<NistP521, sha2::Sha512>>(&p521_poprf_tvs)?; test_poprf_blind::<NistP521>(&p521_poprf_tvs)?;
test_poprf_blind_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_poprf_tvs)?; test_poprf_blind_evaluate::<NistP521>(&p521_poprf_tvs)?;
test_poprf_finalize::<Suite<NistP521, sha2::Sha512>>(&p521_poprf_tvs)?; test_poprf_finalize::<NistP521>(&p521_poprf_tvs)?;
test_poprf_evaluate::<Suite<NistP521, sha2::Sha512>>(&p521_poprf_tvs)?; test_poprf_evaluate::<NistP521>(&p521_poprf_tvs)?;
Ok(()) Ok(())
} }
+22 -22
View File
@@ -553,8 +553,8 @@ mod tests {
use rand::rngs::SysRng; use rand::rngs::SysRng;
use super::*; use super::*;
use crate::Group;
use crate::common::{Dst, STR_HASH_TO_GROUP}; use crate::common::{Dst, STR_HASH_TO_GROUP};
use crate::{Group, Suite};
fn prf<CS: CipherSuite>( fn prf<CS: CipherSuite>(
input: &[u8], input: &[u8],
@@ -774,32 +774,32 @@ mod tests {
zeroize_voprf_server::<Ristretto255>(); zeroize_voprf_server::<Ristretto255>();
} }
verifiable_retrieval::<Suite<NistP256, sha2::Sha256>>(); verifiable_retrieval::<NistP256>();
verifiable_batch_retrieval::<Suite<NistP256, sha2::Sha256>>(); verifiable_batch_retrieval::<NistP256>();
verifiable_bad_public_key::<Suite<NistP256, sha2::Sha256>>(); verifiable_bad_public_key::<NistP256>();
verifiable_batch_bad_public_key::<Suite<NistP256, sha2::Sha256>>(); verifiable_batch_bad_public_key::<NistP256>();
verifiable_server_evaluate::<Suite<NistP256, sha2::Sha256>>(); verifiable_server_evaluate::<NistP256>();
zeroize_voprf_client::<Suite<NistP256, sha2::Sha256>>(); zeroize_voprf_client::<NistP256>();
zeroize_voprf_server::<Suite<NistP256, sha2::Sha256>>(); zeroize_voprf_server::<NistP256>();
verifiable_retrieval::<Suite<NistP384, sha2::Sha384>>(); verifiable_retrieval::<NistP384>();
verifiable_batch_retrieval::<Suite<NistP384, sha2::Sha384>>(); verifiable_batch_retrieval::<NistP384>();
verifiable_bad_public_key::<Suite<NistP384, sha2::Sha384>>(); verifiable_bad_public_key::<NistP384>();
verifiable_batch_bad_public_key::<Suite<NistP384, sha2::Sha384>>(); verifiable_batch_bad_public_key::<NistP384>();
verifiable_server_evaluate::<Suite<NistP384, sha2::Sha384>>(); verifiable_server_evaluate::<NistP384>();
zeroize_voprf_client::<Suite<NistP384, sha2::Sha384>>(); zeroize_voprf_client::<NistP384>();
zeroize_voprf_server::<Suite<NistP384, sha2::Sha384>>(); zeroize_voprf_server::<NistP384>();
verifiable_retrieval::<Suite<NistP521, sha2::Sha512>>(); verifiable_retrieval::<NistP521>();
verifiable_batch_retrieval::<Suite<NistP521, sha2::Sha512>>(); verifiable_batch_retrieval::<NistP521>();
verifiable_bad_public_key::<Suite<NistP521, sha2::Sha512>>(); verifiable_bad_public_key::<NistP521>();
verifiable_batch_bad_public_key::<Suite<NistP521, sha2::Sha512>>(); verifiable_batch_bad_public_key::<NistP521>();
verifiable_server_evaluate::<Suite<NistP521, sha2::Sha512>>(); verifiable_server_evaluate::<NistP521>();
zeroize_voprf_client::<Suite<NistP521, sha2::Sha512>>(); zeroize_voprf_client::<NistP521>();
zeroize_voprf_server::<Suite<NistP521, sha2::Sha512>>(); zeroize_voprf_server::<NistP521>();
Ok(()) Ok(())
} }