@Test public void testECRecover() { String addr = EthereumSign.recoverAddress("imToken", expectedSignature); String expectedAddr = new EthereumAddressCreator().fromPrivateKey(privateKey); Assert.assertEquals(addr, expectedAddr); String sig = "0 x1 87 ebc72 f217017 b2 a8349 abdd1 8 f1 22 d16 c8 7 bf5 e455794 d641 426 d4 f65 d9 e9001 765494362 b4 b38 a60 e571 7 e96 c411 72 d25475 a9 a43 c6217 00 dded28935 b221 c".replace(" ", "").trim(); addr = EthereumSign.recoverAddress("z78ubpeks2", sig); System.out.println(addr); }
public static BigInteger ecRecover(String data, String signature) throws SignatureException { byte[] msgBytes = dataToBytes(data); signature = NumericUtil.cleanHexPrefix(signature); byte[] r = Hex.decode(signature.substring(0, 64)); byte[] s = Hex.decode(signature.substring(64, 128)); int receiveId = Integer.valueOf(signature.substring(128), 16); SignatureData signatureData = new SignatureData((byte) receiveId, r, s); return signedMessageToKey(msgBytes, signatureData); }
EthereumSign { public static BigInteger ecRecover(String data, String signature) throws SignatureException { byte[] msgBytes = dataToBytes(data); signature = NumericUtil.cleanHexPrefix(signature); byte[] r = Hex.decode(signature.substring(0, 64)); byte[] s = Hex.decode(signature.substring(64, 128)); int receiveId = Integer.valueOf(signature.substring(128), 16); SignatureData signatureData = new SignatureData((byte) receiveId, r, s); return signedMessageToKey(msgBytes, signatureData); } }
EthereumSign { public static BigInteger ecRecover(String data, String signature) throws SignatureException { byte[] msgBytes = dataToBytes(data); signature = NumericUtil.cleanHexPrefix(signature); byte[] r = Hex.decode(signature.substring(0, 64)); byte[] s = Hex.decode(signature.substring(64, 128)); int receiveId = Integer.valueOf(signature.substring(128), 16); SignatureData signatureData = new SignatureData((byte) receiveId, r, s); return signedMessageToKey(msgBytes, signatureData); }  }
EthereumSign { public static BigInteger ecRecover(String data, String signature) throws SignatureException { byte[] msgBytes = dataToBytes(data); signature = NumericUtil.cleanHexPrefix(signature); byte[] r = Hex.decode(signature.substring(0, 64)); byte[] s = Hex.decode(signature.substring(64, 128)); int receiveId = Integer.valueOf(signature.substring(128), 16); SignatureData signatureData = new SignatureData((byte) receiveId, r, s); return signedMessageToKey(msgBytes, signatureData); }  static String personalSign(String data, byte[] prvKeyBytes); static String sign(String data, byte[] prvKeyBytes); static BigInteger ecRecover(String data, String signature); static String recoverAddress(String data, String signature); static SignatureData signAsRecoverable(byte[] value, ECKey ecKey); }
EthereumSign { public static BigInteger ecRecover(String data, String signature) throws SignatureException { byte[] msgBytes = dataToBytes(data); signature = NumericUtil.cleanHexPrefix(signature); byte[] r = Hex.decode(signature.substring(0, 64)); byte[] s = Hex.decode(signature.substring(64, 128)); int receiveId = Integer.valueOf(signature.substring(128), 16); SignatureData signatureData = new SignatureData((byte) receiveId, r, s); return signedMessageToKey(msgBytes, signatureData); }  static String personalSign(String data, byte[] prvKeyBytes); static String sign(String data, byte[] prvKeyBytes); static BigInteger ecRecover(String data, String signature); static String recoverAddress(String data, String signature); static SignatureData signAsRecoverable(byte[] value, ECKey ecKey);  }