Fire Equipment Information Traceability System based on Blockchain

To solve the problems of centralization, tampering, incomplete storage, and privacy of fire fighting equipment traceability system, this paper proposes a fire fighting equipment information traceability system based on blockchain. The system is developed on the Fabric blockchain platform of Hyperledger. The system environment is equipped with three organizations: manufacturer, dealer, and consumers, and the query request is initiated with the traceability function of fire fighting equipment in the chaincode. Finally, through the certificate authentication user account can realize the fire fighting equipment information inquiry, and the query response time average value is 19.5 ms. The characteristics of blockchain are difficult to tamper with, timestamp and transaction traceability, which can be well applied to the traceability system of fire fighting equipment, which makes the traceability function of the system more perfect, and consumers can get all traceability information, including production information, logistics information and usage information of fire fighting equipment.


INTRODUCTION
In today's fire protection field, due to the opacity of the maintenance of fire fighting equipment, it is difficult to trace the responsibility according to the state of fire fighting equipment after the accident [1]. Nowadays, the identity information and usage status management of fire fighting equipment in the market generally adopt backward manual records. To solve the problem of traceability of fire fighting equipment, the industry has also adopted the method of deploying a supervision system. This kind of information record for fire fighting equipment adopts C/S, B/S mixed architecture design, and the deployer of the system is the central fire protection product supervision organization [2]. Fire equipment manufacturers, fire equipment dealers, fire equipment users, in the equipment information management system, according to their identity using the corresponding key to log on to their respective management systems, using Bluetooth wireless connection, RFID technology, Register and update the status of fire fighting equipment. Users can log on to the system through a 14-bit identity code to query the status of fire fighting equipment, use and maintain information [3].
In the above traditional fire fighting equipment maintenance system, the fire fighting equipment information is not open and transparent, there is the behavior of the open merchant tampering with the fire fighting information of the product privately, and the equipment information bears the risk of leakage and tampering. To maximize personal interests, the thirdparty tamper with the product information in the centralized server. In this paper, blockchain technology is combined with modern fire control, and the distributed decentralized system scheme is adopted, which fundamentally ensures the data can not be tampered with and avoids the malicious tampering of fire equipment information by third parties to maintain their interests. Can effectively solve fire safety system information sharing, data security, and other issues. Caro et al .2018 proposed a fully decentralized traceability system AgriBlockIoT, for agricultural supply chain management with integrated blockchain technology and the Internet of things This system designs and deploys a classic food traceability scenario from farm to table, Using two different blockchain platforms, Ethereum and Hyperledger Sawtooth, and analyze, evaluate and compare the performance of the two systems according to the delay, CPU load, and network usage. This system stores the effective data information generated by the Internet of things equipment in the whole agricultural product supply chain in the blockchain to the bottom, blockchain technology is used to ensure fault tolerance, invariance, transparency, and traceability of transaction records [4]. The same year Figorilli and others combined RFID sensor technology and blockchain technology to achieve a blockchain architecture of wood chain traceability system, This system integrates traceability information and wood quality information into an online system, Secure storage of data information and transaction records using the decentralized and distributed storage features of blockchain technology, Realize the electronic traceability of wood from stand wood to end-user [5]. Lin and others proposed and developed a food safety traceability system based on blockchain and EPC information services in Ethernet Square, This system uses the characteristics of traceability, timestamp, and tamper-proof of blockchain technology to accurately record, share and track the effective data in the whole food supply chain in combination with smart contract and consensus mechanism, Prevent data tampering and information leakage during information exchange, For effective detection and prevention of food safety problems and accountability [6].

SYSTEM ARCHITECTURE
Based on blockchain, the traceability system of fire fighting equipment is based on fire fighting equipment and the Fabric blockchain platform. first, according to the functional requirements of the system, fire equipment manufacturers, dealers, buyers as organizations to join the Fabric network, using the method of file configuration to complete the multi-machine deployment of the Fabric environment, so that it has a chaincode operating environment. Then the chaincode is developed and deployed, and the production, sale and use information of fire fighting equipment is encrypted and uploaded to the blockchain by the certified user account in each organization at the terminal or client. Finally, the consumer initiates the inquiry request through the client through the fire fighting equipment traceability code, realizes the fire fighting equipment traceability information inquiry. Figure 1 shows the overall design process of the system: including Fabric network environment, chaincode development, client development, and fire equipment information upload and query. The process is as follows: ① Fabric environment multi-machine deployment and chaincode development: according to the functional requirements of the system deployment Fabric environment, the system environment configuration has three organizations, corresponding to fire equipment manufacturers, dealers, buyers three real-world scenarios, the nodes of the three organizations to join the same channel, Each organization node installed different chaincode to achieve different organizations of fire equipment different operational functions.
② fire equipment information upload: fire equipment in the factory is produced and packaged, fire equipment packaging will have a unique fire equipment traceability code. According to the function of installing chaincode on each organization node, the fire fighting equipment traceability code is used as the key when the fire fighting equipment flows to the manufacturer, dealer, and consumers, and the production information, circulation information and use the information of the fire fighting equipment are uploaded to the Fabric blockchain with the certified user account number in each organization at the terminal or client.
③ fire fighting equipment traceability information query: after purchasing or using fire fighting equipment, consumers use organized certified user accounts to log on to blockchain fire fighting equipment anticounterfeiting traceability platform, input fire fighting equipment traceability code, You can jump to the fire equipment traceability information display interface, fire equipment from production to use each stage of traceability information.

