Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ repository = "https://github.com/robertDurst/stellar-vanity-address-generator"
license-file = "LICENSE"

[dependencies]
rand = "0.4"
sha2 = "0.7.0"
ed25519-dalek = "0.6.1"
rand = "0.6"
ed25519-dalek = "1.0.0-pre.1"
base32 = "0.3.1"
crc16 = "0.3.4"
bytes = "0.4.6"
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ extern crate bytes;
extern crate crc16;
extern crate ed25519_dalek;
extern crate rand;
extern crate sha2;

pub mod vanity_key;
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ fn main() {
let postfix = matches.value_of("POSTFIX").unwrap();

println!("\nSEARCHING INITIATED");

let (public_key, private_key) =
stellar_vanity::vanity_key::generate_vanity_key(&postfix.to_uppercase());

println!(
"\nSUCCESS!\nPublic Key: {:?}\nSecret Key: {:?}",
public_key, private_key
Expand Down
14 changes: 9 additions & 5 deletions src/vanity_key/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use rand::{Rng, OsRng};
use sha2::Sha512;
use rand::{Rng, CryptoRng};
use rand::rngs::OsRng;
use ed25519_dalek::Keypair;
use base32::encode;
use base32::Alphabet::RFC4648;
use crc16::*;
use byteorder::LittleEndian;
use bytes::{BufMut, BytesMut};

fn generate_random_key(rng: &mut Rng) -> (String, String) {
fn generate_random_key<A>(rng: &mut A) -> (String, String)
where A: Rng + CryptoRng
{
// Generate ED25519 key pair
let keypair: Keypair = Keypair::generate::<Sha512>(rng);
let keypair: Keypair = Keypair::generate(rng);

// ************** Encode the public key ***************** //
const VERSION_BYTE_ACCOUNT_ID: u8 = 6 << 3;
Expand Down Expand Up @@ -64,8 +66,10 @@ fn generate_random_key(rng: &mut Rng) -> (String, String) {
/// ````
pub fn generate_vanity_key(word: &str) -> (String, String) {
let start = 56 - word.len();

// Create cryptographically secure pseudorandom number generator
let mut rng: OsRng = OsRng::new().unwrap();
let mut rng = OsRng::new().unwrap();

loop {
let (public_key, private_key) = generate_random_key(&mut rng);
let three_letter = &public_key[start..];
Expand Down