Search code examples
javascripthyperledger-fabricblockchainibm-blockchain

hyperledger fabric : access the private data only by the owner


So I was trying hyperledger fabric private data collection feature, but since I'm a beginner, I don't know how to make that only the owner has access to his data and not the entire Organisation


Solution

  • There is no direct way in fabric to do this. Collections Config only supports it at identity groups level

    You will have to add necessary rules in your chaincode while querying and make your data aware of the ownerId

    While storing the data You can add a field to your data called OwnerId stub.GetCreator() can be used to populate this field

    While querying the data In your chaincode, validate the OwnerId field with stub.GetCreator()