예제 #1
0
        public void GetR_Data()
        {
            var list = new BigInteger[samples];

            for (int i = 0; i < samples; i++)
            {
                PoupardStern.GetR(keySize, out list[i]);
            }

            Console.WriteLine(String.Join(",", list.ToList()));
        }
예제 #2
0
        public void GetW_Data()
        {
            var keyPair = TestUtils.GeneratePrivate(Exp, keySize);

            var pubKey = (RsaKeyParameters)keyPair.Public;

            BigK = 5000;

            var Modulus = pubKey.Modulus;

            BigInteger[] Datalist = new BigInteger[BigK];

            // Initialize list of z values
            BigInteger[] zValues = new BigInteger[BigK];

            // Generate the list of z Values
            for (int i = 0; i < BigK; i++)
            {
                zValues[i] = PoupardStern.SampleFromZnStar(pubKey, ps, i, BigK, keySize);
            }

            for (int i = 0; i < BigK; i++)
            {
                // Initialize list of x values.
                BigInteger[] xValues = new BigInteger[BigK];

                // Generate r
                PoupardStern.GetR(keySize, out BigInteger r);

                for (int j = 0; j < BigK; j++)
                {
                    // Compute x_i
                    xValues[j] = zValues[j].ModPow(r, Modulus);
                }

                // Compute w
                PoupardStern.GetW(pubKey, ps, xValues, k, keySize, out BigInteger w);

                Datalist[i] = w;
            }
            Console.WriteLine(String.Join(",", Datalist.ToList()));
        }
예제 #3
0
        public void GetWTest()
        {
            var k       = 128;
            var BigK    = k + 1;
            var keyPair = TestUtils.GeneratePrivate(Exp, keySize);

            var pubKey = (RsaKeyParameters)keyPair.Public;

            var Modulus = pubKey.Modulus;

            // Initialize list of z values
            BigInteger[] zValues = new BigInteger[BigK];

            // Generate the list of z Values
            for (int i = 0; i < BigK; i++)
            {
                zValues[i] = PoupardStern.SampleFromZnStar(pubKey, ps, i, BigK, keySize);
            }

            // Initialize list of x values.
            BigInteger[] xValues = new BigInteger[BigK];

            // Generate r
            PoupardStern.GetR(keySize, out BigInteger r);

            for (int j = 0; j < BigK; j++)
            {
                // Compute x_i
                xValues[j] = zValues[j].ModPow(r, Modulus);
            }

            // Compute w
            PoupardStern.GetW(pubKey, ps, xValues, k, keySize, out BigInteger w);

            // Check that the bitLength of w equals to k.
            Assert.IsTrue(w.BitLength <= k);
        }