/bitp0wn

Showcase of algorithms to get private keys from public keys with ECDSA

Primary LanguagePython

Bitp0wn

This repo is a showcase of alogrithms to get a private key from a public key on ecdsa.
The scripts are not optimised and are only proof-of-concepts.  

You can find a little desription of each files below :

  • brute_force.py : You will find a simple brute algorithm wich test every possibilities.

  • anniversary.py : This algorithm try to generate new signatures from the same address. This is based on birthday attack.

  • local_maximum.py : Worst heuristic, try to find a local maximum with a bad fitness function.

  • genetic.py : Here we try to crack private key using a metaheuristic (also with a bad fitness function): genetic algorithm. This is much better than local_maximum.py.

  • r_exploit.py : This algorithm exploit a failure in signatures generation. If the same address use the same k in 2 differents signatures (i.e same r-value), then you can retrieve the private key instantly.

  • substract_optim.py : My best algorithm wich work in O(2^(n/2)) or O(2^sqrt(n)) with n the number of bits of the private key. The idea is to generate once for all every public keys with with the private key being inferior to n/2. Then, we multiply them by (n/2) and we substract the public key. We found the private key when we found a key present in the pre-generated base.

Then you can find 2 other files :

  • playground.py : This file contains relations between values of differents signatures for an identical address.

  • double.py : This file is more about finding relationship between 2 public keys on the curve. Most of formulaes are specific to secp256k1. If you want to help, there is a quartic equation at the end that I haven't solved to this day.