encodePointAsEven static method

ProjectiveECCPoint encodePointAsEven(
  1. List<int> keys, {
  2. bool allowInfinity = false,
})

Implementation

static ProjectiveECCPoint encodePointAsEven(
  List<int> keys, {
  bool allowInfinity = false,
}) {
  try {
    if (keys.length == EcdsaKeysConst.pubKeyCompressedByteLen) {
      if (allowInfinity && BytesUtils.bytesEqual(keys, zeroPk())) {
        return ProjectiveECCPoint.infinity(MuSig2Constants.curve);
      }
      final point = encodePoint(keys);
      if (!point.isZero()) {
        final p = P2TRUtils.liftX(point.x);
        if (keys[0] == 2) {
          return p;
        } else if (keys[0] == 3) {
          return -p;
        }
      }
    }
  } catch (_) {}
  throw ArgumentException.invalidOperationArguments(
    "encodePointAsEven",
    name: "keys",
    reason: "Invalid public key.",
  );
}