VestaNativePoint.random constructor

VestaNativePoint.random()

Implementation

factory VestaNativePoint.random() {
  while (true) {
    final x = VestaNativeFq.random();
    final ySign = QuickCrypto.nextU32() % 2;
    final x3 = x.square() * x;
    VestaNativeFq? y =
        (x3 + PastaCurveParams.vestaNative.b).sqrt().sqrtOrNull();
    if (y == null) continue;
    if (y == VestaNativeFq.fromBytes(y.toBytes())) {
      final sign = y.isOdd() ? 1 : 0;
      if ((ySign ^ sign) != 0) {
        y = -y;
      }
      return VestaAffineNativePoint(x: x, y: y).toCurve();
    }
  }
}