Vishvajeet Ramanuj
Vishvajeet Ramanuj

Reputation: 349

Encryption with single key and decryption with multiple keys

I am searching for a mechanism which encrypt using single key. but for decryption it require multiple keys 2,3,4 and 5. Note that I want all (2,3,4 and 5) keys need to decrypt. I want to implement it in python. but i couldn't found concrete material online. I found answer encryption/decryption with multiple keys according to it i can use GnuPG for this purpose. I read GnuPG but i couldn't able to find answer to it. I found Shamir's Secret Sharing I believe it could solve my problem. But i couldn't found it's implementation in cryptography or other popular python package. i am ready to implement code which is given in Wikipedia page of Shamir's Secret Sharing. but i have one problem. I am not sure about it's implementation is secure ?

Upvotes: 2

Views: 1582

Answers (1)

gusto2
gusto2

Reputation: 12087

Note that I want all (2,3,4 and 5) keys need to decrypt.
found Shamir's Secret Sharing I believe it could solve my problem

Shamir's Secret Sharing could as well solve your problem, but it can do more (recover the decryption key having only a subset of the keys). It's doing that in expense of complexity and performance. If you consider any future option to use the shares (subsets), imho the link from Kelalaka is maybe the best you can get for your case.

If you need all the keys for decryption, you can simplify your code to derive the encryption key from N random keys (faster and simpler) using any secure operation (XOR, hash, remainterless addition, ..). I'd prefer using simple XOR as it is a commutative operation, fast and supported out of box

example:

  • generate N random decryption keys
  • XOR all the decryption keys to get the encryption key

Note. Your first link (encryption/decryption with multiple keys) is using GPG to encrypt a single encryption key for multiple recipients (public keys) separately, so any of the recipients would be able to recover the encryption key

Upvotes: 4

Related Questions