Skip to content

Commit

Permalink
Add match timetable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderYastrebov committed Feb 11, 2025
1 parent f3ae8a6 commit 8bbe7e7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,23 @@ PASS
ok github.com/AlexanderYastrebov/wireguard-vanity-key 21.154s
```

Time to get n-symbol prefix at rate 18'000'000 keys per second with probability of:
```
n 50% 95% 99%
4 0:00:01 0:00:03 0:00:04
5 0:00:41 0:02:59 0:04:35
6 0:44:06 3:10:37 4:53:01
7 1 day, 23:02:41 8 days, 11:19:25 13 days, 0:33:28
8 125 days, 10:51:28 542 days, 4:42:40 833 days, 11:42:23
```
I.e. you may expect a match for a 5 character prefix after
41 seconds 50% of the time and after 4-5 minutes to be 99% sure.

## Similar projects

* [wireguard-vanity-address](https://github.com/warner/wireguard-vanity-address)
* [wireguard-vanity-keygen](https://github.com/axllent/wireguard-vanity-keygen)
* [Wireguard-Vanity-Key-Searcher](https://github.com/volleybus/Wireguard-Vanity-Key-Searcher)
* [wgmine](https://github.com/thatsed/wgmine)
* [Vanity](https://github.com/samuel-lucas6/Vanity)
* [mkp224o](https://github.com/cathugger/mkp224o)
33 changes: 33 additions & 0 deletions matchtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
'''
Prints the time table it would take for the number of trials t at rate r
to get at least 1 match with n characters of base b and a probability p with the formula
t = log(1-p)/log(1-1/b^n)
See https://github.com/cathugger/mkp224o/issues/27#issuecomment-568291087
'''
import math
import datetime

R = 18_000_000
P = [50, 95, 99]
N = [4, 5, 6, 7, 8]
B = 64

def t(p, n):
return math.log(1 - p/100) / math.log(1 - 1/B**n)

print('Time to get n-symbol match at rate {R} trials per second with probability of:')
print('n', end='')
for p in P:
print(f' {p:19d}%', end='')
print()

for n in N:
print(n, end='')
for p in P:
v = t(p, n) / R
s = str(datetime.timedelta(seconds=round(v)))
print(f' {s:>20}', end='')
print()

0 comments on commit 8bbe7e7

Please sign in to comment.