summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-08-30 15:52:32 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-08-30 15:52:32 +0200
commit776dba9473df7f4b1ca071b61c994fdcca3e07b3 (patch)
tree2a49821db8888cd45ae2bccd5eab4aa3895dc68c
parentca5de48d6431cd1321b60718b900712918176911 (diff)
stronger tests
-rw-r--r--test/other/recover.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/other/recover.cpp b/test/other/recover.cpp
index fa491e8..72853e5 100644
--- a/test/other/recover.cpp
+++ b/test/other/recover.cpp
@@ -5,7 +5,7 @@
void stress_test() {
ll queries = 0;
timer t;
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < 500; i++) {
ll p = Random::prime<ll>(10000);
for (ll j = 0; 2*j*j < p; j++) {
for (ll b = 1; 2*b*b < p; b++) {
@@ -22,7 +22,17 @@ void stress_test() {
}
}
}
-
+ for (ll c = 0; c < p; c++) {
+ t.start();
+ auto [x, y] = recover(c, p);
+ t.stop();
+
+ if (y < 0) continue;
+ if (y == 0) cerr << "error: y=0" << FAIL;
+ ll got = (((x * multInv(y, p)) % p) + p) % p;
+ if (got != c) cerr << "got: " << got << ", expected: " << c << FAIL;
+ queries++;
+ }
}
cerr << "tested random queries: " << queries << endl;
if (t.time > 500) cerr << "too slow: " << t.time << FAIL;