예제 #1
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 ((m_Degree & 0x01) == 0)
            {
                throw new Exception();
            }

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

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

            return(h);
        }
예제 #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 < m_Degree; i++)
            {
                t.SquareThis();
                t.AddToThis(this);
            }

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

            return(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 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;
        }