Browse thread
[Caml-list] primality test for Big_int ?
-
Francesco Abbate
- Xavier Leroy
- Yamagata Yoriyuki
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <xavier.leroy@i...> |
| Subject: | Re: [Caml-list] primality test for Big_int ? |
> I was implementing a modular GCD algorithm for polynomial with > big_int coefficients when I've discovered that there isn't any > primality test in the Nums library. > > Someone can help me about this question ? The Cryptokit library (http://pauillac.inria.fr/~xleroy/software.html) contains an implementation of probabilistic primality testing, as part of RSA key generation. The function is called "is_pseudoprime" and it's not exported, but it shouldn't be hard to extract it from the sources. It operates on type "nat", so you'll have to stick a "Big_int.nat_of_big_int" conversion on input. The algorithm used is that of PGP 2.6: Fermat tests against 8 small primes. While not as sophisticated as Miller-Rabin, this test seems good enough for PGP, so it's good enough for me :-) > If possible I would avoid to implement a primality test by myself because > - I have to study the Rabin-Miller test > - I have to implement it in C to obtain a good speed (maybe ?) No need for C: Caml code working at the "nat" level (hand-allocated big natural integers) is plenty fast enough. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners