NEEDS REVIEW - Fix #30. Replace ctypes with cryptography (cffi).#62
NEEDS REVIEW - Fix #30. Replace ctypes with cryptography (cffi).#62posita wants to merge 1 commit intopetertodd:masterpetertodd/python-bitcoinlib:masterfrom posita:use-pyca-cryptography-for-bignum-ops-30Copy head branch name to clipboard
Conversation
ctypes with cffi/cryptography.ctypes with cryptography (cffi).
ctypes with cryptography (cffi).ctypes with cryptography (cffi).
ctypes with cryptography (cffi).|
@petertodd, can you tell me if this is worth pursuing? Please close if not. Other than this, I do not have any suggestions for addressing #30. |
|
Sorry, I'm off in the states travelling and haven't had a chance to look at this in detail. :( Give me another few days. |
|
@petertodd, np. Sorry for nagging! 😊 I filed pyca/cryptography#1969 to request that |
|
Hmm, I'm pretty reluctant to move to https://github.com/pyca/cryptography, basically because it gets us further away from doing exactly what Bitcoin Core does by adding another layer/dependency. I'm inclined to wait for libsecp256k1 before doing anything wholesale. Equally, to fix #30 I'd rather see a more targeted patch. What can I say, crypto code is dangerous and hard to review thoroughly, and I know people are using python-bitcoinlib in production, so I'm inclined to tread very carefully with regard to changing anything. |
|
Totally understood. Closing as "won't merge". See also #77. |
Fix #30. Replace
ctypeswithcryptography(cffi).There is currently one known issue:
CECKey.set_privkeyandCECKey.get_privkeyrequire theFFIinstance to expose thed2i_ECPrivateKeyandi2d_ECPrivateKeyfunctions, respectively, from the underlying OpenSSL library. Currently,cryptographydoes not expose these functions. This means that those functions will not work. I have not yet investigated or considered using a hybridctypesapproach for that narrow set of functionality (if that is even possible).This only affects the
*_privkeygetter and setter. I was able to provide alternatives to theo2i_ECPublicKeyandi2o_ECPublicKeyfunctions used in the corresponding*_pubkeyfunctions (see this and this). I have not yet found (or am not clever enough to recognize) equivalents on the private key side.The reason why unit tests still pass is because the
*_privkeygetter and setter are not called from any of the tests. This is unchanged from before (I did not add tests to cover those methods).