Code Monkey home page Code Monkey logo

stellar-vanity-address-generator's Introduction

Stellar Vanity

A simple CLI tool to generate Stellar vanity addresses.

Vanity Address: similar to a vanity license plate, a vanity cryptocurrency address is an address where either the beginning (prefix) or end (postfix) is a special or meaningful phrase. Generating such an address requires work.

Benchmarking

Benchmarking is performed by using criterion.rs via cargo bench, which executes the benches/benchmark.rs file.

How can I Benchmark?

Ah, thanks so much! I have limited computing power (if you do too... do not attempt, will likely be long and costly)

  1. git clone https://github.com/robertDurst/stellar-vanity-address-generator.git
  2. cd stellar-vanity-address-generator
  3. cargo bench

Benchmark Configurations:

  • as many threads as possible (see note below)
  • varied samples per method
  • 1 - 3 prefixes

Note: this uses num_cpus::get() from num_cpus to determine the maximum number of cores availible. If that is not desired, you'll have to dig in and set this number manually... or open a pr if you know how to pass CLI args to cargo bench :)

How to use library:

use stellar_vanity::vanity_key::AddressGenerator, deserialize_public_key};;

let mut generator: AddressGenerator = Default::default();
let keypair = generator.find(|key| {
    let public = deserialize_public_key(key);
    // any conditions go here
    public.as_str().ends_with("RUST") // e.g. find address with the "RUST" suffix
});

This will continuously loop until a key with the desired properties is found. Once the vanity address is found, a keypair will be returned, which may be deserialized with deserialize_public_key and deserialize_private_key respectively. Note, this is a synchronous function.

How to use CLI:

cargo run -- [--postfix=<POSTFIX>] [--prefix=<PREFIX>] [-c=<NUMBER_OF_THREADS>]

Either `--postfix` or `--prefix` option is required, while thread count is optional.

As an example, the following looks for an address ending in pizza with 8 threads:

cargo run -- -c=8 --postfix=pizza

The --prefix and --postfix options will search using RegEx expressions. You may need to enclose the expression in quotes when running from the command-line.

The following looks for an address ending in joe with a number before it, using 8 threads:

cargo run -- -c=8 --postfix='[0-9]joe'

stellar-vanity-address-generator's People

Contributors

charlie-wasp avatar fu5ha avatar josephgeis avatar robertdurst avatar synesso avatar thorhs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stellar-vanity-address-generator's Issues

Parallelize account generation

Allow for someone to specify a given number of threads:

cargo run <PREFIX> --threads=<THREADS>

and run this process in parallel.

This should be an optional flag, defaulting to just one (current functionality).

CLI Errors

I tried running the following commands before getting the following errors. What am I doing wrong here?

git clone [email protected]:robertDurst/stellar-vanity-address-generator.git
cd stellar-vanity-address-generator
cargo run -- -c=8 --postfix=p
charliefish@Charlies-MacBook-Pro stellar-vanity-address-generator % cargo run -- -c=8 --postfix=p
   Compiling stellar_vanity v0.5.0 (/Users/charliefish/stellar-vanity-address-generator)
error[E0277]: the trait bound `T: rand_core::CryptoRng` is not satisfied
   --> src/vanity_key/mod.rs:56:32
    |
51  |     T: Rng + CryptoRng,
    |                        - help: consider further restricting type parameter `T`: `, T: rand_core::CryptoRng`
...
56  |         Some(Keypair::generate(&mut self.rng))
    |                                ^^^^^^^^^^^^^ the trait `rand_core::CryptoRng` is not implemented for `T`
    | 
   ::: /Users/charliefish/.cargo/registry/src/github.com-1ecc6299db9ec823/ed25519-dalek-1.0.0-pre.3/src/ed25519.rs:130:12
    |
130 |         R: CryptoRng + RngCore,
    |            --------- required by this bound in `ed25519_dalek::Keypair::generate`

error[E0277]: the trait bound `T: rand_core::RngCore` is not satisfied
   --> src/vanity_key/mod.rs:56:32
    |
51  |     T: Rng + CryptoRng,
    |                        - help: consider further restricting type parameter `T`: `, T: rand_core::RngCore`
...
56  |         Some(Keypair::generate(&mut self.rng))
    |                                ^^^^^^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `T`
    | 
   ::: /Users/charliefish/.cargo/registry/src/github.com-1ecc6299db9ec823/ed25519-dalek-1.0.0-pre.3/src/ed25519.rs:130:24
    |
130 |         R: CryptoRng + RngCore,
    |                        ------- required by this bound in `ed25519_dalek::Keypair::generate`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `stellar_vanity`.

To learn more, run the command again with --verbose.

Cant compile

Ubuntu 20.04.5 LTS
i run - "cargo bench" get -

Compiling serde_cbor v0.11.2
error[E0599]: no method named difference found for struct backend::fs::types::AtFlags in the current scope
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustix-0.37.14/src/backend/linux_raw/fs/syscalls.rs:1396:10
|
1396 | .difference(AtFlags::EACCESS | AtFlags::SYMLINK_NOFOLLOW)
| ^^^^^^^^^^ method not found in backend::fs::types::AtFlags
|
::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustix-0.37.14/src/backend/linux_raw/fs/types.rs:23:1
|
23 | / bitflags! {
24 | | /// AT_* constants for use with [openat], [statat], and other *at
25 | | /// functions.
26 | | ///
... |
53 | | }
54 | | }
| |_- method difference not found for this struct

For more information about this error, try rustc --explain E0599.
error: could not compile rustix due to previous error
warning: build failed, waiting for other jobs to finish...

=(

Right now the command line interface is very non-intuitive

So, even though I wrote the original clap interface, I totally forgot how it worked -- took me many tries to eventually figure out the following (case sensitive) is correct:

cargo run -- --postfix=ROB

This probably requires documentation and code changes.

Benchmark

As we move to actually making this thing run a little faster (#7 and #8), it might be interesting to have some benchmark data.

Remove all dependencies

This is quite a long term goal, and even one that is rather unnecessary... NEVER EVER ROLL YOUR OWN CRYPTO!!!!
No!

Nevertheless, it would be cool to have written the entirety of this app from scratch.

Improve documentation

The following sections are needed:

  • how it works (the technical details)
  • contributing (Contributing.md)
  • move roadmap/todos to open issues

And possibly more, but this is a start...

Implement Improvement Suggestions

Johansten on Keybase had some good suggestions for improving the speed here:

Gotcha.. Quick thoughts:

  1. You don't need to randomize more than once. The first thing that ed25519 does with the seed anyway is run it through a hash. You can just += 1 for all the following seeds.
  2. You don't need to deserialize the privkey until you know the pubkey was a match
  3. You don't need to do the match in base32, convert your needle to binary instead and match it that way. You probably need a mask first, since you might end up with bitstrings w/ lengths that aren't multiples of eight.
  4. In #3, you don't need to calculate the checksum unless you have a partial match already

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.