concept client application in category hyperledger

appears as: client application, client application, A client application, The client application, client applications
Programming Hyperledger Fabric: Creating Permissioned Blockchains

This is an excerpt from Manning's book Programming Hyperledger Fabric: Creating Permissioned Blockchains.

Once Bob has gathered the endorsements required, he will pack all the endorsements together with his original proposal into a packet, seal it with his digital signature and submit the resulting transaction to what is known as Fabric’s ordering service. In practice, of course Bob will not be doing the work. He will be using some app on a device to perform these steps. This app is the client application. The ordering service is necessary to ensure that all transactions are processed in the same order by the peer nodes. Otherwise you can imagine a problem if two banks process transactions in different order. Transactions do not commute. Ordering service is there to take care of one and only one problem. Given two transactions T1 and T2:

In the previous chapter, we did a pretty good deep dive into Fabric’s transaction flow in Section 1.6. We also learned a whole host of new terms like peers, orderer, smart contract, transactions, digital signatures, client application, endorsement policy, consensus, Kafka, Raft etc. However two questions were left unanswered:

With the above background in place, let’s see how Bob gets his X.509 certificate when he makes the request in Section 1.6. We assume the use of Fabric CA in the discussion. First, Bob submits a username and password to the bank’s client application to log into it.63 The client application verifies that username and password against a users db such as Azure AD. Client application then checks if Bob’s X.509 certificate is already cached in a wallet - think of it as something that is used to store X.509 credentials. If a cached certificate is found in the wallet, the client application uses it. Otherwise, client application checks if Bob is already registered in Fabric CA. To answer this question, Fabric CA consults its database of registered users - we will call it the CA db. If Bob is registered, client application will request Bob’s certificate which will be retrieved from CA db by Fabric CA. If Bob is not registered, client application has to first register Bob against Fabric CA - this just creates a user record in CA db - and then client application has to enroll Bob in a separate call. When the client application submits an enrollment request, it basically drafts up a X.509 certificate with the attributes it would like in that certificate. The Fabric CA just reviews that certificate signing request and signs the certificate making it legit and returns it back to the client application. 64 The private key associated with the X.509 certificate is generated on the client and it is never sent to the CA server. Once the client application gets the signed certificate, it can securely store it in a wallet so that it doesn’t have to retrieve it from Fabric CA every time Bob logs in. The entire process is illustrated in Figure 2.1. There are a total of three calls that happen between client application and Fabric CA in the worst case - is user registered, register user, enroll user. And per call there will be a round-trip between Fabric CA and CA db. A client application written in Node would use the fabric-ca-client 65 package to communicate with a Fabric CA. Once the client application has Bob’s X.509 certificate it can use it to make a chaincode invocation request on peer nodes. Note that Bob never sees his X.509 certificate. There is no need for it. All this happens behind-the-scenes to him.

CH02 F01 Jain

Figure 2.1 How the client application gets a user’s X.509 certificate. Step 1 user submits a username and password to the client application. Step 2 the client application verifies that username and password against a users db such as Azure AD. Step 3 client application checks if user’s X.509 certificate is already cached in the wallet. Step 4 if not, client application retrieves the X.509 certificate from Fabric CA. During this process it might have to register and enroll a user if user does not already exist in the CA db.

The channel creation, join peer nodes to channel, install, approve and commit chaincode are all done using the peer CLI that ships with Fabric. As of this writing, it is not possible to do any of this from a Node app. A Node app would provide a friendly UI to perform these actions and could potentially be used by people who are not Fabric developers such as people in Ops. Fabric plans to develop a fabric-admin package which will provide ability to install, approve and commit chaincode from a Node app but the channel provisioning would still need to be done from the CLI. 82 Note that version 1.4 of the fabric-client Node package has support for channel creation and chaincode provisioning APIs but this package is deprecated and not suggested to be used with Fabric 2.0. In v2.0, fabric-network is the only recommended API for developing client applications. 83 As Fabric 2.0 is very new at time of this writing expect things to evolve. In fact v2.0 of the fabric-network package itself is under beta.