1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| from sage.all import *
n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551
signatures = [ (5832921593739954772384341732387581797486339670895875430934592373351528180781, 78576287416983546819312440403592484606132915965726128924031253623117138586396, 108582979377193966287732302562639670357586761346333866965382465209612237330851), (85517239535736342992982496475440962888226294744294285419613128065975843025446, 60425040031360920373082268221766168683222476464343035165195057634060216692194, 27924509924269609509672965613674355269361001011362007412205784446375567959036), (90905761421138489726836357279787648991884324454425734512085180879013704399530, 75779605492148881737630918749717271960050893072832415117470852442721700807111, 72740499400319841565890543635298470075267336863033867770902108413176557795256), (103266614372002123398101167242562044737358751274736728792365384600377408313142, 89519601474973769723244654516140957004170211982048028366151899055366457476708, 23639647021855356876198750083669161995553646511611903128486429649329358343588), (9903460667647154866199928325987868915846235162578615698288214703794150057571, 17829304522948160053211214227664982869100868125268116260967204562276608388692, 74400189461172040580877095515356365992183768921088660926738652857846750009205), (54539896686295066164943194401294833445622227965487949234393615233511802974126, 66428683990399093855578572760918582937085121375887639383221629490465838706027, 25418035697368269779911580792368595733749376383350120613502399678197333473802), ]
R = PolynomialRing(Zmod(n), names=('a', 'b', 'c', 'd')) a, b, c, d = R.gens()
k_list = [] for h, r, s in signatures: s_inv = inverse_mod(s, n) k_expr = (h + r * d) * s_inv k_list.append(k_expr)
eqs = [] for i in range(5): f = a * k_list[i]**2 + b * k_list[i] + c - k_list[i+1] eqs.append(f)
I = R.ideal(eqs) G = I.groebner_basis()
found = False for g in G: if g.degree(d) > 0: poly = g.univariate_polynomial() roots = poly.roots() for root, _ in roots: d_val = int(root) print(f"[+] Found private key d = {d_val}") print(f"L3HCTF{{{d_val}}}") found = True if not found: print("[-] Failed to recover private key. Try different subsets or check equations.")
|