Implement Hash for PublicKey.
This commit is contained in:
parent
cfde1f9925
commit
6686c213dd
|
@ -17,6 +17,8 @@
|
|||
//! Direct bindings to the underlying C library functions. These should
|
||||
//! not be needed for most users.
|
||||
use std::mem;
|
||||
use std::hash;
|
||||
|
||||
use libc::{c_int, c_uchar, c_uint, c_void, size_t};
|
||||
|
||||
/// Flag for context to enable no precomputation
|
||||
|
@ -65,6 +67,12 @@ impl PublicKey {
|
|||
pub unsafe fn blank() -> PublicKey { mem::uninitialized() }
|
||||
}
|
||||
|
||||
impl hash::Hash for PublicKey {
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
state.write(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Library-internal representation of a Secp256k1 signature
|
||||
#[repr(C)]
|
||||
pub struct Signature([c_uchar; 64]);
|
||||
|
|
|
@ -39,9 +39,10 @@ pub static ONE: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
|
|||
0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
|
||||
/// A Secp256k1 public key, used for verification of signatures
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct PublicKey(ffi::PublicKey);
|
||||
|
||||
|
||||
fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] {
|
||||
let mut ret = [0u8; 32];
|
||||
rng.fill_bytes(&mut ret);
|
||||
|
|
Loading…
Reference in New Issue