-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprettyaddr.go
More file actions
43 lines (38 loc) · 918 Bytes
/
prettyaddr.go
File metadata and controls
43 lines (38 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"bytes"
"flag"
"fmt"
"log"
"github.com/ethereum/go-ethereum/crypto"
)
var numZeros int
var numThreads int
func init() {
flag.IntVar(&numZeros, "num-zeros", 1, "Number of zero bytes at the end of address")
flag.IntVar(&numThreads, "num-threads", 4, "Number of threads to mine")
flag.Parse()
}
func main() {
done := make(chan interface{})
for i := 0; i < numThreads; i++ {
go genKey(numZeros, done)
}
<-done
}
func genKey(numZeros int, done chan<- interface{}) {
bs := make([]byte, numZeros)
for {
sk, err := crypto.GenerateKey()
if err != nil {
log.Panic(err.Error())
}
addr := crypto.PubkeyToAddress(sk.PublicKey)
if bytes.Equal(addr.Bytes()[20-numZeros:], bs) {
fmt.Printf("Private Key: %x\n", crypto.FromECDSA(sk))
fmt.Printf("Public Key: %x\n", crypto.FromECDSAPub(&sk.PublicKey))
fmt.Printf("ETH Address: %s\n", addr.Hex())
done <- nil
}
}
}