When you start learning any new tool and technology , very first thing is to learn is the basics and start with Hello World sample. Even before you jump to development, you need to have environment setup.
Same applies to Hyperledger Fabric as well, before you jump to development, you need to have the environment setup.
Hyperledger fabric team simplify the things for you by providing you one complete shell file that you can simply run and that will setup whole environment for you but real challenge is to understand each and every file and commands involved in Hyperledger fabric environment setup.
In series of articles, we will explain the different files involved in Hyperledger fabric environment setup.
- Understand crypto-config.yaml file : Used to create cryptography material.
- Configtx.yaml file: Used to create genesis block and channel.
- Understand docker-compose.yaml file: Used to create docker container.
This blog is first part of that series where we will explain about crypto-config.yaml file and show you how to generate cryptography material using that file.
Before you proceed further, you need to ensure that fabric sample is downloaded and other items installed, In case it is not, you can refer this link, that guides you to pre-requisites.
In this post, we are taking reference of first-network sample that you get when you clone fabric-samples.
What is cypto-config.yaml file ?
cypto-config.yaml is the file that contains the details about business network like orderer, peer nodes etc and helps us to generate required cryptography material for our business network using cryptogen command.
How crypto-config.yaml file is structured ?
crypto-config.yaml consists of below parts.
- Organization structure
- Number of peer in each organization
- User in each organization
Sample of crypto-config.yaml file ?
Below is the content of the file.
Now let's understand this in detail.
Here OrdererOrgs is organization that will host orderer node where name is name of orderer and domain is domain name of the orderer.
PeerOrgs contains the details about peer organizations, you can have n number of organization in one network but here in first network, you have only 2 peer organizations.
First one is Org1 with name Org1, domain is org1.example.com.
Count under Template define the number of node in that organization so for for Org1 there are 2 nodes defined.
Count under Users define the number of non admin user and in case of Org1 is set to 1.
How to generate cryptography material using crypto-config.yaml file ?
To generate cryptography material using crypto-config.yaml file, you need to run below command.
First of all you need to go to bin folder where cryptogen command is there.
./cryptogen generate --config=../first-network/crypto-config.yaml --output=../first-network/crypto-output
This command will generate require cryptography material for orderer and peer organizations.