visit
In today’s enterprise business sector data confidentiality is a real biggest challenged for the companies. Many competitors in the market seek data privacy and confidentiality for their clients. But all the major blockchain platforms provide a Permissionless platform and their architecture doesn’t provide such facility to create a transaction for certain groups.
In this case, Hyperledger Fabric utilizes the opportunity of controlling as a Permissioned platform enabling structured Private Data architecture. We will see in the course of this article, how the Transaction flows with Private data architecture in Hyperledger Fabric.
Transaction flow with Private Data
In comparison with the Ordering Service Transaction flow, Private data transaction flow differs in some cases.
As we can create collections among authorized organizations, so the collections will follow policy while instantiating the Chaincode. These policies define which organization’s peers are authorized to store the private data in their private state database.
And these policies will be different from overall endorsing peer policy for a single Chaincode instantiation.
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).
Here there are two collection configs for two sets of organization groups.
collCfg1 belongs only to Org1 & Org2
collCfg2 belongs only to Org3 & Org4
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
}
While instantiating the chaincode, all the collection configs will be added into a config array.
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]))
I have developed a POC demonstrating the Private Data Collection using Fabric Go SDK. It’s more like an implementation of Fabric Go SDK libraries for Private data. Please follow below GitHub link below to check the project.
Github:
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.
”
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.