-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
By @Bhargavasomu from: #24 (comment)
The following things come to my mind.
- The classes
FQ,FQP,FQ2andFQ12need 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.pyand 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
assert linefunc(one, two, one) == FQ(0) assert linefunc(one, two, two) == FQ(0) assert linefunc(one, two, three) != FQ(0) assert linefunc(one, two, negthree) == FQ(0) assert linefunc(one, negone, one) == FQ(0) assert linefunc(one, negone, negone) == FQ(0) assert linefunc(one, negone, two) != FQ(0) assert linefunc(one, one, one) == FQ(0) assert linefunc(one, one, two) != FQ(0) assert linefunc(one, one, negtwo) == FQ(0) - Also the type hinting should be further generalized wherever possible (in terms of removing redundant types; like
Optimized_FQPoint2Dcould be replaced byFQPoint2D). Similary the type hinting should be carried out for thebs12_381andoptimized_bs12_381submodules.
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
twistfunction
@vbuterin are my facts right or am I missing anything.
@pipermerriam is the above design ok?