I've been thinking about designing a system, where every student's grades are stored on the blockchain in encrypted form.

However, I've read enough posts describing why this is not a good idea: Ethereum discourages the use of storage, and contracts cannot store the decryption key safely/hidden anyway (all contract data is visible to anyone on the blockchain, right?).

The system should facilitate a paid service for, e.g., companies that want information on a particular student.

My initial thoughts of such system is as follows (assuming both parties, i.e., university and company, have an Ethereum account with public/private key pair):

  1. The company sends a request to the university web server, requesting information, and providing the public key of the company.
  2. The university creates a smart contract with the encrypted information (under the company's public key) and a hash of the plaintext.
  3. The company sends a transaction to the smart contract, paying some amount of ether, whereafter it gets the encrypted information and hash. The contract then suicides and transfer its funds to the university.
  4. The company decrypts the information under its private key and verifies the hash.

There is a problem with this idea. After the smart contract (step 2.) has been deployed, the company can just read its data without sending any ether to it. How can this be fixed?

In general, what approach would I choose for designing such paid service for information retrieval?

  • You seem to be falling into the trap of trying to use blockchain for something that does not need blockchain. Why does this need anything more than a payment processor and a web server? Commented Aug 31, 2017 at 10:21
  • @ThomasClowes - it might not need more than that. However, I'm looking for a project for my master thesis that makes use of blockchain and language based-security.
    – Shuzheng
    Commented Aug 31, 2017 at 10:23

1 Answer 1


The only way to fix the issue you've determined with the system is to wait to send them the decryption key until your company has verified that the contract has been paid.

But at that point, you might as well just withhold the data entirely, use a normal address instead of a smart contract, and give them the data once they pay up, i.e. run a normal, centralized service. Having the data out there and encrypted doesn't give you much of an advantage over just keeping it on an in-house server, and it doesn't remove any trust since until the client has the decryption key, for all they know the encrypted data could just be gibberish.

Currently, there is no way to implement a system like the one you are describing (and I believe it might actually be strictly impossible, violating the laws of information in the universe for a properly functioning blockchain). Either the data is accessible on the blockchain or it is not, and your company can only change that by releasing the data (or an encryption key) after you have verified the payment through a centralized (off-chain) means.

In short, if you want to keep information secret, you cannot trust a network based on complete and perfect information to control access to it.

Here's an idea though - you could always encrypt the data using an M-of-N scheme and distribute the N keys to a set of trusted validators (which could be users, companies, etc.). They could release their key to the client when the payment comes in. When most of them verify the payment and release keys, the client can use the keys to decrypt the content.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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