From 55d9dd960b90e7273006e491ada26c7677617cd7 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 13 Jan 2021 06:39:32 -0800 Subject: [PATCH] ecdsa: remove FieldBytes bounds These are no longer needed as of `ff` v0.9: https://github.com/zkcrypto/ff/pull/43 --- ecdsa/src/hazmat.rs | 4 ---- ecdsa/src/lib.rs | 1 - ecdsa/src/rfc6979.rs | 1 - ecdsa/src/sign.rs | 29 +++++++++-------------------- ecdsa/src/verify.rs | 39 +++++++++++++-------------------------- 5 files changed, 22 insertions(+), 52 deletions(-) diff --git a/ecdsa/src/hazmat.rs b/ecdsa/src/hazmat.rs index 34e78e5f..88f30c74 100644 --- a/ecdsa/src/hazmat.rs +++ b/ecdsa/src/hazmat.rs @@ -40,7 +40,6 @@ use elliptic_curve::{generic_array::ArrayLength, weierstrass::Curve}; pub trait SignPrimitive where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField>, SignatureSize: ArrayLength, { @@ -65,7 +64,6 @@ where pub trait RecoverableSignPrimitive where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField>, SignatureSize: ArrayLength, { @@ -87,7 +85,6 @@ impl SignPrimitive for T where C: Curve + ProjectiveArithmetic, T: RecoverableSignPrimitive, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField>, SignatureSize: ArrayLength, { @@ -111,7 +108,6 @@ where pub trait VerifyPrimitive where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField>, SignatureSize: ArrayLength, { diff --git a/ecdsa/src/lib.rs b/ecdsa/src/lib.rs index d5e8687a..a3d3b5c8 100644 --- a/ecdsa/src/lib.rs +++ b/ecdsa/src/lib.rs @@ -350,7 +350,6 @@ where impl CheckSignatureBytes for C where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'a> From<&'a Scalar>, Scalar: PrimeField>, SignatureSize: ArrayLength, { diff --git a/ecdsa/src/rfc6979.rs b/ecdsa/src/rfc6979.rs index 82083e6c..a34029f7 100644 --- a/ecdsa/src/rfc6979.rs +++ b/ecdsa/src/rfc6979.rs @@ -24,7 +24,6 @@ pub fn generate_k( where C: ProjectiveArithmetic, D: FixedOutput + BlockInput + Clone + Default + Reset + Update, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> + Zeroize, { diff --git a/ecdsa/src/sign.rs b/ecdsa/src/sign.rs index 04732453..4be829ec 100644 --- a/ecdsa/src/sign.rs +++ b/ecdsa/src/sign.rs @@ -50,7 +50,6 @@ use core::str::FromStr; pub struct SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> @@ -64,7 +63,6 @@ where impl SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> @@ -108,7 +106,6 @@ where impl From> for SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + ConstantTimeEq + FromDigest @@ -125,13 +122,12 @@ where impl DigestSigner> for SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, + D: FixedOutput + BlockInput + Clone + Default + Reset + Update, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, - D: FixedOutput + BlockInput + Clone + Default + Reset + Update, SignatureSize: ArrayLength, { /// Sign message prehash using a deterministic ephemeral scalar (`k`) @@ -149,15 +145,14 @@ where impl signature::Signer> for SigningKey where + Self: DigestSigner>, C: Curve + ProjectiveArithmetic + DigestPrimitive, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, SignatureSize: ArrayLength, - Self: DigestSigner>, { fn try_sign(&self, msg: &[u8]) -> Result, signature::Error> { self.try_sign_digest(C::Digest::new().chain(msg)) @@ -167,13 +162,12 @@ where impl RandomizedDigestSigner> for SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, + D: FixedOutput + BlockInput + Clone + Default + Reset + Update, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, - D: FixedOutput + BlockInput + Clone + Default + Reset + Update, SignatureSize: ArrayLength, { /// Sign message prehash using an ephemeral scalar (`k`) derived according @@ -198,15 +192,14 @@ where impl RandomizedSigner> for SigningKey where + Self: RandomizedDigestSigner>, C: Curve + ProjectiveArithmetic + DigestPrimitive, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, SignatureSize: ArrayLength, - Self: RandomizedDigestSigner>, { fn try_sign_with_rng( &self, @@ -220,7 +213,6 @@ where impl From> for SigningKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, Scalar: PrimeField> + FromDigest + Invert> @@ -239,14 +231,13 @@ where impl From<&SigningKey> for VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, + AffinePoint: Copy + Clone + Debug + Default, + ProjectivePoint: From>, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, - AffinePoint: Copy + Clone + Debug + Default, - ProjectivePoint: From>, SignatureSize: ArrayLength, { fn from(signing_key: &SigningKey) -> VerifyingKey { @@ -259,13 +250,12 @@ where impl FromPrivateKey for SigningKey where C: Curve + AlgorithmParameters + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, + AffinePoint: Copy + Clone + Debug + Default, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, - AffinePoint: Copy + Clone + Debug + Default, SignatureSize: ArrayLength, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, @@ -282,14 +272,13 @@ where impl FromStr for SigningKey where C: Curve + AlgorithmParameters + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, + AffinePoint: Copy + Clone + Debug + Default, + SignatureSize: ArrayLength, Scalar: PrimeField> + FromDigest + Invert> + SignPrimitive + Zeroize, - AffinePoint: Copy + Clone + Debug + Default, - SignatureSize: ArrayLength, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { diff --git a/ecdsa/src/verify.rs b/ecdsa/src/verify.rs index a6ad14d1..4ac92ff3 100644 --- a/ecdsa/src/verify.rs +++ b/ecdsa/src/verify.rs @@ -35,9 +35,8 @@ use core::str::FromStr; pub struct VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug, + Scalar: PrimeField>, { pub(crate) inner: PublicKey, } @@ -45,10 +44,9 @@ where impl VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { @@ -77,10 +75,9 @@ impl DigestVerifier> for VerifyingKey where C: Curve + ProjectiveArithmetic, D: Digest, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField> + FromDigest, AffinePoint: Copy + Clone + Debug + VerifyPrimitive, ProjectivePoint: From>, + Scalar: PrimeField> + FromDigest, SignatureSize: ArrayLength, { fn verify_digest(&self, digest: D, signature: &Signature) -> Result<(), Error> { @@ -94,10 +91,9 @@ impl signature::Verifier> for VerifyingKey where C: Curve + ProjectiveArithmetic + DigestPrimitive, C::Digest: Digest, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField> + FromDigest, AffinePoint: Copy + Clone + Debug + VerifyPrimitive, ProjectivePoint: From>, + Scalar: PrimeField> + FromDigest, SignatureSize: ArrayLength, { fn verify(&self, msg: &[u8], signature: &Signature) -> Result<(), Error> { @@ -108,10 +104,9 @@ where impl From<&VerifyingKey> for EncodedPoint where C: Curve + ProjectiveArithmetic + point::Compression, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { @@ -123,9 +118,8 @@ where impl From> for VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug, + Scalar: PrimeField>, { fn from(public_key: PublicKey) -> VerifyingKey { VerifyingKey { inner: public_key } @@ -135,9 +129,8 @@ where impl From<&PublicKey> for VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug, + Scalar: PrimeField>, { fn from(public_key: &PublicKey) -> VerifyingKey { public_key.clone().into() @@ -147,9 +140,8 @@ where impl From> for PublicKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug, + Scalar: PrimeField>, { fn from(verify_key: VerifyingKey) -> PublicKey { verify_key.inner @@ -159,9 +151,8 @@ where impl From<&VerifyingKey> for PublicKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug, + Scalar: PrimeField>, { fn from(verify_key: &VerifyingKey) -> PublicKey { verify_key.clone().into() @@ -171,10 +162,9 @@ where impl Eq for VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { @@ -183,10 +173,9 @@ where impl PartialEq for VerifyingKey where C: Curve + ProjectiveArithmetic, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { @@ -200,10 +189,9 @@ where impl FromPublicKey for VerifyingKey where C: Curve + AlgorithmParameters + ProjectiveArithmetic + point::Compression, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, { @@ -217,10 +205,9 @@ where impl FromStr for VerifyingKey where C: Curve + AlgorithmParameters + ProjectiveArithmetic + point::Compression, - FieldBytes: From> + for<'r> From<&'r Scalar>, - Scalar: PrimeField>, AffinePoint: Copy + Clone + Debug + Default + FromEncodedPoint + ToEncodedPoint, ProjectivePoint: From>, + Scalar: PrimeField>, UntaggedPointSize: Add + ArrayLength, UncompressedPointSize: ArrayLength, {