mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-29 10:53:09 +00:00
Conversion from public key to ethereum address
This commit is contained in:
parent
11a2329bf2
commit
9b580395d8
@ -22,3 +22,10 @@ proc `$`*(key: PrivateKey): string =
|
||||
|
||||
proc parse*(_: type PrivateKey, s: string): ?PrivateKey =
|
||||
SkSecretKey.fromHex(s).toOption()
|
||||
|
||||
proc toAddress*(key: PublicKey): EthAddress =
|
||||
let hash = keccak256.digest(key.toRaw())
|
||||
var bytes: array[20, byte]
|
||||
for i in 0..<20:
|
||||
bytes[i] = hash.data[12 + i]
|
||||
EthAddress(bytes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user