encodePointAsEvenConst static method

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

Implementation

static Secp256k1Point encodePointAsEvenConst(
  List<int> keys, {
  bool allowInfitity = false,
}) {
  try {
    if (keys.length == EcdsaKeysConst.pubKeyCompressedByteLen) {
      if (_isZeroX(keys)) {
        if (allowInfitity) return Secp256k1Point.identity_;
      } else {
        if (keys[0] != 0x02 && keys[0] != 0x03) {
          throw const FormatException('bad prefix');
        }
        final even = Secp256k1AffinePoint.liftX(keys.sublist(1)).toCurve();
        return keys[0] == 0x03 ? -even : even;
      }
    }
  } catch (_) {}
  throw CoreErrors.invalidOperationArguments(
    "encodePointAsEven",
    name: "keys",
    reason: "Invalid public key.",
  );
}