mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add support for hashing (as in HashMap) dalek points
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
ops::{Deref, Add, AddAssign, Sub, SubAssign, Neg, Mul, MulAssign},
|
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
|
ops::{Deref, Add, AddAssign, Sub, SubAssign, Neg, Mul, MulAssign},
|
||||||
iter::{Iterator, Sum},
|
iter::{Iterator, Sum},
|
||||||
|
hash::{Hash, Hasher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
@@ -413,6 +414,16 @@ macro_rules! dalek_group {
|
|||||||
$Point(&b.0 * &self.0)
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user