jedisct1 / libhydrogen

A lightweight, secure, easy-to-use crypto library suitable for constrained environments.
https://libhydrogen.org
Other
608 stars 92 forks source link

Encryption with public key then decryption with private key #18

Closed edubois closed 6 years ago

edubois commented 6 years ago

Hi again,

I read the doc, but I'm trying to do something customized. I need:

I also need the reciprocity (something encoded with PRV is decryptable by the PUB)

Is it something I can do with your library?

Thanks,

jedisct1 commented 6 years ago

Encrypting with your own public key is equivalent to symmetric encryption.

So I assume you want to encrypt using another party's public key instead, and that other party will use its private key to decrypt the content.

Use the Noise N variant: https://github.com/jedisct1/libhydrogen/wiki/N-variant to get a shared key. Encrypt using that shared key, and wipe that shared key. That shared key can be later recovered using the initiator's public key and the receiver's secret key.