Open
Description
By @Bhargavasomu from: #24 (comment)
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
py_ecc/py_ecc/bn128/bn128_pairing.py
Lines 74 to 83 in 067a402
- 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?