This was how they worked originally, but they were changed a long time
ago to count up from zero instead. This makes it impossible for a
stepper or tester function to know in advance how many times it will be
invoked, which turns out to be important for a forthcoming change.
The reason it was changed wasn't explained in the commit
(
283b9af095a5b24ae71b49a6d2dcbdcdaae47c40) that made it, but I deduce
that it was so that `pgen_test' could identify the first test round and
use the somewhat faster approach of using (the residue whose Montgomery
REDC representative is) 2, rather than a random witness. That change
has now been undone, so we can restore the documented behaviour.
ev.m = MP_COPY(m);
else
ev.m = 0;
- ev.steps = 0;
- ev.tests = 0;
+ ev.steps = steps;
+ ev.tests = tests;
ev.r = fibrand_create(0);
/* --- Tell the event handler we're under way --- */
/* --- If decrementing counters is requested, do that --- */
if ((act & A_STEP) && steps) {
- ev.steps++;
- if (ev.steps == steps) {
+ ev.steps--;
+ if (!ev.steps) {
act |= A_EVENT | A_ENDSTEP | A_DONE;
rc = PGEN_ABORT;
}
- ev.tests = 0;
+ ev.tests = tests;
}
if ((act & A_TEST) && tests) {
- ev.tests++;
- if (ev.tests == tests) {
+ ev.tests--;
+ if (!ev.tests) {
act |= A_ENDTEST | A_ENDSTEP | A_DONE;
rc = PGEN_DONE;
}