summaryrefslogtreecommitdiff
path: root/test/other/recover.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/other/recover.cpp')
-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;