1 Commits

Author SHA1 Message Date
Maxime Vorwerk
b8a45eb92c flag_printer_temp 2025-02-15 18:38:54 +01:00
4 changed files with 1769670 additions and 0 deletions

1769611
flag_printer/encoded.txt Normal file

File diff suppressed because it is too large Load Diff

28
flag_printer/flag_printer.py Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python3
import galois
import numpy as np
MOD = 7514777789
points = []
for line in open('encoded.txt', 'r').read().strip().split('\n'):
x, y = line.split(' ')
points.append((int(x), int(y)))
GF = galois.GF(MOD)
print(GF.properties)
matrix = []
solution = []
for point in points:
x, y = point
solution.append(GF(y % MOD))
row = []
for i in range(3):
row.append(GF((x ** i) % MOD))
matrix.append(GF(row))
print('solving')
open('output.bmp', 'wb').write(bytearray(np.linalg.lstsq(GF(matrix), GF(solution)).tolist()[:-1]))

0
flag_printer/output.bmp Normal file
View File

31
flag_printer/sol.py Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
from sage.all import *
MOD = 7514777789
ring=GF(MOD)
points = []
for line in open('encoded.txt', 'r').read().strip().split('\n'):
x, y = line.split(' ')
points.append((int(x), int(y)))
print("building matrices")
solution = []
M = []
for point in points:
x, y = point
solution.append(ring(y % MOD))
row = []
for i in range(3):
row.append(pow(x, i, MOD))
M.append(row)
print("converting matrices")
solution = vector(solution)
M = Matrix(M, base_ring=GF(MOD))
print('solving')
open('output.bmp', 'wb').write(bytearray(M.solve_right(solution).tolist()[:-1]))