Skip to content

saicharanpogul/grincel.gpu

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Grincel - GPU Vanity Address Generator

A blazing-fast GPU-accelerated Solana vanity address generator written in Zig with Metal compute shaders.

License: Unlicense

โœจ Features

  • ๐ŸŽฎ GPU Acceleration - Metal compute shaders for parallel key generation
  • ๐Ÿš„ High Performance - 2+ Million keys per second on M1/M2/M3 Max
  • ๐ŸŽฏ Flexible Pattern Matching - Starts-with, ends-with, or both
  • ๐Ÿ”ข Target Counts - Generate multiple addresses per pattern
  • ๐Ÿ”  Case Options - Case-sensitive or case-insensitive matching
  • ๐Ÿ’พ Auto-Save - Found keypairs saved to JSON files
  • ๐Ÿ–ฅ๏ธ CLI Interface - Similar to solana-keygen grind
  • ๐ŸŽ macOS Native - Optimized for Apple Silicon (Metal)

๐Ÿ†• Recent Improvements

  • โœ… Optimized Performance - Fixed-Base Comb optimization yields ~2M keys/s (8x speedup)
  • โœ… Complete CLI Rewrite - Now supports --starts-with, --ends-with, --starts-and-ends-with
  • โœ… Metal GPU Backend - Real GPU acceleration with Verified 64-bit Ed25519
  • โœ… Multiple Patterns - Search for multiple patterns simultaneously
  • โœ… Target Counts - Specify how many matches you want per pattern
  • โœ… JSON Output - Each found keypair saved to <ADDRESS>.json

๐Ÿ› ๏ธ Building

Prerequisites

  • Zig 0.15.2
  • macOS with Metal support (for GPU acceleration)

Build Commands

# Build optimized release binary
zig build -Doptimize=ReleaseFast --global-cache-dir ./.zig-global-cache

# Run directly
zig build run --global-cache-dir ./.zig-global-cache -- --starts-with ABC:1

Note: Use --global-cache-dir if you encounter permission issues with Zig cache.

๐Ÿ“ฆ Installation

To install grincel for global usage:

  1. Build the release binary:
    zig build -Doptimize=ReleaseFast
  2. The executable will be located at zig-out/bin/grincel.
  3. Add it to your PATH or copy it to a bin directory:
    cp zig-out/bin/grincel /usr/local/bin/
  4. Verify installation:
    grincel --help

๐ŸŽฏ Usage

Command-Line Interface

# Find one address starting with "SOL"
zig build run -- --starts-with SOL:1

# Find 5 addresses ending with "ANA"
zig build run -- --ends-with ANA:5

# Find addresses starting with "CRT" and ending with "LESS"
zig build run -- --starts-and-ends-with CRT:LESS:1

# Case-insensitive matching
zig build run -- --starts-with abc:1 --ignore-case

# Multiple patterns at once
zig build run -- --starts-with SOL:2 --ends-with ANA:1 --ignore-case

CLI Options

Usage: grincel [options]
Options:
  --starts-with <PREFIX>[:COUNT]              Find addresses starting with PREFIX
  --ends-with <SUFFIX>[:COUNT]                Find addresses ending with SUFFIX
  --starts-and-ends-with <PRE>:<SUF>[:COUNT]  Find addresses starting with PRE and ending with SUF
  --ignore-case                               Case-insensitive matching
  --help, -h                                  Show this help

Output

Found keypairs are automatically saved to JSON files named <ADDRESS>.json. The format is a standard Solana keypair file (JSON array of 64 bytes), compatible with solana-cli.

[15,240,99,201,38,...]

You can import this wallet directly:

solana config set --keypair CRTtn6wqCH3WTxHwdPerR5rhkMfq9FtiZRmCyKjY69Zn.json

๐Ÿ—๏ธ Architecture

GPU Pipeline

graph LR
    A[CLI Args] --> B[Pattern Parser]
    B --> C[Metal Context]
    C --> D[GPU Shader]
    D --> E[SHA-512]
    E --> F[Ed25519]
    F --> G[Base58]
    G --> H[Pattern Match]
    H --> I[Results Buffer]
    I --> J[JSON Files]
