From 2ee867dfd9e7914601058a6b465b87ebffa8d0a1 Mon Sep 17 00:00:00 2001 From: creamwhip Date: Mon, 29 Nov 2021 18:01:20 +0800 Subject: [PATCH] common/random_test: ensure odd relative prime int in TestGetRandomQuadraticNonResidue --- common/random_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/random_test.go b/common/random_test.go index ec6ab7c..fa295c6 100644 --- a/common/random_test.go +++ b/common/random_test.go @@ -46,9 +46,13 @@ func TestGetRandomPrimeInt(t *testing.T) { assert.True(t, prime.ProbablyPrime(50), "rand prime should be prime") } -func TestGetRandomQuandraticNonResidue(t *testing.T) { +func TestGetRandomQuadraticNonResidue(t *testing.T) { rnd := common.MustGetRandomInt(randomIntBitLen) N := common.GetRandomPositiveRelativelyPrimeInt(rnd) + // ensure N is odd + for N.Bit(0) == 0 { + N = common.GetRandomPositiveRelativelyPrimeInt(rnd) + } w := common.GetRandomQuandraticNonResidue(N) assert.Equal(t, big.Jacobi(w, N), -1, "must get quandratic non residue") }