### Question:
EncryptedData { public static EncryptedData encrypt(byte[] plaintext, byte[] keySeed, byte[] theirPublicKey) { if (plaintext.length == 0) { return EMPTY_DATA; } byte[] nonce = new byte[32]; Crypto.getSecureRandom().nextBytes(nonce); byte[] sharedKey = Crypto.getSharedKey(Crypto.getPrivateKey(keySeed), theirPublicKey, nonce); byte[] data = Crypto.aesEncrypt(plaintext, sharedKey); return new EncryptedData(data, nonce); } EncryptedData(byte[] data, byte[] nonce); static EncryptedData encrypt(byte[] plaintext, byte[] keySeed, byte[] theirPublicKey); static EncryptedData readEncryptedData(ByteBuffer buffer, int length, int maxLength); static EncryptedData readEncryptedData(byte[] bytes); static int getEncryptedDataLength(byte[] plaintext); static int getEncryptedSize(byte[] plaintext); byte[] decrypt(byte[] keySeed, byte[] theirPublicKey); byte[] getData(); byte[] getNonce(); int getSize(); byte[] getBytes(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final EncryptedData EMPTY_DATA; }### Answer:
@Test public void testEncrypt() throws IOException { byte[] plaintext = plain_data; byte[] keySeed = Crypto.getKeySeed(secretPhraseA); byte[] theirPublicKey = Crypto.getPublicKey(secretPhraseB); EncryptedData result_enc = EncryptedData.encrypt(plaintext, keySeed, theirPublicKey); byte[] plain_res = result_enc.decrypt(keySeed, theirPublicKey); assertArrayEquals(plaintext, plain_res); writeToFile(ByteBuffer.wrap(result_enc.getBytes()), TST_OUT_DIR+OUT_FILE_ENCRYPTED); }