Closed krisbitney closed 1 year ago
This is resolved. It was my mistake. I wasn't adding the prefix!
private fun locallySignMessage(message: ByteArray, signer: ECKeyPair): String {
val len = message.size.toString().encodeToByteArray()
return "0x" + signer.signMessage(MESSAGE_PREFIX + len + message).toHex()
}
companion object {
val MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n".encodeToByteArray()
}
There seems to be a bug somewhere in
signMessage
. I am trying to replicate the output from libraries in a few other languages and I'm getting a different result.Provider:
"https://bsc-dataseed1.binance.org/"
Private Key:"0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"
Message:"Hello World".encodeToByteArray()
Code:
Test: https://github.com/polywrap/ethereum-wallet/blob/a7dd7132ba2dac6938734fe547a375413c68204b/implementations/kt/src/test/kotlin/io/polywrap/plugins/ethereum/EthereumWalletPluginTest.kt#L64