public interface BinaryMessage extends Message
Message.BuilderBODY_OFFSET, HEADER_SIZE, MAX_BODY_SIZE, MESSAGE_TYPE_OFFSET, NET_ID_OFFSET, PAYLOAD_LENGTH_OFFSET, SERVICE_ID_OFFSET, SIGNATURE_SIZE, VERSION_OFFSET| Modifier and Type | Method and Description |
|---|---|
static BinaryMessage |
fromBytes(byte[] messageBytes)
Creates a binary message from a byte array.
|
default byte[] |
getMessageNoSignature()
Returns a message without signature, i.e., without the last 64 bytes of the binary message.
|
java.nio.ByteBuffer |
getSignedMessage()
Returns the whole binary message.
|
default HashCode |
hash()
Returns the SHA-256 hash of this message.
|
default BinaryMessage |
sign(CryptoFunction cryptoFunction,
PrivateKey authorSecretKey)
Signs this message, creating a new signed binary message.
|
default boolean |
verify(CryptoFunction cryptoFunction,
PublicKey authorPublicKey)
Verifies the cryptographic signature against the given public key.
|
getBody, getMessageType, getNetworkId, getServiceId, getSignature, getVersion, messageSize, signatureOffset, sizestatic BinaryMessage fromBytes(byte[] messageBytes)
messageBytes - an array with message bytesjava.lang.IllegalArgumentException - if message has invalid sizedefault byte[] getMessageNoSignature()
@CheckReturnValue default BinaryMessage sign(CryptoFunction cryptoFunction, PrivateKey authorSecretKey)
cryptoFunction - a cryptographic function to useauthorSecretKey - a secret key of the author of this messagejava.lang.IllegalArgumentException - if the key is not valid for the cryptographic function@CheckReturnValue default boolean verify(CryptoFunction cryptoFunction, PublicKey authorPublicKey)
cryptoFunction - a cryptographic function to useauthorPublicKey - a public key of the author of this messagejava.nio.ByteBuffer getSignedMessage()
default HashCode hash()
Copyright © 2018 Exonum. All rights reserved.