Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Francesco Abbate <france.abbate@tiscalinet.it>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] primality test for Big_int ?
Date: Mon, 1 Sep 2003 15:33:48 +0200	[thread overview]
Message-ID: <20030901153348.B18747@pauillac.inria.fr> (raw)
In-Reply-To: <20030901141617.70df1116.france.abbate@tiscalinet.it>; from france.abbate@tiscalinet.it on Mon, Sep 01, 2003 at 02:16:17PM +0200

> 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


  reply	other threads:[~2003-09-01 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-01 12:16 Francesco Abbate
2003-09-01 13:33 ` Xavier Leroy [this message]
2003-09-01 13:35 ` Yamagata Yoriyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030901153348.B18747@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=france.abbate@tiscalinet.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox