point multiplication testing

Point multiplication testing works.

/* CG - March 2010
   program to check point multiplication
*/

#include <stdio.h>
#include <stdlib.h>
#include "field2n.h"
#include "poly.h"
#include "eliptic.h"

extern FIELD2N poly_prime;

void set_field(value, n)
FIELD2N *value;
INDEX n;
{
   value->e[0] = n;
}

void set_curve(curv)
CURVE *curv;
{
   curv->form = 1;
   set_field(&curv->a6, 1L);
   set_field(&curv->a2, 2L);
}

int main()
{
        FIELD2N *data;
        FIELD2N *t;
	FIELD2N y, x, y2, xy;
	ELEMENT index, check;
        INDEX i, error;
	FILE *del;
	CURVE *curve;
        POINT *p, *r;
	char curve_string[80];
	
        data = malloc(sizeof(FIELD2N));
        if (data == NULL) {exit(-1);}

        t = malloc(sizeof(FIELD2N));
        if (t == NULL) {exit(-1);}

        curve = malloc(sizeof(CURVE));
        if (curve == NULL) {exit(-1);}

        p = malloc(sizeof(POINT));
        if (p == NULL) {exit(-1);}

        r = malloc(sizeof(POINT));
        if (r == NULL) {exit(-1);}

	if (!irreducible(&poly_prime)) return(0);
	print_field("poly_prime = ", &poly_prime);
	
	if (error = init_poly_math())
	{
		printf("Can't initialize S matrix, row = %d\n", error);
		return(-1);
	}

        data->e[0] = 1L;	
        data->e[1] = 1L;
        print_field("data test = ", data);

//        printf("NUMWORD = %ld\n", NUMWORD );
        null(t);
        t->e[NUMWORD] = 2L;
        print_field("t = ", t);

        printf("setting up curves\n\n");
        set_curve(curve);
        print_curve("the curve after setting up: ", curve);

        poly_embed(data, curve, 1, 0, p);
        printf("data after embedded to the curve: \n");
        print_point("p = ", p);

        printf("after point multiplication: \n");
        poly_elptic_mul(t, p, r, curve);
        print_point("r = ", r);	
}

This is the result of 2P.

lss-67-23:Rosing Experiments CG chika$ ./test_left_right_eq2
poly_prime =
8 0 0 0 0 c9

NUMBITS = 163
NUMWORD = 5
MAXLONG = 6
a2 =
2 0 0 0 0 0
a6 =
1 0 0 0 0 0

1 1899fea5 56c420f2 9e4b1f87 5cb6b783 899feb0c
y =
1 26a707a1 8daf42c0 dde1d433 6638016d fd2dfcd4
yy =
0 1460a86a b5fd89df 6fc41f77 67325e56 91b4cecb
xy =
6 ed2088de 820e441 93687252 d3242e3a 62be995e
x_2 =
4 3e3b1763 9148e81e efc41b97 24c6e697 82da1543
x_3 =
4 ae6b51e0 468d0597 9c179778 e018bf6e 60eb0e54
ax2 =
3 572b7154 fb506809 60bbfa5d 540ecf02 93e159c1
left =
6 f94020b4 bddd6d9e fcac6d25 b416706c f30a5795
right =
6 f94020b4 bddd6d9e fcac6d25 b416706c f30a5795

And this is for 10P

lss-67-23:Rosing Experiments CG chika$ ./test_left_right_eq2
poly_prime =
8 0 0 0 0 c9

NUMBITS = 163
NUMWORD = 5
MAXLONG = 6
a2 =
2 0 0 0 0 0
a6 =
1 0 0 0 0 0

3 91d7e88a 1bb31eaf bdf2e27d bf0271b6 333c29ce
y =
3 5d3c582c cbc0a643 fe11bd5a f6e54c0 41df835f
yy =
5 69b24b3f 8d3d7709 cd222a06 3d76432f 401b8c42
xy =
6 53764521 604fe896 ed4d10b9 660cd6e3 6c398bdd
x_2 =
7 a53af799 5d9b4e28 8a12d0c9 bb9dae71 9625d3c3
x_3 =
4 6d0ed674 6bfff7dd f5b93ab2 88c98b98 c3079c7f
ax2 =
6 57cad86a 868d6842 d5d6000d d3b31e54 ef259be0
left =
3 3ac40e1e ed729f9f 206f3abf 5b7a95cc 2c22079f
right =
3 3ac40e1e ed729f9f 206f3abf 5b7a95cc 2c22079f

Advertisements