src: fix keypair problem
This commit is contained in:
parent
2f159241fa
commit
5b29f9fc12
19
src/main.rs
19
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
use clap::{load_yaml, App};
|
use clap::{load_yaml, App};
|
||||||
use ed25519_dalek::{ExpandedSecretKey, Keypair, PublicKey};
|
use ed25519_dalek::{SecretKey, PublicKey, Keypair};
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
@ -8,10 +8,6 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|
||||||
struct ExpandedKeypair {
|
|
||||||
public: PublicKey,
|
|
||||||
secret: ExpandedSecretKey,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = load_yaml!("options.yaml");
|
let options = load_yaml!("options.yaml");
|
||||||
|
@ -65,19 +61,12 @@ fn main() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace(".ed25519", "");
|
.replace(".ed25519", "");
|
||||||
let privkey = base64::decode(privkey).unwrap();
|
let privkey = base64::decode(privkey).unwrap();
|
||||||
let privkey = ExpandedSecretKey::from_bytes(privkey.as_slice()).unwrap();
|
let privkey = SecretKey::from_bytes(&privkey[00..32]).unwrap();
|
||||||
|
|
||||||
ExpandedKeypair {
|
Keypair { public: pubkey, secret: privkey }
|
||||||
public: pubkey,
|
|
||||||
secret: privkey,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let mut csprng = OsRng {};
|
let mut csprng = OsRng {};
|
||||||
let keypair = Keypair::generate(&mut csprng);
|
Keypair::generate(&mut csprng)
|
||||||
ExpandedKeypair {
|
|
||||||
public: keypair.public,
|
|
||||||
secret: ExpandedSecretKey::from(&keypair.secret),
|
|
||||||
}
|
|
||||||
// TODO: write this keypair to a fresh secret file
|
// TODO: write this keypair to a fresh secret file
|
||||||
};
|
};
|
||||||
println!("{:?}", keypair.public.to_bytes());
|
println!("{:?}", keypair.public.to_bytes());
|
||||||
|
|
Loading…
Reference in New Issue