<p>There is no math that would get the private key from a public key. That is the whole point of the Elliptic-Curve Cryptography. You can always get the public key from a private key, but not the opposite since this would mean that anybody could spend the Bitcoins of anybody and Bitcoin itself would be worthless.</p>

CC BY-SA 4.0
2020-08-29T14:38:11.057Z
Ok do you have any code to do it
Srijayaram H
CC BY-SA 4.0
2020-08-29T17:12:45.600Z
https://brainwalletx.github.io/#generator
Oscar Serna
CC BY-SA 4.0
2020-08-29T17:19:09.380Z
Thank you how to compress an public key and private key send me python codes
Srijayaram H
CC BY-SA 4.0
2020-08-29T19:35:43.830Z
If the y coordinate of the public key is an even number, then the compressed public key starts with the byte '02' followed by the x coordinate. If it is an odd number then the compressed public key starts with the byte '03' followed by the x coordinate. Here is some code from a great book where I learnt a lot from: https://github.com/jimmysong/programmingbitcoin/blob/master/code-ch05/ecc.py
Oscar Serna
CC BY-SA 4.0
2020-08-29T19:39:05.380Z
your public key is already compressed since it only has 33 bytes (1 byte for the y coordinate and 32 bytes for the x coordinate) Also, it starts with 02 which means the y coordinate is an even number. If it were not compressed then it would start with the byte '04'
Oscar Serna
CC BY-SA 4.0
2020-09-07T20:32:35.410Z
Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/data/data/com.termux/files/usr/tmp/pip-install-4lpak8y9/hashlib/setup.py", line 68
        print "unknown OS, please update setup.py"
              ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print("unknown OS, please update setup.py")?
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command out
Srijayaram H
CC BY-SA 4.0
2020-09-07T20:44:21.627Z
Can i get your gmail I can't load more
Srijayaram H
CC BY-SA 4.0
2020-09-08T22:16:28.603Z
That error usually means the code was originally developed for python 2, but now you are running it on python 3. All you have to do is to open the file that is throwing the error, and fix the "print" statement. In python3, the correct syntax for a print statement is: print("your_message"). You might have to fix a couple of them.
Oscar Serna
CC BY-SA 4.0
2020-09-10T13:06:57.347Z
ripemd160.update(hashlib.sha256(s.decode('hex')).digest())
AttributeError: 'str' object has no attribute 'decode'
Srijayaram H
CC BY-SA 4.0
2020-09-10T13:08:06.240Z
inputAddr = base58.b58decode_check(keyUtils.pubKeyToAddr(pub))
  File "/storage/emulated/0/Bitcoin-Key-Compression-Tool-master/Bitcoin-Key-Compression-Tool-master/keyUtils.py", line 55, in pubKeyToAddr
Srijayaram H
CC BY-SA 4.0
2020-09-10T13:08:41.553Z
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 11, in <module>
  File "/storage/emulated/0/Bitcoin-Key-Compression-Tool-master/Bitcoin-Key-Compression-Tool-master/txnUtils.py", line 53, in getSignableTxn
Srijayaram H
CC BY-SA 4.0
2020-09-10T13:09:01.667Z
Can you explain this what to add
Srijayaram H
CC BY-SA 4.0
2020-09-11T04:15:59.453Z
Again, these errors are caused by trying to use python2 code in python3. Maybe try to run the code using python2. But if you can't do that for whatever reason, just try to google the errors. Most of them are pretty easy fixes. Your first error, for instance, is giving you a hard time because the syntax inside the sha256() is a python2 syntax. Just replace ```s.decode('hex')``` by ```bytes(s,"utf-8")```. The other error messages are incomplete. Good luck!
Oscar Serna
CC BY-SA 4.0
2020-08-29T13:56:49.227Z
2020-08-29T13:56:49.227Z
Oscar Serna
<p>I have an ecdsa public key how to get the private key of this public key;
0222d2deda24c03b2cc2b458c35780c62b6b5603c088709f17607b7ecf1399e4d7 how to solve this on python I am using Pydroid 3 on my mobile any sources to do this any code for this and also tell me how to do this on termux not random entering public key and finding private key hex can any body can help me</p>

