Exemple #1
0
 def testCreateElement(self):
     F125 = FiniteExtendedField(5, 3)
     self.assertEqual(
         F125.createElement(6),
         F125.createElement(
             FinitePrimeFieldPolynomial(enumerate([1, 1]),
                                        FinitePrimeField.getInstance(5))))
     self.assertEqual(F125.createElement(6), F125.createElement([1, 1]))
Exemple #2
0
 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)))
Exemple #3
0
 def testContains(self):
     # elements of the field
     F125 = FiniteExtendedField(5, 3)
     self.assertTrue(F125.one in F125)
     self.assertTrue(F125.createElement(17) in F125)
     # elements of prime fields
     self.assertTrue(FinitePrimeField.getInstance(5).one in F125)
     # different characteristic
     self.assertFalse(FinitePrimeFieldElement(3, 7) in F125)
     # elements of disjoint fields
     F25 = FiniteExtendedField(5, 2)
     self.assertFalse(F25.one in F125)
     self.assertFalse(F25.createElement(17) in F125)
     F625 = FiniteExtendedField(5, 4)
     self.assertFalse(F625.one in F125)
     self.assertFalse(F625.createElement(17) in F125)
     # we don't expect an element of extended fields be in the field
     # even if it actually is.
     F15625 = FiniteExtendedField(5, 6)
     self.assertFalse(F15625.one in F125)
Exemple #4
0
    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))