├── LICENSE ├── README.md └── ethvanity.go /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ethvanity 2 | Generate an ethereum address that starts with some prefix 3 | 4 | ### installation 5 | 6 | You need to install golang 1.8, first, check https://golang.org/ 7 | 8 | Just drop into the command line: 9 | 10 | `go get github.com/adriamb/ethvanity` 11 | 12 | ### execution 13 | 14 | `~/go/bin/ethvanity ` 15 | 16 | It will find an account that starts with a prefix (hexdecimal lowercase), 17 | using the specified threads (gorutines), e.g. 18 | 19 | `~/go/bin/ethvanity 5 ab1a` 20 | 21 | Will output a private key with an account that starts with 0xab1a 22 | -------------------------------------------------------------------------------- /ethvanity.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | "crypto/rand" 6 | "encoding/hex" 7 | "log" 8 | "math" 9 | "os" 10 | "strconv" 11 | "strings" 12 | "sync/atomic" 13 | 14 | "github.com/ethereum/go-ethereum/crypto" 15 | "github.com/ethereum/go-ethereum/crypto/secp256k1" 16 | ) 17 | 18 | func main() { 19 | 20 | if len(os.Args) != 3 { 21 | log.Fatal("Usage ethvanity ") 22 | } 23 | 24 | concurrency, err := strconv.Atoi(os.Args[1]) 25 | if err != nil { 26 | log.Fatal("Bad concurrency parameter") 27 | } 28 | prefix := os.Args[2] 29 | 30 | var combinations = math.Pow(16, float64(len(prefix))) 31 | 32 | log.Println("Generating key with address starting with", prefix, "using", concurrency, "threads") 33 | log.Println("Total combinations are", uint64(combinations)) 34 | 35 | var counter uint64 = 0 36 | var finished = make(chan bool) 37 | 38 | for i := 0; i < concurrency; i++ { 39 | 40 | go func() { 41 | 42 | for { 43 | 44 | atomic.AddUint64(&counter, 1) 45 | if counter%25000 == 0 { 46 | current := (float64(counter) * 100) / combinations 47 | log.Printf("%v (%.3f %%)", counter, current) 48 | } 49 | 50 | k, err := ecdsa.GenerateKey(secp256k1.S256(), rand.Reader) 51 | if err != nil { 52 | log.Fatal(err) 53 | } 54 | 55 | address := crypto.PubkeyToAddress(k.PublicKey) 56 | addressStr := hex.EncodeToString(address[:]) 57 | 58 | if strings.HasPrefix(addressStr, os.Args[2]) { 59 | 60 | pvkStr := hex.EncodeToString(crypto.FromECDSA(k)) 61 | log.Println("\n\nFOUND address=[", addressStr, "] pvk=[", pvkStr, "]") 62 | 63 | finished <- true 64 | 65 | } 66 | } 67 | }() 68 | } 69 | 70 | <-finished 71 | } 72 | --------------------------------------------------------------------------------