System architecture
The architecture model of this paper includes three parts: Fabric network environment module, smart contract module, Web service module, and client development module [7]. The architecture design is shown in figure 2.

Figure. 2. System architecture model
Fabric network environment module includes data layer and network layer. The data layer is the core part of the blockchain, which is used to encrypt the data generated in the circulation of fire fighting equipment and upload it to the blockchain [8]. The network layer is the basis of information transmission Fabric the blockchain platform, including consensus mechanism, P2P network, and data verification mechanism [9]. The data collected in the data collection part includes the production information, logistics information and use information of firefighting equipment, and the specific classification of the collected data is shown in Figure  3.The fire equipment information displayed here is the information that the system needs to upload and query. The smart contract module refers to the contract layer, which is the core of the system and encapsulates the smart contract which can realize the function of the system [10]. The smart contract on the Fabric is also called chaincode, which can be verified, stored, and executed on the Fabric blockchain platform, and the chaincode also has the function of interacting with the Fabric network.
The Web service and client development module include the application layer and user layer, which enables consumers and participants in the circulation process of fire fighting equipment to interact with the Fabric blockchain platform and provide users with a concise interactive interface [11]. The application layer includes input interface and various information query entry, and user level to users or merchants, including various participants in the circulation of fire fighting supplies.

System function realization
Fire equipment traceability system needs to be implemented Fabric network environment, smart contract cooperation, the following will be the detailed introduction of each module function.

Fabric Network Environment Module
Fabric main function of the network environment module is to create the organization node needed by the system, have the running environment of the chaincode, and upload the data information of the fire fighting equipment to the blockchain. The Fabric environment is deployed according to the system flow chart shown in figure 1, the organization node is created by using the configuration file method, and the certificate and data file are generated through the Fabric module. Finally, open the orderer node and peer node, create the channel and add the node to the channel, complete the multimachine deployment of the Fabric network environment of the firefighting equipment traceability system, so as to realize the storage and query of firefighting equipment data, and ensure the authenticity and integrity of the data.According to the requirements of the system, the organization identifier and organization ID in its configuration information and the name of the chain code subsequently installed are shown in Table 1

