File tree Expand file tree Collapse file tree 4 files changed +4
-114
lines changed
test/java/cc/etherspace/web3j Expand file tree Collapse file tree 4 files changed +4
-114
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,6 @@ interface Web3 {
6060 }
6161
6262 interface Personal {
63- @Throws(IOException ::class )
64- fun ecRecover (dataThatWasSigned : String , signature : Signature ): String
65-
6663 @Throws(IOException ::class )
6764 fun ecRecover (dataThatWasSigned : ByteArray , signature : Signature ): String
6865 }
Original file line number Diff line number Diff line change @@ -25,16 +25,10 @@ class Web3jAdapter(val web3j: Web3j) : Web3 {
2525 override val eth: Web3jEth = Web3jEth ()
2626
2727 class Web3jPersonal : Web3 .Personal {
28- override fun ecRecover (dataThatWasSigned : String , signature : Web3 .Signature ): String =
29- ecRecover(dataThatWasSigned.toByteArray(Charsets .UTF_8 ), signature)
30-
3128 override fun ecRecover (dataThatWasSigned : ByteArray , signature : Web3 .Signature ): String {
3229 val prefixMsgHash = attachEthereumSignedMessage(dataThatWasSigned)
33- val ecdsaSignature = ECDSASignature (Numeric .toBigInt(signature.r),
34- Numeric .toBigInt(signature.s))
35- val publicKey = RecoverFromSignature .recoverFromSignature(signature.v - 27 ,
36- ecdsaSignature,
37- prefixMsgHash)
30+ val publicKey = Sign .signedMessageToKey(prefixMsgHash,
31+ Sign .SignatureData (signature.v, signature.r, signature.s))
3832 return Keys .toChecksumAddress(Numeric .prependHexPrefix(Keys .getAddress(publicKey)))
3933 }
4034 }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ class Web3jAdapterTest {
5252 Numeric .hexStringToByteArray(" 0x70757c5a9bad86a90c89951c078ff45e0830c99aa313576d7dba349568251a9c" ))
5353
5454 val data = Numeric .hexStringToByteArray(" 0x48540bdede62ae1b3868651336d31d36c29100af9db1559945879d14532a8067" )
55- val address = web3jAdapter.eth.personal.ecRecover(data, signature)
56- address.`should be equal to`(address )
55+ val recoveredAddress = web3jAdapter.eth.personal.ecRecover(data, signature)
56+ address.`should be equal to`(recoveredAddress )
5757 }
5858
5959 @Test
You can’t perform that action at this time.
0 commit comments