Beispiel #1
0
 def __init__(self, x: Any, y: Optional[BLS12_381_F1] = None) -> None:
     self.value: G1Obj = G1Obj()
     if isinstance(x, G1Obj):
         MilagroCurve.ECP_BLS381_copy(byref(self.value), byref(x))
     elif isinstance(x, BLS12_381_G1):
         MilagroCurve.ECP_BLS381_copy(byref(self.value), byref(x.value))
     elif (isinstance(x, BLS12_381_F1) and isinstance(y, BLS12_381_F1)):
         xBig: Big384 = x.value.toBig384()
         yBig: Big384 = y.value.toBig384()
         if MilagroCurve.ECP_BLS381_set(byref(self.value), xBig, yBig) != 1:
             raise Exception("Passed invalid x/y to G1 constructor.")
     else:
         raise Exception("Unknown type passed to BLS12-381 G1 constructor.")
Beispiel #2
0
 def __add__(self, other: Any) -> GroupElement:
     result: G1Obj = G1Obj()
     MilagroCurve.ECP_BLS381_copy(byref(result), byref(self.value))
     MilagroCurve.ECP_BLS381_add(byref(result), byref(other.value))
     return BLS12_381_G1(result)