forked from isgasho/vanity-age
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vanity-age.go
62 lines (49 loc) · 1.45 KB
/
vanity-age.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
package main
import (
"fmt"
"os"
"regexp"
"strings"
"time"
"filippo.io/age"
)
// Probably doesn't need to be any more than the number of cores you have
const THREADS = 4
func main() {
if len(os.Args) == 1 {
fmt.Println(`ERROR: No regular expression provided. Please specify a valid regular expression in the case of: regexp.MatchString("[your_regexp]", "age1*********************************************************"). age keys are 58 characters long, in all lowercase, excluding 'age1' prefix. Exceedingly notable to the author is that the charactes "b", "i", "o", and "1" after the first "1" in "age1" are not present in any age public key.`)
return
}
m, err := regexp.MatchString("[1bio]", os.Args[1])
if err != nil {
fmt.Println("ERROR: Unable to process this regexp")
fmt.Println(err.Error())
return
}
if m {
fmt.Println(`Query string contains one of: [1bio]`)
return
}
query := "^age1(" + strings.ToLower(os.Args[1]) + ")$"
keyChan := make(chan *age.X25519Identity)
for i := 0; i < THREADS; i++ {
go generate(query, keyChan)
}
key := <-keyChan
fmt.Println("Created: ", time.Now().Format(time.RFC3339))
fmt.Println("Public key: ", key.Recipient())
fmt.Println(key)
}
func generate(query string, keyChan chan *age.X25519Identity) {
for {
k, _ := age.GenerateX25519Identity()
m, err := regexp.MatchString(query, k.Recipient().String())
if err != nil {
fmt.Println(err.Error())
return
}
if m {
keyChan <- k
}
}
}