Loading

Key Components

  • Metal Shader (src/shaders/vanity.metal) - GPU compute kernel with SHA-512, Ed25519, Base58
  • Objective-C Bridge (src/metal_bridge.m) - Interface to Metal APIs
  • Zig Integration (src/metal.zig) - Host-side GPU dispatch
  • Pattern System (src/pattern.zig) - Multi-mode pattern matching
  • CLI Parser (src/main.zig) - Argument parsing and main loop

๐Ÿš€ Performance

Current Status

The GPU implementation successfully calls custom Metal compute shaders. The infrastructure is complete with:

  • โœ… SHA-512 hashing on GPU
  • โœ… Base58 encoding on GPU
  • โœ… Pattern matching on GPU
  • โœ… Full 64-bit Ed25519 Arithmetic (Verified against CPU)
  • โœ… Fixed-Base Optimization (Comb Method w/ 64KB Tables)

Benchmarks

Device Speed Notes
Apple M1/M2/M3 Max ~2,000,000 keys/s 8x Faster than CPU
solana-keygen grind ~500,000 keys/s 12 CPU threads

Production Readiness

The generator produces cryptographically valid Solana keypairs. The Ed25519 implementation uses standard 5-limb 64-bit field arithmetic ("Ref10" logic) and has been verified against Python and CPU reference implementations for correctness. It properly handles scalar clamping, point multiplication, and encoding.

Note: While verified correct, this is experimental software. Always verify generated keys with a second tool if managing significant funds.

๐Ÿ“Š Examples

# Quick test
$ zig build run -- --starts-with gr:1
Using GPU backend: metal
Patterns current: 1
Case-sensitive: true
Searching for Solana addresses matching patterns...
Searched 262_144 keypairs in 0.13s. 0 matches found.
Searched 524_288 keypairs in 0.26s. 0 matches found.

[Pattern 0] Found match 1/1: grb4eR3RA7UY69XHVvb5FtTkoxezt7NnUvjeXjDGJCt

All target matches found!

๐Ÿ”ง Development

Project Structure

grincel.gpu/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.zig              # CLI entry point
โ”‚   โ”œโ”€โ”€ metal.zig             # Metal backend
โ”‚   โ”œโ”€โ”€ metal_bridge.m        # Objective-C bridge
โ”‚   โ”œโ”€โ”€ metal_bindings.zig    # Zig FFI
โ”‚   โ”œโ”€โ”€ pattern.zig           # Pattern matching
โ”‚   โ”œโ”€โ”€ search_state.zig      # Search state management
โ”‚   โ”œโ”€โ”€ ed25519.zig           # Ed25519 wrapper
โ”‚   โ”œโ”€โ”€ base58.zig            # Base58 encoding
โ”‚   โ””โ”€โ”€ shaders/
โ”‚       โ””โ”€โ”€ vanity.metal      # GPU compute shader
โ”œโ”€โ”€ build.zig                 # Build configuration
โ””โ”€โ”€ README.md

Adding Full Ed25519

The next major milestone is implementing complete Ed25519 in Metal:

  1. Field Arithmetic - Addition, subtraction, multiplication, squaring, inversion over GF(2^255-19)
  2. Point Operations - Point addition, doubling on Edwards curve
  3. Scalar Multiplication - Double-and-add or windowed method
  4. Key Derivation - SHA-512 based per RFC 8032

This will enable production-ready vanity address generation.

๐Ÿค Contributing

Contributions welcome! Key areas:

  • Full Ed25519 implementation in Metal
  • Performance optimizations
  • Cross-platform support (Vulkan for Linux/Windows)
  • Additional pattern matching modes

๐Ÿ“„ License

This project is released into the public domain under the Unlicense.

๐Ÿ™ Acknowledgments

  • Inspired by solana-keygen grind
  • Built with Zig and Metal
  • Ed25519 reference: RFC 8032

About

zig gpu vanity grinder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 85.4%
  • Zig 6.9%
  • Metal 5.1%
  • Python 1.1%
  • Objective-C 0.9%
  • C 0.3%
  • Other 0.3%