27 lines
1.1 KiB
Go
27 lines
1.1 KiB
Go
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package big
|
|
|
|
// ProbablyPrime reports whether x is probably prime,
|
|
// applying the Miller-Rabin test with n pseudorandomly chosen bases
|
|
// as well as a Baillie-PSW test.
|
|
//
|
|
// If x is prime, ProbablyPrime returns true.
|
|
// If x is chosen randomly and not prime, ProbablyPrime probably returns false.
|
|
// The probability of returning true for a randomly chosen non-prime is at most ¼ⁿ.
|
|
//
|
|
// ProbablyPrime is 100% accurate for inputs less than 2⁶⁴.
|
|
// See Menezes et al., Handbook of Applied Cryptography, 1997, pp. 145-149,
|
|
// and FIPS 186-4 Appendix F for further discussion of the error probabilities.
|
|
//
|
|
// ProbablyPrime is not suitable for judging primes that an adversary may
|
|
// have crafted to fool the test.
|
|
//
|
|
// As of Go 1.8, ProbablyPrime(0) is allowed and applies only a Baillie-PSW test.
|
|
// Before Go 1.8, ProbablyPrime applied only the Miller-Rabin tests, and ProbablyPrime(0) panicked.
|
|
func (x *Int) ProbablyPrime(n int) bool {
|
|
panic("ProbablyPrime: todo")
|
|
}
|