I have a use case where I need to ensure that a file is received from users in a group. Users may be added or removed from this group and encryption is not mandatory, just to ensure that the file came from one of those users

My first thought was to use symmetric encryption, but it would make removing users from the group hard.

Then I though using a private and public key pair for each user, the user encrypts the file with his private key and when I have to use it decrypt it with the public key. If a user needs to be removed I could just revoke his certificate

The problem is that I don't know from which user the file came from, therefore I should try to decrypt it with every key until it successfully decrypts

Is there a simpler way to achieve this?

  • 1
    the user encrypts the file with his private key In a typical private and public key pair usage, the private key is never used for encryption. The key that's used for ensuring is the public key, and private key is used for signing. – Lie Ryan Apr 11 '17 at 0:44
  • It seems like a framework like UFTP: UDP based FTP, (uftp-multicast.sourceforge.net) can solve your problem. – Limit Apr 11 '17 at 17:04

That sounds like a use-case for GPG - have you tried GPG and found it lacking (as many others have), and want a different solution?

If not, then GPG sounds like the appropriate tool for the job - although it does mean you will have one key per user, and no control over that key (although you can choose to mark it as untrusted).

If you do need control over the key, then x509 does sound like the better way to go, but as you say, you need to then manage decryption.

I would also caution against your private key encrypt, public key decrypt approach, as it means all users with access to the public key (i.e. anyone having had a copy of the cert) can decrypt. To avoid that, you would need to use the recipient's public key for encryption (and the sender's private key for signing).

In passing: you seem to be talking about signing, for which you don't need to worry about encryption. Either way, publishing/validating public keys (e.g. in LDAP, or using x509) seems like a possible solution.


You're on the right track, but the best option is sign-and-encrypt. You have a key pair, as does each of the users in the group. They sign the message with their private key, and encrypt with your public key.

Then, you can decrypt as you describe with your private key, and verify which user the message came from by verifying the signature with that user's public key.


As others have said, here are probably tools already that can do this, but I'll try to show one way how this can be done.

The users need to have public/private keys. Each user has his own private key and the public keys of all other users. When sending data, he will generate symmetric keys and use them to encrypt the data. The key that is needed for decrypting the data is then added multiple times to that message, each time encrypted with the public key of another user.

When receiving the message, a user will use his own private key to decrypt the generated symmetric key and will use that to decrypt the initial data.

In this way, each message will be accessible only to the intended recipients. Adding or removing recipients can be done on a per message basis.

If the user sending the data is creating a hash of this data and encrypts that hash with his own private key, all receiving users will be able to decrypt that hash. By generating a local hash and comparing this with the decrypted one, the user is confirming that the originator is indeed the owner of the matching private key. If the hashed data contains the list of recipients as well, each receiver will be able to validate that list of recipients.

  • Your answer is well explained but doesn't apply to my use case. The method you proposed doesn't ensure the message came from an authorized user, it just ensures that only a group of users would be able to decrypt the message – Mr. E Apr 11 '17 at 13:53
  • @Mr.E I have updated the solution with information on how to digitally sign the message. – Leo Apr 11 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.