Smart Contract Module
The smart contract module of fire equipment traceability system based on blockchain encapsulates the chaincode of fire equipment data storage and query. A complete chaincode contains two parts: chaincode and chaincode management command. Chaincode is the bearer of functional business, responsible for specific business logic and identity authentication. The chaincode management command is responsible for the deployment, installation, and call of the chaincode. The command contains the data information of the operation object. Through the overall analysis, the specific structure of the chaincode applied to the traceability system of fire fighting equipment is shown in figure 4 [12]. The information management in the code layer is to communicate with the chaincode on other nodes in the same channel and interact with the commands from the client so that the node address provided in the chaincode is found and notified. Function realization is to write code according to system function requirements to upload and query fire equipment information [13].
The management command layer contains the data information of each operation object. The chaincode name and channel names are the chaincode and channel that the operation command needs to specify [14]. The key traceability information includes all the information uploaded to the blockchain from production to use, or the traceability code of the fire fighting equipment [15].
Chaincode function flow: The chaincode of the Fabric is the bridge between the client and the Fabric network [16]. The three chaincodes are installed on the nodes of different organizations. The functions of the chaincode include uploading the information of fire fighting equipment, obtaining the information of fire fighting equipment, and obtaining the transaction record of fire fighting equipment. The chaincode installed on the organization 3 nodes also has the function of calling the chaincode installed on organization 1 and the organization 2 nodes to complete the traceability of the fire fighting equipment information. Figure 5 shows the chaincode function flow chart deployed on the organization's 3 nodes. The system initialization Init method will be used in the instantiation process after the successful deployment of the chaincode, followed by the system Invoke method, the main function is to initiate the transaction. The Invoke method of this chaincode development defines three parameters: function type functiontype 、 fire fighting equipment name 、 fire fighting equipment data. The function type corresponds to the storage management method of the following four interfaces. This system design needs four functions: ① if functiontype=putdata, uses the PutState method of the ChaincodeStubInterface interface, which stores data into the Fabric books and receives and stores data about the use of fire fighting equipment transmitted from the client.
② if functiontype=getdata, the GetState method of the ChaincodeStubInterface interface is used. The function of this method is to obtain the specified data from the Fabric account book and hand the obtained data to the chaincode for processing. Can be responsible for verifying that the data stored through function 1 exists in the Fabric account book.
③if functiontype=gethistory, the GetHistoryForKey method of the ChaincodeStubInterface interface is used. The function of this method is to obtain the history of the specified key. In this system, a fire equipment traceability code is used as the specified key to obtaining the history of the fire fighting equipment.
④ if functiontype=get equipment history, use the GetHistoryForKey method of the ChaincodeStubInterface interface and call other chaincode methods. The former function is the same as function 3, and the latter function is to call the chaincode installed on the organization 1 and organization 2 nodes. To ensure that the specified fire equipment from production to use by performing function 4. If the function method is not the above four, return the null value directly. Chaincode execution process: The realization of system function can not be separated from the execution of chaincode. The key traceability information of fire fighting equipment also needs to be stored and queried by chaincode. After the chaincode is installed and instantiated, the chaincode needs to be called by input command at the terminal or client. Figure 6 is a schematic diagram of chaincode execution, which shows the specific execution process of chaincode when the client initiates the traceability query of fire fighting equipment.
① The consumer initiates the fire equipment traceability inquiry request through the client. ② The client's Fabric-SDK obtains the consumer (query initiator) authentication certificate. ③ The client establishes a connection with the peer node. ④The client sends the transaction proposal to the Fabric peer node, The endorsement node shows the start of the query process proposal. Fabric side initiates validation of proposal messages, Including authentication of organization identity, channel information, and chaincode address. First, verify the channel header information, Second, check the initiator's signature information, Including whether the identity of the initiator organization is legal and whether the signature exists correctly. Finally, verify the chaincode information, Including header information and chaincode name verification. ⑤ Endorsement node provides process proposal transaction number txid, Fabric side retrieves transactions by transaction number and builds a new transaction simulator, The endorsement node begins to simulate the proposal and provides the transaction number txid and channel id. Then start the chaincode (if the chaincode is running, You don't need to restart), A series of operations include execution, setting up chaincode proposal, sending execution message, Fabric side processing chaincode message and sending status message transaction. ⑥ The chaincode initiated queries the corresponding books based on the transaction proposal, The data needed to get the chaincode from the cache, Get the notification after completion and exit. ⑦ peer node exits the call process of the chaincode, the Fabric side completes transaction simulation/query execution, Exit query process proposal. The node on the blockchain returns the corresponding information, completing the query process.

RESULTS & DISCUSSION
This fire fighting equipment anti-counterfeiting traceability system design environment construction part completes in the virtual machine VMware, the operating system is the ubuntu16.4. The virtual machine is set as follows: memory 1 GB, processor 2, hard disk 30 GB.
The identity information of the initiator of this query is"username ： 'Alice', mspid ： 'Org3MSP'", And the node where the request is initiated is peer0org3, When the fire equipment traceability code is added, the traceability request is initiated again, The chaincode deployed on the organization 3 node starts, Then call the chaincode deployed at the first two organizational nodes, You can get all the traceability information from production to use of fire fighting equipment. Here is an example of a "carbon dioxide fire extinguisher" for fire fighting equipment, Assuming the carbon dioxide fire extinguisher's traceability code is 0000001, As shown in Figure 7, the query request equipment _id=0000001 is initiated in the browser, You can get traceability information, The data are shown in Figure 7, It can be seen that the traceability code of fire fighting equipment in the query result is consistent with the input traceability code of fire fighting equipment.  Figure 8 shows the response time Fabric after the query command is issued, taking 20 query results as an example. The horizontal coordinate i represents the i query, and the vertical coordinate t represents the response time Fabric each query, and the specific response time is in a dynamic change. The average response time is 19.5 ms, which meets the network delay requirement. When consumers query the traceability information of fire fighting equipment on the client-side, the result display interface will not appear Catton or crash and can obtain a better user experience. To ensure the privacy of the data and make the consumer's personal information not leaked, the traceability system of fire fighting equipment based on the blockchain can determine the chaincode that the query can call according to the different identity information of the query initiator. And according to the chaincode function to obtain different data information. A user authenticated by organization 1 and organization 2 can not get the use information of fire fighting equipment stored by organization 3 nodes. Taking the query authenticated by Organization 2 with the identity information of "username: 'Alice' and mspid: 'Org2MSP'" as an example, the information query issued by this node can only call the chaincode deployed on Organization 2 node, and the information obtained is the circulation information of fire fighting equipment, the specific data is shown in Figure 9.