From 7be735712617daca0a51076b9b339dd4157ae7f8 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Tue, 9 Jun 2026 09:41:31 +0200 Subject: [PATCH] use sagemath built in function --- src/tea3/variable_search.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/tea3/variable_search.py b/src/tea3/variable_search.py index f641a49..c675ba0 100644 --- a/src/tea3/variable_search.py +++ b/src/tea3/variable_search.py @@ -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