Add support for hashing (as in HashMap) dalek points

This commit is contained in:
Luke Parker 2023-03-07 03:10:55 -05:00
parent 0e8c55e050
commit b1ea2dfba6
No known key found for this signature in database

View file

@ -2,9 +2,10 @@
#![no_std]
use core::{
ops::{Deref, Add, AddAssign, Sub, SubAssign, Neg, Mul, MulAssign},
borrow::Borrow,
ops::{Deref, Add, AddAssign, Sub, SubAssign, Neg, Mul, MulAssign},
iter::{Iterator, Sum},
hash::{Hash, Hasher},
};
use zeroize::Zeroize;
@ -413,6 +414,16 @@ macro_rules! dalek_group {
$Point(&b.0 * &self.0)
}
}
// Support being used as a key in a table
// While it is expensive as a key, due to the field operations required, there's frequently
// use cases for public key -> value lookups
#[allow(clippy::derived_hash_with_manual_eq)]
impl Hash for $Point {
fn hash<H: Hasher>(&self, state: &mut H) {
self.to_bytes().hash(state);
}
}
};
}