示例#1
0
        static void Main(string[] args)
        {
            int Nice             = 0;
            int NotNice          = 0;
            BigIntegerRandom BIR = new BigIntegerRandom();

            DigitalSignature NewSignature = new DigitalSignature(64); //p,g
                                                                      //Console.WriteLine("i=={0,3} G=={1}", i,NewSignature.G);

            BigInteger X;

            do
            {
                X = BIR.GenerateSimple(64);
                if (GCDEX.GetX(X, NewSignature.P - 1) > 0)
                {
                    break;
                }
            } while (true);
            //Закрытый ключ
            BigInteger M = BigInteger.Parse("465498132");           //Исходное сообщение
            BigInteger Z = BigInteger.ModPow(M, X, NewSignature.P); //Подписанное сообщение

            for (int i = 0; i < 10; i++)
            {
                if (Bob(NewSignature.P, NewSignature.G, X, Z, M))
                {
                    Nice++;
                }
                else
                {
                    NotNice++;
                }
            }

            Console.WriteLine("Nice=={0}\nNotNice=={1}", Nice, NotNice);
        }