Beispiel #1
0
        public BigInteger[] getFactorsSerial()
        {
            BigInteger p = 1997333137;
            BigInteger q = 2106945901;

            BigInteger integer_to_factor = p * q;

            Console.WriteLine("p value: " + p);
            Console.WriteLine("q value: " + q);


            BigInteger[] bruteforce_Serial = LeedamKeyson.factorModulusSerial(integer_to_factor);

            Console.WriteLine("brute force serial p value: " + bruteforce_Serial[0]);
            Console.WriteLine("brute force serial q value: " + bruteforce_Serial[1]);


            BigInteger[] bruteforce_Parallel = LeedamKeyson.factorModulusParallel(integer_to_factor);

            Console.WriteLine("brute force parallel p value: " + bruteforce_Parallel[0]);
            //Console.WriteLine("brute force parallel q value" + bruteforce_Parallel[1]);


            int factor_serial = QuadraticSieveFunctions.SieveofSundaramSerial(integer_to_factor);

            Console.WriteLine("Serial returns the p value: " + factor_serial);
            Console.WriteLine("Serial returns the q value: " + (integer_to_factor / factor_serial));

            int factor_parallel = QuadraticSieveFunctions.SieveofSundaramParallel(integer_to_factor);

            Console.WriteLine("Parallel returns the p value: " + factor_parallel);
            Console.WriteLine("Parallel returns the q value: " + (integer_to_factor / factor_parallel));



            int factor_base_size = QuadraticSieveFunctions.getFactorBaseSize(integer_to_factor);

            factor_base_size = (int)BigIntegerWrapper.SqRt(integer_to_factor);
            BigInteger sieve_interval_upper = QuadraticSieveFunctions.getSieveInterval(factor_base_size);

            int[] factor_base = QuadraticSieveFunctions.SieveOfErastosthenesSerial(factor_base_size);
            factor_base = new int[] { 0 };
            factor_base = QuadraticSieveFunctions.SieveOfErastosthenesParallel(factor_base_size);



            int[] quadratic_residues = QuadraticSieveFunctions.getResiduesSerial(factor_base, integer_to_factor);

            BigInteger sieve_interval       = QuadraticSieveFunctions.getSieveInterval(factor_base_size);
            BigInteger sieve_interval_start = BigIntegerWrapper.SqRt(integer_to_factor);

            LinkedList <BigInteger[]> smooth_numbers = QuadraticSieveFunctions.SmoothNumberSieveSerial(integer_to_factor, quadratic_residues, sieve_interval_start, sieve_interval_start + sieve_interval);
            //int k = 100000000;
            //QuadraticSieveFunctions.getFactorBaseSize(integer_to_factor);
            //int test_factor_base_size = QuadraticSieveFunctions.getFactorBaseSize(k);


            int result  = factorSerial(factor_base, integer_to_factor);
            int result2 = factorParallel(factor_base, integer_to_factor);

            //int[] factor_base_parallel_improved = QuadraticSieveFunctions.SieveOfErastosthenesParallelImproved(2 * k);
            //int[] factor_base_parallel = QuadraticSieveFunctions.SieveOfErastosthenesParallel(2*k);

            return(new BigInteger[] { result, (int)(sieve_interval_upper / result) });
        }
Beispiel #2
0
        public BigInteger[] getFactorsParallel()
        {
            int k = QuadraticSieveFunctions.getFactorBaseSize(integer_to_factor);

            return(new BigInteger[] { new BigInteger(QuadraticSieveFunctions.getFactorBaseSize(integer_to_factor)), new BigInteger(QuadraticSieveFunctions.getFactorBaseSize(integer_to_factor)) });
        }