ECDSAPublicKey constructor

ECDSAPublicKey(
  1. ProjectiveECCPoint generator,
  2. ProjectiveECCPoint point, {
  3. bool verify = true,
})

Creates an ECDSA public key with a generator and a point.

Parameters:

  • generator: The generator point for the elliptic curve.
  • point: The public key point.
  • verify: Set to true to verify that the point is on the curve and has a valid order (default is true).

Implementation

factory ECDSAPublicKey(ProjectiveECCPoint generator, ProjectiveECCPoint point,
    {bool verify = true}) {
  final curve = generator.curve;
  final n = generator.order;
  final p = curve.p;

  if (!(BigInt.zero <= point.x && point.x < p) ||
      !(BigInt.zero <= point.y && point.y < p)) {
    throw const ArgumentException(
        "The public point has x or y out of range.");
  }

  if (verify && !curve.containsPoint(point.x, point.y)) {
    throw const ArgumentException("AffinePointt does not lay on the curve");
  }

  if (n == null) {
    throw const ArgumentException("Generator point must have order.");
  }

  if (verify && curve.cofactor() != BigInt.one && !(point * n).isInfinity) {
    throw const ArgumentException("Generator point order is bad.");
  }
  return ECDSAPublicKey._(generator, point);
}