简体   繁体   中英

Hyperledger Fabric: Can a smart contract secretly add numbers and only share the sum?

Scenario:

I have 4 nodes in which each node sends a number. Each number should not be visible to any node other than the owner. The smart contract should secretly add all 4 numbers without viewing them to any member. Only the result which is the summation should be visible to all contracts.

Is the above scenario possible when using hyperledger fabric?

The asymmetric encryption maybe the way to do it. The nodes use the public key to encrypt their number. And only smart contract have the key to decrypt it. You somehow need to dig deep inside the API see how the contract interact with the CA server.

You can easily achieve this by using Symmetric encryption like AES.

  • Data(number) that you are using can be encrypted using AES. what you will get as output will be IV, password, tag and encrypted data. You can store encrypted data on blockchain for everyone to see. However, only those entities that wish to see the decrypted data can ask the owner of data for the required 3 keys(IV, password, tag) which will not be stored in the blockchain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM