Remove ecdsa dependency, use cryptography only#2
Closed
Conversation
onvej-sl
reviewed
Dec 18, 2025
| if x1 == x2: | ||
| return None | ||
|
|
||
| slope = ((y2 - y1) * self._inverse_mod((x2 - x1) % self.p)) % self.p |
Collaborator
There was a problem hiding this comment.
% is unnecessary since it happens in _inverse_mod().
Suggested change
| slope = ((y2 - y1) * self._inverse_mod((x2 - x1) % self.p)) % self.p | |
| slope = ((y2 - y1) * self._inverse_mod(x2 - x1)) % self.p |
onvej-sl
reviewed
Dec 18, 2025
| if y == 0: | ||
| return None | ||
|
|
||
| slope = ((3 * x * x + self.a) * self._inverse_mod((2 * y) % self.p)) % self.p |
Collaborator
There was a problem hiding this comment.
Suggested change
| slope = ((3 * x * x + self.a) * self._inverse_mod((2 * y) % self.p)) % self.p | |
| slope = ((3 * x * x + self.a) * self._inverse_mod(2 * y)) % self.p |
onvej-sl
reviewed
Dec 18, 2025
| y3 = (slope * (x - x3) - y) % self.p | ||
| return x3, y3 | ||
|
|
||
| def _scalar_mult(self, scalar: int, point: Tuple[int, int]) -> Point: |
Collaborator
There was a problem hiding this comment.
Suggested change
| def _scalar_mult(self, scalar: int, point: Tuple[int, int]) -> Point: | |
| def _scalar_mult(self, scalar: int, point: Point) -> Point: |
onvej-sl
reviewed
Dec 18, 2025
Comment on lines
+205
to
+206
| x = int.from_bytes(data[1 : 1 + self.coordinate_size], "big") | ||
| y = int.from_bytes(data[1 + self.coordinate_size :], "big") |
Collaborator
There was a problem hiding this comment.
Suggested change
| x = int.from_bytes(data[1 : 1 + self.coordinate_size], "big") | |
| y = int.from_bytes(data[1 + self.coordinate_size :], "big") | |
| x = int.from_bytes(data[1 : 1 + self.coordinate_size], "big") | |
| if (x >= self.p): | |
| raise ValueError("Invalid x-coordinate") | |
| y = int.from_bytes(data[1 + self.coordinate_size :], "big") | |
| if (y >= self.p): | |
| raise ValueError("Invalid y-coordinate") |
onvej-sl
reviewed
Dec 18, 2025
| if len(data) != self.coordinate_size + 1 or data[0] not in (2, 3): | ||
| raise ValueError("Invalid public key encoding") | ||
|
|
||
| x = int.from_bytes(data[1:], "big") |
Collaborator
There was a problem hiding this comment.
Suggested change
| x = int.from_bytes(data[1:], "big") | |
| if (x >= self.p): | |
| raise ValueError("Invalid x-coordinate") |
onvej-sl
reviewed
Dec 18, 2025
Comment on lines
+228
to
+229
| if x >= self.p: | ||
| raise ValueError("Invalid point") |
Collaborator
There was a problem hiding this comment.
Suggested change
| if x >= self.p: | |
| raise ValueError("Invalid point") | |
| if self.p % 4 != 3: | |
| raise NotImplementedError("Square root for this modulus is not implemented") |
Collaborator
|
Closing in favor of #4. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What title says
The code was generated using Codex - please review meticulously!
The tests pass though.