Exemplo n.º 1
0
        public void TestFactorizeOnMZIExample()
        {
            BigInteger number = 455839;

            BigInteger[] expected = new BigInteger[] { 599, 761 };
            BigInteger[] actual   = new BigInteger[2];
            actual[0] = new LenstraECFactorization().Factorize(number);
            actual[1] = number / actual[0];

            CollectionAssert.AreEquivalent(expected, actual);
        }
Exemplo n.º 2
0
        public void TestFactorizeOnPrime()
        {
            BigInteger number = 10061;

            BigInteger[] expected = new BigInteger[] { 1, number };
            BigInteger[] actual   = new BigInteger[2];
            actual[0] = new LenstraECFactorization().Factorize(number);
            actual[1] = number / actual[0];

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void TestFactorizeOnBookExample()
        {
            BigInteger number = 661643;

            BigInteger[] expected = new BigInteger[] { 541, 1223 };
            BigInteger[] actual   = new BigInteger[2];
            actual[0] = new LenstraECFactorization().Factorize(number);
            actual[1] = number / actual[0];

            CollectionAssert.AreEquivalent(expected, actual);
        }
Exemplo n.º 4
0
        public void TestFactorizeOnBigPrimes()
        {
            BigInteger a      = BigInteger.Parse("274876858367");
            BigInteger b      = BigInteger.Parse("68718952447");
            BigInteger number = a * b;

            BigInteger[] expected = new BigInteger[] { a, b };
            BigInteger[] actual   = new BigInteger[2];
            actual[0] = new LenstraECFactorization(baseSize: 100).Factorize(number);
            actual[1] = number / actual[0];

            CollectionAssert.AreEquivalent(expected, actual);
        }
Exemplo n.º 5
0
        private void ChangeSizeOfBase()
        {
            Console.Write("Enter new size of base (count of primes) (min 2): ");

            if (int.TryParse(Console.ReadLine(), out int size) && size >= 2)
            {
                this._lenstra = new LenstraECFactorization(this._lenstra.Attempts, size);
                Console.WriteLine("Change successful.\n");
            }
            else
            {
                Console.WriteLine("Invalid input. Change canceled.\n");
            }
        }
Exemplo n.º 6
0
        private void ChangeCountOfAttempts()
        {
            Console.Write("Enter new count of attempts (min 1): ");

            if (int.TryParse(Console.ReadLine(), out int count) && count >= 1)
            {
                this._lenstra = new LenstraECFactorization(count, this._lenstra.SizeOfBase);
                Console.WriteLine("Change successful.\n");
            }
            else
            {
                Console.WriteLine("Invalid input. Change canceled.\n");
            }
        }
Exemplo n.º 7
0
 public Utility()
 {
     this._lenstra  = new LenstraECFactorization();
     this._firstRun = true;
 }