diff options
Diffstat (limited to 'src/account.rs')
| -rw-r--r-- | src/account.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/account.rs b/src/account.rs index 7d1eeb5..6233f6a 100644 --- a/src/account.rs +++ b/src/account.rs @@ -25,10 +25,15 @@ impl PrivateKey { Ok(PrivateKey(key)) } + /// Returns the public key for the private key. + pub fn public(&self) -> PublicKey { + let secp = Secp256k1::signing_only(); + PublicKey::from_secret_key(&secp, &self.0) + } + /// Returns the public address for the private key. pub fn address(&self) -> Address { - let secp = Secp256k1::signing_only(); - let public_key = PublicKey::from_secret_key(&secp, &self.0).serialize_uncompressed(); + let public_key = self.public().serialize_uncompressed(); // NOTE: An ethereum address is the last 20 bytes of the keccak hash of // the public key. Note that `libsecp256k1` public key is serialized |
