use sagemath built in function

This commit is contained in:
2026-06-09 09:41:31 +02:00
parent c9957ab4ab
commit 7be7357126
+1 -10
View File
@@ -4,19 +4,10 @@ from tea3.pretty_print import pretty_print
def count_monomials(poly):
s = pretty_print(poly).strip()
if not s or s == "0":
return 0
return sum(1 for term in s.split("+") if term.strip())
return len(poly.monomials())
def apply_variable_change(model, coeffs):
"""
Variable change inside each 8-bit register:
x_{r,0} = y_{r,0} + a1*y_{r,1} + ... + a7*y_{r,7}
x_{r,j} = y_{r,j} for j = 1..7
for every register r in {0,...,4}.
"""
orig_x = [list(model.v[r * 8 : (r + 1) * 8]) for r in range(5)]
orig_y = model.y_bits