Package org.symbol.sdk.symbol
Class MessageEncoder
java.lang.Object
org.symbol.sdk.symbol.MessageEncoder
- MessageEncoder
- Encrypts and encodes messages between two Symbol parties. Wire format is
[0x01 | tag(16) | iv(12) | cipherText]; persistent harvesting delegations use[FE2A8061577301E2 marker(8) | ephemeralPubKey(32) | tag(16) | iv(12) | cipherText].
-
Constructor Summary
ConstructorsConstructorDescriptionMessageEncoder(KeyPair keyPair) Creates a message encoder around a key pair. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encode(CryptoTypes.PublicKey recipientPublicKey, byte[] message) Encodes a message to a recipient using the recommended format.byte[]encodeDeprecated(CryptoTypes.PublicKey recipientPublicKey, byte[] message) Encodes a message to a recipient using the deprecated wallet format; provided only for compatibility with the original Symbol wallets — new code should useencode(CryptoTypes.PublicKey, byte[]).byte[]encodePersistentHarvestingDelegation(CryptoTypes.PublicKey nodePublicKey, KeyPair remoteKeyPair, KeyPair vrfKeyPair) Encodes a persistent harvesting delegation to a node.Returns the public key used for message encoding.tryDecode(CryptoTypes.PublicKey recipientPublicKey, byte[] encodedMessage) Tries to decode an encoded message.tryDecodeDeprecated(CryptoTypes.PublicKey recipientPublicKey, byte[] encodedMessage) Tries to decode an encoded message using the deprecated wallet format; provided only for compatibility with the original Symbol wallets — new code should usetryDecode(CryptoTypes.PublicKey, byte[]).
-
Constructor Details
-
MessageEncoder
Creates a message encoder around a key pair.- Parameters:
keyPair- Key pair.
-
-
Method Details
-
getPublicKey
- MessageEncoder.publicKey
- Returns the public key used for message encoding.
- Returns:
- Public key used for message encoding.
-
tryDecode
public MessageEncoderResult tryDecode(CryptoTypes.PublicKey recipientPublicKey, byte[] encodedMessage) - MessageEncoder.tryDecode
- Tries to decode an encoded message.
- Parameters:
recipientPublicKey- Recipient's public key.encodedMessage- Encoded message bytes.- Returns:
- Decoded result.
isDecoded()istrueon success.
-
encode
- MessageEncoder.encode
- Encodes a message to a recipient using the recommended format.
- Parameters:
recipientPublicKey- Recipient public key.message- Message to encode.- Returns:
- Encrypted and encoded message.
-
encodePersistentHarvestingDelegation
public byte[] encodePersistentHarvestingDelegation(CryptoTypes.PublicKey nodePublicKey, KeyPair remoteKeyPair, KeyPair vrfKeyPair) - MessageEncoder.encodePersistentHarvestingDelegation
- Encodes a persistent harvesting delegation to a node.
- Parameters:
nodePublicKey- Node public key.remoteKeyPair- Remote key pair.vrfKeyPair- VRF key pair.- Returns:
- Encrypted and encoded harvesting delegation request.
-
tryDecodeDeprecated
public MessageEncoderResult tryDecodeDeprecated(CryptoTypes.PublicKey recipientPublicKey, byte[] encodedMessage) - MessageEncoder.tryDecodeDeprecated
- Tries to decode an encoded message using the deprecated wallet format; provided only for compatibility with the original Symbol wallets — new code should use
tryDecode(CryptoTypes.PublicKey, byte[]).
- Parameters:
recipientPublicKey- Recipient's public key.encodedMessage- Encoded message bytes.- Returns:
- Decoded result.
-
encodeDeprecated
- MessageEncoder.encodeDeprecated
- Encodes a message to a recipient using the deprecated wallet format; provided only for compatibility with the original Symbol wallets — new code should use
encode(CryptoTypes.PublicKey, byte[]).
- Parameters:
recipientPublicKey- Recipient public key.message- Message to encode.- Returns:
- Encrypted and encoded message.
-