bless
This commit is contained in:
parent
954a7219b0
commit
5b9834519d
@ -38,21 +38,34 @@ fn verify_message(
|
||||
}
|
||||
|
||||
impl Wallet {
|
||||
pub fn verifying_key_to_address(private_key: &SigningKey) -> Address {
|
||||
let public_key = private_key.verifying_key();
|
||||
let public_key_bytes = public_key.to_encoded_point(false);
|
||||
let public_key_bytes = public_key_bytes.as_bytes();
|
||||
|
||||
let hash = Keccak256::digest(&public_key_bytes[1..]);
|
||||
|
||||
let mut address: Address;
|
||||
address.copy_from_slice(&hash[12..]);
|
||||
address
|
||||
}
|
||||
|
||||
pub fn address_from_pubkey(key: VerifyingKey) -> Address {
|
||||
let addr = key.to_encoded_point(true);
|
||||
}
|
||||
|
||||
fn new() -> Self {
|
||||
let key = SigningKey::random(&mut OsRng);
|
||||
let pub_key = key.verifying_key();
|
||||
let address = Self::verifying_key_to_address(&key);
|
||||
Self {
|
||||
nonce: 0,
|
||||
|
||||
balance: 0,
|
||||
address,
|
||||
private_key: key
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sign(&self, transaction: Tx) -> SignedTransaction {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user