I am using Hyperledger Fabric V1.4 on my project. I have enrolled and registered users. And now I want to transfer files between users while remain private, which means I need to encrypt the file so that only the receiver can see. For example, user A wants to send a file to user B. The basic workflow I'm thinking right now is that:
- User A and B register in the Hyperledger Network and get public/private keys.
- User A uploads a file in IPFS and gets a hash from IPFS. (Since everyone with the hash can access the file, we need to encrypt the file hash.)
- Encrypt the file hash with user B's public key.
- Send the encrypted hash to user B.
- User B receives the encrypted hash and uses B's private key to decrypt the hash, and gets the IPFS file hash. Then B can view the hash using IPFS.
Problems I'm having:
- In step 3, how to get a user's public key? I only found ways to get certificate and private key. Or can I get public key from the certificate?
- Is there an algorithm to encrypt files/strings using Hyperledger-generated public and private keys?
Thank you!