multivariate_coppersmith

zer0pts CTF 2021 | easy pseudorandom

#zer0ptsCTF2021 from Crypto.Util.number import* from flag import flag nbits = 256 p = random_prime(1 << nbits) Fp = Zmod(p) P.<v> = PolynomialRing(Fp) b = randrange(p) d = 2 F = v^2 + b v0 = randrange(p) v1 = F(v0) k = ceil(nbits * (d / (d + </v>…

Securinets Quals 2022 | Escrime

#Securinets_Quals_2022 from Crypto.Util.number import getStrongPrime, getPrime, isPrime, bytes_to_long FLAG = b"Securinets{REDACTED}" def genPrime(prime): while True: a = getPrime(256) p = 2*prime*a + 1 if isPrime(p): break while True: b =…

zer0pts CTF 2022 | CurveCrypto

#zer0ptsCTF2022 import os from random import randrange from Crypto.Util.number import bytes_to_long, long_to_bytes, getStrongPrime from Crypto.Util.Padding import pad from fastecdsa.curve import Curve def xgcd(a, b): x0, y0, x1, y1 = 1, 0,…

HITCON CTF 2022 | Chimera

#HITCON_CTF_2022 import os from Crypto.Util.number import bytes_to_long, getPrime from Crypto.Cipher import AES from Crypto.Util.Padding import pad from hashlib import sha256 from secret import flag p = getPrime(384) q = getPrime(384) n = …

pbctf 2021 | yet another RSA

#pbctf_2021 #rbtree #!/usr/bin/env python3 from Crypto.Util.number import * import random def genPrime(): while True: a = random.getrandbits(256) b = random.getrandbits(256) if b % 3 == 0: continue p = a ** 2 + 3 * b ** 2 if p.bit_length()…

CrewCTF 2022 | The D

#CrewCTF_2022 #uninterested_challenge_list from Crypto.Util.number import getStrongPrime, inverse, bytes_to_long, GCD from random import randint from flag import flag p = getStrongPrime(512) q = getStrongPrime(512) n = p * q while True: d …

3kCTF-2021 | Digital

#3kCTF-2021 from Crypto.Util.number import inverse import hashlib import os rol = lambda val, r_bits, max_bits: (val << r_bits%max_bits) & (2**max_bits-1) | ((val & (2**max_bits-1)) >> (max_bits-(r_bits%max_bits))) class Random(): def __in…

Midnightsun CTF 2021 Quals | dbcsig

#midnightsunctf2021quals from hashlib import sha256 def keygen(password): while True: p = 2 * random_prime(2 ^ 521) + 1 if p.is_prime(proof=False): break base, h = 3, password for i in range(256): h = sha256(h).digest() x = int.from_bytes(…

pbctf2020 | LeaK

ECDSA pbctf2020 #!/usr/bin/env python3 from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from ecdsa import SECP256k1 from ecdsa.ecdsa import Public_key, Private_key from flag import flag import hashlib import random …

Coppersmith's Theorem

univariate coppersmith method multivariate coppersmith 多項式の上の小さい根または上の小さい根を多項式時間で求めるアルゴリズム。つまり または となるようなを求めるということ。Sagemathではsmall_roots というメソッドが生えている。 というパラメ…

Midnightsun CTF 2021 Quals | ocat_024

#midnightsunctf2021quals u = getrandbits(512) p = next_prime(1337 * u + getrandbits(300)) q = next_prime(2021 * u + getrandbits(300)) n = p * q sage: n 376347864369130929314918003073529176189619811132906053032580291332225522349124770927556…