[libmath-prime-util-perl] 05/18: Add tests for verify_prime

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:48:02 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.26
in repository libmath-prime-util-perl.

commit 43a7cb9b927ab1b16c5d9b48a8aa3aea242ad474
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Apr 11 09:14:56 2013 -0700

    Add tests for verify_prime
---
 bin/factor.pl |  2 +-
 t/81-bignum.t | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/bin/factor.pl b/bin/factor.pl
index 6905038..f7293dd 100755
--- a/bin/factor.pl
+++ b/bin/factor.pl
@@ -47,7 +47,7 @@ sub eval_expr {
   die "$expr cannot be evaluated" if $expr =~ tr|-0123456789+*/() :||c;
   $expr =~ s/:1/nth_prime/g;
   $expr =~ s/:2/log/g;
-  $expr =~ s/(\d+)/ Math::BigInt->new($1) /g;
+  $expr =~ s/(\d+)/ Math::BigInt->new("$1") /g;
   my $res = eval $expr; ## no critic
   die "Cannot eval: $expr\n" if !defined $res;
   $res = int($res->bstr) if ref($res) eq 'Math::BigInt' && $res <= ~0;
diff --git a/t/81-bignum.t b/t/81-bignum.t
index b90be6f..0d2b838 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -76,6 +76,7 @@ plan tests =>  0
              + scalar(keys %allfactors)
              + 5   # moebius, euler_phi, jordan totient
              + 15  # random primes
+             + 3   # verify_prime
              + 0;
 
 # Using GMP makes these tests run about 2x faster on some machines
@@ -113,6 +114,7 @@ use Math::Prime::Util qw/
   random_nbit_prime
   random_strong_prime
   random_maurer_prime
+  verify_prime
 /;
 # TODO:  is_strong_lucas_pseudoprime
 #        ExponentialIntegral
@@ -286,3 +288,36 @@ sub check_pcbounds {
   cmp_ok( ($pcapf - $pclo)/$pcapf,    '<=', $percent   , "PC lower");
   cmp_ok( ($pcup - $pcapf)/$pcapf,    '<=', $percent   , "PC upper");
 }
+
+###############################################################################
+
+# Provable primes
+{
+  my @proof;
+  @proof = ('3364125245431456304736426076174232972735419017865223025179282077503701', 'n-1',
+    [2,5,127, ['28432789963853652887491983185920687231739655787', 'n-1',
+                [ 2,3,163,650933, [ '44662634059309451871488121651101494489', 'n-1',
+                                    [ 2,3,23,4021,2321273 ],
+                                    [ 11, 2, 2, 2, 2 ]
+                                  ] ],
+                [ 2, 2, 2, 2, 2 ]
+              ],
+              '9316417838190714313' ],
+    [ 2, 2, 2, 2, 2 ]);
+  ok( verify_prime(@proof), "simple proof verified" );
+
+  @proof = ('6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151', 'n-1',
+  [ 2,3,5,11,17,31,41,53,131,157,521,1613,61681,8191,42641,858001,51481, '7623851', '308761441' ],
+  [ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 ] );
+  ok( verify_prime(@proof), "2**521-1 primality proof verified" );
+
+  @proof = ('531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127', 'n-1',
+  [ 2,3,7,607,'112102729', '341117531003194129', '7432339208719',
+    ['845100400152152934331135470251', 'n-1',
+      [2,5,11,31,41,101,251,601,1801],
+      [2,3,3,3,3,2,3,3,3]
+    ] ],
+  [ 3,5,3,2,3,3,3,3 ] );
+  ok( verify_prime(@proof), "2**607-1 primality proof verified" );
+
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list