nucypher / pyUmbral

NuCypher's reference implementation of Umbral (threshold proxy re-encryption) using OpenSSL and Cryptography.io
https://pyumbral.readthedocs.io
GNU General Public License v3.0
284 stars 71 forks source link

Possibility of overloading the encrypt function? #89

Closed tpmccallum closed 6 years ago

tpmccallum commented 6 years ago

Hi, I have been using pyUmbral and am researching a distributed ledger information sharing design which incorporates pyUmbral. You can read about it and see a diagram here

In short what I am wondering is ... could the encrypt function [1] be overloaded to just return a cipher (and not both the cipher and the capsule)? Perhaps just another/different function capable of producing only a cipher of Alice's plain text would suffice.

The reason that I need this is I want to demonstrate that chunks of encoded/compressed and encrypted (byPyumbral) data can be stored in the blockchain state (either as a message -> transaction or as a state variable in a smart contract). An example of this would be storing firstname, lastname, address etc. as only a cipher. Then, in the event that someone (like a delivery driver) needs only an address (and none of the other important/private information which is encrypted by pyUmbral in the blockchain) the software/app can fetch this specific information from the blockchain (decrypt and decompress to plain text) and then encrypt it using the current encrypt function (producing the cipher of this specific information as well as the new capsule for the whole proxy re-encryption process as it stands).

Please have a read of the overview of the idea and let me know what you think. I would love to create a demo (even if it is using Vyper smart contract on Ethereum etc.) so that we can show how sustainable p2p e-commerce could work using NuCypher.

Many thanks

[1] https://github.com/nucypher/pyUmbral/blob/ccdb877a34a8af844198c7c3836eb25dfc7e2598/umbral/pre.py#L443

tuxxy commented 6 years ago

could the encrypt function [1] be overloaded to just return a cipher (and not both the cipher and the capsule)?

By "cipher", I'm presuming that you mean the ciphertext.

I'm probably misunderstanding you, but why would you want the ciphertext without the corresponding key to decrypt it? A pyUmbral "capsule" is an encrypted key that can be decrypted with the pubkey given in the encrypt function. A decrypted capsule is then used to decrypt the ciphertext.

michwill commented 6 years ago

In principle, the capsule is supposed to be stored and distributed together with the ciphertext.

You certainly could store capsule + ciphertext on a blockchain, however it's probably a better idea to keep them in an offchain storage (such as IPFS or Swarm) and just reference the link in the smart contract you're using.

Thanks for sharing your idea, having a look!

jMyles commented 6 years ago

@tpmccallum Thanks for again hanging out around these parts. :-)

How are you?

I think @tuxxy and @michwill pretty much covered it - it's hard to understand what the use is of the ciphertext if the capsule is cast aside. Can you outline more specifically how you intend to handle these two parts, if not together?

FWIW, we have started referring to these two parts together as a "MessageKit", and we are designing our KMS around the idea that a Character seeks a MessageKit as a way to receive information from any other actor.

While dividing this kit into two pieces is not unreasonable, they need to eventually be united in order for the message to be decryptable.

tpmccallum commented 6 years ago

Hi @jMyles , @tuxxy and @michwill

Thanks for your responses. Would love to discuss this more, thanks for your time, much appreciated. I guess there are two parts to this example e-commerce scenario. 1) a buyer's app (which doesn't know what data will need to be shared yet) encrypts the buyers firstname, lastname, address and more on the blockchain as part of standard operation. The buyer is able to view their own data (which is stored on the blockchain) because their app knows where to find it and how to decrypts it. 2) one day the buyer's app triggers a delivery to the buyer's address (because the buyer bought something online). The buyer's app gathers only the information that the delivery driver needs (say lastname and address just for an example) and creates a ciphertext and capsule of this specific cohort of information (for delivery purposes only). The ciperhtext (delivery address) is recorded in the blockchain as a permanent record i.e. as part of the consignment note. A URL is provided to the off-chain capsule. The capsule is modified by a third party, the delivery driver's app decrypts the message as intended. The capsule is destroyed as it is no longer needed. However the ciphertext (delivery address) and some extra binary checks such as "goodsDelivered=yes" are stored in the blockchain.

This is the basic process, I have deliberately left out some things like the public key sharing etc to keep the example short. I understand how pyUmbral works right down to each of the functions, their arguments and what they return etc. Ultimately what I would like to know is can it be used to do step one above as well as step two. The idea is that very small amounts of data are constantly stored in the app (firstname, lastname etc.) Whilst these must be encrypted, where it really gets interesting is if the app can deliberately assemble specific parts of data and then use pyUmbral to share those specific parts of data with which every party needs them i.e. delivery, accountant, auditor, web analytics company etc.

Please note, I have updated the link from yesterday, please check this out and let me know what you think. Great product guys. Thank you so much, chat soon. Happy to call if more explanation is required,

Kind regards Tim

DLISh

tuxxy commented 6 years ago

@tpmccallum Thanks for the clarification.

From what I understand, this sounds like a great use case for proxy re-encryption/NuCypher.

Essentially, the data that you need to share (the address, name, etc) are encrypted with the data owner's public key in that original encrypt function. These pieces of data are encrypted separately from each other. (IE: encrypt the name separately from the address, etc.)

When this data needs to get accessed, you'll pass along the capsule for the specific ciphertexts that the delivery-person will need access to. The data owner will generate the re-encryption keys for these capsules and have them re-encrypted for the delivery person (Do you plan on using NuCypher?).

In summary, yes we can do steps one and two, as I understand the problem. Each piece of data will need to be encrypted separately with different capsules for each piece of data.

Is there anything else that I can help clarify or answer for you with regards to how this works?

tpmccallum commented 6 years ago

Hi @tuxxy This is perfect, thank you! Will be in touch. Thank you so much. Tim