CC BY-SA 4.0
2020-08-29T20:28:03.470Z
This is not possible. If it were, anyone could steal anyone's bitcoin.
Pieter Wuille
<private-key><public-key><ecdsa>
ECDSA public key to private key hex
Srijayaram H
# ECDSA public key to private key hex

(Asked by: username_0 on 2020-08-29)

I have an ecdsa public key how to get the private key of this public key;
0222d2deda24c03b2cc2b458c35780c62b6b5603c088709f17607b7ecf1399e4d7 how to solve this on python I am using Pydroid 3 on my mobile any sources to do this any code for this and also tell me how to do this on termux not random entering public key and finding private key hex can any body can help me

**Tags:** private-key, public-key, ecdsa

> **Comments:**
> **username_1**: This is not possible. If it were, anyone could steal anyone's bitcoin.  

---

## 1 answers

### Answer by username_2 on 2020-08-29. Score: 2

There is no math that would get the private key from a public key. That is the whole point of the Elliptic-Curve Cryptography. You can always get the public key from a private key, but not the opposite since this would mean that anybody could spend the Bitcoins of anybody and Bitcoin itself would be worthless.

> **Comments:**
> **username_0**: Ok do you have any code to do it  
> **username_2**: https://brainwalletx.github.io/#generator  
> **username_0**: Thank you how to compress an public key and private key send me python codes  
> **username_2**: If the y coordinate of the public key is an even number, then the compressed public key starts with the byte '02' followed by the x coordinate. If it is an odd number then the compressed public key starts with the byte '03' followed by the x coordinate. Here is some code from a great book where I learnt a lot from: https://github.com/jimmysong/programmingbitcoin/blob/master/code-ch05/ecc.py  
> **username_2**: your public key is already compressed since it only has 33 bytes (1 byte for the y coordinate and 32 bytes for the x coordinate) Also, it starts with 02 which means the y coordinate is an even number. If it were not compressed then it would start with the byte '04'  
> **username_0**: Traceback (most recent call last):       File "<string>", line 1, in <module>       File "/data/data/com.termux/files/usr/tmp/pip-install-4lpak8y9/hashlib/setup.py", line 68         print "unknown OS, please update setup.py"               ^     SyntaxError: Missing parentheses in call to 'print'. Did you mean print("unknown OS, please update setup.py")?     ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command out  
> **username_0**: Can i get your gmail I can't load more  
> **username_2**: That error usually means the code was originally developed for python 2, but now you are running it on python 3. All you have to do is to open the file that is throwing the error, and fix the "print" statement. In python3, the correct syntax for a print statement is: print("your_message"). You might have to fix a couple of them.  
> **username_0**: ripemd160.update(hashlib.sha256(s.decode('hex')).digest()) AttributeError: 'str' object has no attribute 'decode'  
> **username_0**: inputAddr = base58.b58decode_check(keyUtils.pubKeyToAddr(pub))   File "/storage/emulated/0/Bitcoin-Key-Compression-Tool-master/Bitcoin-Key-Compression-Tool-master/keyUtils.py", line 55, in pubKeyToAddr  
> **username_0**: Traceback (most recent call last):   File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>     start(fakepyfile,mainpyfile)   File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start     exec(open(mainpyfile).read(),  __main__.__dict__)   File "<string>", line 11, in <module>   File "/storage/emulated/0/Bitcoin-Key-Compression-Tool-master/Bitcoin-Key-Compression-Tool-master/txnUtils.py", line 53, in getSignableTxn  
> **username_0**: Can you explain this what to add  
> **username_2**: Again, these errors are caused by trying to use python2 code in python3. Maybe try to run the code using python2. But if you can't do that for whatever reason, just try to google the errors. Most of them are pretty easy fixes. Your first error, for instance, is giving you a hard time because the syntax inside the sha256() is a python2 syntax. Just replace ```s.decode('hex')``` by ```bytes(s,"utf-8")```. The other error messages are incomplete. Good luck!  

---

