Skip to content

Commit 83eb78b

Browse files
authored
Test P-384 (#84)
1 parent 5badeff commit 83eb78b

File tree

7 files changed

+64
-0
lines changed

7 files changed

+64
-0
lines changed

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ p256 = { version = "=0.13.0-pre", default-features = false, features = [
4949
"hash2curve",
5050
"voprf",
5151
] }
52+
p384 = { version = "=0.13.0-pre", default-features = false, features = [
53+
"hash2curve",
54+
"voprf",
55+
] }
5256
proptest = "1"
5357
rand = "0.8"
5458
regex = "1"
@@ -62,3 +66,4 @@ targets = []
6266

6367
[patch.crates-io]
6468
p256 = { git = "https://github.com/RustCrypto/elliptic-curves", rev = "136fed7944d53c0508b1a93cd97bdab46891bcf7" }
69+
p384 = { git = "https://github.com/RustCrypto/elliptic-curves", rev = "136fed7944d53c0508b1a93cd97bdab46891bcf7" }

src/group/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{Error, Group, Result};
1515
#[test]
1616
fn test_group_properties() -> Result<()> {
1717
use p256::NistP256;
18+
use p384::NistP384;
1819

1920
#[cfg(feature = "ristretto255")]
2021
{
@@ -27,6 +28,9 @@ fn test_group_properties() -> Result<()> {
2728
test_identity_element_error::<NistP256>()?;
2829
test_zero_scalar_error::<NistP256>()?;
2930

31+
test_identity_element_error::<NistP384>()?;
32+
test_zero_scalar_error::<NistP384>()?;
33+
3034
Ok(())
3135
}
3236

src/oprf.rs

+8
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ mod tests {
425425
#[test]
426426
fn test_functionality() -> Result<()> {
427427
use p256::NistP256;
428+
use p384::NistP384;
428429

429430
#[cfg(feature = "ristretto255")]
430431
{
@@ -445,6 +446,13 @@ mod tests {
445446
zeroize_oprf_client::<NistP256>();
446447
zeroize_oprf_server::<NistP256>();
447448

449+
base_retrieval::<NistP384>();
450+
base_inversion_unsalted::<NistP384>();
451+
server_evaluate::<NistP384>();
452+
453+
zeroize_oprf_client::<NistP384>();
454+
zeroize_oprf_server::<NistP384>();
455+
448456
Ok(())
449457
}
450458
}

src/poprf.rs

+8
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ mod tests {
965965
#[test]
966966
fn test_functionality() -> Result<()> {
967967
use p256::NistP256;
968+
use p384::NistP384;
968969

969970
#[cfg(feature = "ristretto255")]
970971
{
@@ -985,6 +986,13 @@ mod tests {
985986
zeroize_verifiable_client::<NistP256>();
986987
zeroize_verifiable_server::<NistP256>();
987988

989+
verifiable_retrieval::<NistP384>();
990+
verifiable_bad_public_key::<NistP384>();
991+
verifiable_server_evaluate::<NistP384>();
992+
993+
zeroize_verifiable_client::<NistP384>();
994+
zeroize_verifiable_server::<NistP384>();
995+
988996
Ok(())
989997
}
990998
}

src/serialization.rs

+1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ mod test {
389389
}
390390

391391
let _ = $item::<p256::NistP256>::deserialize(&$bytes[..]);
392+
let _ = $item::<p384::NistP384>::deserialize(&$bytes[..]);
392393
};
393394
}
394395

src/tests/test_cfrg_vectors.rs

+28
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ macro_rules! json_to_test_vectors {
8787
#[test]
8888
fn test_vectors() -> Result<()> {
8989
use p256::NistP256;
90+
use p384::NistP384;
9091

9192
let rfc: Value = serde_json::from_str(rfc_to_json(super::cfrg_vectors::VECTORS).as_str())
9293
.expect("Could not parse json");
@@ -159,6 +160,33 @@ fn test_vectors() -> Result<()> {
159160
test_poprf_finalize::<NistP256>(&p256_poprf_tvs)?;
160161
test_poprf_evaluate::<NistP256>(&p256_poprf_tvs)?;
161162

163+
let p384_oprf_tvs =
164+
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("OPRF"));
165+
assert_ne!(p384_oprf_tvs.len(), 0);
166+
test_oprf_seed_to_key::<NistP384>(&p384_oprf_tvs)?;
167+
test_oprf_blind::<NistP384>(&p384_oprf_tvs)?;
168+
test_oprf_blind_evaluate::<NistP384>(&p384_oprf_tvs)?;
169+
test_oprf_finalize::<NistP384>(&p384_oprf_tvs)?;
170+
test_oprf_evaluate::<NistP384>(&p384_oprf_tvs)?;
171+
172+
let p384_voprf_tvs =
173+
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("VOPRF"));
174+
assert_ne!(p384_voprf_tvs.len(), 0);
175+
test_voprf_seed_to_key::<NistP384>(&p384_voprf_tvs)?;
176+
test_voprf_blind::<NistP384>(&p384_voprf_tvs)?;
177+
test_voprf_blind_evaluate::<NistP384>(&p384_voprf_tvs)?;
178+
test_voprf_finalize::<NistP384>(&p384_voprf_tvs)?;
179+
test_voprf_evaluate::<NistP384>(&p384_voprf_tvs)?;
180+
181+
let p384_poprf_tvs =
182+
json_to_test_vectors!(rfc, String::from("P384-SHA384"), String::from("POPRF"));
183+
assert_ne!(p384_poprf_tvs.len(), 0);
184+
test_poprf_seed_to_key::<NistP384>(&p384_poprf_tvs)?;
185+
test_poprf_blind::<NistP384>(&p384_poprf_tvs)?;
186+
test_poprf_blind_evaluate::<NistP384>(&p384_poprf_tvs)?;
187+
test_poprf_finalize::<NistP384>(&p384_poprf_tvs)?;
188+
test_poprf_evaluate::<NistP384>(&p384_poprf_tvs)?;
189+
162190
Ok(())
163191
}
164192

src/voprf.rs

+10
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ mod tests {
834834
#[test]
835835
fn test_functionality() -> Result<()> {
836836
use p256::NistP256;
837+
use p384::NistP384;
837838

838839
#[cfg(feature = "ristretto255")]
839840
{
@@ -858,6 +859,15 @@ mod tests {
858859
zeroize_voprf_client::<NistP256>();
859860
zeroize_voprf_server::<NistP256>();
860861

862+
verifiable_retrieval::<NistP384>();
863+
verifiable_batch_retrieval::<NistP384>();
864+
verifiable_bad_public_key::<NistP384>();
865+
verifiable_batch_bad_public_key::<NistP384>();
866+
verifiable_server_evaluate::<NistP384>();
867+
868+
zeroize_voprf_client::<NistP384>();
869+
zeroize_voprf_server::<NistP384>();
870+
861871
Ok(())
862872
}
863873
}

0 commit comments

Comments
 (0)