Skip to content

Commit 3a4455f

Browse files
committed
Remove the p256 crate feature
1 parent aaf5ca1 commit 3a4455f

File tree

7 files changed

+62
-76
lines changed

7 files changed

+62
-76
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
backend_feature:
38-
- ristretto255-ciphersuite,ristretto255_u64
39-
- ristretto255-ciphersuite,ristretto255_u32
40-
- p256
41-
- ristretto255-ciphersuite,ristretto255_u64,p256
38+
- --features ristretto255-ciphersuite,ristretto255_u64
39+
- --features ristretto255-ciphersuite,ristretto255_u32
4240
frontend_feature:
4341
-
4442
- --features danger
@@ -62,19 +60,19 @@ jobs:
6260
uses: actions-rs/cargo@v1
6361
with:
6462
command: test
65-
args: --no-default-features --features ${{ matrix.backend_feature }}
63+
args: --no-default-features ${{ matrix.backend_feature }}
6664

6765
- name: Run cargo test with alloc
6866
uses: actions-rs/cargo@v1
6967
with:
7068
command: test
71-
args: --no-default-features ${{ matrix.frontend_feature }},alloc --features ${{ matrix.backend_feature }}
69+
args: --no-default-features ${{ matrix.frontend_feature }},alloc ${{ matrix.backend_feature }}
7270

7371
- name: Run cargo test with std
7472
uses: actions-rs/cargo@v1
7573
with:
7674
command: test
77-
args: --no-default-features ${{ matrix.frontend_feature }},std --features ${{ matrix.backend_feature }}
75+
args: --no-default-features ${{ matrix.frontend_feature }},std ${{ matrix.backend_feature }}
7876

7977
build-no-std:
8078
name: Build with no-std on ${{ matrix.target }}
@@ -91,7 +89,6 @@ jobs:
9189
-
9290
- --features ristretto255-ciphersuite,ristretto255_u64
9391
- --features ristretto255-ciphersuite,ristretto255_u32
94-
- --features p256
9592
frontend_feature:
9693
-
9794
- --features danger
@@ -130,7 +127,7 @@ jobs:
130127
RUSTDOCFLAGS: -D warnings
131128
with:
132129
command: doc
133-
args: --no-deps --document-private-items --features std,p256
130+
args: --no-deps --document-private-items --features danger,std
134131

135132

