G2NativeAffinePoint.fromBytes constructor

G2NativeAffinePoint.fromBytes(
  1. List<int> bytes, {
  2. bool check = true,
})

Creates a G2 point from bytes, validating that it is on-curve and in the correct subgroup.

Implementation

factory G2NativeAffinePoint.fromBytes(List<int> bytes, {bool check = true}) {
  final affine = G2NativeAffinePoint.fromBytesUnchecked(bytes);
  if (!check) return affine;
  if (affine.isOnCurve() && affine.isTorsionFree()) {
    return affine;
  }
  throw ArgumentException.invalidOperationArguments(
    "fromBytes",
    reason: "Invalid G2 encoding.",
  );
}