getHistoryForKey using private collections #fabric-sdk-go


@informartin
 

Hey everyone,

is there any way to retrieve the history for a key in a private data collection? The `getHistoryForKey` function available in the SDK doesn't seem to apply for private collections.

Best regards
Martin

 


David Enyeart
 

There is no chaincode API to get the history of a private key (the team was waiting to see how private data was used by the community and if there was demand for it, before implementing it).

As a workaround... you could leverage the existing getHistoryForKey on public data. So in addition to writing the private data to state, you could write just the private key or the sha256 hash of the private key including a salt (if the key itself is sensitive) to public state.
Then use GetHistoryForKey like normal to find the history of transactions that updated that private key.
If you then need to get the actual private data within each of those transactions, you could use DeliverWithPrivateData API to pull out each of those blocks (as this is the only existing API that will return the private data in a block back to the client, assuming the client is authorized).


Dave Enyeart

westerkamp---04/22/2020 04:21:09 AM---Hey everyone, is there any way to retrieve the history for a key in a private data collection? The `

From: westerkamp@...
To: fabric@...
Date: 04/22/2020 04:21 AM
Subject: [EXTERNAL] [Hyperledger Fabric] getHistoryForKey using private collections #fabric-sdk-go
Sent by: fabric@...





Hey everyone,

is there any way to retrieve the history for a key in a private data collection? The `getHistoryForKey` function available in the SDK doesn't seem to apply for private collections.

Best regards
Martin