pow method

VestaFq pow(
  1. List<BigInt> exp
)

Implementation

VestaFq pow(List<BigInt> exp) {
  var res = VestaFq.one(); // equivalent of Self::ONE
  for (var e in exp.reversed) {
    for (var i = 63; i >= 0; i--) {
      res = res.square();
      // Conditional multiply: if bit i is 1, multiply by base
      var bit = (e >> i) & BigInt.one;
      var tmp = res * this;
      if (bit == BigInt.one) {
        res = tmp;
      }
    }
  }

  return res;
}