CryptTool { public static byte[] decrypt(byte[] box, byte[] privateKey, byte[] publicKey, byte[] nonce) { return new NaCl(privateKey, publicKey).decrypt(box, nonce); }  static EncryptResult encryptTextMessage(String text, byte[] senderPrivateKey, byte[] recipientPublicKey); static EncryptResult encryptImageMessage(EncryptResult encryptResult, UploadResult uploadResult, byte[] senderPrivateKey, byte[] recipientPublicKey); static EncryptResult encryptFileMessage(EncryptResult encryptResult,
	                                               UploadResult uploadResult,
	                                               String mimeType,
	                                               String fileName,
	                                               int fileSize,
	                                               UploadResult uploadResultThumbnail,
	                                               byte[] senderPrivateKey, byte[] recipientPublicKey); static byte[] decrypt(byte[] box, byte[] privateKey, byte[] publicKey, byte[] nonce); static byte[] decryptFileData(byte[] fileData, byte[] secret); static byte[] decryptFileThumbnailData(byte[] fileData, byte[] secret); static ThreemaMessage decryptMessage(byte[] box,  byte[] recipientPrivateKey, byte[] senderPublicKey, byte[] nonce); static void generateKeyPair(byte[] privateKey, byte[] publicKey); static EncryptResult encrypt(byte[] data,byte[] privateKey, byte[] publicKey); static EncryptResult encryptFileData(byte[] data); static EncryptResult encryptFileThumbnailData(byte[] data, byte[] encryptionKey); static byte[] hashEmail(String email); static byte[] hashPhoneNo(String phoneNo); static byte[] randomNonce(); static byte[] derivePublicKey(byte[] privateKey);  }
@Test public void testDecrypt() throws Exception { String nonce = "0a1ec5b67b4d61a1ef91f55e8ce0471fee96ea5d8596dfd0"; String box = "45181c7aed95a1c100b1b559116c61b43ce15d04014a805288b7d14bf3a993393264fe554794ce7d6007233e8ef5a0f1ccdd704f34e7c7b77c72c239182caf1d061d6fff6ffbbfe8d3b8f3475c2fe352e563aa60290c666b2e627761e32155e62f048b52ef2f39c13ac229f393c67811749467396ecd09f42d32a4eb419117d0451056ac18fac957c52b0cca67568e2d97e5a3fd829a77f914a1ad403c5909fd510a313033422ea5db71eaf43d483238612a54cb1ecfe55259b1de5579e67c6505df7d674d34a737edf721ea69d15b567bc2195ec67e172f3cb8d6842ca88c29138cc33e9351dbc1e4973a82e1cf428c1c763bb8f3eb57770f914a"; Key privateKey = Key.decodeKey(Common.otherPrivateKey); Key publicKey = Key.decodeKey(Common.myPublicKey); ThreemaMessage message = CryptTool.decryptMessage( DataUtils.hexStringToByteArray(box), privateKey.key, publicKey.key, DataUtils.hexStringToByteArray(nonce) ); Assert.assertNotNull(message); Assert.assertTrue("message is not a instance of text message", message instanceof TextMessage); Assert.assertEquals(((TextMessage) message).getText(), "Dies ist eine Testnachricht. äöü"); }