Closed Sorunome closed 2 years ago
shared_key
ultimately calls crypto_box_curve25519xsalsa20poly1305_beforenm
, which does not just perform an ECDH scalarmult operation: https://github.com/jedisct1/libsodium/blob/6d566070b48efd2fa099bbe9822914455150aba9/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c#L35
If you're just looking for ECDH with curve25519 that's generally called X25519. cryptography
has native APIs for this, but I think in PyNaCl you can do the scalarmult yourself if needed.
Great, thank you for the insight and the pointers, this helped a lot!
Hello, I am having trouble trying to use curve25519 ECDH with pynacl. Looking at the docs i'd want to invoke Box.shared_key, however, while consistent within pynacl, it does not seem to be consistent with other curve25519 implementations.
Given the following example code:
Yields, for example, the following output:
Of course the exact keys will be different every time it is run, but the important thing to note here is that the donna25519 exchange yields a different result from the pynacl result. The donna25519 one seems to be the correct one for just ECDH, though. Does
shared_key
do more than just ECDH? How could I use just ECDH with pynacl?