Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
creationix opened this issue Mar 14, 2023 · 7 comments
Open

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

creationix opened this issue Mar 14, 2023 · 7 comments

Comments

@creationix
Copy link

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
Copy link
Owner

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
Copy link
Author

creationix commented May 16, 2023

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

What I want is a system where:

  • A message is encrypted end-to-end (relays can't read it)
  • The sender doesn't know any keys of the receiver.
  • The receiver only knows the sender's public key and wants to verify the message comes from sender via that public key.
  • The relay doesn't know the sender's public key, only a hash of it (it's semi public)

My construction idea is:

  • Sender encrypts a message using their private key (similar to signing, but the whole message is encrypted not just the content digest)
  • how do I encrypt the bulk message using a private key? I assume I want to embed some kind of symmetric key that is encrypted right?

@jedisct1
Copy link
Owner

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
Copy link
Author

creationix commented May 16, 2023

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:

  • message is hashed and that hash is encrypted using the sender's private key
  • receiver decrypts the hash using the sender's public key and verifies the hash matches the message.

What I want:

  • sender encrypts the message with a random symmetric key
  • sender encrypts the key using their private key
  • receiver decrypts the shared key using sender's public key
  • receiver decrypts message using symmetric key

Am I misunderstanding something fundamental about these primitives?

@creationix
Copy link
Author

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

@creationix
Copy link
Author

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
Copy link
Author

creationix commented May 17, 2023

Or what I want without specifying implementation details:

  • sender encrypts a message and publishes it publicly without disclosing the corresponding public key, only a hash of the public key
  • authorized readers know from a side-channel how to resolve the hash back to the original public key and only they can decrypt and authenticate it.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants