[libmath-prime-util-perl] 15/18: Fixup for 5.6.2

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:48:04 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 a5e69946da84a38f645ba53a8e991ac884af329c
Author: Dana Jacobsen <dana at acm.org>
Date:   Sat Apr 20 23:33:55 2013 -0700

    Fixup for 5.6.2
---
 Changes                   |  3 ++-
 lib/Math/Prime/Util.pm    | 17 +++++++++++------
 lib/Math/Prime/Util/PP.pm |  9 +++++++--
 t/81-bignum.t             |  2 +-
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/Changes b/Changes
index 1425355..7176213 100644
--- a/Changes
+++ b/Changes
@@ -16,7 +16,8 @@ Revision history for Perl extension Math::Prime::Util.
     - Pure perl primality proof now uses BLS75 instead of Lucas, so some
       numbers will be much faster.  n-1 only needs factoring to (n/2)^1/3.
 
-    - Math::Prime::Util::EllipticCurve module.
+    - Math::Prime::Util::ECAffinePoint and ECProjectivePoint modules for
+      dealing with elliptic curves.
 
 0.25 19 March 2013
 
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 58e7724..44c9464 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -1919,12 +1919,19 @@ sub verify_prime {
         warn "verify_prime: incorrect AGKM block point format\n";
         return 0;
       }
-      $ni = $n->bzero->badd($ni) unless ref($ni) eq 'Math::BigInt';
+      my($Px, $Py) = @$P;
+      $ni = $n->copy->bzero->badd("$ni") unless ref($ni) eq 'Math::BigInt';
+      $a  = $n->copy->bzero->badd("$a")  unless ref($a)  eq 'Math::BigInt';
+      $b  = $n->copy->bzero->badd("$b")  unless ref($b)  eq 'Math::BigInt';
+      $m  = $n->copy->bzero->badd("$m")  unless ref($m)  eq 'Math::BigInt';
+      $q  = $n->copy->bzero->badd("$q")  unless ref($q)  eq 'Math::BigInt';
+      $Px = $n->copy->bzero->badd("$Px") unless ref($Px) eq 'Math::BigInt';
+      $Py = $n->copy->bzero->badd("$Py") unless ref($Py) eq 'Math::BigInt';
       if (Math::BigInt::bgcd($ni, 6) != 1) {
         warn "verify_prime: AGKM block n '$ni' is divisible by 2 or 3\n";
         return 0;
       }
-      my $c = ($n-$n+4) * $a*$a*$a + ($n-$n+27)*$b*$b;
+      my $c = $a*$a*$a * 4 + $b*$b * 27;
       if (Math::BigInt::bgcd($c, $ni) != 1) {
         warn "verify_prime: AGKM block gcd 4a^3+27b^2,n incorrect\n";
         return 0;
@@ -1938,11 +1945,9 @@ sub verify_prime {
         eval { require Math::Prime::Util::ECAffinePoint; 1; }
         or do { croak "Cannot load Math::Prime::Util::ECAffinePoint"; };
       }
-      $m = Math::BigInt->new("$m") unless ref($m) eq 'Math::BigInt';
-      $q = Math::BigInt->new("$q") unless ref($q) eq 'Math::BigInt';
-      my $ECP = Math::Prime::Util::ECAffinePoint->new($a, $b, $ni, $P->[0], $P->[1]);
+      my $ECP = Math::Prime::Util::ECAffinePoint->new($a, $b, $ni, $Px, $Py);
       # Compute U = (m/q)P, check U != point at infinity
-      $ECP->mul( int($m/$q) );
+      $ECP->mul( $m->copy->bdiv($q)->as_int );
       if ($ECP->is_infinity) {
         warn "verify_prime: AGKM point does not multiply correctly.\n";
         return 0;
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 34a2ee1..4207bd9 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -1218,9 +1218,14 @@ sub _found_factor {
   if ($f == 1 || $f == $n) {
     push @factors, $n;
   } else {
+    # Perl 5.6.2 needs things spelled out for it.
+    my $f2 = (ref($n) eq 'Math::BigInt') ? $n->copy->bdiv($f)->as_int
+                                         : int($n/$f);
     push @factors, $f;
-    push @factors, int($n/$f);
-    croak "internal error in $what" unless ($f * int($n/$f)) == $n;
+    push @factors, $f2;
+    croak "internal error in $what" unless $f * $f2 == $n;
+    # MPU::GMP prints this type of message if verbose, so do the same.
+    print "$what found factor $f\n" if Math::Prime::Util::prime_get_config()->{'verbose'} > 0;
   }
   @factors;
 }
diff --git a/t/81-bignum.t b/t/81-bignum.t
index a6eeb1d..3322521 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -329,6 +329,6 @@ sub check_pcbounds {
   [ 3,5,3,2,3,3,3,3 ] );
   ok( verify_prime(@proof), "2**607-1 primality proof verified" );
 
-  @proof = ('677826928624294778921',"AGKM", [677826928624294778921, 404277700094248015180, 599134911995823048257, 677826928656744857936, 104088901820753203, [2293544533, 356794037129589115041]], [104088901820753203, 0, 73704321689372825, 104088902465395836, 1112795797, [3380482019, 53320146243107032]], [1112795797, 0, 638297481, 1112860899, 39019, [166385704, 356512285]]);
+  @proof = ('677826928624294778921',"AGKM", ['677826928624294778921', '404277700094248015180', '599134911995823048257', '677826928656744857936', '104088901820753203', ['2293544533', '356794037129589115041']], ['104088901820753203', '0', '73704321689372825', '104088902465395836', '1112795797', ['3380482019', '53320146243107032']], ['1112795797', '0', '638297481', '1112860899', '39019', ['166385704', '356512285']]);
   ok( verify_prime(@proof), "ECPP primality proof of 677826928624294778921 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