136133
rustfmt:

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ elliptic-curve = { version = "0.12.0-pre.0", features = [
3535
"voprf",
3636
] }
3737
generic-array = "0.14"
38-
p256 = { version = "0.10.1", default-features = false, features = [
39-
"hash2curve",
40-
"voprf",
41-
], optional = true }
4238
rand_core = { version = "0.6", default-features = false }
4339
serde = { version = "1", default-features = false, features = [
4440
"derive",
@@ -51,13 +47,17 @@ zeroize = { version = "1", default-features = false }
5147
generic-array = { version = "0.14", features = ["more_lengths"] }
5248
hex = "0.4"
5349
json = "0.12"
50+
p256 = { version = "0.10.1", default-features = false, features = [
51+
"hash2curve",
52+
"voprf",
53+
] }
5454
proptest = "1"
5555
rand = "0.8"
5656
regex = "1"
5757
sha2 = "0.10"
5858

5959
[package.metadata.docs.rs]
60-
features = ["danger", "p256", "std"]
60+
features = ["danger", "std"]
6161
targets = []
6262

6363
[patch.crates-io]

src/group/tests.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::{Error, Group, Result};
1414

1515
#[test]
1616
fn test_group_properties() -> Result<()> {
17+
use p256::NistP256;
18+
1719
#[cfg(feature = "ristretto255")]
1820
{
1921
use crate::Ristretto255;
@@ -22,13 +24,8 @@ fn test_group_properties() -> Result<()> {
2224
test_zero_scalar_error::<Ristretto255>()?;
2325
}
2426

25-
#[cfg(feature = "p256")]
26-
{
27-
use p256::NistP256;
28-
29-
test_identity_element_error::<NistP256>()?;
30-
test_zero_scalar_error::<NistP256>()?;
31-
}
27+
test_identity_element_error::<NistP256>()?;
28+
test_zero_scalar_error::<NistP256>()?;
3229

3330
Ok(())
3431
}

src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
//! ```
5353
//! # #[cfg(feature = "ristretto255")]
5454
//! # type CipherSuite = voprf::Ristretto255;
55-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
55+
//! # #[cfg(not(feature = "ristretto255"))]
5656
//! # type CipherSuite = p256::NistP256;
5757
//! use rand::rngs::OsRng;
5858
//! use rand::RngCore;
@@ -74,7 +74,7 @@
7474
//! ```
7575
//! # #[cfg(feature = "ristretto255")]
7676
//! # type CipherSuite = voprf::Ristretto255;
77-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
77+
//! # #[cfg(not(feature = "ristretto255"))]
7878
//! # type CipherSuite = p256::NistP256;
7979
//! use rand::rngs::OsRng;
8080
//! use rand::RngCore;
@@ -96,7 +96,7 @@
9696
//! ```
9797
//! # #[cfg(feature = "ristretto255")]
9898
//! # type CipherSuite = voprf::Ristretto255;
99-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
99+
//! # #[cfg(not(feature = "ristretto255"))]
100100
//! # type CipherSuite = p256::NistP256;
101101
//! # use voprf::NonVerifiableClient;
102102
//! # use rand::{rngs::OsRng, RngCore};
@@ -124,7 +124,7 @@
124124
//! ```
125125
//! # #[cfg(feature = "ristretto255")]
126126
//! # type CipherSuite = voprf::Ristretto255;
127-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
127+
//! # #[cfg(not(feature = "ristretto255"))]
128128
//! # type CipherSuite = p256::NistP256;
129129
//! # use voprf::NonVerifiableClient;
130130
//! # use rand::{rngs::OsRng, RngCore};
@@ -171,7 +171,7 @@
171171
//! ```
172172
//! # #[cfg(feature = "ristretto255")]
173173
//! # type CipherSuite = voprf::Ristretto255;
174-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
174+
//! # #[cfg(not(feature = "ristretto255"))]
175175
//! # type CipherSuite = p256::NistP256;
176176
//! use rand::rngs::OsRng;
177177
//! use rand::RngCore;
@@ -200,7 +200,7 @@
200200
//! ```
201201
//! # #[cfg(feature = "ristretto255")]
202202
//! # type CipherSuite = voprf::Ristretto255;
203-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
203+
//! # #[cfg(not(feature = "ristretto255"))]
204204
//! # type CipherSuite = p256::NistP256;
205205
//! use rand::rngs::OsRng;
206206
//! use rand::RngCore;
@@ -222,7 +222,7 @@
222222
//! ```
223223
//! # #[cfg(feature = "ristretto255")]
224224
//! # type CipherSuite = voprf::Ristretto255;
225-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
225+
//! # #[cfg(not(feature = "ristretto255"))]
226226
//! # type CipherSuite = p256::NistP256;
227227
//! # use voprf::VerifiableClient;
228228
//! # use rand::{rngs::OsRng, RngCore};
@@ -251,7 +251,7 @@
251251
//! ```
252252
//! # #[cfg(feature = "ristretto255")]
253253
//! # type CipherSuite = voprf::Ristretto255;
254-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
254+
//! # #[cfg(not(feature = "ristretto255"))]
255255
//! # type CipherSuite = p256::NistP256;
256256
//! # use voprf::VerifiableClient;
257257
//! # use rand::{rngs::OsRng, RngCore};
@@ -304,7 +304,7 @@
304304
//! ```
305305
//! # #[cfg(feature = "ristretto255")]
306306
//! # type CipherSuite = voprf::Ristretto255;
307-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
307+
//! # #[cfg(not(feature = "ristretto255"))]
308308
//! # type CipherSuite = p256::NistP256;
309309
//! # use voprf::VerifiableClient;
310310
//! # use rand::{rngs::OsRng, RngCore};
@@ -328,7 +328,7 @@
328328
//! ```
329329
//! # #[cfg(feature = "ristretto255")]
330330
//! # type CipherSuite = voprf::Ristretto255;
331-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
331+
//! # #[cfg(not(feature = "ristretto255"))]
332332
//! # type CipherSuite = p256::NistP256;
333333
//! # use voprf::{VerifiableServerBatchEvaluatePrepareResult, VerifiableServerBatchEvaluateFinishResult, VerifiableClient};
334334
//! # use rand::{rngs::OsRng, RngCore};
@@ -367,7 +367,7 @@
367367
//! # #[cfg(feature = "alloc")] {
368368
//! # #[cfg(feature = "ristretto255")]
369369
//! # type CipherSuite = voprf::Ristretto255;
370-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
370+
//! # #[cfg(not(feature = "ristretto255"))]
371371
//! # type CipherSuite = p256::NistP256;
372372
//! # use voprf::{VerifiableServerBatchEvaluateResult, VerifiableClient};
373373
//! # use rand::{rngs::OsRng, RngCore};
@@ -402,7 +402,7 @@
402402
//! # #[cfg(feature = "alloc")] {
403403
//! # #[cfg(feature = "ristretto255")]
404404
//! # type CipherSuite = voprf::Ristretto255;
405-
//! # #[cfg(all(feature = "p256", not(feature = "ristretto255")))]
405+
//! # #[cfg(not(feature = "ristretto255"))]
406406
//! # type CipherSuite = p256::NistP256;
407407
//! # use voprf::{VerifiableServerBatchEvaluateResult, VerifiableClient};
408408
//! # use rand::{rngs::OsRng, RngCore};
@@ -458,9 +458,6 @@
458458
//! - The `alloc` feature requires Rusts [`alloc`] crate and enables batching
459459
//! VOPRF evaluations.
460460
//!
461-
//! - The `p256` feature enables using [`NistP256`](p256::NistP256) as the
462-
//! underlying group for the [Group] choice.
463-
//!
464461
//! - The `serde` feature, enabled by default, provides convenience functions
465462
//! for serializing and deserializing with [serde](https://serde.rs/).
466463
//!
@@ -470,6 +467,9 @@
470467
//! that need access to these raw values and are able to perform the necessary
471468
//! validations on them (such as being valid group elements).
472469
//!
470+
//! - The `ristretto255-ciphersuite` features enables using [`Ristretto255`] as
471+
//! a [`CipherSuite`].
472+
//!
473473
//! - The `ristretto255` feature enables using [`Ristretto255`] as the
474474
//! underlying group for the [Group] choice. A backend feature, which are
475475
//! re-exported from [curve25519-dalek] and allow for selecting the

src/tests/voprf_test_vectors.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ macro_rules! json_to_test_vectors {
8585

8686
#[test]
8787
fn test_vectors() -> Result<()> {
88+
use p256::NistP256;
89+
8890
let rfc = json::parse(rfc_to_json(super::voprf_vectors::VECTORS).as_str())
8991
.expect("Could not parse json");
9092

@@ -115,29 +117,24 @@ fn test_vectors() -> Result<()> {
115117
test_verifiable_finalize::<Ristretto255>(&ristretto_verifiable_tvs)?;
116118
}
117119

118-
#[cfg(feature = "p256")]
119-
{
120-
use p256::NistP256;
120+
let p256base_tvs =
121+
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("Base"));
121122

122-
let p256base_tvs =
123-
json_to_test_vectors!(rfc, String::from("P-256, SHA-256"), String::from("Base"));
123+
let p256verifiable_tvs = json_to_test_vectors!(
124+
rfc,
125+
String::from("P-256, SHA-256"),
126+
String::from("Verifiable")
127+
);
124128

125-
let p256verifiable_tvs = json_to_test_vectors!(
126-
rfc,
127-
String::from("P-256, SHA-256"),
128-
String::from("Verifiable")
129-
);
130-
131-
test_base_seed_to_key::<NistP256>(&p256base_tvs)?;
132-
test_base_blind::<NistP256>(&p256base_tvs)?;
133-
test_base_evaluate::<NistP256>(&p256base_tvs)?;
134-
test_base_finalize::<NistP256>(&p256base_tvs)?;
129+
test_base_seed_to_key::<NistP256>(&p256base_tvs)?;
130+
test_base_blind::<NistP256>(&p256base_tvs)?;
131+
test_base_evaluate::<NistP256>(&p256base_tvs)?;
132+
test_base_finalize::<NistP256>(&p256base_tvs)?;
135133

136-
test_verifiable_seed_to_key::<NistP256>(&p256verifiable_tvs)?;
137-
test_verifiable_blind::<NistP256>(&p256verifiable_tvs)?;
138-
test_verifiable_evaluate::<NistP256>(&p256verifiable_tvs)?;
139-
test_verifiable_finalize::<NistP256>(&p256verifiable_tvs)?;
140-
}
134+
test_verifiable_seed_to_key::<NistP256>(&p256verifiable_tvs)?;
135+
test_verifiable_blind::<NistP256>(&p256verifiable_tvs)?;
136+
test_verifiable_evaluate::<NistP256>(&p256verifiable_tvs)?;
137+
test_verifiable_finalize::<NistP256>(&p256verifiable_tvs)?;
141138

142139
Ok(())
143140
}

src/util.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ mod unit_tests {
4242
{
4343
let _ = $item::<crate::Ristretto255>::deserialize(&$bytes[..]);
4444
}
45-
#[cfg(feature = "p256")]
46-
{
47-
let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]);
48-
}
45+
46+
let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]);
4947
};
5048
}
5149

