groebner_basis

Midnight Sun CTF Qualifiers 2023 | ikea

#midnight_sun_ctf_qualifiers_2023 p = random_prime(2**1024) q = random_prime(2**1024) a = randint(0, 2**1024) b = randint(0, 2**1024) def read_flag(file='flag.txt'): with open(file, 'rb') as fin: flag = fin.read() return flag def pad_flag(…

corCTF 2021 | lcg_k

#corctf2021 from Crypto.Util.number import bytes_to_long, inverse from hashlib import sha256 from secrets import randbelow from private import flag from fastecdsa.curve import P256 G = P256.G N = P256.q class RNG: def __init__(self, seed, …

CrewCTF 2022 | signsystem

#CrewCTF_2022 import sys import random from hashlib import sha256 from Crypto.Util.number import inverse import ecdsa from secret import FLAG curve = ecdsa.curves.SECP112r1 p = int(curve.curve.p()) G = curve.generator n = int(curve.order) …

0CTF Finals 2021 | ezmat

#0ctf2021finals from hashlib import sha256 from secret import flag global p, alphabet p = 71 alphabet = '=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$!?_{}<>' flag = flag.lstrip('flag{').rstrip('}') assert len(flag) == 2…

ACSC 2021 | swap on curve

#acsc2021 from params import p, a, b, flag, y x = int.from_bytes(flag, "big") assert 0 < x < p assert 0 < y < p assert x != y EC = EllipticCurve(GF(p), [a, b]) assert EC(x,y) assert EC(y,x) print("p = {}".format(p)) print("a = {}".format(a…

resultant

消去式のこと。なんかmagicallyに変数を減らすことができて便利。resultantの偉いところは合成数modでも使えるというところ(groebner basisがで動くのに対して)。別にグレブナー基底もで式を建ててから移せばいいんですけど n = randint(0, 2^100) Zn = Zm…