Page MenuHomePhabricator

[electrum] cleanup ser_to_point
ClosedPublic

Authored by PiRK on Jun 19 2024, 12:24.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC1e5fc68f200a: [electrum] cleanup ser_to_point
Summary

Use better variable names, split the function from ser_to_point(bytes) -> Point into ser_to_coordinates(bytes) -> (int, int)] and ser_to_point(bytes) -> Point.

This will allow us in future commits to remove some ecdsa import in other modules, to keep implementation details contained in ecc.py.

Depends on D16347

This is split out of D16301

Test Plan

python test_runner.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jun 19 2024, 12:24
Fabien requested changes to this revision.Jun 19 2024, 19:45
Fabien added a subscriber: Fabien.
Fabien added inline comments.
electrum/electrumabc/ecc.py
167 ↗(On Diff #48296)

It' no longer returning a point but coordinates => ser_to_coordinates is a better name

177 ↗(On Diff #48296)

I understand why you named it like so but it puzzled me at first, as ecdsa is not a curve but an algorithm so it has no point. Not sure if the "ecdsa python module format" idea can be conveyed with a better name though, so I leave that up to you

This revision now requires changes to proceed.Jun 19 2024, 19:45
electrum/electrumabc/ecc.py
177 ↗(On Diff #48296)

I agree that the name is pretty bad. I kept it just to make future backports easier, but if we are going to rename the other one this one can get a better name too.

PiRK edited the summary of this revision. (Show Details)
PiRK edited the test plan for this revision. (Show Details)

rename ser_to_point -> ser_to_coordinates and ser_to_ecdsa_python_point -> ser_to_point
Use a NamedTuple for the output of ser_to_point (better type-safety than a generic 2-tuple)

This makes this diff much smaller

Fabien added inline comments.
electrum/electrumabc/ecc.py
161 ↗(On Diff #48315)
This revision is now accepted and ready to land.Jun 20 2024, 07:13
This revision was automatically updated to reflect the committed changes.