Is there any way to maintain private data between peers using hyperledger composer? - hyperledger

I am trying to develop an application using fabric and composer. I had read that private data can be maintained using fabric chaincode, but i am curious to know that, is it possible to maintain private data between peers/channels/orgs using composer?

No you cannot use private data in hyperledger composer. Hyperledger Composer is now deprecated and is unlikely to deliver any further releases. The recommendation is to look at the apis provided by hyperledger fabric especially around fabric-network for client side code development and the contract api for node chaincode (smart contract) development.

Related

On Premise deployment of Hyperledger Fabric without cloud

I have created a PoC application using hyperledger fabric for three organizations.
Most of the content on internet is instructing to use cloud for the deployment of the solution.
https://juarezjunior.medium.com/how-to-deploy-your-first-hyperledger-fabric-components-with-azure-kubernetes-service-aks-760563d9d543
https://medium.com/google-cloud/fabric-on-google-cloud-platform-97525323457c
https://www.youtube.com/watch?v=ubrA3W1JMk0
If peers, orderers,ca server of all organizations are deployed in a
cloud then how come hyperledger fabric is distribued?
Can this setup can be made in distributed , "in premise"
infrastructure?
Is there any source for reference/links to do this sort of setup?
any suggestions/references will be very helpful.
If peers, orderers,ca server of all organizations are deployed in a cloud then how come hyperledger fabric is distribued?
Each service (orderer, peer, etc) would be run on a different (virtual) machine within the same environment/cloud provider. Those machines could be distributed across various data-centers globally, or across different cloud providers, or even on many varying organisation's hardware. It makes relatively little difference, so long as they're not all on the same box, under the control of one organisation/person. Then it will be distributed.
Can this setup can be made in distributed , "in premise" infrastructure?
Yes - it can be set up to run however you like, although you may run into access issues, from firewalls, etc. Perhaps you'd have different departments run their own peers within a single organisation across many offices.
Is there any source for reference/links to do this sort of setup?
I believe most people start using the scripts from the hyperledger fabric codebase. Theres documentation here https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html about spinning up the "build your first network" script - byfn.sh (looks like this may have been removed)
https://github.com/hyperledger/fabric-samples has a ci folder. Within it there's some steps to build/run/test the codebase examples. Eg. https://github.com/hyperledger/fabric-samples/blob/main/ci/scripts/run-test-network-basic.sh
calls network.sh which is here: https://github.com/hyperledger/fabric-samples/blob/main/test-network/network.sh
If you really want to understand the necessary steps you'll need to work through it all. There's also some good documentation on what the various parts of the hyperledger-fabric system do here: https://github.com/hyperledger/fabric/tree/345a08b5cd30ef937a8270d1722462e4cad1caa9/docs/source - you'll need to navigate through the directories to the parts you're interested in and locate the .md files which contain the documentation : eg.
Peer docs/source/peers/peers.md
Orderer docs/source/orderer/ordering_service.md
Smart Contracts (aka Chaincode) - docs/source/smartcontract/smartcontract.md
Channels - docs/source/create_channel/channel_policies.md
You may also find some Dockerfiles in various repositories with different setups.

How to deploy contracts with hyperledger sawtooth

Could anyone kindly help me with this:
I understand that there is no "compiling" and "deploying of contracts in hyperledger sawtooth as such. I tried working with the tuna-chain supply chain and there it seemed like one command $docker-composer up did it all. But how exactly does that work?
I mean, say if I was making my own network on sawtooth, and I have written all the business logic (ie transaction processors), what are the docker files I need to make, how to make them?
The tuna supply chain code can be found here: https://github.com/hyperledger/education/tree/master/LFS171x/sawtooth-material
THANKS!
The analogy of contracts in sawtooth are called Transaction Processors (TPs). Sawtooth can be deployed to a native machine as executables or interpreted code, or deployed as docker images. Docker compose files allow for bringing up a network of docker images that may/may not interact with each other.
There are a number of language development kits for sawtooth. For information on developing sawtooth TPs you should read through and understand the architecture, components, API, etc.: https://sawtooth.hyperledger.org/docs/core/releases/latest/
There is also the github repo that is chock full of example TPs: https://github.com/hyperledger/sawtooth-core
As Frank rightly said, Sawtooth provides interfaces to write your smart contract in any language. You can define how the transaction will be defined and how will they be processed to change the state of blockchain.
These smart contracts will be executed by transaction processors, which depends on transaction families. All the validation part will be handled by validators, Once validation is done, validator will forward the contracts for a particular transaction family to their transaction processor.
All the serialization is done on Protobuf to save space and add speed.
There is a great example which will clear your concepts.
https://github.com/askmish/sawtooth-simplewallet
In order to understand above repo, you need to have clear understanding of Transaction families, Transaction processors, Apply method.
The post is old however if you have discovered a better solution please share, otherwise here is what I discovered.
You need to run the transaction processor and connect it to validator in order to submit your transactions.
In reality it will be rare to have all the validators on the same machine which is the case in most of the examples available on Hyperledger Sawtooth documentation for Docker, Ubuntu and AWS. In a real life scenario, on a business network companies will be running their own systems within their own networks with a couple of validators, settings-tp, rest-api and custom transaction processors. These validators will be connecting to other validators on the business network and that’s why only validator’s port is advised to open for world.
I wish there could be an easy way to register custom transaction processor on a running network possiby something like a cli similar to azure or aws, a native sawtooth cli that could connect to any sawtooth validator, upload transaction processor using a certificate and that transaction family become available for all future transactions.

