Skip to content

Instantly share code, notes, and snippets.

@brenzi
Last active February 6, 2020 21:10
Show Gist options
  • Save brenzi/b715100763e73e44d1b164d6677b277c to your computer and use it in GitHub Desktop.
Save brenzi/b715100763e73e44d1b164d6677b277c to your computer and use it in GitHub Desktop.
keystore playground
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());
}
}
@joepetrowski
Copy link

// is for hard path derivation. You need /// for the password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment