1
votes

I'm writting DApp on Ethereum (Solidity) and I need to find a solution how to store a private data on blockchain, when I also need to proceed them somehow. If it is only about storing, I can use some normal encrypting, but the problem is that I need to read the data IN the smart contract and proceed it somehow too.

Let's say:

1) I want to send some private number to a blockchain.

2) I need to check if the privete number is bigger than the last stored private number and smaller than the second last stored number.

if (storage[n] < y < storage[n-1]) storage.push(y);

3) If yes, I want to store it privately.

Any ideas? Thank you.

2

2 Answers

0
votes

it is better to use a data structure with two entries e.g. a tuple, with the first entry to use as the counter (i.e. to take care of check if the private number is bigger than the last stored private number part, and the second entry to store an encrypted data, one to use as a counter.

y = new Dapp(sno, value)
# compare y's sno with the record, store private data in value
0
votes

You can encrypt the data before sending to the blockchain. Encryption and decryption should be done off-chain because the blockchain is public and you don't want your plaintext to be exposed.

You can compare those numbers on-chain without exposing your plaintext if you use homomorphic encryption.

Homomorphic encryption is a form of encryption that allows computation on ciphertexts, generating an encrypted result which, when decrypted, matches the result of the operations as if they had been performed on the plaintext. - Wikipedia