Skip to content

davidrhodus/vain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vain

Solana vanity address generator in C. GPU-accelerated via Metal on Apple Silicon.

Performance

Mode Throughput Method
Seed 357M/s Metal GPU + ARM SHA-256 hardware
Keypair 17M/s Metal GPU ed25519 scalar multiply

Benchmarks on Apple M1 Pro. Scales linearly across multiple Macs via built-in TCP distribution.

Build

Requires libsodium:

brew install libsodium

# CPU only
make

# CPU + Metal GPU (recommended on Apple Silicon)
make ENABLE_METAL=1

Usage

Keypair mode

Generates ed25519 keypairs. Output is Solana CLI compatible.

# Find address starting with "pipe"
./vain keypair -p pipe

# Case-insensitive, find 3 matches
./vain keypair -p dave -i -c 3

# Prefix + suffix
./vain keypair -p ab -s xyz

Output:

address: pipeMXQicFoESLebuk5TCMgwGQkhytF14HQ7ez1HxSJ
seed:    eff3550d4e6559fa...
keypair: [239,243,85,13,...,180,215]

Save the keypair line to a JSON file for use with Solana CLI:

./vain keypair -p cool 2>/dev/null | grep keypair | sed 's/keypair: //' > wallet.json
solana-keygen pubkey wallet.json

Seed mode

Grinds CreateAccountWithSeed seeds — much faster (SHA-256 only, no curve math).

./vain seed -p abc -b <base_pubkey> -o <owner_pubkey>

Options

-p <str>     Base58 prefix to match
-s <str>     Base58 suffix to match
-i           Case-insensitive matching
-t <N>       CPU thread count (default: all cores)
-c <N>       Number of matches to find (default: 1)
-b <pubkey>  Base public key (seed mode)
-o <pubkey>  Owner program public key (seed mode)

Distributed Mode

Run across multiple Macs over the network. Each machine uses its own CPU + GPU.

# Coordinator (parses args, accepts workers, grinds locally)
./vain keypair -p pipeNetwork --listen 9999

# Workers (connect, receive config, grind)
./vain keypair --connect 192.168.1.10:9999
./vain keypair --connect 192.168.1.10:9999  # add as many as you want

Throughput scales linearly. First match from any machine stops all nodes.

Architecture

src/main.c            CLI, pthreads, matching, output
src/base58.c          Firedancer O(1) base58 encoder + decoder
src/sha256_arm.c      ARM Crypto Extensions SHA-256
src/net.c             TCP coordinator/worker distribution
src/grind_seed.metal  Metal GPU kernel (SHA-256 + base58)
src/grind_keypair.metal  Metal GPU kernel (ed25519 + base58)
src/metal_grind.m     Metal host code (Obj-C)

Optimizations

  • Firedancer base58: precomputed table encoder, O(1) vs O(n²) division
  • Partial prefix check: early reject from first intermediate digits
  • ARM SHA-256: hardware crypto extensions for seed mode
  • SHA-512 precomputation: constant padding precomputed for keypair mode
  • Montgomery batch inversion: 8 keypairs share one fe_invert on GPU
  • Chain PRNG: SHA-512 output reuse eliminates RNG calls on GPU
  • Double-buffered Metal dispatch: overlaps GPU execution with result checking

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors