public interface Message
The message hierarchy does not work well with the target use-cases, e.g., you cannot do much without a BinaryMessage, including signing, see ECR-745 for details. However, improvements are delayed so that they are made to the new message format that is going to be integrated soon in the core framework. Until then, use something like that to sign a message:
BinaryMessage signedMessage = new Message.Builder()
// (0) Set all required fields, setting signature is not required.
//…
// (1) Create an unsigned message.
.buildRaw()
// (2) Sign it using BinaryMessage#sign.
.sign(CryptoFunctions.ed25519(), authorSecretKey);
Modifier and Type | Interface and Description |
---|---|
static class |
Message.Builder |
Modifier and Type | Field and Description |
---|---|
static int |
BODY_OFFSET |
static int |
HEADER_SIZE |
static int |
MAX_BODY_SIZE |
static int |
MESSAGE_TYPE_OFFSET |
static int |
NET_ID_OFFSET |
static int |
PAYLOAD_LENGTH_OFFSET |
static int |
SERVICE_ID_OFFSET |
static int |
SIGNATURE_SIZE |
static int |
VERSION_OFFSET |
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
getBody()
Returns the message body.
|
short |
getMessageType()
Returns the type of this message within a service (e.g., a transaction identifier).
|
byte |
getNetworkId()
Returns the blockchain network id.
|
short |
getServiceId()
Returns the identifier of the service this message belongs to,
or zero if this message is an internal Exonum message.
|
byte[] |
getSignature()
Returns the Ed25519 signature
over this binary message.
|
byte |
getVersion()
Returns the major version of the Exonum serialization protocol.
|
static int |
messageSize(int bodySize)
Calculates the message size given the size of the body.
|
default int |
signatureOffset()
Returns the signature offset in this message.
|
default int |
size()
Returns the size of a binary representation of this message in bytes.
|
static final int NET_ID_OFFSET
static final int VERSION_OFFSET
static final int MESSAGE_TYPE_OFFSET
static final int SERVICE_ID_OFFSET
static final int PAYLOAD_LENGTH_OFFSET
static final int HEADER_SIZE
static final int BODY_OFFSET
static final int SIGNATURE_SIZE
static final int MAX_BODY_SIZE
static int messageSize(int bodySize)
bodySize
- the size of the message body in bytesjava.lang.IllegalArgumentException
- if bodySize is negativebyte getNetworkId()
byte getVersion()
short getServiceId()
short getMessageType()
java.nio.ByteBuffer getBody()
byte[] getSignature()
The signature is not guaranteed to be valid and must be verified against the signer’s public key.
CryptoFunctions.ed25519()
default int signatureOffset()
default int size()
Copyright © 2018 Exonum. All rights reserved.