[Ecm-commits] r2425 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Wed Feb 20 19:15:26 CET 2013


Author: morain
Date: 2013-02-20 19:15:26 +0100 (Wed, 20 Feb 2013)
New Revision: 2425

Log:
Looking for a bug.


Modified:
   trunk/addlaws.c
   trunk/manyecm.c
   trunk/torsions.c
Modified: trunk/addlaws.c
===================================================================
--- trunk/addlaws.c	2013-02-20 10:39:36 UTC (rev 2424)
+++ trunk/addlaws.c	2013-02-20 18:15:26 UTC (rev 2425)
@@ -283,9 +283,9 @@
     memcpy(takeit, ok, nE);
 #if DEBUG_ADD_LAWS >= 2
     printf("In pt_many_add, adding\n");
-    pt_many_print(tP, nE, n);
+    pt_many_print(tE, tP, nE, n);
     printf("and\n");
-    pt_many_print(tQ, nE, n);
+    pt_many_print(tE, tQ, nE, n);
 #endif
     for(i = 0; i < nE; i++){
 	if(ok[i] == 0)
@@ -375,7 +375,7 @@
 	    break;
 	  }
 #if DEBUG_ADD_LAWS >= 2
-	printf("Rdup:="); pt_many_print(tQ, nE, n); printf(";\n");
+	printf("Rdup:="); pt_many_print(tE, tQ, nE, n); printf(";\n");
 #endif
 	if (mpz_tstbit (e, l))
 	  {
@@ -385,7 +385,7 @@
 		break;
 	      }
 #if DEBUG_ADD_LAWS >= 2
-	      printf("Radd:="); pt_many_print(tQ, nE, n); printf(";\n");
+	      printf("Radd:="); pt_many_print(tE, tQ, nE, n); printf(";\n");
 #endif
 	  }
     }
@@ -424,7 +424,7 @@
 	    break;
 	}
 #if DEBUG_ADD_LAWS >= 2
-	printf("Rdup:="); pt_many_print(tQ, nE, n); printf(";\n");
+	printf("Rdup:="); pt_many_print(tE, tQ, nE, n); printf(";\n");
 #endif
 	if(S[j] == 1){
 	    if(pt_many_add(tQ, tQ, tP, tE, nE, n, num, den, inv, ok) == 0){
@@ -432,7 +432,7 @@
 		break;
 	    }
 #if DEBUG_ADD_LAWS >= 2
-	    printf("Radd:="); pt_many_print(tQ, nE, n); printf(";\n");
+	    printf("Radd:="); pt_many_print(tE, tQ, nE, n); printf(";\n");
 #endif
 	}
 	else if(S[j] == -1){
@@ -441,7 +441,7 @@
 		break;
 	    }
 #if DEBUG_ADD_LAWS >= 2
-	    printf("Rsub:="); pt_many_print(tQ, nE, n); printf(";\n");
+	    printf("Rsub:="); pt_many_print(tE, tQ, nE, n); printf(";\n");
 #endif
 	}
     }
@@ -498,9 +498,9 @@
 void
 pt_w_set_to_zero(ell_point_t P, mpmod_t n)
 {
-    mpres_set_ui (P->x, 0, n);
-    mpres_set_ui (P->y, 1, n);
-    mpres_set_ui (P->z, 0, n);
+    mpres_set_ui(P->x, 0, n);
+    mpres_set_ui(P->y, 1, n);
+    mpres_set_ui(P->z, 0, n);
 }
 
 int
@@ -514,9 +514,9 @@
 	    mpres_t x, mpres_t y, mpres_t z,
 	    ATTRIBUTE_UNUSED mpmod_t n)
 {
-  mpres_set (x0, x, n);
-  mpres_set (y0, y, n);
-  mpres_set (z0, z, n);
+  mpres_set(x0, x, n);
+  mpres_set(y0, y, n);
+  mpres_set(z0, z, n);
 }
 
 void
