happens is that a reference is lost to whatever the destination
used to refer to, and a reference to the new result is gained.
The address might be different, and then again it might not.
- Destinations acn be the same as sources -- that works fine.
+ Destinations can be the same as sources -- that works fine.
Finally, there's the magic value `MP_NEW'. MP_NEW is a special
constant which, as a destination, means `create a new place and
put the answer there'.
Multiply y by z, putting the result in x, but making y
no longer useful.
- Here's some examples of how to do it wrong:
+ Here are some examples of how to do it wrong:
mp_mul(y, y, z);
- mp_mul might choose somewhere other than b's storage to
+ mp_mul might choose somewhere other than y's storage to
write its result. (In fact, the current version
certainly will.) So y is trashed because there are no
references to it any more, and the result of the
value x R^{-1} mod m. That doesn't sound very useful, does it?
Things start looking more hopeful when you multiply your inputs
- by R. (There's a clever way of doing that: see below.) To
+ by R. (There's a clever way of doing that: see below.) To
compute xy mod m, you can first calculate xR and yR, multiply
them together to get xyR^2, and do a Montgomery reduction to get
xyR^2 R^{-1} mod m. Then the R^{-1} cancels one of the Rs and
mpmont mm;
mp *ar, *br, *p;
mpmont_create(&mm, m);
- ar = mp_mul(MP_NEW, a, m.r2); /* aR mod m */
- br = mp_mul(MP_NEW, b, m.r2); /* bR mod m */
+ ar = mpmont_mul(MP_NEW, a, m.r2); /* aR mod m */
+ br = mpmont_mul(MP_NEW, b, m.r2); /* bR mod m */
p = mpmont_mul(&mm, MP_NEW, ar, br); /* abR mod m */
p = mpmont_reduce(&mm, p, p); /* ab mod m */
mpmont_destroy(&mm);
Finding prime numbers
Prime numbers are important too. Finding them is not ever-so
- easy. THere's a huge variety of useful properties which are
+ easy. There's a huge variety of useful properties which are
needed, and it's basically impossible to cover everything.
Catacomb has two useful facilities. There's a fast sequential-
- search filtering system called `pfilt, and a good (but
+ search filtering system called `pfilt', and a good (but
probabilistic) primality tester which implements the Rabin-
Miller test.
- Over the top of this is a confgurable plug-in-appropriate-bits
- system called `pgen' which tied everything together. You're
+ Over the top of this is a configurable plug-in-appropriate-bits
+ system called `pgen' which ties everything together. You're
much better off using `pgen' than grovelling about with the
filter and Rabin-Miller tests by hand. The low-level details
are much better used to create new `pgen' components.
maths library. I hope it's provided enough background that the
comments start making sense.
---
-[mdw]
+-- [mdw]
\f
Local variables: