pow method

PallasFp pow(
  1. List<BigInt> expWords
)

Implementation

PallasFp pow(List<BigInt> expWords) {
  var res = PallasFp.one();
  var foundOne = false;

  // Process exponent words from most-significant to least
  for (var e in expWords.reversed) {
    // Each word is 64 bits, iterate from MSB to LSB
    for (var i = 63; i >= 0; i--) {
      if (foundOne) {
        res = res.square();
      }

      if (((e >> i).toU64 & BigInt.one) == BigInt.one) {
        foundOne = true;
        res = res * this; // or res = res.mul(this);
      }
    }
  }

  return res;
}