Closed peirick closed 4 years ago
Hi peirick,
Unfortunately, what you are trying to do is impossible. Monocypher is compatible with Libsodium only. Not with NaCl nor TweetNacl. There are two major differences here:
crypto_box()
hashes the shared secret with HSalsa20. Monocypher hashes is with HChacha20.There's a third major difference with EdDSA (called Ed25519 in (Tweet)NaCl and Libsodium, but Monocypher provides a way to use SHA-512 like everyone else (and thus fully conform to Ed25519).
To interoperate with Libsodium, you want to use those Libsodium functions:
crypto_scalarmult_base() // generate public key
crypto_scalarmult() // key exchange
crypto_core_hchacha20() // hash shared secrets with that
crypto_aead_xchacha20poly1305_ietf_encrypt()
crypto_aead_xchacha20poly1305_ietf_decrypt()
crypto_aead_xchacha20poly1305_ietf_encrypt_detached()
crypto_aead_xchacha20poly1305_ietf_decrypt_detached()
May I ask you what part of the documentation lead you to believe Monocypher was compatible with TweetNaCl? Something somewhere is probably not as clear as it should be.
Now that you said that. It's not explicitly stated. It just has been my impression. Maybe the benchmarks and the explicit comparison to tweetnacl and NaCl, and statements from Readme:
If Monocypher is too slow, try Libsodium or NaCl. If you're not sure, you can always switch later.
and that in the Documenatation under
Why not LibHydrogen?
It's explicitly stated that It's incompatible with libsodium. But it's nowhere stated that Monocypher is incompatible with NaCl.
So my wrong conclusion must have been, that if NaCl/tweetnacl ist compatible with libsodium and Monocypher is compatible with libsodium, so Monocypher must be compatible with NaCl/tweetnacl.
Thanks for clarification.
Thanks, I made a couple mistakes indeed. The README was outright mistaken, sorry about that. It's fixed now.
Additionally, the Why page now states: "Monocypher is compatible with Libsodium (Libsodium only, not (Tweet)NaCl)."
Sorry again for the confusion, and thank you for your feedback.
Hi Loup Vaillant,
following the documentation monocypher should be compatible with Libsodium/TweetNaCL in the sense that the client can run monocypher and the server can run Libsodium.
I wrote a simple test application, but encryption with monocypher and decryption with TweetNaCl does not work.
Here my very basic code:
Maybe you can spot the error in my code? Btw. it would also be nice to have a migration guide from NaCL API to Monocypher API.
Regards