diff --git a/plonky2/src/curve/curve_types.rs b/plonky2/src/curve/curve_types.rs index 15f80bc6..264120c7 100644 --- a/plonky2/src/curve/curve_types.rs +++ b/plonky2/src/curve/curve_types.rs @@ -1,4 +1,5 @@ use std::fmt::Debug; +use std::hash::Hash; use std::ops::Neg; use plonky2_field::field_types::{Field, PrimeField}; @@ -120,6 +121,17 @@ impl PartialEq for AffinePoint { impl Eq for AffinePoint {} +impl Hash for AffinePoint { + fn hash(&self, state: &mut H) { + if self.zero { + self.zero.hash(state); + } else { + self.x.hash(state); + self.y.hash(state); + } + } +} + /// A point on a short Weierstrass curve, represented in projective coordinates. #[derive(Copy, Clone, Debug)] pub struct ProjectivePoint { diff --git a/plonky2/src/curve/ecdsa.rs b/plonky2/src/curve/ecdsa.rs index 11e05535..cabe038a 100644 --- a/plonky2/src/curve/ecdsa.rs +++ b/plonky2/src/curve/ecdsa.rs @@ -13,7 +13,7 @@ pub struct ECDSASignature { #[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ECDSASecretKey(pub C::ScalarField); -#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ECDSAPublicKey(pub AffinePoint); pub fn sign_message(msg: C::ScalarField, sk: ECDSASecretKey) -> ECDSASignature {