dvEthereumAddress function
The address for an uncompressed secp256k1 public key.
Keccak-256 of the 64 body bytes -- the 0x04 tag is dropped -- and the low
20 bytes of that. Including the tag produces a different, plausible-looking
address for every key.
Implementation
String dvEthereumAddress(Uint8List uncompressedPublicKey) {
final Uint8List body = uncompressedPublicKey.length == 65
? Uint8List.sublistView(uncompressedPublicKey, 1)
: uncompressedPublicKey;
final Uint8List hash = dvKeccak256(body);
final String hex = Uint8List.sublistView(hash, 12)
.map((int b) => b.toRadixString(16).padLeft(2, '0'))
.join();
return dvToChecksumAddress('0x$hex');
}