Impled Hash for AffinePoint

This commit is contained in:
BGluth 2022-02-14 12:41:24 -07:00
parent 983c066b80
commit 1467732616
2 changed files with 13 additions and 1 deletions

View File

@ -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<C: Curve> PartialEq for AffinePoint<C> {
impl<C: Curve> Eq for AffinePoint<C> {}
impl<C: Curve> Hash for AffinePoint<C> {
fn hash<H: std::hash::Hasher>(&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<C: Curve> {

View File

@ -13,7 +13,7 @@ pub struct ECDSASignature<C: Curve> {
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ECDSASecretKey<C: Curve>(pub C::ScalarField);
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ECDSAPublicKey<C: Curve>(pub AffinePoint<C>);
pub fn sign_message<C: Curve>(msg: C::ScalarField, sk: ECDSASecretKey<C>) -> ECDSASignature<C> {