/**
* Decodes a message which was encoded using {{@link #encodeMessage(Message, SignatureFactory)}}.
*/
public static Message decodeMessage(Buffer buf, InetSocketAddress recipient, InetSocketAddress sender, SignatureFactory signatureFactory)
throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, SignatureException, IOException {
Decoder d = new Decoder(signatureFactory);
final int readerBefore = buf.buffer().readerIndex();
d.decodeHeader(buf.buffer(), recipient, sender);
final boolean donePayload = d.decodePayload(buf.buffer());
d.decodeSignature(buf.buffer(), readerBefore, donePayload);
return d.message();
}