After a lot of digging and testing. I believe this is the appropriate way to deserialize the signature.
final Sign.SignatureData signatureData = new Sign.SignatureData(
Arrays.copyOfRange(signatureBytes, 64, 65),
Arrays.copyOfRange(signatureBytes, 0, 32),
Arrays.copyOfRange(signatureBytes, 32, 64)
);
Similar implementation here:
. eth-lib/account.js at master · MaiaVictor/eth-lib · GitHub
Which I believe is used here
. caver-js/utils.js at dev · klaytn/caver-js · GitHub
However, using this approach, along with carver-java’s “Utils.recover()” method, I’m unable to correctly extract the address used to sign an arbitrary string with the Kaikas wallet on the kaikas tutorials site.
Address: 0x9462e1f20dd41d3def4a206e00a1767a6787411a
Message: test
Signature: 0x70b6343882d94dfc34f201b368d2747b0dab3f0db02804408680835ec3d513567c33a8bb58e19eafc371e2dc10a99fc9b1579577f1c21d0e616fce99d5971e391c
When I run a
Utils.recover("test", signatureData /* as deserialized above*/)
I get the following address:
0x849963e0388746505e3839d3048a83fc007ef189
Which naturally is not a match and does not validate.
However, if I use the private key for this address
0x329d18c99f679d721100f1ca85e1fe0c986f3268
To sign a message using
org.web3j.crypto.Sign.signMessage()
And then run a Utils.recover
on that, I get the correct address as a result.
What do I need to do differently to verify Kaikas signatures? It would seem that they are using a different algorithm.