Library refactor
See original GitHub issueBy @Bhargavasomu from: https://github.com/ethereum/py_ecc/issues/24#issuecomment-442701351
The following things come to my mind.
- The classes
FQ
,FQP
,FQ2
andFQ12
need not be reinitialized every time as they are not dependent on the type of curve or extension. So probably we could have these created infield_elements.py
and we could use them everywhere (bn128
,optimized_bn128
,bls
,optimized_bls
). - We could also have a general class
BaseCurve
, and then maybe every curve (bn128_curve
,optimized_bn128_curve
, …) could inherit this and make the changes specific to the inherited class. - We should probably move the constants into a seperate file (
constants.py
) - We should also remove the assert statements which are not part of any function, but are part of the script in general, as shown https://github.com/ethereum/py_ecc/blob/067a40261ad39526f6aa8bd69def7d6982993d13/py_ecc/bn128/bn128_pairing.py#L74-L83
- Also the type hinting should be further generalized wherever possible (in terms of removing redundant types; like
Optimized_FQPoint2D
could be replaced byFQPoint2D
). Similary the type hinting should be carried out for thebs12_381
andoptimized_bs12_381
submodules.
Also the only difference I see in all the curves is
- Difference in the constants such as
b
,b2
,b12
,G2
,G12
… - Difference in the
twist
function
@vbuterin are my facts right or am I missing anything. @pipermerriam is the above design ok?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Incomplete Library Class - Refactoring.Guru
The only solution to the problem—changing the library—is often impossible since the library is read-only. Reasons for the Problem. The author of the...
Read more >The New Refactoring Library 🏛️ - by Luca Rossi
The New Refactoring Library 🏛️. Discover the best collection of online resources to level up your engineering game. Luca Rossi.
Read more >Refactoring Code With the Standard Library - YouTube
John Reesehttps://2018.pycon-au.org/talks/45063- refactoring -code-with-the-standard- library /What if you could refactor your entire code base, ...
Read more >AST-based fragmental source code refactoring toolkit for Python
Refactor. PyPI version Documentation Try It. Simple, hassle-free, dependency-free, AST based fragmental source code refactoring and transformation toolkit.
Read more >Angular Libraries : Refactor Existing Components into a ...
When we read Angular's documentation on refactoring components into libraries, we find that it's shor... Tagged with angular, typescript.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Bhargavasomu I’ve submitted a request to have a bounty attached to this.
Issue Status: 1. Open 2. Cancelled
The funding of 250.0 DAI (250.0 USD @ $1.0/DAI) attached to this issue has been cancelled by the bounty submitter