Created
January 30, 2023 12:19
-
-
Save RareSkills/eb51623908f348663cd6a241d9dbf115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ecpy.curves import Curve | |
from sha3 import keccak_256 | |
private_key = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | |
cv = Curve.get_curve('secp256k1') | |
pu_key = private_key * cv.generator # just multiplying the private key by generator point (EC multiplication) | |
concat_x_y = pu_key.x.to_bytes(32, byteorder='big') + pu_key.y.to_bytes(32, byteorder='big') | |
eth_addr = '0x' + keccak_256(concat_x_y).digest()[-20:].hex() | |
print('private key: ', hex(private_key)) | |
print('eth_address: ', eth_addr) |
To get the private key, you’d need to reverse the keccak256 hash and do the
inverse of elliptic curve multiplication (discrete logarithm). Both of
these operations are known to be computationally infeasible.
…On Thu, Feb 9, 2023 at 11:12 AM smallyu ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Now that can calculate the address from the private key, why can't
calculate the private key just using the reverse calculation process from
the address?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/eb51623908f348663cd6a241d9dbf115#gistcomment-4465001>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3IJURLP2C5ZBDJTJ6KKLULWWRVDLBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMBVHA3TQNZRU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that can calculate the address from the private key, why can't calculate the private key just using the reverse calculation process from the address?