Make sure public key bit length is an even number

For an odd n-bit number, we can't find two n-1-bit numbers which
multiplied gives an n-bit number. That's why public key length n must be
an even number.

I have also renamed AreSafePrimes to IsSafePrime since only the first
function argument is considered to be a safe prime according to a safe
prime definition.
This commit is contained in:
Piotr Dyraga committed 2018-08-08 11:11:05 +02:00
1 parent d5973f86a7
commit 12b3dadef7
4 files changed
+26 -10

No files matched your search

+3 -1
View File
@@ -59,7 +59,9 @@ func TestFactorial(t *testing.T) {
}
}
func AreSafePrimes(p, q *big.Int, expectedLength int, t *testing.T) {
// IsSafePrime checks whether `p` is a safe prime. A safe prime is a prime
// number of the form `2q + 1`, where `q` is also a prime.
func IsSafePrime(p, q *big.Int, expectedLength int, t *testing.T) {
if l := p.BitLen(); l != expectedLength {
t.Error("p does not have the good length. ", l)
}