Skip to content

Instantly share code, notes, and snippets.

@tsusanka
Created May 2, 2015 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsusanka/96dc60e20d65174073cf to your computer and use it in GitHub Desktop.
Save tsusanka/96dc60e20d65174073cf to your computer and use it in GitHub Desktop.
Mathematica GF multiplication
X = 16^^00000000331100002201;
Y = 16^^0000000000223811f321;
m = 79;
f = \[Alpha]^79 + \[Alpha]^9 + 1;
polynomialBasis = Table[\[Alpha]^i, {i, m - 1, 0, -1}];
Print["X = ", BaseForm[X, 16]];
Print["Y = ", BaseForm[Y, 16]];
x = IntegerDigits[X, 2, m].polynomialBasis;
y = IntegerDigits[Y, 2, m].polynomialBasis;
z = PolynomialMod[x*y, {f, 2}];
zx = z /. {\[Alpha] -> 2};
Print["X * Y = ", BaseForm[zx, 16] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment