From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA16911; Mon, 1 Sep 2003 15:34:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA16616 for ; Mon, 1 Sep 2003 15:34:15 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h81DXnf18744; Mon, 1 Sep 2003 15:33:49 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA19876; Mon, 1 Sep 2003 15:33:48 +0200 (MET DST) Date: Mon, 1 Sep 2003 15:33:48 +0200 From: Xavier Leroy To: Francesco Abbate Cc: caml-list@inria.fr Subject: Re: [Caml-list] primality test for Big_int ? Message-ID: <20030901153348.B18747@pauillac.inria.fr> References: <20030901141617.70df1116.france.abbate@tiscalinet.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20030901141617.70df1116.france.abbate@tiscalinet.it>; from france.abbate@tiscalinet.it on Mon, Sep 01, 2003 at 02:16:17PM +0200 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 polynomial:01 coefficients:01 nums:01 nat:01 nat:01 primes:01 caml:01 int:01 int:01 pgp:02 pgp:02 cryptokit:02 modular:02 algorithm:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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