decompressPublicKey function

Uint8List? decompressPublicKey(
  1. Uint8List publicKey
)

Implementation

Uint8List? decompressPublicKey(Uint8List publicKey) {
  final length = publicKey.length;
  final firstByte = publicKey[0];

  if ((length != 33 && length != 65) || firstByte < 2 || firstByte > 4) {
    throw ArgumentError.value(publicKey, 'publicKey', 'invalid public key');
  }

  final ecPublicKey = ECCurve_secp256k1().curve.decodePoint(publicKey);
  return ecPublicKey?.getEncoded(false);
}