示例#1
0
def decompress_G1(pt: int) -> Tuple[FQ, FQ, FQ]:
    if pt == 0:
        return (FQ(1), FQ(1), FQ(0))
    x = pt % 2**383
    y_mod_2 = pt // 2**383
    y = pow((x**3 + b.n) % q, (q + 1) // 4, q)

    if pow(y, 2, q) != (x**3 + b.n) % q:
        raise ValueError("he given point is not on G1: y**2 = x**3 + b")
    if y % 2 != y_mod_2:
        y = q - y
    return (FQ(x), FQ(y), FQ(1))
示例#2
0
 def Fq(cls, n: int) -> "FieldElement":
     return FQ(n)