LoupVaillant / Monocypher

An easy to use, easy to deploy crypto library
https://monocypher.org
Other
580 stars 80 forks source link

Clarify degree of compatibility with libsodium? #223

Closed snej closed 2 years ago

snej commented 2 years ago

I'm currently using Monocypher, but about to add a 3rd party library that uses libSodium. I don't mind linking both libraries, but I'm not clear on whether I can take keys created with one library and use them with the other.

For example, can I generate a key-pair with libsodium's crypto_sign_keypair() and then pass those keys to Monocypher's crypto_sign? Will the resulting signature be recognized by libsodium?

The "Why Monocypher" page implies that Monocypher is derived from NaCl, as of course is libsodium, which would imply that they use compatible algorithms and data structures; but I'm still unsure. It would be nice if the docs stated something about compatibility.

LoupVaillant commented 2 years ago

Compatibility is as follows:

As far as I know Elligator is the only hard incompatibility between the two libraries. For almost everything else, there’s a way for Libdodium to do what Monocypher does. The reverse is not true. Unlike Libsodium, Monocypher aims to provide "one true way" of doing things. You’ll most likely need to make some changes or additions to make the two compatible.

Or, if you don’t care about compatibility and can shoulder the maintenance of the patch, you could rip out Libsodium from your 3rd party library, and replace everything with Monocypher’s equivalent. If that library is well written, its interface with the crypto library should be small enough to be easily severed.

The "Why Monocypher" page implies that Monocypher is derived from NaCl,

Monocypher followed the philosophy behind NaCl, and took most of its primitives. But it never aimed for full compatibility. The compatibility it does have is mostly a consequence of existing NaCl libraries getting so many things right.

snej commented 2 years ago

Thanks very much!

fscoto commented 2 years ago

@LoupVaillant Shouldn't this go on the website somewhere (subpage of Why Monocypher?)? This is useful information and libsodium interoperability may influence whether people choose Monocypher.

LoupVaillant commented 2 years ago

Yes @fscoto it should, which is why the issue is still open. I’ll fix it as you suggests.

LoupVaillant commented 2 years ago

Done at last!

Anything to add, or can we close this issue?

snej commented 2 years ago

Looks good!

fscoto commented 2 years ago

@LoupVaillant,

Done at last!

Anything to add, or can we close this issue?

Nit: ChaCha20, not Chacha20. See 0eabd81445d096eca59b14586f5716649ef12527.

Is "pro tip" appropriate for documentation?

Other than that ok fscoto

LoupVaillant commented 2 years ago

Good points, thanks. Should be corrected now.