ECPair constructor

ECPair({
  1. Uint8List? D,
  2. Uint8List? Q,
  3. ECPairOptions? options,
})

Implementation

ECPair({this.D, this.Q, ECPairOptions? options}) {
  if (options != null) {
    this.options = options;
  }
  compressed = this.options.compressed;
  network = this.options.network ?? networks.bitcoin;

  if (Q != null) {
    if (Q!.length < 128) {
      final point = eccParam.curve.decodePoint(publicKey);
      if (point == null) throw ArgumentError('Invalid Public Key');
      Q = point.getEncoded(this.options.compressed);
    } else {
      final x = BigInt.parse(hex.encode(Q!).substring(0, 64), radix: 16);
      final y = BigInt.parse(hex.encode(Q!).substring(64), radix: 16);
      Q = eccParam.curve
          .createPoint(x, y)
          .getEncoded(this.options.compressed);
    }
  }
}