Created
October 13, 2024 18:02
-
-
Save maple3142/b0d47badb579d90257d6534411e0a33b to your computer and use it in GitHub Desktop.
GF multiply by constant to matrix multiplication
This file contains hidden or 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
x = polygen(GF(2)) | |
mod = x.parent().irreducible_element(8, algorithm='random') | |
F = GF(2^8, 'a', modulus=mod) | |
def get_multiply_matrix(mul, mod): | |
return mul.polynomial()(matrix.companion(mod)) | |
mul = F.random_element() | |
T = get_multiply_matrix(mul, mod) | |
for _ in range(100): | |
r = F.random_element() | |
va = vector(r.polynomial().padded_list(8)) | |
vb = vector((r * mul).polynomial().padded_list(8)) | |
assert T * va == vb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment