### Question:
Sign { public static BigInteger signedMessageToKey( byte[] message, SignatureData signatureData) throws SignatureException { byte[] r = signatureData.getR(); byte[] s = signatureData.getS(); verifyPrecondition(r != null && r.length == 32, "r must be 32 bytes"); verifyPrecondition(s != null && s.length == 32, "s must be 32 bytes"); int header = signatureData.getV() & 0xFF; if (header < 0 || header > 7) { throw new SignatureException("Header byte out of range: " + header); } ECDSASignature sig = new ECDSASignature( new BigInteger(1, signatureData.getR()), new BigInteger(1, signatureData.getS())); byte[] messageHash = Hash.sha3(message); int recId = header; BigInteger key = recoverFromSignature(recId, sig, messageHash); if (key == null) { throw new SignatureException("Could not recover public key from signature"); } return key; }  static SignatureData signMessage(byte[] message, ECKeyPair keyPair); static BigInteger signedMessageToKey(
            byte[] message, SignatureData signatureData); static BigInteger publicKeyFromPrivate(BigInteger privKey);  }### Answer:
@Test public void testSignedMessageToKey() throws SignatureException { Sign.SignatureData signatureData = Sign.signMessage(TEST_MESSAGE, SampleKeys.KEY_PAIR); BigInteger key = Sign.signedMessageToKey(TEST_MESSAGE, signatureData); assertThat(key, equalTo(SampleKeys.PUBLIC_KEY)); }
@Test(expected = RuntimeException.class) public void testInvalidSignature() throws SignatureException { Sign.signedMessageToKey( TEST_MESSAGE, new Sign.SignatureData((byte) 27, new byte[]{1}, new byte[]{0})); }