encodePointAsEvenConst static method

Secp256k1Ge encodePointAsEvenConst(
  1. List<int> keys, {
  2. bool allowInfitity = false,
})

Implementation

static Secp256k1Ge encodePointAsEvenConst(
  List<int> keys, {
  bool allowInfitity = false,
}) {
  try {
    if (keys.length == EcdsaKeysConst.pubKeyCompressedByteLen) {
      Secp256k1Fe x = Secp256k1Fe();
      if (Secp256k1.secp256k1FeImplSetB32Limit(x, keys.sublist(1)).toBool) {
        if (Secp256k1.secp256k1FeIsZero(x).toBool) {
          if (allowInfitity) return Secp256k1Ge.infinity();
        } else {
          final r = liftX(
            x,
            keys[0] == Secp256k1Const.secp256k1TagPubkeyOdd ? 1 : 0,
          );
          if (r != null) return r;
        }
      }
    }
  } catch (_) {}
  throw ArgumentException.invalidOperationArguments(
    "encodePointAsEven",
    name: "keys",
    reason: "Invalid public key.",
  );
}