src/voprf.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,8 @@ mod tests {
15581558

15591559
#[test]
15601560
fn test_functionality() -> Result<()> {
1561+
use p256::NistP256;
1562+
15611563
#[cfg(feature = "ristretto255")]
15621564
{
15631565
use crate::Ristretto255;
@@ -1575,22 +1577,17 @@ mod tests {
15751577
zeroize_verifiable_server::<Ristretto255>();
15761578
}
15771579

1578-
#[cfg(feature = "p256")]
1579-
{
1580-
use p256::NistP256;
1581-
1582-
base_retrieval::<NistP256>();
1583-
base_inversion_unsalted::<NistP256>();
1584-
verifiable_retrieval::<NistP256>();
1585-
verifiable_batch_retrieval::<NistP256>();
1586-
verifiable_bad_public_key::<NistP256>();
1587-
verifiable_batch_bad_public_key::<NistP256>();
1588-
1589-
zeroize_base_client::<NistP256>();
1590-
zeroize_base_server::<NistP256>();
1591-
zeroize_verifiable_client::<NistP256>();
1592-
zeroize_verifiable_server::<NistP256>();
1593-
}
1580+
base_retrieval::<NistP256>();
1581+
base_inversion_unsalted::<NistP256>();
1582+
verifiable_retrieval::<NistP256>();
1583+
verifiable_batch_retrieval::<NistP256>();
1584+
verifiable_bad_public_key::<NistP256>();
1585+
verifiable_batch_bad_public_key::<NistP256>();
1586+
1587+
zeroize_base_client::<NistP256>();
1588+
zeroize_base_server::<NistP256>();
1589+
zeroize_verifiable_client::<NistP256>();
1590+
zeroize_verifiable_server::<NistP256>();
15941591

15951592
Ok(())
15961593
}

0 commit comments

Comments
 (0)