Interledger Connector for Hyperledger?

Understand that Interledger is an open protocol suite for sending payments across different ledgers -- supports and integrates with Bitcoin, Ethereum (IS 20022)
Does Interledger supports hyperledger and/or vice versa? i.e., any integration possibilities between Interledger and Hyperledger? i.e., hyperledger <-> interledger <-> ethereum and/or bitcoin?
Understand that Hyperledger does not have cryptocurrency but I might have digital assets within my hyperledger network that can be exchanged with ether or bitcoin.
Thus I wish to know if there are integration possibilities between Hyperledger and Interledger?
Interledger is a protocol, not a system so I would rephrase your question as:
I wish to know if there are integration possibilities between Hyperledger and other ledgers using Interledger?
The answer is yes but this depends also on the use case. What do you mean by "integration"?
Interledger defines some standards for distributed transaction execution according to a two-phase commit strategy. It is specifically well-suited to transfers of digital assets across multiple ledgers because it's resiliency is depends on the economic incentives of the intermediaries to claim the assets that have been transferred to them (and in so doing providing the key to the next intermediary to do the same).
The most important standard is the use of a SHA-256 hash in the prepare request and the pre-image of that hash as the commit trigger of the two phase asset transfer on each ledger. We call the hash a condition and the pre-image the fulfillment.
If you want to perform a transaction that transfers digital assets from a sender on one ledger to a receiver on another ledger then you will first establish a condition that can only be fulfilled by the receiver (i.e. only the receiver knows the pre-image).
This way you can involve an untrusted intermediary that will accept a transfer on the sender's ledger and make a corresponding transfer to the receiver on their ledger. Both transfers are prepared using the condition and when the receiver releases the fulfillment to their ledger the assets are transferred to them.
The intermediary will then have possession of the fulfillment (they observed the assets they transferred to the receiver being committed) and will use the same fulfillment to claim the assets transferred to them by the sender.
Any Hyperledger ledger that can be used to underwrite asset ownership and support this two-phase commit strategy can be used in an Interledger payment.
There are examples of writing smart contracts that do just this in Ethereum so I assume the same could be achieved using Fabric, Sawtooth or any other Hyperledger ledger.
I am not aware of any existing implementations of such a plugin that would allow the reference ILP connector to be run as an intermediary between a Hyperledger ledger and other ILP-compatible ledgers but I'd certainly welcome any efforts to build one and would be happy to assist.
Interledger looks to be a service that wants you to route financial transactions through them. There is some simple sample code for compatible wallets and transactions in JavaScript. Presumably you can do this in any language.
Which leads me to point out that Hyperledger supports smart contracts and applications written in Go, Java, Python, and JavaScript (through the Hyperledger Composer) and so there is a pretty good chance that you can implement an ISO 20022 / Interledger compatible data model and protocol.
HOWEVER
You need to follow best practices and smart contracts should never directly update external services as their is no way of rolling back external service changes if the smart contract sends successful external transactions but then fails for other reasons.
So, you need to design multi-stage transactions in your smart contracts and related applications. Applications will have to coordinate with smart contracts and post on their behalf to other services, recording results in the ledger and triggering next stage updates and transactions.
This allows the blockchain ledger to reflect the reality of external states from Interledger or whatever ISO 20022 compatible service you use.
This all presumes that the other financial institution refuses direct participation with the smart contract and hyperledger blockchain, which is always going to be more efficient, reliable, and secure.
It sounds like you want something like Hyperledger Quilt, which interoperates between different blockchain technologies.

Is local system data use discouraged in hyperledger chaincode?

I wish to implement a contract that is subject to market data which each user has access to in their own LAN, but which they are not licensed to share over the internet. I understand that chaincode is supposed to be deterministic. Does this mean that it is not designed to tolerate referencing out-of-band data (data not available in the log or state) - so it would be hazardous in this protocol to reference this market data from chaincode?
Hyperledger Fabric (version 1.0) gives you the chance to create your own distributed networks, via channels. When you create a channel, you decide which are the participants of it, and you isolate them from the rest of the network. Then, you deploy, instantiate and invoke your chaincode, via that channel. So that, you don't share that chaincode and the transactions with all the people/network.
When you execute a transaction, you do it using some parameters. You would define it in your chaincode. You decide whether your chaincode could get parameters or not.
I have found many different questions in your question. Could you specify more wich is your issue?!

How does Hyperledger Fabric implement private data sharing among related parties?

How does Hyperledger Fabric share the private data only among intended parties without revealing the data to the other network participants?
Is it similar to R3's Corda?
Current version of fabric v0.6 does not provide such possibility, i.e. every peer can see the same as the other peers. But there is intention to implement this feature in 1.0 http://hyperledger-fabric.readthedocs.io/en/latest/abstract_v1/
As of Hyperledger Fabric 1.0.0, full support for channels is provided. A channel can be thought of as an overlay network in a larger blockchain network, including a restricted set of peers belonging to selected organizations and an orderer. All transactions are conducted in the context of a channel, and all transaction information is shared ONLY with those peers that participate in the channel.
More information can be found in the documentation.
In Fabric version 1.2, support for 'private data collections' was added, in addition to the concept of 'channels'. Private data collections allow for organizations on a (blockchain) channel to share private data peer-to-peer, with a hash of the private data going on the blockchain. See more details in the private data documentation.
For a comparison with Corda, see this answer.

Resources