Ejemplo n.º 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!");
            }

            _degree     = Degree;
            _polynomial = Polynomial;
        }
Ejemplo n.º 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");
            }

            _polynomial = LittleEndian.OctetsToInt(Encoded);

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

            _degree = PolynomialRingGF2.Degree(_polynomial);
        }