How to use two blockchains for the same application? - hyperledger-fabric

Can we use two blockchains such that one blockchain is permissioned and other is permissionless for some application so that one blockchain can be used to have private data and the other is used to store public data for verification?
I am not checking for interoperabilty..
for example, In process of buying a car, The buyer actually buys it from dealer and the buyer do not want his details plus car details(buyer id, VIN, engine number,car make,...) to be put onto public blockchain except the fact that a particular car model is sold to some blockchain address. So using private chain between RTO and Dealer, if dealer uploads details(buyer id, VIN, engine number,car make,...) onto private chain then RTO can verify the owner of the car.

Yes, you can use any number of blockchains within an application.
Blockchain is just used for the following operations:
Query the contents of a ledger.
Submit transactions to a ledger.
Computations using a smart contract.
You just need to take care of the endpoints at the application level or in the smart contract to perform write and query operations.
Interchain communication is a different problem altogether.

Related

desiging better private data collections in Hyperledger Fabric

I have a very case-specific query related to the implementation of private data collection and I am seeking recommendations/suggestions from the experts here. We have a product running on Hyperledger Fabric 2.3.3 and the platform can have any number of organizations. For instance, initially, there will be 4 organizations, next week 10 more organizations can join the network. The problem arises when these organizations start transactions with each other. These transactions can have a number of objects that need to be private between these organizations only. 

For this, we can create private data collections with names:
collection_org1
collection_org2
collection_org3
collection_org1_org2
collection_org1_org3
collection_org1_org2_org3
collection_org2_org3
Assume if the network has 20 organizations as participants, how many private data collection combinations will be there.
This is because, at a given time, any organization can begin a transaction with another organization or a series of organizations in the network. The problem here is that we have to create a large number of private data collections using the pattern and maintain it.
Because of this problem, we removed this implementation and used the implicit private data collection for each organization. Now if there is an object that should be shared only with org1, org2 & org3, the object is pushed to collection_org1, collection_org2, collection_org3. We did this using setting memberOnlyRead: false and memberOnlyWrite: false and added the validations at the chaincode level.

This implementation solved the above problem but has created a new problem. Now, we wanted to implement key-level endorsement policy such that if org1 changes a private object that is shared among org2 & org3, the org1 has to obtain the endorsements from org2 & org3 peers. This means that the peers will read the object from their own private data collection resulting in a different read-set in endorsement proposal response which further leads to an error saying read/write sets do not match.
For example, org1 during the endorsement proposal will read object key: key1 from its own private data collection collection_org1. In a similar way, org2 will read the same key during endorsement from its own collection collection_org2, and likewise for org3. This leads to a different read-set in the endorsement proposal.

I am seeking suggestions to implement this whole functionality in a better way. 

Please let me know your suggestions/recommendations.
GetPrivateDataHash() is your answer. You can use this function to verify that each of the endorsers have the same value, and ensure that your read sets are consistent.
See the secured transfer tutorial and sample for an example of using it for this purpose.

Using HLF peers for off ledger communication

I would like to leverage Hyperledger Fabric Peers (specifically identities) to communicate data that does not need to be recorded as a world state.
The Private Data Collection seems a step in that direction but everything is ordered and recorded.
Is there a way to send a payload between participants that does not get persisted?
Of course, every parameter sent is recorded in the channel's chain (but not in the world state unless your chaincode specifically does it).
Maybe you can save the payload (encrypted if you need it) in a distributed storage system (IPFS, for instance), share the IPFS hash/index via Fabric and delete from IPFS when it is no longer needed. I don't know if it fits your use case.

How to handle an event raised in one channel in a different channel in Hyperledger Composer of Fabric?

I have this scenario that a single node is part of different channels. In one channel there are only traders. In the other channel there are traders and regulator. Details of the trades should not be shared with the regulator. The only thing which is being shared is aggregated value at the end of the business day. By aggregated value, we mean how much of each asset is sold, not the detail of each trade. In other words there is confidential information between two parties that cannot be shared with regulator, and there is aggregated value that is not confidential and must be shared with the regulator.
Now I have an event when there is a nomination. By nomination I mean a trade made over some asset in the first channel, the one without regulator. Is it possible to handle this trading event in the other channel where the regulator is?
As I read through the documents, channels are isolated. But how isolated are they? Are they isolated in a way that events raised in one channel cannot be seen or handled in another channel? In that case, how do you suggest to implement this scenario? I mean do you suggest any specific architecture or tools enabling implementation of this scenario? Also do you think Hyperledger Fabric or Composer are suitable for these requirements?
I appreciate any help. Thank you.
So you have two channels, two separate ledgers and two separate business networks (as you've configured it).
Your 'nomination' is, in effect, a 'transaction' as described above. (events in Composer mean, business events that are usually subscribed to by a client application FYI).
In Hyperledger Composer, you can do 'cross-channel' or 'inter business network' queries. So can allow [only] the Regulator (from the 2nd channel) to query [only] those trade 'events' (ie transactions with the fields that contain the 'trade') or indeed assets (updated by the transaction), if need be - back in the '1st' channel (and access controls) in the 2nd channel can restrict the Regulator to do only that 'query' (if that's all he/she is supposed to have jurisdiction to do). Hope this helps.
See example
https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network

How to keep one account consistent between the two channels in fabric network

There are three accounts A,B and C and two channels CH1 and CH2 in fabric network. There are a transaction between A and B in CH1 and another transaction between A and C in CH2.
My problem is that how to keep the account of A consistent between the two different ledgers about CH1 and CH2.
Typically, the data within a channel is restricted to that channel. It is possible to have some state external to the channel that is managed independently of the channel's ledger.
There is a new feature of Hyperledger Fabric in v1.2 (coming real soon... RC1 is available today) called SideDB that allows you to manage such data, though I am not certain that it would make sense to manage accounts in that manner.
The new SideDB feature, referred to as Private Data, is described here:
http://hyperledger-fabric.readthedocs.io/en/latest/private-data/private-data.html
and
http://hyperledger-fabric.readthedocs.io/en/latest/private-data-arch.html

How to maintain provenance in a network while using channels

I am wondering of how to maintain provenance in a network while using channels. In marbles example, lets say Regulator, Manufacturer, country dealer and retailers are transacting on a blockchain network.
Regulator,Manufacturer and dealer are transacting on Channel1 whereas dealer transact with retailer1 on Channel2 and with retailer2 on Channel3, just to keep privacy on selling price for different retailers. As marble1 was originated in Channel1 by the manufacturer , How do the same marble is available in Channel2 or Channel3 for transactions without duplicating the marble and keeping its provenance to Channel1.
I don't know how works the marbles example. However, I think that not all the participants could see all the information and provenance for a marble.
The dealer is in the three channels, so he would be duplicating the info in the three channels. The dealer would has an application that links all the info.
I believe that this issue is more related to the client application.
It is related to client code. A channel cannot send data to other channel due to privacy in fabric. One can implement state of transaction in application code. One way to achieve it through the application code could be to keep id of marble same in all channnels and then run GetHistoryForKey() method on different channel and then accumulate txns in one place in client app to arrive at a solution.

Resources