sageのdiscrete_logが対応していない群の離散対数問題を解くテク

DownUnderCTF 2021 | yadlp

#joseph #downunderctf2021 def G_add(A, B): x1, y1 = A x2, y2 = B return ((x1*x2 + D*y1*y2) % p, (x1*y2 + x2*y1 + 2*y1*y2) % p) def G_mul(A, k): out = (1, 0) while k > 0: if k & 1: out = G_add(out, A) A = G_add(A, A) k >>= 1 return out def …

InCTF 2020 | DLPoly

#inctf2020 sage: p 35201 sage: len(flag) 14 sage: X = int.from_bytes( flag.strip(b'inctf{').strip(b'}') , 'big') sage: n 1629*x^256 + 25086*x^255 + 32366*x^254 + 21665*x^253 + 24571*x^252 + 20588*x^251 + 17474*x^250 + 30654*x^249 + 31322*x…

redpwn CTF 2021 | scrambled-elgs

#redpwnctf2021 #!/usr/bin/env sage import secrets import json from Crypto.Util.number import bytes_to_long, long_to_bytes from sage.combinat import permutation n = 25_000 Sn = SymmetricGroup(n) def pad(M): padding = long_to_bytes(secrets.r…