-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Pure python EC #15826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure python EC #15826
Conversation
|
Concept ACK |
|
Concept ACK Excellent work! Thanks for doing this! |
|
❤️ Makes it easier to run the tests on native windows, where I couldn't figure out how to install that library. Will give it a try... |
That seems like a good motivation for making a change like this, but I'm curious if there are other reasons as well? |
|
@sdaftuar The original motivation was that for testing a Schnorr signature implementation we'll want a Python version to test against, which needs much of this logic anyway, and it felt silly to maintain two independent versions just for testing (especially as one relies on OpenSSL we're trying to get rid of as a dependency). @MarcoFalke I added the verify_ecdsa function to test the sign_ecdsa code while writing it, but expect it may be useful to test against the Bitcoin Core signing code. I can either make the linter ignore it, or at a simple test that invokes it. Up to you. |
|
Yeah, having a test that |
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK!
|
I've added ecdsa_verify to the ignore list. I'll try to write a test that actually uses it, but it's not that trivial either. |
17dca8e to
048cbc4
Compare
|
At a glance this looks fine, I was going to urge you to put a really strong warning on it, but the warning looks adequate. I'm not going to give this any cryptographic review because I don't think it needs/deserves any. |
4571397 to
c01a1b9
Compare
|
This will be merged next Monday unless there are objections |
| @@ -1,226 +1,343 @@ | |||
| # Copyright (c) 2011 Sam Rushing | |||
| """ECC secp256k1 OpenSSL wrapper. | |||
| # Copyright (c) 2019 Pieter Wuille | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the project have a policy on individual contributors' copyright notices in source files? Do you also want to include the MIT license boilerplate here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few files with individual author's names. As the "Copyright The Bitcoin Core contributors" is likely meaningless I think listing actual authors is preferable when it's a well-defined set of people, but I don't feel strongly.
jnewbery
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. A couple of nits inline, but otherwise ACK 8cc786094fb55907a25a4b46caa7f1f8fb512363
I added copious comments and notes for myself as I was reviewing. They're here: jnewbery@af36c8a. Feel free to take that commit for this PR.
|
good to lose this dependency on an external library w/ ctypes, this makes porting the tests easier ACK 8cc786094fb55907a25a4b46caa7f1f8fb512363 (though would be good to integrate @jnewbery's comments) |
This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1.
|
I've rewritten the extgcd/modinv functions to be a bit faster, and also included @jnewbery's comments (after rebasing that commit). |
|
Nice find for the quicker modinv(). utACK ac050deca0227fe44346f3f91c79d733ed5705d8 |
This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1. Github-Pull: bitcoin#15826 Rebased-From: 8c7b932
Github-Pull: bitcoin#15826 Rebased-From: b679785
27fcb40 doc: replace outdated OpenSSL comment in test README (fanquake) Pull request description: The OpenSSL dependency was removed in #15826. ACKs for top commit: laanwj: ACK 27fcb40 theStack: ACK 27fcb40 Tree-SHA512: eb7a3b18fefa91e6f27c50fa065d6cc330f7b633ae8ee51145cdeec4df51dea5155f0d1fa91e75f1202adef04e063f3eda12773cd00a093f29f5a5e83c4fda73
Summary: ``` This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1. ``` Backport of core [[bitcoin/bitcoin#15826 | PR15826]]. Test Plan: ninja check-functional-extended *The following depends on D14007:* Build for windows, then: - Install python if needed and add it to your path - If you copy the project to some place, you need at least the `src`, `test`, `share` and your build directories. - Copy the test_runner.py to the build directory to replace the symlink - Update the config.ini file to match you paths Then in a powershell: $env:PYTHONIOENCODING="utf-8" python .\test\functional\test_runner.py --force You should note that only a few tests remain red, in particular all the schnorr related tests since they still use openssl. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5965
Summary: ``` This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1. ``` Backport of core [[bitcoin/bitcoin#15826 | PR15826]]. Test Plan: ninja check-functional-extended *The following depends on D14007:* Build for windows, then: - Install python if needed and add it to your path - If you copy the project to some place, you need at least the `src`, `test`, `share` and your build directories. - Copy the test_runner.py to the build directory to replace the symlink - Update the config.ini file to match you paths Then in a powershell: $env:PYTHONIOENCODING="utf-8" python .\test\functional\test_runner.py --force You should note that only a few tests remain red, in particular all the schnorr related tests since they still use openssl. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5965
…ADME 27fcb40 doc: replace outdated OpenSSL comment in test README (fanquake) Pull request description: The OpenSSL dependency was removed in bitcoin#15826. ACKs for top commit: laanwj: ACK 27fcb40 theStack: ACK bitcoin@27fcb40 Tree-SHA512: eb7a3b18fefa91e6f27c50fa065d6cc330f7b633ae8ee51145cdeec4df51dea5155f0d1fa91e75f1202adef04e063f3eda12773cd00a093f29f5a5e83c4fda73
b679785 Add comments to Python ECDSA implementation (John Newbery) 8c7b932 Pure python EC (Pieter Wuille) Pull request description: This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1. ACKs for commit b67978: jnewbery: utACK b679785 Tree-SHA512: 181445eb08b316c46937b80dc10aa50d103ab1fdddaf834896c0ea22204889f7b13fd33cbcbd00ddba15f7e4686fe0d9f8e8bb4c0ad0e9587490c90be83966dc
This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python
toy implementation of secp256k1.