Googulator / TeslaCrack

Decryptor for the TeslaCrypt malware
GNU General Public License v3.0
177 stars 36 forks source link

Optimize unfactor scripts in case of repeating factors #6

Open Googulator opened 8 years ago

Googulator commented 8 years ago

For non-squarefree keys (ones with the same factor multiple times), the unfactor scripts waste resources by trying the same key multiple times.

E.g. having "2 2 2" on the command line, there are only 4 possible combinations (1, 2, 4, 8), but unfactor.py will treat each factor as different, and will try (1, 2, 2, 2, 4, 4, 4, 8) as possible keys, and it only gets worse with more repetitions.

Unfactor-ecdsa.py already has some optimization (it will do the EC math only once for each real key candidate), but things can still slow down significantly if the key is e.g. a power of 3.