Class SignedMessage
java.lang.Object
com.exonum.binding.common.message.SignedMessage
public final class SignedMessage
extends java.lang.Object
A wrapper around
Messages.SignedMessage
protobuf message containing
Messages.CoreMessage
, which converts protobuf types into internal types.
It currently does not support verification of the signature against the author's public key — such functionality may be added later if needed.
-
Method Summary
Modifier and Type Method Description static SignedMessage
fromProto(Messages.SignedMessage message)
Creates a wrapper around signed message.PublicKey
getAuthorPk()
Returns the key of the message author.Messages.CoreMessage
getPayload()
Returns the message payload.byte[]
getSignature()
Returns the signature of the payload, created with the private key, corresponding to the author's key.HashCode
hash()
Returns the hash of the signed message, which is the hash of the protobuf-serialized representation.static SignedMessage
parseFrom(byte[] messageBytes)
Parses the signed message bytes.
-
Method Details
-
parseFrom
public static SignedMessage parseFrom(byte[] messageBytes) throws com.google.protobuf.InvalidProtocolBufferExceptionParses the signed message bytes. The parsing does not involve the signature verification — do it separately if needed.- Parameters:
messageBytes
- the serialized message to parse- Returns:
- a signed message with exonum message as its payload
- Throws:
com.google.protobuf.InvalidProtocolBufferException
- if the given bytes are not a serializedMessages.SignedMessage
; or if the payload of the message is notMessages.CoreMessage
-
fromProto
public static SignedMessage fromProto(Messages.SignedMessage message) throws com.google.protobuf.InvalidProtocolBufferExceptionCreates a wrapper around signed message.- Parameters:
message
- a signed message- Throws:
com.google.protobuf.InvalidProtocolBufferException
- if a signed message does not contain a valid payload that is a serializedMessages.CoreMessage
-
getPayload
Returns the message payload. -
getAuthorPk
Returns the key of the message author.The correctness of the signature is not verified against this key and must be done separately if needed.
-
getSignature
public byte[] getSignature()Returns the signature of the payload, created with the private key, corresponding to the author's key.The correctness of the signature is not verified against this key and must be done separately if needed.
-
hash
Returns the hash of the signed message, which is the hash of the protobuf-serialized representation.
-