aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-15 12:26:52 -0400
committerJack Lloyd <[email protected]>2018-05-15 12:26:52 -0400
commit006d926d17f4490d1cad8c8204d734fa683bf01d (patch)
treebd1263e308b5f43919cb46a6990b0effb094e752 /src/lib/math
parentcc6f46322c01f39c428d36250d8348e777e5440f (diff)
Add clarifying comments and increase M-R tests for 256-bit integers
See #1542 and #1569
Diffstat (limited to 'src/lib/math')
-rw-r--r--src/lib/math/numbertheory/numthry.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/math/numbertheory/numthry.cpp b/src/lib/math/numbertheory/numthry.cpp
index 0e0893dd0..1458a8943 100644
--- a/src/lib/math/numbertheory/numthry.cpp
+++ b/src/lib/math/numbertheory/numthry.cpp
@@ -449,11 +449,15 @@ bool mr_witness(BigInt&& y,
if(y == 1) // found a non-trivial square root
return true;
- if(y == n_minus_1) // -1, trivial square root, so give up
+ /*
+ -1 is the trivial square root of unity, so ``a`` is not a
+ witness for this number - give up
+ */
+ if(y == n_minus_1)
return false;
}
- return true; // fails Fermat test
+ return true; // is a witness
}
size_t mr_test_iterations(size_t n_bits, size_t prob, bool random)
@@ -483,7 +487,7 @@ size_t mr_test_iterations(size_t n_bits, size_t prob, bool random)
if(n_bits >= 512)
return 12; // < 2^-129
if(n_bits >= 256)
- return 28; // < 2^-128
+ return 29; // < 2^-128
}
/*