-
-
Notifications
You must be signed in to change notification settings - Fork 2
Remove ecdsa dependency, use cryptography only #2
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
Conversation
| if x1 == x2: | ||
| return None | ||
|
|
||
| slope = ((y2 - y1) * self._inverse_mod((x2 - x1) % self.p)) % self.p |
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.
% is unnecessary since it happens in _inverse_mod().
| slope = ((y2 - y1) * self._inverse_mod((x2 - x1) % self.p)) % self.p | |
| slope = ((y2 - y1) * self._inverse_mod(x2 - x1)) % self.p |
| if y == 0: | ||
| return None | ||
|
|
||
| slope = ((3 * x * x + self.a) * self._inverse_mod((2 * y) % self.p)) % self.p |
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.
| 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 |
| y3 = (slope * (x - x3) - y) % self.p | ||
| return x3, y3 | ||
|
|
||
| def _scalar_mult(self, scalar: int, point: Tuple[int, int]) -> Point: |
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.
| def _scalar_mult(self, scalar: int, point: Tuple[int, int]) -> Point: | |
| def _scalar_mult(self, scalar: int, point: Point) -> Point: |
| x = int.from_bytes(data[1 : 1 + self.coordinate_size], "big") | ||
| y = int.from_bytes(data[1 + self.coordinate_size :], "big") |
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.
| 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") |
| 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") |
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.
| x = int.from_bytes(data[1:], "big") | |
| if (x >= self.p): | |
| raise ValueError("Invalid x-coordinate") |
| if x >= self.p: | ||
| raise ValueError("Invalid point") |
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.
| if x >= self.p: | |
| raise ValueError("Invalid point") | |
| if self.p % 4 != 3: | |
| raise NotImplementedError("Square root for this modulus is not implemented") |
|
Closing in favor of #4. |
What title says
The code was generated using Codex - please review meticulously!
The tests pass though.