Пример #1
0
        private void ComputeType()
        {
            if ((DegreeN & 7) == 0)
            {
                throw new Exception("The extension degree is divisible by 8!");
            }

            // checking for the type
            int s = 0;
            int k = 0;

            m_Type = 1;

            for (int d = 0; d != 1; m_Type++)
            {
                s = m_Type * DegreeN + 1;
                if (BigMath.IsPrime(s))
                {
                    k = BigMath.Order(2, s);
                    d = BigMath.Gcd(m_Type * DegreeN / k, DegreeN);
                }
            }
            m_Type--;

            if (m_Type == 1)
            {
                s = (DegreeN << 1) + 1;
                if (BigMath.IsPrime(s))
                {
                    k = BigMath.Order(2, s);
                    int d = BigMath.Gcd((DegreeN << 1) / k, DegreeN);
                    if (d == 1)
                    {
                        m_Type++;
                    }
                }
            }
        }