Example #1
0
        static public void FindSecondPart()
        {
            b = new long[Program.NumberEncrypt.Length];
            ELGAmal.extendedGCD(k, p - 1, out long t1, out long t2, out long d);
            for (int i = 0; i < b.Length; i++)
            {
                long firstPart  = t1 + p - 1;
                long secondPart = ELGAmal.Mod(Program.NumberEncrypt[i] + 1 - x * a, p - 1);
                //Console.WriteLine(firstPart + " " + secondPart);

                b[i] = ELGAmal.Mod(firstPart * secondPart, p - 1);

                //Console.WriteLine(b[i]);
            }
            PrintB(b);
        }
Example #2
0
        static public void verificationOfDigitalSignature(long a, long[] b, long[] NumberEncrypt)
        {
            long[] LeftPart  = new long[b.Length]; //Левая часть
            long[] RightPart = new long[b.Length]; //Правая часть

            PrintLog("Левая часть: ", false);
            for (int i = 0; i < b.Length; i++)
            {
                RightPart[i] = (long)ELGAmal.reSquaring(KeyAbonentG, NumberEncrypt[i], KeyAbonentP);
                Console.Write(RightPart[i] + " ");
            }
            Console.WriteLine();

            PrintLog("Правая часть: ", false);
            for (int i = 0; i < b.Length; i++)
            {
                long temp = (long)(ELGAmal.reSquaring(KeyAbonentY, a, KeyAbonentP) * ELGAmal.reSquaring(a, b[i], KeyAbonentP));
                LeftPart[i] = ELGAmal.Mod(temp, KeyAbonentP);
                Console.Write(RightPart[i] + " ");
            }
            Console.WriteLine("\nПроверка показала идентичность ЭЦП и открытой подписи!");
        }