chiark
/
gitweb
/
~mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cf76bcb
)
pgen_safetest: Use a separate witness for each test.
author
Mark Wooding
<mdw@distorted.org.uk>
Sat, 11 Feb 2006 12:41:26 +0000
(12:41 +0000)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sat, 11 Feb 2006 12:41:26 +0000
(12:41 +0000)
I have a suspicion that not doing this can do bad things to the
probability of returning a non-prime.
pgen-safe.c
patch
|
blob
|
blame
|
history
diff --git
a/pgen-safe.c
b/pgen-safe.c
index 115f7b4926d0f3a681a5cd554e2ca0f9bc73d163..bd644dca184abc4d7ee12031ad41fd59f7d42d70 100644
(file)
--- a/
pgen-safe.c
+++ b/
pgen-safe.c
@@
-180,10
+180,12
@@
int pgen_safetest(int rq, pgen_event *ev, void *p)
rc = PGEN_TRY;
break;
case PGEN_TRY: {
- mp *m = mprand_range(MP_NEW, c->c.
q
.m, ev->r, 0);
+ mp *m = mprand_range(MP_NEW, c->c.
p
.m, ev->r, 0);
rc = rabin_test(&c->p, m);
- if (rc == PGEN_PASS)
+ if (rc == PGEN_PASS) {
+ m = mprand_range(m, c->c.q.m, ev->r, 0);
rc = rabin_test(&c->q, m);
+ }
mp_drop(m);
} break;
case PGEN_DONE: