class Homomorphism2Test(unittest.TestCase): """ test for homomorphisms """ def setUp(self): """ create two different Fq's. """ self.F2 = FinitePrimeField.getInstance(2) f = FinitePrimeFieldPolynomial([(0, 1), (5, 1), (6, 1)], self.F2) self.F64 = FiniteExtendedField(2, f) self.F3 = FinitePrimeField.getInstance(3) f = FinitePrimeFieldPolynomial(enumerate([1, 2, 1, 2, 1]), self.F3) self.F81 = FiniteExtendedField(3, f) def testIsomorphism(self): """ test for fqiso """ g = FinitePrimeFieldPolynomial(enumerate([1, 1, 0, 0, 1, 1, 1]), self.F2) F64b = FiniteExtendedField(2, g) f64iso = fqiso(self.F64, F64b) self.assertEqual(F64b.zero, f64iso(self.F64.zero)) self.assertEqual(F64b.one, f64iso(self.F64.one)) x = F64b.createElement(2) self.assertEqual(F64b.order(x), self.F64.order(f64iso(x))) g = FinitePrimeFieldPolynomial(enumerate([2, 0, 0, 1, 1]), self.F3) F81b = FiniteExtendedField(3, g) f81iso = fqiso(self.F81, F81b) self.assertEqual(F81b.zero, f81iso(self.F81.zero)) self.assertEqual(F81b.one, f81iso(self.F81.one)) def testEmbedding(self): """ test for embedding """ F8 = FiniteExtendedField(2, 3) embed8to64 = embedding(F8, self.F64) self.assertEqual(self.F64.zero, embed8to64(F8.zero)) self.assertEqual(self.F64.one, embed8to64(F8.one)) x = F8.createElement(2) self.assertEqual(F8.order(x), self.F64.order(embed8to64(x))) def testDoubleEmbeddings(self): """ test for double_embeddings """ # linearly disjoint F32 = FiniteExtendedField(2, 5) e1, e2 = double_embeddings(F32, self.F64) self.assertEqual(e1(F32.one), e2(self.F64.one))
def testEmbedding(self): """ test for embedding """ F8 = FiniteExtendedField(2, 3) embed8to64 = embedding(F8, self.F64) self.assertEqual(self.F64.zero, embed8to64(F8.zero)) self.assertEqual(self.F64.one, embed8to64(F8.one)) x = F8.createElement(2) self.assertEqual(F8.order(x), self.F64.order(embed8to64(x)))
def testIsomorphism(self): """ test for fqiso """ g = FinitePrimeFieldPolynomial(enumerate([1, 1, 0, 0, 1, 1, 1]), self.F2) F64b = FiniteExtendedField(2, g) f64iso = fqiso(self.F64, F64b) self.assertEqual(F64b.zero, f64iso(self.F64.zero)) self.assertEqual(F64b.one, f64iso(self.F64.one)) x = F64b.createElement(2) self.assertEqual(F64b.order(x), self.F64.order(f64iso(x))) g = FinitePrimeFieldPolynomial(enumerate([2, 0, 0, 1, 1]), self.F3) F81b = FiniteExtendedField(3, g) f81iso = fqiso(self.F81, F81b) self.assertEqual(F81b.zero, f81iso(self.F81.zero)) self.assertEqual(F81b.one, f81iso(self.F81.one))