chainside / btcpy

A Python3 SegWit-compliant library which provides tools to handle Bitcoin data structures in a simple fashion.
https://www.chainside.net
GNU Lesser General Public License v3.0
271 stars 74 forks source link

PrivateKey generation from entropy #31

Open SimoneBronzini opened 6 years ago

SimoneBronzini commented 6 years ago

It would be useful to have a way to generate PrivateKeys (and their extended version) from a secure source of entropy.

peerchemist commented 6 years ago

Python 3.6 introduces secrets module which can be used for this: https://docs.python.org/3/library/secrets.html

csyhuang commented 4 years ago

I'm interested in helping. To satisfy the requirement, am I supposed to modify the PrivateKey class: https://github.com/chainside/btcpy/blob/7e95e9e43be0506f165381ae85f16705e616ff9f/btcpy/structs/crypto.py Would you mind defining the class more precisely? Thanks! 🙂

SimoneBronzini commented 4 years ago

Thanks for your interest in our project! The right way to do it I believe would be creating a @staticmethod in the PrivateKey class called generate that creates a PrivateKey using python's secrets standard module. If you have any further doubts please let me know.

csyhuang commented 4 years ago

@SimoneBronzini Thanks! I've submitted a pull request #59 with this new function. Let me know if there are more things to add. 🙂 If you approve my pull request, may you label it as hacktoberfest-accepted? I'm participating in the HacktoberFest and wish this can be counted. Thanks in advance!