This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
p = 211 | |
q = 192 | |
a = 201 | |
b = 102 | |
e = 13 | |
Fp = GF(p) | |
Zq = Zmod(q) | |
E = EllipticCurve(Fp, [a, b]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
primes = list(prime_range(1000000)) | |
# 4p = 1 + Dy^2, p = p1 * p2 * ... * pm + 1 | |
# 4 * p1 * ... * pm + 3 = D * y^2 (p1 should be 2) | |
# 8 * p2 * ... * pm = D * y^2 - 3 = (sqrt(D) * y - sqrt(3)) * (sqrt(D) * y + sqrt(3)) | |
# when D = 27, r.h.s. = 3 * (3*y - 1) * (3*y + 1) | |
cnt = 0 | |
y3_min = int(sqrt(2 ** 255 * 4 // 3)) | |
y3_max = int(sqrt(2 ** 256 * 4 // 3)) | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from Crypto.Util.number import bytes_to_long, long_to_bytes | |
from z3 import * | |
N = 624 | |
M = 397 | |
MATRIX_A = 0x9908B0DF | |
UPPER_MASK = 0x80000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from z3 import * | |
from tqdm import tqdm | |
from functools import lru_cache | |
from collections import Counter | |
from itertools import combinations | |
import time | |
def _prod(L): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://static.chunichi.co.jp/chunichi/pages/feature/QR/galois_field_in_auto_factory.html | |
X = GF(2).polynomial_ring().gen() | |
poly = X ** 8 + X ** 4 + X ** 3 + X ** 2 + 1 | |
F = GF(2 ** 8, name="a", modulus=poly) | |
R.<x> = PolynomialRing(F) | |
def tobin(x, n): | |
x = Integer(x) | |
nbits = x.nbits() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pwn import * | |
elf = ELF("./caniride") | |
context.binary = elf | |
REMOTE = True | |
if REMOTE: | |
io = remote("challs.actf.co", 31228) | |
libc = ELF("./libc.so.6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a small prime for brevity | |
p = 4 * 3 * 5 * 7 - 1 | |
primes = [3, 5, 7] | |
Fp = GF(p) | |
def from_weierstrass(EC): | |
a, b = EC.a4(), EC.a6() | |
F = EC.base_field() | |
PR = PolynomialRing(F, name="z") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import binascii | |
import itertools | |
import struct | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
# configurable stuff | |
bits = 64 |