Example #1
0
        public void TestIsSafeElementForNeutralElementCofactorOne()
        {
            var groupAlgebra = new MultiplicativeGroupAlgebra(BigPrime.CreateWithoutChecks(11), BigPrime.CreateWithoutChecks(10), 2);

            Assert.That(groupAlgebra.IsPotentialElement(groupAlgebra.NeutralElement));
            Assert.That(!groupAlgebra.IsSafeElement(groupAlgebra.NeutralElement));
        }
Example #2
0
        public void TestComputeSecurityLevel()
        {
            var mod = BigPrime.CreateWithoutChecks(BigInteger.One << 2047);

            Assert.AreEqual(115, MultiplicativeGroupAlgebra.ComputeSecurityLevel(mod, mod));

            var smallOrder = BigPrime.CreateWithoutChecks(new BigInteger(4));

            Assert.AreEqual(2 * NumberLength.GetLength(smallOrder).InBits, MultiplicativeGroupAlgebra.ComputeSecurityLevel(mod, smallOrder));
        }
Example #3
0
        public void TestEqualsFalseForOtherAlgebra()
        {
            var otherAlgebra = new MultiplicativeGroupAlgebra(
                BigPrime.CreateWithoutChecks(2 * 53 + 1),
                BigPrime.CreateWithoutChecks(53),
                4
                );

            Assert.IsFalse(groupAlgebra !.Equals(otherAlgebra));
        }
Example #4
0
        public void TestComputePrimeLengthForSecurityLevel()
        {
            // dominated by NFS
            var l = MultiplicativeGroupAlgebra.ComputePrimeLengthForSecurityLevel(100);
            var p = BigPrime.CreateWithoutChecks(BigInteger.One << (l.InBits - 1));
            var s = MultiplicativeGroupAlgebra.ComputeSecurityLevel(p, p);

            Assert.AreEqual(100, s);

            // dominated by Pollard Rho
            l = MultiplicativeGroupAlgebra.ComputePrimeLengthForSecurityLevel(1);
            Assert.AreEqual(2, l.InBits);
        }