X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/0ca05eea35ca50cab44f60187284ffa224e9b8da..3e248c3b5b309bc03eb5f70762d3f5671d51f996:/README.mp diff --git a/README.mp b/README.mp index bc75817..8a276c4 100644 --- a/README.mp +++ b/README.mp @@ -129,7 +129,7 @@ The high-level interface 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'. @@ -163,10 +163,10 @@ The high-level interface 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 @@ -243,7 +243,7 @@ Modular multiplication and exponentiation 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 @@ -263,8 +263,8 @@ Modular multiplication and exponentiation 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); @@ -319,16 +319,16 @@ Modular multiplication and exponentiation 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. @@ -340,8 +340,7 @@ Conclusion maths library. I hope it's provided enough background that the comments start making sense. --- -[mdw] +-- [mdw] Local variables: