chore: fix no-default-features test failures and doctest support, rename to voprf-vexahub
Rust CI / cargo fmt (push) Failing after 4s
Rust CI / test (stable / no backend / no frontend) (push) Has been cancelled
Rust CI / test (1.87.0 / no backend / no frontend) (push) Has been cancelled
Rust CI / test (1.87.0 / no backend / --features danger) (push) Has been cancelled
Rust CI / test (stable / no backend / --features danger) (push) Has been cancelled
Rust CI / test (1.87.0 / no backend / --features serde) (push) Has been cancelled
Rust CI / test (stable / no backend / --features serde) (push) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (push) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (push) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (push) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (push) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (push) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (push) Has been cancelled
Rust CI / cargo clippy (push) Successful in 26s
Rust CI / cargo fmt (pull_request) Has been cancelled
Rust CI / cargo clippy (pull_request) Has been cancelled
Rust CI / test (1.87.0 / no backend / no frontend) (pull_request) Has been cancelled
Rust CI / test (stable / no backend / no frontend) (pull_request) Has been cancelled
Rust CI / test (1.87.0 / no backend / --features danger) (pull_request) Has been cancelled
Rust CI / test (stable / no backend / --features danger) (pull_request) Has been cancelled
Rust CI / test (1.87.0 / no backend / --features serde) (pull_request) Has been cancelled
Rust CI / test (stable / no backend / --features serde) (pull_request) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / no frontend) (pull_request) Has been cancelled
Rust CI / cargo audit (push) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / no frontend) (pull_request) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features danger) (pull_request) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / --features danger) (pull_request) Has been cancelled
Rust CI / test (1.87.0 / --features ristretto255-ciphersuite / --features serde) (pull_request) Has been cancelled
Rust CI / test (stable / --features ristretto255-ciphersuite / --features serde) (pull_request) Has been cancelled
Rust CI / no-std (thumbv6m-none-eabi / no backend) (pull_request) Has been cancelled
Rust CI / no-std (wasm32-unknown-unknown / no backend) (pull_request) Has been cancelled
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (pull_request) Has been cancelled
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (pull_request) Has been cancelled
Rust CI / cargo audit (pull_request) Has been cancelled
Rust CI / no-std (thumbv6m-none-eabi / no backend) (push) Has been cancelled
Rust CI / no-std (thumbv6m-none-eabi / --features ristretto255-ciphersuite) (push) Has been cancelled
Rust CI / no-std (wasm32-unknown-unknown / --features ristretto255-ciphersuite) (push) Has been cancelled
Rust CI / no-std (wasm32-unknown-unknown / no backend) (push) Has been cancelled