@@ -562,11 +562,10 @@
 	       mpres_t x1, mpres_t y1, mpres_t z1,
 	       mpmod_t n, ell_curve_t E)
 {
-    if(pt_w_is_zero(z1, n))
-      {
-	pt_w_set(x3, y3, z3, x1, y1, z1, n);
-	return 1;
-      }
+    if(pt_w_is_zero(z1, n)){
+      pt_w_set(x3, y3, z3, x1, y1, z1, n);
+      return 1;
+    }
     if(E->type == ECM_EC_TYPE_WEIERSTRASS && E->law == ECM_LAW_AFFINE){
 	/* buf[1] <- 2*y1 */
 	mpres_add(E->buf[1], y1, y1, n);
@@ -666,6 +665,10 @@
 	/* Cohen-Miyaji-Ono: 12M+2S+6add+1*2 */
 	/* mapping: y1z2 = buf, AA = buf+1, u = buf+2, v = buf+3, R = buf+4, */
 	/* vvv = buf+5; */
+      printf("y1="); print_mpz_from_mpres(y1, n); printf("\n");
+      printf("y2="); print_mpz_from_mpres(y2, n); printf("\n");
+      printf("z1="); print_mpz_from_mpres(z1, n); printf("\n");
+      printf("z2="); print_mpz_from_mpres(z2, n); printf("\n");
 	/*  Y1Z2:=Y1*Z2 mod p;	# M*/
 	mpres_mul(E->buf[0], y1, z2, n);
 	/*	A:=X1*Z2 mod p;	# M*/
@@ -1277,11 +1280,12 @@
     mpres_init(P->x, n);
     mpres_init(P->y, n);
     mpres_init(P->z, n);
-    if(E->type == ECM_EC_TYPE_WEIERSTRASS && E->law == ECM_LAW_AFFINE)
-	mpz_set_ui (P->z, 1);
-    else if(E->type == ECM_EC_TYPE_WEIERSTRASS 
-	    && E->law == ECM_LAW_HOMOGENEOUS)
+    if(E->type == ECM_EC_TYPE_WEIERSTRASS){
+      if(E->law == ECM_LAW_AFFINE)
+	mpz_set_ui(P->z, 1); /* humf */
+      else if(E->law == ECM_LAW_HOMOGENEOUS)
 	mpres_set_ui(P->z, 1, n);
+    }
     else if(E->type == ECM_EC_TYPE_HESSIAN)
 	mpres_set_ui(P->z, 1, n);
 }
@@ -1613,12 +1617,12 @@
     ell_point_init(P0, E, n);
     ell_point_set_to_zero(P0, E, n);
 
-#if DEBUG_ADD_LAWS >= 2
+#if DEBUG_ADD_LAWS >= 0
     printf("P:="); ell_point_print(P, E, n); printf(";\n");
 #endif
     /* S = [[ts, 2*ds+1], ... */
     for(j = 0; j < iS; j += 2){
-#if DEBUG_ADD_LAWS >= 2
+#if DEBUG_ADD_LAWS >= 0
 	printf("P0:="); ell_point_print(P0, E, n); printf(";\n");
 #endif
 	i = abs(S[j+1]) >> 1; /* (abs(S[j+1])-1)/2, S[j+1] is always odd */
@@ -1628,7 +1632,7 @@
 		status = 0;
 		break;
 	    }
-#if DEBUG_ADD_LAWS >= 2
+#if DEBUG_ADD_LAWS >= 0
 	    printf("iP%d:=", i); ell_point_print(iP[i], E, n); printf(";\n");
 	    printf("Radd:="); ell_point_print(P0, E, n); printf(";\n");
 	    printf("Q:=ProjEcmAdd(P0, iP%d, E, N); ProjEcmEqual(Q, Radd, N);\n", i);
@@ -1640,7 +1644,7 @@
 		status = 0;
 		break;
 	    }
-#if DEBUG_ADD_LAWS >= 2
+#if DEBUG_ADD_LAWS >= 0
 	    printf("Rsub:="); ell_point_print(P0, E, n); printf(";\n");
 #endif
 	}
@@ -1650,7 +1654,7 @@
 		status = 0;
 		break;
 	    }
-#if DEBUG_ADD_LAWS >= 2
+#if DEBUG_ADD_LAWS >= 0
 	    printf("Rdup:="); ell_point_print(P0, E, n); printf(";\n");
 #endif
 	}

Modified: trunk/manyecm.c
===================================================================
--- trunk/manyecm.c	2013-02-20 10:39:36 UTC (rev 2424)
+++ trunk/manyecm.c	2013-02-20 18:15:26 UTC (rev 2425)
@@ -1251,7 +1251,7 @@
 	res = ECM_NO_FACTOR_FOUND;
 	tried = 0;
 	if(method == ECM_ECM){
-	    if(b != 0){
+	    if(b != 0 && disc != 0){
 		nf = 0;
 		res = process_special_blend(tf,&nf,&tried,N,bb,n,disc,B1,B2,
 					    params,savefilename);

Modified: trunk/torsions.c
===================================================================
--- trunk/torsions.c	2013-02-20 10:39:36 UTC (rev 2424)
+++ trunk/torsions.c	2013-02-20 18:15:26 UTC (rev 2425)
@@ -736,13 +736,13 @@
     mpres_init(tmp2, n);
     mpz_set_str(f, "-8", 10); 
     mpres_set_z(tmp2, f, n);
-    ell_curve_init_set(E, ECM_EC_TYPE_WEIERSTRASS, ECM_LAW_HOMOGENEOUS, tmp2, n);
+    ell_curve_init_set(E, ECM_EC_TYPE_WEIERSTRASS, ECM_LAW_AFFINE, tmp2, n);
     ell_point_init(P, E, n);
     mpz_set_str(f, "12", 10); 
     mpres_set_z(P->x, f, n);
     mpz_set_str(f, "40", 10);
     mpres_set_z(P->y, f, n);
-    mpres_set_ui(P->z, 1, n);
+    mpz_set_ui(P->z, 1);
 
     ell_point_init(Q, E, n);
     for(u = umin; u < umax; u++){
@@ -754,13 +754,14 @@
 	    ret = ECM_FACTOR_FOUND_STEP1;
 	    break;
 	}
-#if DEBUG_TORSION >= 2
+#if DEBUG_TORSION >= 0
 	printf("(s, t)[%d]:=", u);
 	pt_print(Q, n);
 	printf(";\n");
 #endif
 	mpres_get_z(a, Q->x, n);
 	mpres_get_z(b, Q->y, n);
+#if 0 /* useless in affine form? */
 	mpres_get_z(d, Q->z, n);
 	if(mpz_invert(f, d, n->orig_modulus) == 0){
 	    printf("found factor in Z2xZ8 (normalization)\n");
@@ -768,8 +769,9 @@
 	    break;
 	}
 	mpz_mul(a, a, f);
+	mpz_mul(b, b, f);
+#endif
 	mpz_mod(wx0, a, n->orig_modulus);
-	mpz_mul(b, b, f);
 	mpz_sub_si(a, a, 9);
 	mpz_mod(a, a, n->orig_modulus);
 	mpz_add_si(b, b, 25);




More information about the Ecm-commits mailing list