forked from darosior/python-bip32
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Remove ecdsa dependency, use cryptography only II #4
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
Open
onvej-sl
wants to merge
7
commits into
master
Choose a base branch
from
remove-ecda-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e0e3707
Fix edge case
onvej-sl b15308e
Use cryptography instead of ecdsa
onvej-sl ad5f255
Remove ecdsa package
onvej-sl b630c62
Test `add_points()`
onvej-sl 4af0b5b
Do not terminate all jobs when one fails
onvej-sl 16c914e
Fix pytest for python 3.10
onvej-sl 3ab780e
fixup! Test `add_points()`
onvej-sl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import pytest | ||
|
|
||
| from slip10.utils import SECP256K1, SECP256R1 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("curve", (SECP256K1, SECP256R1)) | ||
| def test_curve_arithmetic(curve): | ||
| generator = curve.privkey_to_pubkey((1).to_bytes(32, "big")) | ||
| minus_generator = curve.privkey_to_pubkey( | ||
| (curve.curve.group_order - 1).to_bytes(32, "big") | ||
| ) | ||
| double_generator = curve.privkey_to_pubkey((2).to_bytes(32, "big")) | ||
| triple_generator = curve.privkey_to_pubkey((3).to_bytes(32, "big")) | ||
|
|
||
| assert curve.add_points(generator, minus_generator) == bytes.fromhex("00") | ||
| assert curve.add_points(generator, generator) == double_generator | ||
| assert curve.add_points(generator, double_generator) == triple_generator |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How does this function handle if one of the inputs is a point at infinity? Does
from_encoded_point()raise an exception? I think the only way to get infinity as an input is if the tweakpayload[:32]comes out zero, which is practically impossible to observe. Maybeprivkey_to_pubkey()already raises an exception in that case. We should at least have a comment explaining how this function behaves for infinity inputs and why it's OK.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.
Besides that, I also realized that
privkey_to_pubkey()raises an exception ifprivkeyis greater than the curve's order, which would break this test vector, if we had it included in our tests.Uh oh!
There was an error while loading. Please reload this page.
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.
We have that test vector included in our tests,
but it tests retry in master key generation. We should generate a test vector for retry in child key derivation too and add it to the spec.