-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvanity.go
72 lines (61 loc) · 1.25 KB
/
vanity.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"crypto/ed25519"
"crypto/rand"
"encoding/hex"
"fmt"
"os"
"sync/atomic"
"time"
"github.com/btcsuite/btcutil/base58"
)
// comp compares the input against two separate bytes
func comp(s, l1, l2 byte) bool {
return s == l1 || s == l2
}
var now = time.Now()
var i uint64
var targets []string
func toUpper(b byte) byte {
if 'a' <= b && b <= 'z' {
b -= 'a' - 'A'
}
return b
}
// goroutine loop
func find(sleep uint) {
for {
publicRaw, private, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
fmt.Println(err)
continue
}
public := base58.Encode(publicRaw)
for _, target := range targets {
matched := true
for i := range target {
if !comp(public[i], target[i], toUpper(target[i])) {
matched = false
break
}
}
if matched {
fmt.Printf("%s %s\n", public, hex.EncodeToString(private))
}
}
atomic.AddUint64(&i, 1)
if sleep > 0 {
time.Sleep(time.Microsecond * time.Duration(sleep))
}
}
}
// Start the goroutines using specified settings
func Start(sleep, conc uint) {
fmt.Fprintln(os.Stderr, "Starting...")
if conc > 1 {
for i := uint(0); i < conc-1; i++ {
go find(sleep)
}
}
find(sleep)
}