use sagemath built in function
This commit is contained in:
@@ -4,19 +4,10 @@ from tea3.pretty_print import pretty_print
|
|||||||
|
|
||||||
|
|
||||||
def count_monomials(poly):
|
def count_monomials(poly):
|
||||||
s = pretty_print(poly).strip()
|
return len(poly.monomials())
|
||||||
if not s or s == "0":
|
|
||||||
return 0
|
|
||||||
return sum(1 for term in s.split("+") if term.strip())
|
|
||||||
|
|
||||||
|
|
||||||
def apply_variable_change(model, coeffs):
|
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_x = [list(model.v[r * 8 : (r + 1) * 8]) for r in range(5)]
|
||||||
orig_y = model.y_bits
|
orig_y = model.y_bits
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user