Exemple #1
0
        /// <summary>
        /// Compute the sum of this element and <c>Addend</c>.
        /// </summary>
        ///
        /// <param name="Addend">The addend</param>
        ///
        /// <returns>Returns <c>this + other</c></returns>
        public override IGFElement Add(IGFElement Addend)
        {
            GF2nPolynomialElement result = new GF2nPolynomialElement(this);

            result.AddToThis(Addend);

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Returns the trace of this GF2nPolynomialElement
        /// </summary>
        ///
        /// <returns>The trace of this GF2nPolynomialElement</returns>
        public override int Trace()
        {
            GF2nPolynomialElement t = new GF2nPolynomialElement(this);
            int i;

            for (i = 1; i < mDegree; i++)
            {
                t.SquareThis();
                t.AddToThis(this);
            }

            if (t.IsOne())
            {
                return(1);
            }

            return(0);
        }
Exemple #3
0
        /// <summary>
        /// Returns the half-trace of this GF2nPolynomialElement
        /// </summary>
        ///
        /// <returns>Returns a GF2nPolynomialElement representing the half-trace of this GF2nPolynomialElement</returns>
        private GF2nPolynomialElement HalfTrace()
        {
            if ((mDegree & 0x01) == 0)
            {
                throw new Exception();
            }

            int i;
            GF2nPolynomialElement h = new GF2nPolynomialElement(this);

            for (i = 1; i <= ((mDegree - 1) >> 1); i++)
            {
                h.SquareThis();
                h.SquareThis();
                h.AddToThis(this);
            }

            return(h);
        }
        /// <summary>
        /// Returns the half-trace of this GF2nPolynomialElement
        /// </summary>
        /// 
        /// <returns>Returns a GF2nPolynomialElement representing the half-trace of this GF2nPolynomialElement</returns>
        private GF2nPolynomialElement HalfTrace()
        {
            if ((mDegree & 0x01) == 0)
                throw new Exception();

            int i;
            GF2nPolynomialElement h = new GF2nPolynomialElement(this);

            for (i = 1; i <= ((mDegree - 1) >> 1); i++)
            {
                h.SquareThis();
                h.SquareThis();
                h.AddToThis(this);
            }

            return h;
        }
        /// <summary>
        /// Returns the trace of this GF2nPolynomialElement
        /// </summary>
        /// 
        /// <returns>The trace of this GF2nPolynomialElement</returns>
        public override int Trace()
        {
            GF2nPolynomialElement t = new GF2nPolynomialElement(this);
            int i;

            for (i = 1; i < mDegree; i++)
            {
                t.SquareThis();
                t.AddToThis(this);
            }

            if (t.IsOne())
                return 1;

            return 0;
        }
        /// <summary>
        /// Compute the sum of this element and <c>Addend</c>.
        /// </summary>
        /// 
        /// <param name="Addend">The addend</param>
        /// 
        /// <returns>Returns <c>this + other</c></returns>
        public override IGFElement Add(IGFElement Addend)
        {
            GF2nPolynomialElement result = new GF2nPolynomialElement(this);
            result.AddToThis(Addend);

            return result;
        }