Beispiel #1
0
void testEccAdd3() {
    printf("testEccAdd3 ");

    Point R;

    ecc_add(R, ec, Inf, Q);

    assert(R.x == Q.x);
    assert(R.y == Q.y);
}
Beispiel #2
0
void testEccAdd2() {
    printf("testEccAdd2 ");

    Point R;

    ecc_add(R, ec, P, Inf);

    assert(R.x == P.x);
    assert(R.y == P.y);
}
Beispiel #3
0
void testEccAdd1() {
    printf("testEccAdd1 ");

    Point R;

    ecc_add(R, ec, P, Q);

    assert(R.x == 17);
    assert(R.y == 20);
}
Beispiel #4
0
void r_adding_walk(const EllipticCurve ec,
                   BigInt& c,
                   BigInt& d, 
                   Point& X, 
                   const Triple* branches, 
                   const unsigned long j)
{
    c = (c + branches[j].c) % ec.order;
    d = (d + branches[j].d) % ec.order;
    ecc_add(X, ec, X, branches[j].point);
}
Beispiel #5
0
/* This test will have buffer overflow for type long long */
void testEccAdd4() {
    printf("testEccAdd4 ");

    EllipticCurve ec1;
    ec1 = EllipticCurve(2879867477, 62293, 47905, 2879882063);
    Point R;

    Point tempQ(2023576232, 137974030);
    ecc_add(R, ec1, tempQ, tempQ);

    assert(R.x == 991038922);
    assert(R.y == 753333067);
}
Beispiel #6
0
/*---------------------------------------------------------------------------*/
void
ecc_win_precompute(point_t * baseP, point_t * pointArray)
{
  uint8_t i;

  NN_Assign(pointArray[0].x, baseP->x, NUMWORDS);
  NN_Assign(pointArray[0].y, baseP->y, NUMWORDS);

  for(i = 1; i < NUM_POINTS; i++) {
    ecc_add(&(pointArray[i]), &(pointArray[i-1]), baseP);
  }

  for(i = 0; i < NUM_MASKS; i++) {
    mask[i] = BASIC_MASK << (W_BITS*i);
  }

}
Beispiel #7
0
int init_branches(Triple *branches,
                  const EllipticCurve ec,
                  const Point P, 
                  const Point Q)
{
    BigInt aj, bj;
    int i;

    for(i = 0; i < L; i++) {
        Point Rj, Ptemp, Qtemp;

        aj = random_number(ec.order);
        bj = random_number(ec.order);
        ecc_mul(Ptemp, ec, aj, P);
        ecc_mul(Qtemp, ec, bj, Q);
        ecc_add(Rj, ec, Ptemp, Qtemp);
        branches[i].c = aj;
        branches[i].d = bj;
        branches[i].point = Rj;
    }

    return 0;
}