warner / wireguard-vanity-address

generate Wireguard keypairs with a given prefix string
MIT License
437 stars 32 forks source link

Support Regex #23

Open zmcandee opened 4 years ago

zmcandee commented 4 years ago

Adding support for regex would allow more control over the names you are looking for as well as looking for multiple names at once. The speed cost of RE.is_match() is negligible when you consider the ability to look for multiple names, include number substitutions and incorporate the --in argument.

Regex example matching 72 derivatives of stew+ and 48 derivatives of nancy in the first 10 characters: ^.{0,5}[sS][tT7][eE3][wW][/+]|^.{0,5}[nN][aA4][nN][cC][yY]

warner commented 2 years ago

I like that idea, maybe a --regex= argument which gives you exact control over the matching predicate.

I bet we'd have to give up the yield estimator, though (the code that figures the probability that a random address will meet the criteria, then multiplies that by the measured rate of generation, to give you an idea how how frequently it will emit matching addresses). I know how to calculate the yield with a simple prefix, and I know how to estimate the effect of allowing it to appear within a prefix, but I don't know how to take a generalized regexp and turn it into a ratio. But I think this feature would be great to have even without the estimator.