Author: spouliot
Date: 2007-07-05 11:21:01 -0400 (Thu, 05 Jul 2007)
New Revision: 81398
Modified:
trunk/mcs/class/Mono.Security/Mono.Math.Prime/ChangeLog
trunk/mcs/class/Mono.Security/Mono.Math.Prime/PrimalityTests.cs
Log:
2007-07-05 Sebastien Pouliot <[EMAIL PROTECTED]>
* PrimalityTests.cs: Added Test method that select which algorithm,
SPP or RabinMillerTest, to use based on the prime-candidate size.
Removed previous workaround (as this is both a workaround and a good
fix ;-).
Modified: trunk/mcs/class/Mono.Security/Mono.Math.Prime/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Math.Prime/ChangeLog 2007-07-05
14:52:14 UTC (rev 81397)
+++ trunk/mcs/class/Mono.Security/Mono.Math.Prime/ChangeLog 2007-07-05
15:21:01 UTC (rev 81398)
@@ -1,3 +1,10 @@
+2007-07-05 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * PrimalityTests.cs: Added Test method that select which algorithm,
+ SPP or RabinMillerTest, to use based on the prime-candidate size.
+ Removed previous workaround (as this is both a workaround and a good
+ fix ;-).
+
2007-07-05 Sebastien Pouliot <[EMAIL PROTECTED]>
* PrimalityTests.cs: Rewritten RabinMillerTest to be closer to the
Modified: trunk/mcs/class/Mono.Security/Mono.Math.Prime/PrimalityTests.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Math.Prime/PrimalityTests.cs
2007-07-05 14:52:14 UTC (rev 81397)
+++ trunk/mcs/class/Mono.Security/Mono.Math.Prime/PrimalityTests.cs
2007-07-05 15:21:01 UTC (rev 81398)
@@ -92,6 +92,15 @@
}
}
+ public static bool Test (BigInteger n, ConfidenceFactor
confidence)
+ {
+ // Rabin-Miller fails with smaller primes (at least
with our BigInteger code)
+ if (n.BitCount () < 100)
+ return SmallPrimeSppTest (n, confidence);
+ else
+ return RabinMillerTest (n, confidence);
+ }
+
/// <summary>
/// Probabilistic prime test based on Rabin-Miller's test
/// </summary>
@@ -128,10 +137,7 @@
// Applying optimization from HAC section 4.50 (base ==
2)
// not a really random base but an interesting (and
speedy) one
- BigInteger y = null;
- // FIXME: sadly there a bug that makes this fails for
"small" big integers
- if (n.BitCount () > 100)
- y = mr.Pow (2, r);
+ BigInteger y = mr.Pow (2, r);
// still here ? start at round 1 (round 0 was a == 2)
for (int round = 0; round < t; round++) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches