I am exploring a bit more about Hyperledger Fabric, and have become interested in private data. From what I understand, when a peer node creates private data, it is stored on that node, together with the hash of that private data. Unauthorized nodes will only store the hash of the private data so they can verify its existence.
I am working with a 4 nodes (three peers, one ordered), Where Org1 (peer node) has unique privilidges to create value which has to be made visible to Org2 (peer node) but must not be made visible to Org3 (peer node). Is there a way this can be done. This is a Typescript chaincode sample taken from the IBM Blockchain Platform vscode extension tutorials to create private data.
@Transaction()
public async createMyPrivateAsset(ctx: Context, myPrivateAssetId: string): Promise<void> {
const exists: boolean = await this.myPrivateAssetExists(ctx, myPrivateAssetId);
if (exists) {
throw new Error(`The asset my private asset ${myPrivateAssetId} already exists`);
}
const privateAsset: MyPrivateAsset = new MyPrivateAsset();
const transientData: Map<string, Uint8Array> = ctx.stub.getTransient();
if (transientData.size === 0 || !transientData.has('privateValue')) {
throw new Error('The privateValue key was not specified in transient data. Please try again.');
}
privateAsset.privateValue = transientData.get('privateValue').toString();
const collectionName: string = await getCollectionName(ctx);
await ctx.stub.putPrivateData(collectionName, myPrivateAssetId, Buffer.from(JSON.stringify(privateAsset)));
}
Would I have to change something here for it?
Thanks in advance!