Пример #1
0
double mult2_double(int eb,epoint *g)
{
    big e1,e2;
    int iterations=0;
    clock_t start;
    double elapsed;
    char *mem1;
    char *mem2;
    epoint *w;
    epoint *r1;
    epoint *r2;

    mem1=(char *)memalloc(2);
    mem2=(char *)ecp_memalloc(3);

    e1=mirvar_mem(mem1,0);
    e2=mirvar_mem(mem1,1);
    w=epoint_init_mem(mem2,0);
    r1=epoint_init_mem(mem2,1);
    r2=epoint_init_mem(mem2,2);

    bigbits(eb,e1);
    ecurve2_mult(e1,g,r1);   /* generate a random point on the curve */
    bigbits(eb,e2);
    ecurve2_mult(e2,g,r2);   /* generate a random point on the curve */
    bigbits(eb,e1);
    bigbits(eb,e2);
    start=clock();

    do {
       ecurve2_mult2(e1,r1,e2,r2,w);
       iterations++;
       elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
    } while (elapsed<MIN_TIME || iterations<MIN_ITERS);

    elapsed=1000.0*elapsed/iterations;
    printf("ED - %8d iterations             ",iterations);
    printf(" %8.2lf ms per iteration\n",elapsed);

    ecp_memkill(mem2,3);
    memkill(mem1,2);

    return elapsed;
}
Пример #2
0
EC2 mul(const Big& e1,const EC2& p1,const Big& e2,const EC2& p2)
{ 
    EC2 t; 
    ecurve2_mult2(e1.getbig(),p1.get_point(),e2.getbig(),p2.get_point(),t.get_point());
    return t;
}