Skip to content

Commit

Permalink
add tezos prefix annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguang1010 committed Nov 11, 2020
1 parent dd51eb9 commit efef0b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tcx-tezos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ use tcx_chain::Result;
use tcx_primitive::{Ed25519PrivateKey, PrivateKey, PublicKey};

pub fn build_tezos_base58_private_key(sk: &str) -> Result<String> {
let edsk_prefix = [43 as u8, 246 as u8, 78 as u8, 7 as u8];
//tezos private key prefix
let edsk_prefix : [u8; 4] = [43 , 246, 78, 7];

//prefix + public key + public key
let mut prefixed_sec_key_vec = vec![];
prefixed_sec_key_vec.extend(&edsk_prefix);
let ed25519_private_key =
Ed25519PrivateKey::from_slice(hex::decode(sk).unwrap().as_slice()).unwrap();
prefixed_sec_key_vec.extend(&ed25519_private_key.to_bytes());
prefixed_sec_key_vec.extend(&ed25519_private_key.public_key().to_bytes());

Ok(base58::check_encode_slice(prefixed_sec_key_vec.as_slice()))
}

Expand Down

0 comments on commit efef0b1

Please sign in to comment.