Skip to content

Commit

Permalink
add flag to check for all zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
fxfactorial committed Jun 1, 2021
1 parent a264dac commit 8a6fe51
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
)

var (
signature = flag.String("selector", "", "selector given")
found bool = false
signature = flag.String("selector", "", "selector given")
mustBeZeros = flag.Bool("all_zeros", false, "force search for zeros")
found bool = false
)

// Perm calls f with each permutation of a.
Expand Down Expand Up @@ -48,19 +49,22 @@ func main() {
sig := *signature

atMost := []byte{0x00, 0x00, 0x00, 0xff}
wanted := []byte{0x00, 0x00, 0x00, 0x01}
wanted := []byte{0x00, 0x00, 0x00, 0x00}
started := time.Now()
p := *mustBeZeros

Perm([]rune("abcdefghijklmn"), func(a []rune) {
combined := string(a) + "(" + sig + ")"
b := crypto.Keccak256([]byte(combined))[:4]

if bytes.Equal(wanted, b) {
fmt.Println("FOUND after", time.Since(started), "signature should be", combined)
fmt.Println("FOUND exactly all zeros after",
time.Since(started), "signature should be", combined,
)
return
}

if bytes.Compare(b, atMost) == -1 {
if p == false && bytes.Compare(b, atMost) == -1 {
fmt.Println("this is good enough - can do ctrl-c now",
"use this as your signature",
combined, "found after",
Expand All @@ -72,4 +76,6 @@ func main() {
return
}
})

fmt.Println("odd didnt not find match - please report ticket ")
}

0 comments on commit 8a6fe51

Please sign in to comment.