예제 #1
0
void ECMultBase(GroupElemJac &out, const Number &gn) {
    Number n; n.SetNumber(gn);
    const ECMultConsts &c = GetECMultConsts();
    out.SetAffine(c.prec[0][n.ShiftLowBits(4)]);
    for (int j=1; j<64; j++) {
        out.SetAdd(out, c.prec[j][n.ShiftLowBits(4)]);
    }
    out.SetAdd(out, c.fin);
}
예제 #2
0
 WNAF(const Number &exp, int w) : used(0) {
     int zeroes = 0;
     Number x;
     x.SetNumber(exp);
     int sign = 1;
     if (x.IsNeg()) {
         sign = -1;
         x.Negate();
     }
     while (!x.IsZero()) {
         while (!x.IsOdd()) {
             zeroes++;
             x.Shift1();
         }
         int word = x.ShiftLowBits(w);
         if (word & (1 << (w-1))) {
             x.Inc();
             PushNAF(sign * (word - (1 << w)), zeroes);
         } else {
             PushNAF(sign * word, zeroes);
         }
         zeroes = w-1;
     }
 }