In many blockchain platforms such as Ethereum and Bitcoin, data confidentiality is a kind of excluded item in their blockchain framework. In these distributed blockchain platform transactions are executed in every participant node in the network. So, every transaction in the network can be visible to all the peers. The ledger update process through all the endorsed peers and has to reach an agreement among all before it committed successfully to the ledger. So, in this scenario creating a private record and comprises within a certain group of participants in the network is a complete “No”.
Why Private Data?
- The client application sends the transaction proposal request to the only authorized endorsing peers. Then the peer invokes the request into the Chaincode.
- The peers analyze the private data transaction and stores in the transient data store. Then, the private data collection distributed to other authorized peers via gossip protocol.
- Now the endorsing peers return the proposal response to the client and the response contains the only hash of private data, it’s private key-value pair. The client doesn’t get the original private data in the response.
- The client submits the transaction response to the Ordering Service. The hashed private data gets included in the block.
- The block containing the hash of the private data is distributed to the remaining peers in the network. So the block can be validated among all the peers consistently.
- The authorized peers will validate their private data with the public block containing the hash of the private data. If it matches then they move the private data into the Private State Database and Private Writeset Storage. And then the Private data is deleted from temporary local peer storage or transient data store.
Private Data Collection Policy
In Hyperledger Fabric Go SDK, we can create a collection config for each collection and can use it while instantiating a Chaincode
collCfg1, _ := newCollectionConfig("collectionOrg1Org2", "OR ('Org1MSP.member', 'Org2MSP.member')", peerCount, maximumPeerCount, blockToLive)
collCfg2, _ := newCollectionConfig("collectionOrg3Org4", "OR ('Org3MSP.member', 'Org4MSP.member')", peerCount, maximumPeerCount, blockToLive).
Function newCollectionConfig
func newCollectionConfig(colName, policy string, reqPeerCount, maxPeerCount int32, blockToLive uint64) (*cb.CollectionConfig, error) {
p, err := cauthdsl.FromString(policy)
if err != nil {
fmt.Println("failed to create newCollectionConfig : "+err.Error())
return nil, err
}
cpc := &cb.CollectionPolicyConfig{
Payload: &cb.CollectionPolicyConfig_SignaturePolicy{
SignaturePolicy: p,
},
}
return &cb.CollectionConfig{
Payload: &cb.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &cb.StaticCollectionConfig{
Name: colName,
MemberOrgsPolicy: cpc,
RequiredPeerCount: reqPeerCount,
MaximumPeerCount: maxPeerCount,
BlockToLive: blockToLive,
},
},
}, nil
}
Instantiation of Chaincode
cfg := []*cb.CollectionConfig{ collCfg1, collCfg2}
policy = "OR ('Org1MSP.member','Org2MSP.member','Org3MSP.member','Org4MSP.member')"
// here this policy is a completely separate entity, it relates to the all organization's peers following an endorsing policy to validate all the blocks in the network consistently.
ccPolicy, _ := cauthdsl.FromString(policy) // cauthdsl will convert the policy string to Policy object
resp, err := s.Resmgmt.InstantiateCC(
s.ChannelID,
resmgmt.InstantiateCCRequest{
Name: s.ChaincodeId,
Path: s.ChaincodePath,
Version: s.ChainCodeVersion,
Args: [][]byte{[]byte("init")},
Policy: ccPolicy,
CollConfig: cfg,
},resmgmt.WithRetry(retry.DefaultResMgmtOpts), resmgmt.WithTargets(orgPeers[0], orgPeers[1]))
PrivateLedger
This project requires us to be familiar with the Multi Organization setup using Fabric Go SDK. So, If you need a reference then I have published a Medium article to describe the step by step process for the Multi Organization setup. Please have a look at it.
“A Multi Organization Application in Hyperledger Fabric”
So, this is the overall description regarding the role of Hyperledger Fabric in Data Confidentiality and Privacy. I hope this article gave you some useful insight into the topic.