geScalarMultBase static method

void geScalarMultBase(
  1. GroupElementP3 h,
  2. List<int> a
)

Implementation

static void geScalarMultBase(GroupElementP3 h, List<int> a) {
  a.asMin32("geScalarMultBase");
  List<int> e = List<int>.filled(64, 0);
  int carry;
  GroupElementP1P1 r = GroupElementP1P1();
  GroupElementP2 s = GroupElementP2();
  GroupElementPrecomp t = GroupElementPrecomp();
  int i;

  for (i = 0; i < 32; ++i) {
    e[2 * i + 0] = (a[i] >> 0) & 15;
    e[2 * i + 1] = (a[i] >> 4) & 15;
  }
  /* each e[i] is between 0 and 15 */
  /* e[63] is between 0 and 7 */

  carry = 0;
  for (i = 0; i < 63; ++i) {
    e[i] += carry;
    carry = e[i] + 8;
    carry >>= 4;
    e[i] -= carry << 4;
  }
  e[63] += carry;
  geP3Zero(h);
  for (i = 1; i < 64; i += 2) {
    select(t, i ~/ 2, e[i]);
    geMadd(r, h, t);
    geP1P1ToP3(h, r);
  }

  geP3Dbl(r, h);
  geP1P1ToP2(s, r);
  geP2Dbl(r, s);
  geP1P1ToP2(s, r);
  geP2Dbl(r, s);
  geP1P1ToP2(s, r);
  geP2Dbl(r, s);
  geP1P1ToP3(h, r);
  for (i = 0; i < 64; i += 2) {
    select(t, i ~/ 2, e[i]);
    geMadd(r, h, t);
    geP1P1ToP3(h, r);
  }
}