Exemple #1
0
        /// <summary>
        /// Create a finite field GF(2^m) with the fixed field polynomial
        /// </summary>
        ///
        /// <param name="Degree">The degree of the field</param>
        /// <param name="Polynomial">The field polynomial</param>
        public GF2mField(int Degree, int Polynomial)
        {
            if (Degree != PolynomialRingGF2.Degree(Polynomial))
            {
                throw new ArgumentException(" Error: the degree is not correct!");
            }
            if (!PolynomialRingGF2.IsIrreducible(Polynomial))
            {
                throw new ArgumentException(" Error: given polynomial is reducible!");
            }

            m_degree     = Degree;
            m_polynomial = Polynomial;
        }
Exemple #2
0
        /// <summary>
        /// Create a finite field GF(2^m) using an encoded array
        /// </summary>
        ///
        /// <param name="Encoded">The polynomial and degree encoded as a byte array</param>
        public GF2mField(byte[] Encoded)
        {
            if (Encoded.Length != 4)
            {
                throw new ArgumentException("byte array is not an encoded finite field");
            }

            m_polynomial = LittleEndian.OctetsToInt(Encoded);

            if (!PolynomialRingGF2.IsIrreducible(m_polynomial))
            {
                throw new ArgumentException("byte array is not an encoded finite field");
            }

            m_degree = PolynomialRingGF2.Degree(m_polynomial);
        }