defpell_nummul(k, p, n): ret = p for _ inrange(1, k): ret = pell_addition(ret, p, n) return ret
flag = b"flag{fake_flag}" p = getPrime(256) q = getPrime(256) n = p * q N = (p - 1) * (q - 1) e = 65537 Mx = random.getrandbits(30 * 8) My = bytes_to_long(flag) Z1 = (Mx * My) % n inv_Z1 = inverse(Z1, n) inv_2 = inverse(2, n) X = ((Z1 + inv_Z1) * inv_2) % n Y = My inv_Y = inverse(Y, n) a = ((inv_Z1 - X) * inv_Y) % n D = (a * a) % n
C = pell_nummul(e, (X, Y), n) Cx, Cy = C assert (Cx ** 2 - a ** 2 * Cy ** 2) % n == 1
print(f"{n = }") print(f"{e = }") print(f"{a = }") print(f"{C = }") """ n = 10875869887787663804047839718193475543686118884019867572490803738648470308993079737759024578860813280711311716156127433305656013081574096984215062308086369 e = 65537 a = 10116438763770833335071963736482633275409537527635919273281738401076055253869316673041392938506765451934508925012357512109305204520982892722901613311800701 C = (4849960393113794464754080440760696916372299516798584397604977732217190475324711280614363849676614028060514423502894807465940532815099018702845064455373256, 2090931220172552969273275305442140295254277142601056005437730699641113025524595059533700684844894262935856020588590490821984640023923039365658842315589801) """
p = 110074976061845580741863727679250881593298868143338959238797850091713336013909 q = 98804199436546420052453170362402913799134300214316056984844454343092057022941 n = 10875869887787663804047839718193475543686118884019867572490803738648470308993079737759024578860813280711311716156127433305656013081574096984215062308086369 N = (p - 1) * (q - 1) e = 65537 a = 10116438763770833335071963736482633275409537527635919273281738401076055253869316673041392938506765451934508925012357512109305204520982892722901613311800701 Cxy = (4849960393113794464754080440760696916372299516798584397604977732217190475324711280614363849676614028060514423502894807465940532815099018702845064455373256, 2090931220172552969273275305442140295254277142601056005437730699641113025524595059533700684844894262935856020588590490821984640023923039365658842315589801) Cx, Cy = Cxy assert (Cx ** 2 - a ** 2 * Cy ** 2) % n == 1
D = (a * a) % n C = (Cx - a * Cy) % n d = inverse(e, N) M = pow(C, d, n) inv_M = inverse(M, n) inv_2 = inverse(2, n) inv_a = inverse(a, n) X = (inv_M + M) * inv_2 % n Y = (inv_M - M) * inv_2 * inv_a % n My = Y Mx = M * inverse(Y, n) % n print(Mx, My)