/**
* Encodes a message into a buffer, such that it can be used as a message payload (piggybacked), stored, etc.
*/
public static Buffer encodeMessage(Message message, SignatureFactory signatureFactory) throws InvalidKeyException, SignatureException, IOException {
Encoder e = new Encoder(signatureFactory);
AlternativeCompositeByteBuf buf = AlternativeCompositeByteBuf.compBuffer();
e.write(buf, message, message.receivedSignature());
return new Buffer(buf);
}