aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math/big/int.go7
-rw-r--r--src/math/big/nat.go9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/math/big/int.go b/src/math/big/int.go
index ac5c1f0224..16b7cd131b 100644
--- a/src/math/big/int.go
+++ b/src/math/big/int.go
@@ -551,8 +551,11 @@ func (z *Int) binaryGCD(a, b *Int) *Int {
}
// ProbablyPrime performs n Miller-Rabin tests to check whether x is prime.
-// If it returns true, x is prime with probability 1 - 1/4^n.
-// If it returns false, x is not prime. n must be > 0.
+// If x is prime, it returns true.
+// If x is not prime, it returns false with probability at least 1 - ¼ⁿ.
+//
+// It is not suitable for judging primes that an adversary may have crafted
+// to fool this test.
func (x *Int) ProbablyPrime(n int) bool {
if n <= 0 {
panic("non-positive n for ProbablyPrime")
diff --git a/src/math/big/nat.go b/src/math/big/nat.go
index 121daec829..54f4011ca5 100644
--- a/src/math/big/nat.go
+++ b/src/math/big/nat.go
@@ -1121,9 +1121,12 @@ func (z nat) expNNMontgomery(x, y, m nat) nat {
return zz.norm()
}
-// probablyPrime performs reps Miller-Rabin tests to check whether n is prime.
-// If it returns true, n is prime with probability 1 - 1/4^reps.
-// If it returns false, n is not prime.
+// probablyPrime performs n Miller-Rabin tests to check whether x is prime.
+// If x is prime, it returns true.
+// If x is not prime, it returns false with probability at least 1 - ¼ⁿ.
+//
+// It is not suitable for judging primes that an adversary may have crafted
+// to fool this test.
func (n nat) probablyPrime(reps int) bool {
if len(n) == 0 {
return false