Last active
February 6, 2020 21:10
-
-
Save brenzi/b715100763e73e44d1b164d6677b277c to your computer and use it in GitHub Desktop.
keystore playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use primitives::crypto::Pair; | |
use std::path::PathBuf; | |
use keystore::Store; | |
use app_crypto::{AppKey, AppPublic, AppPair, ed25519, sr25519}; | |
use primitives::crypto::{Ss58Codec}; | |
fn main() { | |
let password = String::from("password"); | |
let store_path = PathBuf::from("./keys/"); | |
let store = Store::open(store_path, Some(password.clone().into())).unwrap(); | |
let key: ed25519::AppPair = store.write().generate().unwrap(); | |
println!("[+] Generated new key and stored it: {}\n", key.public().to_ss58check()); | |
let pair: ed25519::AppPair = store | |
.write() | |
.insert("//some cow fonque") | |
.unwrap(); | |
// list all keys in the store | |
for pubkey in store.read().public_keys::<ed25519::AppPublic>().unwrap().into_iter() { | |
println!("stored: {}",pubkey.to_ss58check()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//
is for hard path derivation. You need///
for the password.