示例#1
0
        public Program()
        {
            InputTuple DLP = GetDLP();

            while (true)
            {
                Console.WriteLine("What value k for the special point condition would you like to use?");
                bool parseSuccess = int.TryParse(Console.ReadLine(), out k);
                if (parseSuccess)
                {
                    if (k >= 0)
                    {
                        break;
                    }

                    Console.WriteLine("Please enter a non-negative number.");
                    continue;
                }

                Console.WriteLine("The input could not be parsed. Please try again.");
            }

            DLPSolver  solver = new DLPSolver(DLP);
            BigInteger?answer = solver.Solve();

            Console.WriteLine($"{DLP}.\nSolution: {answer}.\n");
            Console.ReadLine();
        }
示例#2
0
        public DLPSolver(InputTuple input)
        {
            modulus = input.Modulus;

            if (modulus % 2 == 0)
            {
                throw new NotImplementedException("At the moment, it is not possible to use an even number for a modulus.");
            }

            generator = input.Generator;
            order     = input.Order;
            element   = input.Element;

            wordsPerNumber = modulus.ToUintArray().Length;
            rAsPower       = 32 * wordsPerNumber;

            Pollard_Rho pRho = new Pollard_Rho(input, rAsPower);

            // Initialize the startingPointGenerator.
            gpuStartingPointsBuffer = new OpenCLBuffer <uint>(program, new uint[4 * NUM_GPU_THREADS * wordsPerNumber]);
            startingPointGenerator  = new StartingPointGenerator(input, rAsPower, wordsPerNumber, pRho, program, gpuStartingPointsBuffer);

            // Initialize the specialPointCollector.
            gpuSpecialPointsBuffer = new OpenCLBuffer <uint>(program, new uint[2 * wordsPerNumber * 4 * NUM_GPU_THREADS]);
            specialPointCollector  = new SpecialPointCollector(wordsPerNumber, pRho, gpuSpecialPointsBuffer, startingPointGenerator);
        }
        public Pollard_Rho(InputTuple input, int rAsPower)
        {
            this.modulus   = input.Modulus;
            this.generator = input.Generator;
            this.order     = input.Order;
            this.element   = input.Element;

            this.rAsPower      = rAsPower;
            this.r             = BigInteger.One << rAsPower;
            this.modulus_prime = -Utility.ExtendedEuclidesGCD1(r, modulus).Item2;
        }
示例#4
0
        public StartingPointGenerator(InputTuple input, int rAsPower, int wordsPerNumber, Pollard_Rho pRho, OpenCLProgram program, OpenCLBuffer <uint> startingPointsBuffer)
        {
            this.modulus        = input.Modulus;
            this.generator      = input.Generator;
            this.order          = input.Order;
            this.element        = input.Element;
            this.rAsPower       = rAsPower;
            this.wordsPerNumber = wordsPerNumber;
            this.pRho           = pRho;

            this.kernel = new OpenCLKernel(program, "add_new_starting_points");
            this.newStartingPointsBuffer = new OpenCLBuffer <uint>(program, new uint[4 * DLPSolver.NUM_GPU_THREADS * wordsPerNumber]);

            this.startingPointPool = new uint[4 * DLPSolver.NUM_GPU_THREADS * wordsPerNumber];

            kernel.SetArgument(0, startingPointsBuffer);
            kernel.SetArgument(1, newStartingPointsBuffer);
        }