mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-22 02:34:55 +00:00
Add support for hashing (as in HashMap) dalek points
This commit is contained in:
parent
0e8c55e050
commit
b1ea2dfba6
1 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue