|
@@ -3,24 +3,21 @@ use sha2::Digest;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
#[derive(Clone, Debug)]
|
|
|
pub struct Address {
|
|
pub struct Address {
|
|
|
- pub raw: jubjub::SubgroupPoint,
|
|
|
|
|
pub hash: [u8; 32],
|
|
pub hash: [u8; 32],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl Address {
|
|
impl Address {
|
|
|
pub fn new(raw: jubjub::SubgroupPoint) -> Self {
|
|
pub fn new(raw: jubjub::SubgroupPoint) -> Self {
|
|
|
-
|
|
|
|
|
let mut hasher = sha2::Sha256::new();
|
|
let mut hasher = sha2::Sha256::new();
|
|
|
hasher.update(raw.to_bytes());
|
|
hasher.update(raw.to_bytes());
|
|
|
let hash: [u8; 32] = hasher.finalize().into();
|
|
let hash: [u8; 32] = hasher.finalize().into();
|
|
|
|
|
|
|
|
- Address { raw, hash }
|
|
|
|
|
|
|
+ Address { hash }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Address {
|
|
impl std::fmt::Display for Address {
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
-
|
|
|
|
|
// ripemd160 hash
|
|
// ripemd160 hash
|
|
|
let mut hasher = ripemd160::Ripemd160::new();
|
|
let mut hasher = ripemd160::Ripemd160::new();
|
|
|
hasher.update(self.hash);
|
|
hasher.update(self.hash);
|