Skip to content
Snippets Groups Projects
Commit df67684c authored by Cédric Moreau's avatar Cédric Moreau
Browse files

refact: simplify key displaying

parent b944c412
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,14 @@ impl std::fmt::Display for DuniterKey {
impl DuniterKey {
pub fn get_public_base58(&self) -> String {
bs58::encode(self.public).into_string()
}
pub fn get_secret_base58(&self) -> String {
bs58::encode(self.secret).into_string()
}
pub fn sign(&self, message: &str) -> DuniterSignature {
DuniterSignature::new(ed25519::signature(message.as_bytes(), &self.secret[..]))
}
......
......@@ -4,14 +4,11 @@ use crate::crypto::duniter_key::{DuniterKey, ToDuniterKey};
use crate::crypto::scrypt_duniter_key::ScryptDuniterKey;
pub fn compute_pub(sdk: impl ToDuniterKey) -> String {
String::from(sdk.derive().to_string().split(":").next().unwrap())
sdk.derive().get_public_base58()
}
pub fn compute_sec(sdk: impl ToDuniterKey) -> String {
let key_str = sdk.derive().to_string();
let mut split = key_str.split(":");
split.next();
String::from(split.next().unwrap())
sdk.derive().get_secret_base58()
}
pub fn compute_key(sdk: impl ToDuniterKey) -> String {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment