diff --git a/Cargo.toml b/Cargo.toml index 27975a83..c12d0a28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,12 +17,12 @@ crate-type = ["lib"] [dependencies] cryptoxide = "0.1.2" curve25519-dalek = "3" -digest = "0.9" +digest = "0.10" generic-array = "0.14" typenum = "1.13" ff-zeroize = "0.6.3" hex = { version = "0.4", features = ["serde"] } -hmac = "0.11" +hmac = "0.12" thiserror = "1" lazy_static = "1.4" num-traits = "0.2" @@ -33,8 +33,8 @@ rand_legacy = { package = "rand", version = "0.6" } serde = { version = "1.0", features = ["derive"] } serde_bytes = "0.11" serde_derive = "1.0" -sha2 = "0.9" -sha3 = "0.9" +sha2 = "0.10" +sha3 = "0.10" old_sha2 = { package = "sha2", version = "0.8" } zeroize = "1" merkle-cbt = "0.3" @@ -47,7 +47,7 @@ version = "0.20" features = ["serde", "rand-std", "global-context"] [dependencies.p256] -version = "0.11.1" +version = "0.12" features = ["ecdsa", "ecdsa-core"] [dev-dependencies] @@ -56,7 +56,6 @@ serde_json = "1" paste = "1.0.2" proptest = "0.10" proptest-derive = "0.2" -blake2 = "0.9" [features] default = ["rust-gmp-kzen"] diff --git a/examples/diffie_hellman_key_exchange.rs b/examples/diffie_hellman_key_exchange.rs index 5671e54e..f969521a 100644 --- a/examples/diffie_hellman_key_exchange.rs +++ b/examples/diffie_hellman_key_exchange.rs @@ -38,7 +38,7 @@ fn main() { Some("bls12_381_1") => ecdh::(), Some("bls12_381_2") => ecdh::(), Some("p256") => ecdh::(), - Some(unknown_curve) => eprintln!("Unknown curve: {}", unknown_curve), + Some(unknown_curve) => eprintln!("Unknown curve: {unknown_curve}"), None => eprintln!("Missing curve name"), } } diff --git a/examples/pedersen_commitment.rs b/examples/pedersen_commitment.rs index a489ccca..ba1a2ad8 100644 --- a/examples/pedersen_commitment.rs +++ b/examples/pedersen_commitment.rs @@ -24,8 +24,7 @@ pub fn ped_com(message: &BigInt) { ); println!( - "\ncreated commitment with user defined randomness \n\n blinding_factor {} \n commitment: {:#?}", - blinding_factor, com + "\ncreated commitment with user defined randomness \n\n blinding_factor {blinding_factor} \n commitment: {com:#?}", ); } @@ -40,7 +39,7 @@ fn main() { Some("bls12_381_1") => ped_com::(&message_bn), Some("bls12_381_2") => ped_com::(&message_bn), Some("p256") => ped_com::(&message_bn), - Some(unknown_curve) => eprintln!("Unknown curve: {}", unknown_curve), + Some(unknown_curve) => eprintln!("Unknown curve: {unknown_curve}"), None => eprintln!("Missing curve name"), } } diff --git a/examples/proof_of_knowledge_of_dlog.rs b/examples/proof_of_knowledge_of_dlog.rs index 3727e931..5ee43adc 100644 --- a/examples/proof_of_knowledge_of_dlog.rs +++ b/examples/proof_of_knowledge_of_dlog.rs @@ -27,7 +27,7 @@ fn main() { Some("bls12_381_1") => dlog_proof::(), Some("bls12_381_2") => dlog_proof::(), Some("p256") => dlog_proof::(), - Some(unknown_curve) => eprintln!("Unknown curve: {}", unknown_curve), + Some(unknown_curve) => eprintln!("Unknown curve: {unknown_curve}"), None => eprintln!("Missing curve name"), } } diff --git a/examples/verifiable_secret_sharing.rs b/examples/verifiable_secret_sharing.rs index 9241648c..23b08ca4 100644 --- a/examples/verifiable_secret_sharing.rs +++ b/examples/verifiable_secret_sharing.rs @@ -66,7 +66,7 @@ fn main() { Some("bls12_381_1") => secret_sharing_3_out_of_5::(), Some("bls12_381_2") => secret_sharing_3_out_of_5::(), Some("p256") => secret_sharing_3_out_of_5::(), - Some(unknown_curve) => eprintln!("Unknown curve: {}", unknown_curve), + Some(unknown_curve) => eprintln!("Unknown curve: {unknown_curve}"), None => eprintln!("Missing curve name"), } } diff --git a/src/arithmetic/errors.rs b/src/arithmetic/errors.rs index 26ded60a..65d05441 100644 --- a/src/arithmetic/errors.rs +++ b/src/arithmetic/errors.rs @@ -20,7 +20,7 @@ impl fmt::Display for ParseBigIntError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.reason { #[cfg(feature = "rust-gmp-kzen")] - ParseErrorReason::Gmp(reason) => write!(f, "{}", reason), + ParseErrorReason::Gmp(reason) => write!(f, "{reason}"), #[cfg(feature = "num-bigint")] ParseErrorReason::NumBigint => { write!(f, "invalid {}-based number representation", self.radix) diff --git a/src/arithmetic/mod.rs b/src/arithmetic/mod.rs index e0beea0c..5f63b420 100644 --- a/src/arithmetic/mod.rs +++ b/src/arithmetic/mod.rs @@ -131,7 +131,7 @@ mod test { for (i, expect) in expectations.into_iter().enumerate() { let i = 7 - i - 1; - assert_eq!(n.test_bit(i), expect, "testing {} bit", i) + assert_eq!(n.test_bit(i), expect, "testing {i} bit") } } @@ -285,7 +285,7 @@ mod test { expected = expected.wrapping_mul(n); } } - assert_eq!(actual, BigInt::from(expected), "{} [{:?}] {}", was, op, n) + assert_eq!(actual, BigInt::from(expected), "{was} [{op:?}] {n}") } } diff --git a/src/cryptographic_primitives/commitments/hash_commitment.rs b/src/cryptographic_primitives/commitments/hash_commitment.rs index d7c9d66f..145dd85e 100644 --- a/src/cryptographic_primitives/commitments/hash_commitment.rs +++ b/src/cryptographic_primitives/commitments/hash_commitment.rs @@ -27,8 +27,8 @@ impl Commitment for HashCommitment { blinding_factor: &BigInt, ) -> BigInt { let digest_result = H::new() - .chain(message.to_bytes()) - .chain(blinding_factor.to_bytes()) + .chain_update(message.to_bytes()) + .chain_update(blinding_factor.to_bytes()) .finalize(); BigInt::from_bytes(digest_result.as_ref()) } @@ -47,11 +47,11 @@ mod tests { use super::SECURITY_BITS; use crate::arithmetic::traits::*; use crate::{test_for_all_hashes, BigInt}; - use digest::Digest; + use digest::{Digest, OutputSizeUser}; test_for_all_hashes!(test_bit_length_create_commitment); fn test_bit_length_create_commitment() { - let hex_len = H::output_size() * 8; + let hex_len = ::output_size() * 8; let mut ctr_commit_len = 0; let mut ctr_blind_len = 0; let sample_size = 10_000; @@ -77,7 +77,7 @@ mod tests { test_for_all_hashes!(test_bit_length_create_commitment_with_user_defined_randomness); fn test_bit_length_create_commitment_with_user_defined_randomness() { - let sec_bits = H::output_size() * 8; + let sec_bits = ::output_size() * 8; let message = BigInt::sample(sec_bits); let (_commitment, blind_factor) = HashCommitment::::create_commitment(&message); let commitment2 = HashCommitment::::create_commitment_with_user_defined_randomness( @@ -109,9 +109,9 @@ mod tests { &BigInt::zero(), ); let message2 = message.to_bytes(); - digest.update(&message2); + digest.update(message2); let bytes_blinding_factor = &BigInt::zero().to_bytes(); - digest.update(&bytes_blinding_factor); + digest.update(bytes_blinding_factor); let hash_result = BigInt::from_bytes(digest.finalize().as_ref()); assert_eq!(&commitment, &hash_result); } diff --git a/src/cryptographic_primitives/hashing/ext.rs b/src/cryptographic_primitives/hashing/ext.rs index c6a28512..a706c82d 100644 --- a/src/cryptographic_primitives/hashing/ext.rs +++ b/src/cryptographic_primitives/hashing/ext.rs @@ -1,8 +1,9 @@ -use digest::Digest; +use digest::block_buffer::Eager; +use digest::core_api::{BlockSizeUser, BufferKindUser, CoreProxy, FixedOutputCore, UpdateCore}; +use digest::{Digest, HashMarker, MacError, OutputSizeUser}; use generic_array::GenericArray; -use hmac::crypto_mac::MacError; -use hmac::{Hmac, Mac, NewMac}; -use typenum::Unsigned; +use hmac::{Hmac, Mac}; +use typenum::{IsLess, Le, NonZero, Unsigned, U256}; use crate::arithmetic::*; use crate::elliptic::curves::{Curve, ECScalar, Point, Scalar}; @@ -87,7 +88,7 @@ where D: Digest + Clone, { fn input_bigint(&mut self, n: &BigInt) { - self.update(&n.to_bytes()) + self.update(n.to_bytes()) } fn input_point(&mut self, point: &Point) { @@ -95,7 +96,7 @@ where } fn input_scalar(&mut self, scalar: &Scalar) { - self.update(&scalar.to_bigint().to_bytes()) + self.update(scalar.to_bigint().to_bytes()) } fn result_bigint(self) -> BigInt { @@ -106,15 +107,15 @@ where fn result_scalar(self) -> Scalar { let scalar_len = <::ScalarLength as Unsigned>::to_usize(); assert!( - Self::output_size() >= scalar_len, + ::output_size() >= scalar_len, "Output size of the hash({}) is smaller than the scalar length({})", - Self::output_size(), + ::output_size(), scalar_len ); // Try and increment. for i in 0u32.. { let starting_state = self.clone(); - let hash = starting_state.chain(i.to_be_bytes()).finalize(); + let hash = starting_state.chain_update(i.to_be_bytes()).finalize(); if let Ok(scalar) = Scalar::from_bytes(&hash[..scalar_len]) { return scalar; } @@ -123,7 +124,7 @@ where } fn digest_bigint(bytes: &[u8]) -> BigInt { - Self::new().chain(bytes).result_bigint() + Self::new().chain_update(bytes).result_bigint() } } @@ -147,7 +148,15 @@ pub trait HmacExt: Sized { impl HmacExt for Hmac where - D: digest::Update + digest::BlockInput + digest::FixedOutput + digest::Reset + Default + Clone, + D: CoreProxy, + D::Core: HashMarker + + UpdateCore + + FixedOutputCore + + BufferKindUser + + Default + + Clone, + ::BlockSize: IsLess, + Le<::BlockSize, U256>: NonZero, { fn new_bigint(key: &BigInt) -> Self { let bytes = key.to_bytes(); @@ -163,7 +172,7 @@ where } fn verify_bigint(self, code: &BigInt) -> Result<(), MacError> { - let mut code_array = GenericArray::::OutputSize>::default(); + let mut code_array = GenericArray::::OutputSize>::default(); let code_length = code_array.len(); let bytes = code.to_bytes(); if bytes.len() > code_length { @@ -176,8 +185,6 @@ where #[cfg(test)] mod test { - use digest::generic_array::ArrayLength; - use digest::{BlockInput, FixedOutput, Reset, Update}; use hmac::Hmac; use sha2::{Sha256, Sha512}; @@ -303,9 +310,15 @@ mod test { crate::test_for_all_hashes!(create_hmac_test); fn create_hmac_test() where - H: Update + BlockInput + FixedOutput + Reset + Default + Clone, - H::BlockSize: ArrayLength, - H::OutputSize: ArrayLength, + H: CoreProxy, + H::Core: HashMarker + + UpdateCore + + FixedOutputCore + + BufferKindUser + + Default + + Clone, + ::BlockSize: IsLess, + Le<::BlockSize, U256>: NonZero, { let key = BigInt::sample(512); let result1 = Hmac::::new_bigint(&key) diff --git a/src/cryptographic_primitives/hashing/merkle_tree.rs b/src/cryptographic_primitives/hashing/merkle_tree.rs index a83cced5..71fb492a 100644 --- a/src/cryptographic_primitives/hashing/merkle_tree.rs +++ b/src/cryptographic_primitives/hashing/merkle_tree.rs @@ -85,7 +85,7 @@ where type Item = Output; fn merge(left: &Self::Item, right: &Self::Item) -> Self::Item { - D::new().chain(left).chain(right).finalize() + D::new().chain_update(left).chain_update(right).finalize() } } diff --git a/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_enc.rs b/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_enc.rs index b152be03..4f71ac93 100644 --- a/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_enc.rs +++ b/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_enc.rs @@ -175,6 +175,6 @@ mod tests { E, }; let proof = HomoELGamalProof::::prove(&witness, &delta); - assert!(!proof.verify(&delta).is_ok()); + assert!(proof.verify(&delta).is_err()); } } diff --git a/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_encryption_of_dlog.rs b/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_encryption_of_dlog.rs index b85df09c..86e79f0a 100644 --- a/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_encryption_of_dlog.rs +++ b/src/cryptographic_primitives/proofs/sigma_correct_homomorphic_elgamal_encryption_of_dlog.rs @@ -144,6 +144,6 @@ mod tests { E, }; let proof = HomoELGamalDlogProof::::prove(&witness, &delta); - assert!(!proof.verify(&delta).is_ok()); + assert!(proof.verify(&delta).is_err()); } } diff --git a/src/cryptographic_primitives/proofs/sigma_ec_ddh.rs b/src/cryptographic_primitives/proofs/sigma_ec_ddh.rs index 1581038c..7faf0590 100644 --- a/src/cryptographic_primitives/proofs/sigma_ec_ddh.rs +++ b/src/cryptographic_primitives/proofs/sigma_ec_ddh.rs @@ -131,6 +131,6 @@ mod tests { }; let w = ECDDHWitness { x }; let proof = ECDDHProof::::prove(&w, &delta); - assert!(!proof.verify(&delta).is_ok()); + assert!(proof.verify(&delta).is_err()); } } diff --git a/src/elliptic/curves/bls12_381/g1.rs b/src/elliptic/curves/bls12_381/g1.rs index d1c8ba26..c7329969 100644 --- a/src/elliptic/curves/bls12_381/g1.rs +++ b/src/elliptic/curves/bls12_381/g1.rs @@ -298,7 +298,7 @@ mod tests { // Print in uncompressed form use pairing_plus::EncodedPoint; let point_uncompressed = G1Uncompressed::from_affine(point); - println!("Uncompressed base_point2: {:?}", point_uncompressed); + println!("Uncompressed base_point2: {point_uncompressed:?}"); // Check that ECPoint::base_point2() returns generated point let base_point2: &GE1 = ECPoint::base_point2(); diff --git a/src/elliptic/curves/bls12_381/g2.rs b/src/elliptic/curves/bls12_381/g2.rs index f455395e..702e5ed6 100644 --- a/src/elliptic/curves/bls12_381/g2.rs +++ b/src/elliptic/curves/bls12_381/g2.rs @@ -303,7 +303,7 @@ mod tests { // Print in uncompressed form let point_uncompressed = G2Uncompressed::from_affine(point); - println!("Uncompressed base_point2: {:?}", point_uncompressed); + println!("Uncompressed base_point2: {point_uncompressed:?}"); // Check that ECPoint::base_point2() returns generated point let base_point2: &G2Point = ECPoint::base_point2(); diff --git a/src/elliptic/curves/curve_ristretto.rs b/src/elliptic/curves/curve_ristretto.rs index 2d31834b..35a83c2e 100644 --- a/src/elliptic/curves/curve_ristretto.rs +++ b/src/elliptic/curves/curve_ristretto.rs @@ -36,7 +36,7 @@ lazy_static::lazy_static! { static ref BASE_POINT2: RistrettoPoint = { let g = RistrettoPoint::generator(); - let hash = Sha256::digest(g.serialize_compressed().as_ref()); + let hash = Sha256::digest(g.serialize_compressed()); RistrettoPoint { purpose: "base_point2", ge: RistrettoPoint::deserialize(&hash).unwrap().ge, diff --git a/src/elliptic/curves/ed25519.rs b/src/elliptic/curves/ed25519.rs index 2443bf87..21e65525 100644 --- a/src/elliptic/curves/ed25519.rs +++ b/src/elliptic/curves/ed25519.rs @@ -50,8 +50,8 @@ lazy_static::lazy_static! { static ref BASE_POINT2: Ed25519Point = { let bytes = GENERATOR.serialize_compressed(); - let hashed = sha2::Sha256::digest(bytes.as_ref()); - let hashed_twice = sha2::Sha256::digest(&hashed); + let hashed = sha2::Sha256::digest(bytes); + let hashed_twice = sha2::Sha256::digest(hashed); let p = Ed25519Point::deserialize(&hashed_twice).unwrap(); let eight = Ed25519Scalar::from_bigint(&BigInt::from(8)); Ed25519Point { diff --git a/src/elliptic/curves/p256.rs b/src/elliptic/curves/p256.rs index a720640f..5244adc3 100644 --- a/src/elliptic/curves/p256.rs +++ b/src/elliptic/curves/p256.rs @@ -410,8 +410,8 @@ mod tests { let base_point2 = GE::base_point2(); let g = GE::generator(); - let hash = Sha256::digest(g.serialize_compressed().as_ref()); - let hash = Sha256::digest(&hash); + let hash = Sha256::digest(g.serialize_compressed()); + let hash = Sha256::digest(hash); assert_eq!(BigInt::from_bytes(&hash), base_point2.x_coord().unwrap()); diff --git a/src/elliptic/curves/secp256_k1.rs b/src/elliptic/curves/secp256_k1.rs index a8b16694..c4558d7c 100644 --- a/src/elliptic/curves/secp256_k1.rs +++ b/src/elliptic/curves/secp256_k1.rs @@ -582,9 +582,9 @@ mod test { let base_point2 = GE::base_point2(); let g = GE::generator(); - let hash = Sha256::digest(&g.serialize_compressed()); - let hash = Sha256::digest(&hash); - let hash = Sha256::digest(&hash); + let hash = Sha256::digest(g.serialize_compressed()); + let hash = Sha256::digest(hash); + let hash = Sha256::digest(hash); assert_eq!(BigInt::from_bytes(&hash), base_point2.x_coord().unwrap()); diff --git a/src/elliptic/curves/wrappers/serde_support.rs b/src/elliptic/curves/wrappers/serde_support.rs index 1604a728..2f4f7283 100644 --- a/src/elliptic/curves/wrappers/serde_support.rs +++ b/src/elliptic/curves/wrappers/serde_support.rs @@ -171,7 +171,7 @@ impl<'de, E: Curve> Deserialize<'de> for PointFromBytes { where Err: Error, { - Point::from_bytes(v).map_err(|e| Err::custom(format!("invalid point: {}", e))) + Point::from_bytes(v).map_err(|e| Err::custom(format!("invalid point: {e}"))) } // serde_json serializes bytes as a sequence of u8, so we need to support this format too @@ -200,20 +200,19 @@ impl<'de, E: Curve> Deserialize<'de> for PointFromBytes { if seq.next_element::()?.is_some() { return Err(A::Error::invalid_length( seq_len_hint.unwrap_or(seq_len + 1), - &format!("either {} or {} bytes", compressed_len, uncompressed_len) + &format!("either {compressed_len} or {uncompressed_len} bytes") .as_str(), )); } } else if seq_len != compressed_len { return Err(A::Error::invalid_length( seq_len_hint.unwrap_or(seq_len), - &format!("either {} or {} bytes", compressed_len, uncompressed_len) - .as_str(), + &format!("either {compressed_len} or {uncompressed_len} bytes").as_str(), )); } Point::from_bytes(&buffer.as_slice()[..seq_len]) - .map_err(|e| A::Error::custom(format!("invalid point: {}", e))) + .map_err(|e| A::Error::custom(format!("invalid point: {e}"))) } fn visit_str(self, v: &str) -> Result @@ -230,12 +229,12 @@ impl<'de, E: Curve> Deserialize<'de> for PointFromBytes { hex::decode_to_slice(v, &mut buffer) .map_err(|_| Err::custom("malformed hex encoding"))?; Point::from_bytes(&buffer) - .map_err(|e| Err::custom(format!("invalid point: {}", e)))? + .map_err(|e| Err::custom(format!("invalid point: {e}")))? } else if compressed_len * 2 == v.len() { hex::decode_to_slice(v, &mut buffer[..compressed_len]) .map_err(|_| Err::custom("malformed hex encoding"))?; Point::from_bytes(&buffer[..compressed_len]) - .map_err(|e| Err::custom(format!("invalid point: {}", e)))? + .map_err(|e| Err::custom(format!("invalid point: {e}")))? } else { return Err(Err::custom("invalid point")); }; @@ -390,7 +389,7 @@ impl<'de, E: Curve> Deserialize<'de> for ScalarFromBytes { None => { return Err(A::Error::invalid_length( i, - &format!("{} bytes", expected_len).as_str(), + &format!("{expected_len} bytes").as_str(), )) } }; @@ -400,7 +399,7 @@ impl<'de, E: Curve> Deserialize<'de> for ScalarFromBytes { if seq.next_element::()?.is_some() { return Err(A::Error::invalid_length( seq_len_hint.unwrap_or(expected_len + 1), - &format!("{} bytes", expected_len).as_str(), + &format!("{expected_len} bytes").as_str(), )); } @@ -461,7 +460,7 @@ mod serde_tests { fn serializes_deserializes_point() { let random_point = Point::::generator() * Scalar::random(); for point in [Point::zero(), random_point] { - println!("Point: {:?}", point); + println!("Point: {point:?}"); let bytes = point.to_bytes(true).to_vec(); let tokens = [ Struct { @@ -481,7 +480,7 @@ mod serde_tests { test_for_all_curves!(serializes_deserializes_scalar); fn serializes_deserializes_scalar() { for scalar in [Scalar::::zero(), Scalar::random()] { - println!("Scalar: {:?}", scalar); + println!("Scalar: {scalar:?}"); let bytes = scalar.to_bytes().to_vec(); let tokens = [ Struct { @@ -502,7 +501,7 @@ mod serde_tests { fn deserializes_point_from_seq_of_bytes() { let random_point = Point::::generator() * Scalar::random(); for point in [Point::zero(), random_point] { - println!("Point: {:?}", point); + println!("Point: {point:?}"); let bytes = point.to_bytes(true); let mut tokens = vec![ Struct { @@ -525,7 +524,7 @@ mod serde_tests { test_for_all_curves!(deserializes_scalar_from_seq_of_bytes); fn deserializes_scalar_from_seq_of_bytes() { for scalar in [Scalar::::zero(), Scalar::random()] { - println!("Scalar: {:?}", scalar); + println!("Scalar: {scalar:?}"); let bytes = scalar.to_bytes(); let mut tokens = vec![ Struct { diff --git a/src/test_utils.rs b/src/test_utils.rs index 6be2e279..cc150b89 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -2,19 +2,19 @@ #[macro_export] macro_rules! test_for_all_curves { (#[should_panic] $fn: ident) => { - crate::test_for_all_curves!([#[should_panic]] $fn); + $crate::test_for_all_curves!([#[should_panic]] $fn); }; ($fn: ident) => { - crate::test_for_all_curves!([] $fn); + $crate::test_for_all_curves!([] $fn); }; ([$($attrs:tt)*] $fn: ident) => { - crate::test_for_all!{[$($attrs)*] $fn => - secp256k1 = crate::elliptic::curves::Secp256k1, - p256 = crate::elliptic::curves::Secp256r1, - ed25519 = crate::elliptic::curves::Ed25519, - ristretto = crate::elliptic::curves::Ristretto, - bls12_381_1 = crate::elliptic::curves::Bls12_381_1, - bls12_381_2 = crate::elliptic::curves::Bls12_381_2, + $crate::test_for_all!{[$($attrs)*] $fn => + secp256k1 = $crate::elliptic::curves::Secp256k1, + p256 = $crate::elliptic::curves::Secp256r1, + ed25519 = $crate::elliptic::curves::Ed25519, + ristretto = $crate::elliptic::curves::Ristretto, + bls12_381_1 = $crate::elliptic::curves::Bls12_381_1, + bls12_381_2 = $crate::elliptic::curves::Bls12_381_2, } }; } @@ -23,19 +23,17 @@ macro_rules! test_for_all_curves { #[macro_export] macro_rules! test_for_all_hashes { (#[should_panic] $fn: ident) => { - crate::test_for_all_hashes!([#[should_panic]] $fn); + $crate::test_for_all_hashes!([#[should_panic]] $fn); }; ($fn: ident) => { - crate::test_for_all_hashes!([] $fn); + $crate::test_for_all_hashes!([] $fn); }; ([$($attrs:tt)*] $fn: ident) => { - crate::test_for_all!{[$($attrs)*] $fn => + $crate::test_for_all!{[$($attrs)*] $fn => sha256 = sha2::Sha256, sha512 = sha2::Sha512, sha3_256 = sha3::Sha3_256, sha3_512 = sha3::Sha3_512, - blake2b = blake2::Blake2b, - blake2s = blake2::Blake2s, } }; } @@ -52,7 +50,7 @@ macro_rules! test_for_all { $fn::<$inst>() } } - crate::test_for_all!([$($attrs)*] $fn => $($rest)*); + $crate::test_for_all!([$($attrs)*] $fn => $($rest)*); }; } @@ -60,28 +58,28 @@ macro_rules! test_for_all { #[macro_export] macro_rules! test_for_all_curves_and_hashes { (#[should_panic] $fn: ident) => { - crate::test_for_all_curves_and_hashes!([#[should_panic]] $fn); + $crate::test_for_all_curves_and_hashes!([#[should_panic]] $fn); }; ($fn: ident) => { - crate::test_for_all_curves_and_hashes!([] $fn); + $crate::test_for_all_curves_and_hashes!([] $fn); }; ([$($attrs:tt)*] $fn: ident) => { - crate::test_for_all_curves_and_hashes!{compose: [$($attrs)*] $fn => - secp256k1 = crate::elliptic::curves::Secp256k1, - p256 = crate::elliptic::curves::Secp256r1, - ed25519 = crate::elliptic::curves::Ed25519, - ristretto = crate::elliptic::curves::Ristretto, - bls12_381_1 = crate::elliptic::curves::Bls12_381_1, - bls12_381_2 = crate::elliptic::curves::Bls12_381_2, + $crate::test_for_all_curves_and_hashes!{compose: [$($attrs)*] $fn => + secp256k1 = $crate::elliptic::curves::Secp256k1, + p256 = $crate::elliptic::curves::Secp256r1, + ed25519 = $crate::elliptic::curves::Ed25519, + ristretto = $crate::elliptic::curves::Ristretto, + bls12_381_1 = $crate::elliptic::curves::Bls12_381_1, + bls12_381_2 = $crate::elliptic::curves::Bls12_381_2, } }; (compose: [$($attrs:tt)*] $fn: ident =>) => {}; (compose: [$($attrs:tt)*] $fn: ident => $inst_name: ident = $inst:path, $($rest: tt)*) => { - crate::test_for_all_curves_and_hashes!{private: [$($attrs)*] $fn => + $crate::test_for_all_curves_and_hashes!{private: [$($attrs)*] $fn => $inst_name = $inst | sha256 = sha2::Sha256, $inst_name = $inst | sha512 = sha2::Sha512, } - crate::test_for_all_curves_and_hashes!(compose: [$($attrs)*] $fn => $($rest)*); + $crate::test_for_all_curves_and_hashes!(compose: [$($attrs)*] $fn => $($rest)*); }; (private: [$($attrs:tt)*] $fn: ident =>) => {}; (private: [$($attrs:tt)*] $fn:ident => $inst_name1:ident = $inst1: path | $inst_name2:ident = $inst2:path, $($rest: tt)*) => { @@ -92,6 +90,6 @@ macro_rules! test_for_all_curves_and_hashes { $fn::<$inst1, $inst2>() } } - crate::test_for_all_curves_and_hashes!(private: [$($attrs)*] $fn => $($rest)*); + $crate::test_for_all_curves_and_hashes!(private: [$($attrs)*] $fn => $($rest)*); }; }