jedisct1 / libhydrogen

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

Is there a way to do signcryption with this library? #141

Open creationix opened 1 year ago

creationix commented 1 year ago

I really like the minimalism of this library for embedded use cases.

I'm designing a protocol where I want authenticated messages stored in relays to be encrypted at rest and only readable if you know the public key.

The relay will index the messages by a hash of the public key (similar to how dat works) so that the relay never even knows the public keys and can never decrypt the messages. But any client that knows the public key can ask for the messages from the relay and decrypt and authenticate them.

Is encryption alone enough to authenticate or is something else needed?

jedisct1 commented 1 year ago

If the public key of the recipient is not known, the shared secret cannot be recovered.

Signcryption doesn't seem necessary here, unless the relay needs to verify the sender's identity without being able to decrypt the content.

creationix commented 1 year ago

The relay doesn't need to verify anything. Maybe I misunderstood what signcryption does.

What I want is a system where:

My construction idea is:

jedisct1 commented 1 year ago

The sender doesn't know any keys of the receiver. Sender encrypts a message using their private key

In that case only the sender can decrypt their own message. The recipient cannot do anything with it. Is it what you want?

creationix commented 1 year ago

The receiver knows the sender's public key. Isn't that enough to decrypt the message?

My understanding is this is similar to a normal digital signature.

In signature:

What I want:

Am I misunderstanding something fundamental about these primitives?

creationix commented 1 year ago

I think I'm misunderstanding the primitives. This clears it up for me a bit

creationix commented 1 year ago

I think ECIES might be what I'm looking for. But I also saw that maybe I shouldn't use the same keypair for that as used for signatures.

creationix commented 1 year ago

Or what I want without specifying implementation details:

Is ECIES the correct construction for this using ECC? If so, is this possible with this library?