#miller-rabin #prime #gmp #rabin #miller

rug-miller-rabin

A multi-threaded, arbitrary precision implementation of the Miller-Rabin primality test using rug (GMP)

4 releases

Uses new Rust 2024

0.1.3 Nov 15, 2025
0.1.2 Oct 5, 2025
0.1.1 Dec 28, 2024
0.1.0 Mar 9, 2024

#644 in Math

Download history 4/week @ 2025-07-30 3/week @ 2025-08-06 43/week @ 2025-08-20 18/week @ 2025-08-27 31/week @ 2025-09-03 34/week @ 2025-09-10 22/week @ 2025-09-17 44/week @ 2025-09-24 145/week @ 2025-10-01 33/week @ 2025-10-08 44/week @ 2025-10-15 45/week @ 2025-10-22 17/week @ 2025-10-29 16/week @ 2025-11-05 16/week @ 2025-11-12

102 downloads per month
Used in 5 crates (2 directly)

LGPL-3.0+

17KB
170 lines

Miller-Rabin Test (multi-threaded) for Integer (rug / GMP)

The methog [is_prime] test if a given number is probably prime using the Miller-Rabin method with the given number of iterations.

Example

use miller_rabin::is_prime;

// Mersenne Prime (2^31 - 1)
let n: u64 = 0x7FFF_FFFF;
assert!(is_prime(&n, 16));

Feature

Per default the test will be run in parallel (using [rayon]). The test can run iteratively deactivate the default feature by importing the crate.


Miller Rabin Primality Test for rug (GMP)

Introduction

This crate implements a multi-threaded, arbitrary precision implementation of the Miller-Rabin primality test.

The implementation ist done for Integer from the crate rug, a high-level interface for GMP.

The crate is strongly inspired from the crate miller_rabin.

Installation

See rug for the requirements and installation steps.

Licence

Rug is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the full text of the GNU LGPL for details.

Dependencies

~23MB
~520K SLoC