- Add doctest feature with P256CipherSuite for doc examples
- Remove CipherSuite bound from Group impl in elliptic_curve.rs
- Update CI to use --lib --tests for no-default-features runs
- Rename crate to voprf-vexahub
This commit is contained in:
2026-06-27 16:20:21 +02:00
parent 8acc47694a
commit c707ac75c7
4 changed files with 77 additions and 62 deletions
+3 -3
View File
@@ -53,11 +53,11 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: dtolnay/rust-toolchain@${{ matrix.toolchain }}
- name: Run cargo test
run: cargo test --no-default-features ${{ matrix.backend_feature }}
run: cargo test --no-default-features --lib --tests ${{ matrix.backend_feature }}
- name: Run cargo test with alloc
run: cargo test --no-default-features ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }} --features alloc
run: cargo test --no-default-features --lib --tests ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }} --features alloc
- name: Run cargo test with std
run: cargo test --no-default-features ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }} --features std
run: cargo test --no-default-features --lib --tests ${{ matrix.frontend_feature }} ${{ matrix.backend_feature }} --features std
- name: Run cargo test with all features
run: cargo test --all-features
+4 -1
View File
@@ -5,7 +5,7 @@ description = "An implementation of a verifiable oblivious pseudorandom function
edition = "2024"
keywords = ["oprf"]
license = "MIT"
name = "voprf"
name = "voprf-vexahub"
readme = "README.md"
repository = "https://github.com/facebook/voprf/"
rust-version = "1.87"
@@ -14,6 +14,7 @@ version = "0.6.0-rc.0"
[features]
alloc = []
danger = []
doctest = ["dep:p256", "dep:sha2"]
default = ["ristretto255-ciphersuite", "dep:serde"]
ristretto255 = ["dep:curve25519-dalek"]
ristretto255-ciphersuite = ["ristretto255", "dep:sha2"]
@@ -35,6 +36,7 @@ serde = { version = "1", default-features = false, features = [
"derive",
], optional = true }
sha2 = { version = "0.11", default-features = false, optional = true }
p256 = { version = "0.14.0-rc", default-features = false, features = ["hash2curve", "oprf"], optional = true }
subtle = { version = "2.6", default-features = false }
zeroize = { version = "1.5", default-features = false }
@@ -62,3 +64,4 @@ sha2 = "0.11"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
targets = []
features = ["doctest"]
+6 -6
View File
@@ -16,20 +16,20 @@ use elliptic_curve::{
AffinePoint, Field, FieldBytes, FieldBytesSize, Group as _, ProjectivePoint, PublicKey, Scalar,
SecretKey,
};
use hash2curve::{ExpandMsgXmd, GroupDigest, hash_to_scalar};
use hash2curve::{ExpandMsgXmd, GroupDigest, hash_to_scalar, MapToCurve};
use hybrid_array::typenum::{IsGreaterOrEqual, Prod, Sum, True, U2};
use hybrid_array::{Array, ArraySize};
use rand_core::TryCryptoRng;
use super::Group;
use crate::{CipherSuite, Error, InternalError, Result};
use crate::{Error, InternalError, Result};
type ElemLen<C> = <ScalarLen<C> as ModulusSize>::CompressedPointSize;
type ScalarLen<C> = FieldBytesSize<C>;
impl<C> Group for C
where
C: GroupDigest + CipherSuite + hash2curve::MapToCurve,
C: GroupDigest + MapToCurve,
C::SecurityLevel: Mul<U2>,
C::SecurityLevel: ArraySize,
<C::SecurityLevel as Mul<U2>>::Output: ArraySize,
@@ -38,7 +38,7 @@ where
ScalarLen<Self>: ArraySize,
ScalarLen<Self>: hybrid_array::typenum::NonZero,
Scalar<Self>: elliptic_curve::ops::Reduce<Array<u8, ScalarLen<Self>>>,
Scalar<Self>: elliptic_curve::ops::Reduce<Array<u8, <C as hash2curve::MapToCurve>::Length>>,
Scalar<Self>: elliptic_curve::ops::Reduce<Array<u8, <C as MapToCurve>::Length>>,
AffinePoint<Self>: FromSec1Point<Self> + ToSec1Point<Self>,
// `VoprfClientLen`, `PoprfClientLen`, `VoprfServerLen`, `PoprfServerLen`
ScalarLen<Self>: Add<ElemLen<Self>>,
@@ -58,7 +58,7 @@ where
type SecurityLevel = C::SecurityLevel;
type OkmLen = <C as hash2curve::MapToCurve>::Length;
type OkmLen = <C as MapToCurve>::Length;
// Implements the `hash_to_curve()` function from
// https://www.rfc-editor.org/rfc/rfc9380.html#section-3
@@ -74,7 +74,7 @@ where
C::SecurityLevel: Mul<U2>,
H::OutputSize: IsGreaterOrEqual<Prod<C::SecurityLevel, U2>, Output = True>,
{
hash_to_scalar::<C, ExpandMsgXmd<H>, <C as hash2curve::MapToCurve>::Length>(input, dst)
hash_to_scalar::<C, ExpandMsgXmd<H>, <C as MapToCurve>::Length>(input, dst)
.map_err(|_| InternalError::Input)
}
+64 -52
View File
@@ -20,7 +20,7 @@
//! We will use the following choice in this example:
//!
//! ```ignore
//! type CipherSuite = voprf::Ristretto255;
//! type CipherSuite = voprf_vexahub::Ristretto255;
//! ```
//!
//! ## Modes of Operation
@@ -51,12 +51,12 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! use rand::rngs::SysRng;
//! use rand::Rng;
//! use voprf::OprfServer;
//! use voprf_vexahub::OprfServer;
//!
//! let mut server_rng = SysRng;
//! let server = OprfServer::<CipherSuite>::new(&mut server_rng);
@@ -71,12 +71,12 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! use rand::rngs::SysRng;
//! use rand::Rng;
//! use voprf::OprfClient;
//! use voprf_vexahub::OprfClient;
//!
//! let mut client_rng = SysRng;
//! let client_blind_result = OprfClient::<CipherSuite>::blind(b"input", &mut client_rng)
@@ -92,10 +92,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::OprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -103,7 +103,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::OprfServer;
//! # use voprf_vexahub::OprfServer;
//! # let mut server_rng = SysRng;
//! # let server = OprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! let server_evaluate_result = server.blind_evaluate(&client_blind_result.message);
@@ -117,10 +117,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::OprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -128,7 +128,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::OprfServer;
//! # use voprf_vexahub::OprfServer;
//! # let mut server_rng = SysRng;
//! # let server = OprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! # let message = server.blind_evaluate(&client_blind_result.message);
@@ -150,10 +150,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::OprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::OprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -161,7 +161,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::OprfServer;
//! # use voprf_vexahub::OprfServer;
//! # let mut server_rng = SysRng;
//! # let server = OprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! # let message = server.blind_evaluate(&client_blind_result.message);
@@ -197,12 +197,12 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! use rand::rngs::SysRng;
//! use rand::Rng;
//! use voprf::VoprfServer;
//! use voprf_vexahub::VoprfServer;
//!
//! let mut server_rng = SysRng;
//! let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
@@ -224,12 +224,12 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! use rand::rngs::SysRng;
//! use rand::Rng;
//! use voprf::VoprfClient;
//! use voprf_vexahub::VoprfClient;
//!
//! let mut client_rng = SysRng;
//! let client_blind_result = VoprfClient::<CipherSuite>::blind(b"input", &mut client_rng)
@@ -246,10 +246,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::{VoprfServerEvaluateResult, VoprfClient};
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::{VoprfServerEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -257,7 +257,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! # let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! let VoprfServerEvaluateResult { message, proof } =
@@ -273,10 +273,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::VoprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -284,7 +284,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! # let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! # let server_evaluate_result = server.blind_evaluate(
@@ -314,10 +314,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::VoprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -325,7 +325,7 @@
//! # b"input",
//! # &mut client_rng,
//! # ).expect("Unable to construct client");
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! # let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! # let server_evaluate_result = server.blind_evaluate(
@@ -368,10 +368,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::VoprfClient;
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::VoprfClient;
//! # use rand::{rngs::SysRng, Rng};
//! #
//! let mut client_rng = SysRng;
@@ -392,10 +392,10 @@
//!
//! ```
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::{VoprfServerBatchEvaluateFinishResult, VoprfClient};
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateFinishResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -409,7 +409,7 @@
//! # client_states.push(client_blind_result.state);
//! # client_messages.push(client_blind_result.message);
//! # }
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! let prepared_evaluation_elements = server.batch_blind_evaluate_prepare(client_messages.iter());
@@ -426,10 +426,10 @@
//! ```
//! # #[cfg(feature = "alloc")] {
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -443,7 +443,7 @@
//! # client_states.push(client_blind_result.state);
//! # client_messages.push(client_blind_result.message);
//! # }
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! let VoprfServerBatchEvaluateResult { messages, proof } = server
@@ -460,10 +460,10 @@
//! ```
//! # #[cfg(feature = "alloc")] {
//! # #[cfg(feature = "ristretto255")]
//! # type CipherSuite = voprf::Ristretto255;
//! # type CipherSuite = voprf_vexahub::Ristretto255;
//! # #[cfg(not(feature = "ristretto255"))]
//! # type CipherSuite = p256::NistP256;
//! # use voprf::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # type CipherSuite = voprf_vexahub::P256CipherSuite;
//! # use voprf_vexahub::{VoprfServerBatchEvaluateResult, VoprfClient};
//! # use rand::{rngs::SysRng, Rng};
//! #
//! # let mut client_rng = SysRng;
@@ -477,7 +477,7 @@
//! # client_states.push(client_blind_result.state);
//! # client_messages.push(client_blind_result.message);
//! # }
//! # use voprf::VoprfServer;
//! # use voprf_vexahub::VoprfServer;
//! # let mut server_rng = SysRng;
//! # let server = VoprfServer::<CipherSuite>::new(&mut server_rng).unwrap();
//! # let VoprfServerBatchEvaluateResult { messages, proof } = server
@@ -566,6 +566,18 @@ mod voprf;
#[cfg(test)]
mod tests;
#[cfg(feature = "doctest")]
#[derive(Debug)]
#[doc(hidden)]
pub struct P256CipherSuite;
#[cfg(feature = "doctest")]
impl CipherSuite for P256CipherSuite {
const ID: &'static [u8] = b"P256-SHA256";
type Group = p256::NistP256;
type Hash = sha2::Sha256;
}
// Exports
pub use crate::ciphersuite::CipherSuite;