/* * Test program to implement Comb method for fast * computation of x*G, for fixed G, using precomputation. * This idea can be used to substantially speed up certain phases * of the Elliptic Curve Digital Signature Standard (DSS). * * See "Handbook of Applied Cryptography" * */ #include #include "miracl.h" int main() { FILE *fp; int m,a,b,c; big e,a2,a6,x,y,r; epoint *g; ebrick2 binst; int i,j,len,bptr,nb,window; miracl *mip=mirsys(50,0); e=mirvar(0); a2=mirvar(0); a6=mirvar(0); x=mirvar(0); y=mirvar(0); r=mirvar(0); fp=fopen("common2.ecs","rt"); fscanf(fp,"%d\n",&m); mip->IOBASE=16; cinnum(a2,fp); cinnum(a6,fp); cinnum(r,fp); cinnum(x,fp); cinnum(y,fp); mip->IOBASE=10; fscanf(fp,"%d\n",&a); fscanf(fp,"%d\n",&b); fscanf(fp,"%d\n",&c); printf("modulus is %d bits in length\n",m); printf("Enter size of exponent in bits = "); scanf("%d",&nb); getchar(); printf("Enter window size in bits (1-10)= "); scanf("%d",&window); getchar(); if (!ebrick2_init(&binst,x,y,a2,a6,m,a,b,c,window,nb)) { printf("Failed to Initialize\n"); return 0; } /* Print out the precomputed table (for use in ecdh2m.c ?) len=MR_ROUNDUP(m,MIRACL); bptr=0; for (i=0;i<2*(1<