Ejemplo n.º 1
0
        /// <summary>
        /// Create a finite field GF(2^m)
        /// </summary>
        ///
        /// <param name="Degree">The degree of the field</param>
        public GF2mField(int Degree)
        {
            if (Degree >= 32)
            {
                throw new ArgumentException("Error: the degree of field is too large!");
            }
            if (Degree < 1)
            {
                throw new ArgumentException("Error: the degree of field is non-positive!");
            }

            this.m_degree = Degree;
            m_polynomial  = PolynomialRingGF2.GetIrreduciblePolynomial(Degree);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Return the product of two elements
 /// </summary>
 ///
 /// <param name="A">Integer value A</param>
 /// <param name="B">Integer value b</param>
 ///
 /// <returns>The sum: <c>a*b</c></returns>
 public int Multiply(int A, int B)
 {
     return(PolynomialRingGF2.ModMultiply(A, B, m_polynomial));
 }