pybitcash / bitcash

BitCash: Python Bitcoin Cash Library (fork of ofek's Bit)
https://bitcash.dev
MIT License
97 stars 39 forks source link

Add public/private key encryption and decryption #110

Open yashasvi-ranawat opened 2 years ago

yashasvi-ranawat commented 2 years ago

Uses ECIES encryption decryption method; AES-128-CBC with PKCS7 is used as the cipher; hmac-sha256 is used as the mac

ghost commented 2 years ago

I don't think that this is BitCash specific and might make the most sense to have it in its own repository and Python package. If I'm not mistaken, would this code work for Bitcoin, Bitcoin Cash, and Bitcoin SV?

yashasvi-ranawat commented 2 years ago

@sometato No, this is not BitCash specific. Would work with any Elliptical Curve based public/private key pair crypto.

However, it adds feature parity with the Electron-Cash app. Users of BitCash get the simplicity of public/private key based encryption/decryption. Such encryption/decryption methods are very common, and have allied applications.

@merc1er Although I don't mind waiting for the review, you can also test out the feature parity with the Electron-cash app. >>> key = wif_to_key('cU6s7jckL3bZUUkb3Q2CD9vNu8F1o58K5R5a3JFtidoccMbhEGKZ') >>> key.public_key.hex() '033d5c2875c9bd116875a71a5db64cffcb13396b163d039b1d9327824891804334' This hex of public key can be used in the Electron-Cash app to encrypt any message. >>> encrypted_message = <string of encrypted message from the electron-cash app> >>> key.decrypt_message(encrypted_message) <the message in its binary format>