2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-24 13:47:42 +00:00
restic/doc/test_irreducibility.gap
Alexander Neumann 3cdf3a25b9 chunker: Require a random irreducible polynomial
This also implements the necessary polynomial arithmetics in F_2[X].
2015-04-05 22:52:43 +02:00

26 lines
739 B
Plaintext

# This file is a script for GAP and tests a list of polynomials in hexadecimal
# for irreducibility over F_2
# create x over F_2 = GF(2)
x := Indeterminate(GF(2), "x");
# test if polynomial is irreducible, i.e. the number of factors is one
IrredPoly := function (poly)
return (Length(Factors(poly)) = 1);
end;;
# create a polynomial in x from the hexadecimal representation of the
# coefficients
Hex2Poly := function (s)
return ValuePol(CoefficientsQadic(IntHexString(s), 2), x);
end;;
# list of candidates, in hex
candidates := [ "3DA3358B4DC173" ];
# create real polynomials
L := List(candidates, Hex2Poly);
# filter and display the list of irreducible polynomials contained in L
Display(Filtered(L, x -> (IrredPoly(x))));