publicKeyToAddressBytes static method

Uint8List publicKeyToAddressBytes(
  1. Uint8List input
)

Convert an uncompressed public key to address bytes. (20 bytes)

Implementation

static Uint8List publicKeyToAddressBytes(Uint8List input) {
  final digest = KeccakDigest(256);
  //remove 0x04(first byte)
  var slice = remove0x04(input);
  //Hash the slice and get 32 bytes of result.
  Uint8List h = digest.process(slice);
  // Get the last 20 bytes from the 32 bytes.
  var result = h.sublist(12, h.length);
  return result;
}