コード例 #1
0
    def __init__(self, sig: bytes = bytes()) -> None:
        self.value: G1Obj = G1Obj()
        if len(sig) == 0:
            MilagroPairing.ECP_BLS381_inf(byref(self.value))
            return

        g: Tuple[bool, bool, bool, Big384] = parse(sig)

        if g[0] != g[1]:
            raise Exception("Infinite flag set improperly.")

        if g[0]:
            MilagroPairing.ECP_BLS381_inf(byref(self.value))
            return

        if MilagroPairing.ECP_BLS381_setx(byref(self.value), g[3], 0) != 1:
            raise Exception("Invalid G1.")

        yNeg: FP1Obj = FP1Obj()
        MilagroPairing.FP_BLS381_neg(byref(yNeg), byref(self.value.y))

        a: Big384 = Big384()
        b: Big384 = Big384()
        MilagroCurve.FP_BLS381_redc(a, byref(self.value.y))
        MilagroCurve.FP_BLS381_redc(b, byref(yNeg))
        if (MilagroCurve.BIG_384_58_comp(a, b) == 1) != g[2]:
            if MilagroPairing.ECP_BLS381_setx(byref(self.value), g[3], 1) != 1:
                raise Exception("Setting a proven valid X failed.")
コード例 #2
0
    def __init__(self, sig: bytes = bytes()) -> None:
        self.value: G1Obj = G1Obj()
        if len(sig) == 0:
            MilagroPairing.ECP_BLS381_inf(byref(self.value))
            return

        g: Tuple[bool, bool, bool, Big384] = parse(sig)

        if g[0] != g[1]:
            raise Exception("Infinite flag set improperly.")

        if g[0]:
            MilagroPairing.ECP_BLS381_inf(byref(self.value))
            return

        if MilagroPairing.ECP_BLS381_setx(byref(self.value), g[3], 0) != 1:
            raise Exception("Invalid G1.")

        if self.value.y.isLargerThanNegative() != g[2]:
            if MilagroPairing.ECP_BLS381_setx(byref(self.value), g[3], 1) != 1:
                raise Exception("Setting a proven valid X failed.")