Disclosure of Invention
The present application mainly aims to provide a method, an apparatus, a device and a storage medium for interfacing a blockchain service system based on a middleware gateway, and aims to solve the problem of difficult interfacing between a blockchain service and a service system.
In order to achieve the above object, the present application provides a method for interfacing a blockchain service system based on a middleware gateway, including:
a middleware gateway receives a block chain network interaction request sent by a service system through an http interface and forwards the interaction request to a block chain network, wherein the middleware gateway integrates a block chain SDK;
and the middleware gateway acquires the processing result of the block chain network for the interactive request and returns the processing result to the service system through the http interface.
Further, the step that the middleware gateway receives the block chain network interaction request sent by the service system through the http interface and forwards the block chain network interaction request to the block chain network includes:
acquiring account information of a service system network interaction request initiator;
performing authority identification on the account information;
if the authority passes the authority identification, inquiring the certificate in an account number and certificate mapping relation database in the middleware gateway;
and if the corresponding certificate is not inquired, accessing a block chain certificate management mechanism, signing a certificate for the account and storing the mapping relation between the account and the certificate in a database.
Further, the step of performing authority authentication on the account information includes:
acquiring an identity identification code of the account information;
acquiring a first dynamic verification code input by an account operator;
inquiring a second dynamic verification code in a dynamic verification code dataset corresponding to the account information in a database according to the identity identification code;
and judging whether the first dynamic verification code is matched with the second dynamic verification code, and if so, passing the authority authentication.
Further, the step that the middleware gateway receives the block chain network interaction request sent by the service system through the http interface and forwards the request to the block chain network further includes:
identifying the type of a block chain network interaction request sent by the service system, and calling a corresponding function interface of the middleware gateway;
and sending the interaction request to a corresponding node in a block chain through the corresponding functional interface.
Further, the middleware gateway is independently deployed outside the blockchain network.
Further, the middleware gateway is integrally deployed in a blockchain network.
The embodiment of the present application further provides a device for interfacing a block chain service system based on a middleware gateway, including:
the system comprises a sending module, a middleware gateway and a service system, wherein the sending module is used for receiving a block chain network interaction request sent by the service system through an http interface by the middleware gateway and forwarding the interaction request to a block chain network, and the middleware gateway integrates a block chain SDK;
and the return module is used for acquiring the processing result of the block chain network for the interaction request by the middleware gateway and returning the processing result to the service system through the http interface.
Further, the sending module includes:
the account information acquisition module is used for acquiring the account information of a service system network interaction request initiator;
the authority identification module is used for carrying out authority identification on the account information;
the certificate inquiry module is used for inquiring the certificate in an account number and certificate mapping relation database in the middleware gateway if the certificate passes the authority identification;
and the certificate issuing module is used for accessing the block chain certificate management mechanism if the corresponding certificate is not inquired, issuing the certificate for the account and storing the mapping relation between the account and the certificate in a database.
The present application further provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of any of the above methods when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of any of the above.
According to the block chain service system docking method, device, equipment and readable storage medium based on the middleware gateway, an interface exposed in a common web form is provided for a service system in the form of the middleware gateway, the service system does not need to repeatedly consider how to integrate each module of the block chain, and the problem of extra data management does not need to be solved, so that the threshold of developers for docking the block chain is reduced, the complexity of the service system for docking the block chain is reduced, the service speed of an enterprise development block chain can be increased, the efficiency is improved, and the cost is reduced.
Detailed Description
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
1) Transactions (transactions), equivalent to the computer term "Transaction," include operations that need to be committed to a blockchain network for execution and do not refer solely to transactions in the context of commerce, which embodiments of the present application follow in view of the convention colloquially used in blockchain technology.
For example, a deployment (deployment) transaction is used to install a specified smart contract to a node in a blockchain network and prepare for being invoked; the Invoke (Invoke) transaction is used to append records of the transaction in the blockchain by invoking the smart contract and to perform operations on the state database of the blockchain, including update operations (including adding, deleting, and modifying key-value pairs in the state database) and query operations (i.e., querying key-value pairs in the state database).
2) A Block chain (Blockchain) is a storage structure for encrypted, chained transactions formed from blocks (blocks).
For example, the header of each block may include hash values of all transactions in the block, and also include hash values of all transactions in the previous block, so as to achieve tamper resistance and forgery resistance of the transactions in the block based on the hash values; newly generated transactions, after being filled into the tiles and passing through the consensus of nodes in the blockchain network, are appended to the end of the blockchain to form a chain growth.
3) A Blockchain Network (Blockchain Network) incorporates new blocks into a set of nodes of a Blockchain in a consensus manner.
4) Ledger (legger) is a general term for blockchains (also called Ledger data) and state databases synchronized with blockchains.
Wherein, the blockchain records the transaction in the form of a file in a file system; the state database records the transactions in the blockchain in the form of different types of Key (Key) Value pairs for supporting fast query of the transactions in the blockchain.
5) Intelligent Contracts (Smart Contracts), also known as chain codes (chaincodes) or application codes, are programs deployed in nodes of a blockchain network, and the nodes execute the intelligent Contracts called in received transactions to perform operations of updating or querying key-value data of the account database.
6) Consensus (Consensus), a process in a blockchain network, is used to agree on transactions in a block among a plurality of nodes involved, the agreed block is to be appended to the end of the blockchain, and the mechanisms for achieving Consensus include Proof of workload (PoW, Proof of Work), Proof of rights and interests (PoS, Proof of equity (DPoS), Proof of granted of shares (DPoS), Proof of Elapsed Time (PoET, Proof of Elapsed Time), and so on.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, an embodiment of the present application provides a method for interfacing a blockchain service system based on a middleware gateway, which is applicable to the scientific and technical financial field, and includes the steps of:
s1, the middleware gateway receives a block chain network interaction request sent by a service system through an http interface, and forwards the interaction request to a block chain network, wherein the middleware gateway integrates a block chain SDK;
and S2, the middleware gateway acquires the processing result of the blockchain network for the interaction request, and returns the processing result to the service system through the http interface.
In the scheme, a block chain middleware gateway interconnected with a service system and a block chain network is provided, and an entrance for uniformly accessing a block chain is provided for the service system. By constructing web services, integrating a block chain SDK, integrating certificate storage management and integrating block chain node connection management, a middleware gateway can provide a safe and convenient access mode, the middleware gateway is started in an integrated or independent deployment mode, a service system can directly call a block chain network function, the problems of complex block chain configuration and communication do not need to be additionally processed, and the complexity of the service system for integrally calling the block chain services is greatly reduced.
As described in step S1, when the middleware gateway receives the blockchain network interaction request sent by the service system, the request is sent to the blockchain network through the middleware gateway. The block chain middleware gateway can realize the functions which need to be configured in advance by the service system, such as certificate management, mapping of the corresponding relation between the certificate and the account number of the service system, identity authentication of the account number of the service system, certificate service and the like, and reduce the operation difficulty of the service system end. The blockchain middleware gateway can also realize routing service, and expose the core functions accessed by the blockchain into interfaces, wherein the core functions comprise blockchain link point state access, intelligent contract calling, intelligent contract installation, intelligent contract instantiation, certificate application, certificate revoking, account number-certificate binding functions and the like. The routing service of the middleware gateway can improve the connection speed of a service system and a block chain network and increase the connection safety.
As described in step S2 above, when the blockchain network returns a result, the processing result is returned to the service system through the middleware gateway. The middleware gateway may operate in an integrated or stand-alone deployment manner. The middleware gateway encapsulates the related access functions of the block chains into services, and inserts a layer of middleware between the service and the block chains, thereby shielding complex integration procedures and providing a simplified docking scheme for a service system.
In an embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system includes:
s11, acquiring account information of a service system network interaction request initiator;
s12, authority identification is carried out on the account information;
s13, if the authority identification is passed, inquiring the certificate in the account and certificate mapping relation database in the middleware gateway;
and S14, if the corresponding certificate is not inquired, accessing a block chain certificate management mechanism, signing a certificate for the account and storing the mapping relation between the account and the certificate in a database.
Under normal circumstances, a business system needs to manage certificate storage by itself, and establish a corresponding relationship between a common user account and a block chain certificate identity, otherwise, the block chain cannot be used for submitting data. In this embodiment, functions such as certificate management, mapping of correspondence between a certificate and a service system account, authentication of service system account, and certificate service are integrated in the middleware gateway. The middleware gateway is responsible for managing the certificate data used by the blockchain by establishing a local certificate wallet function and providing an interface to the business account system mapping. The middleware gateway can provide identity authentication service, can be compatible with a third-party account management protocol, and establishes mapping between an account system of a service system and a certificate in a block chain through identity authentication. The middleware gateway provides certificate service, is responsible for operations such as certificate signing and issuing, revoking and the like of the access block chain CA, and provides a service for connecting a certificate operation interface with a business account system. As described above, many core services in the service system access block chain, for example, services related to an intelligent contract, need to perform certificate verification, and the middleware gateway in this scheme integrates functions such as certificate management, mapping of a certificate and a service system account corresponding relation, service system account identity authentication, and certificate service, so that connection verification between the service system and the block chain network can be simplified, and access speed can be increased.
In a specific embodiment, the step of performing authority authentication on the account information includes:
s121, acquiring an identity identification code of the account information;
s122, acquiring a first dynamic verification code input by an account operator;
s123, inquiring a second dynamic verification code in a dynamic verification code dataset corresponding to the account information in a database according to the identity identification code;
and S124, judging whether the first dynamic verification code is matched with the second dynamic verification code, and if so, passing the authority authentication.
As described in the above steps, when an operator of a service system initiates an interaction request with a blockchain network through a login account, the account information needs to be authenticated in order to ensure the validity of the operation. The method for verifying the dynamic verification code is adopted, and specifically, when a middleware gateway receives a block link network access request initiated by a service system, the middleware gateway initiates identity verification on account information, acquires an identity identification code of the account information, requires an account operator to input a first dynamic verification code, then queries a second dynamic verification code in a dynamic verification code data set corresponding to the account information in a database according to the identity identification code, judges whether the first dynamic verification code is matched with the second dynamic verification code, and if the first dynamic verification code is matched with the second dynamic verification code, passes authority authentication. The first dynamic verification code and the second dynamic verification code are set according to a preset rule and change synchronously after a certain preset time period, and each account corresponds to one dynamic verification code data set. The identity authentication of account number information can be realized through the steps, the legality of the operation is ensured, and the safety of block chain data is ensured.
In an embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system further includes:
s15, identifying the type of the block chain network interaction request sent by the service system, and calling a corresponding function interface of the middleware gateway;
and S16, sending the interaction request to a corresponding node in a block chain through the corresponding function interface.
In general, a service system needs to manage connection information of each node of a block chain, the communication mode of the block chain is different from that of web application, and if the block chain connection information does not exist, the service system cannot accurately find the node for communication. In this embodiment, the middleware gateway may provide routing services, and expose the core functions of blockchain access as an interface, where the functions include blockchain link point state access, intelligent contract invocation, intelligent contract installation, intelligent contract instantiation, certificate application, certificate revocation, account-certificate binding functions, and the like. For example, when it is recognized that the interactive request instruction of the service system is to install a new intelligent contract, the service system submits the target blockchain network configuration data/file to be operated to the middleware gateway through the http interface, and the middleware gateway can persist the configuration into the database. And the service system submits the new intelligent contract to be installed and the specified configuration information to the gateway and calls the installation function interface in the gateway. The middleware gateway sends the task to a task flow built in the gateway, when the task flow polls the installation task, configuration information and related certificate information are read, and the packaged block chain native SDK is called to execute the installation task. The routing service of the middleware gateway can improve the connection speed of a service system and a block chain network and increase the connection safety.
In one embodiment, the middleware gateway is independently deployed outside the blockchain network.
As described above, the middleware gateway can be deployed independently outside the blockchain network, which facilitates operation, maintenance and management of the middleware gateway. The independent deployment means that the independent device is deployed between a blockchain network and a service system, an http interface is provided for the service system, a blockchain SDK is integrated, and a certificate management service, a service system account service and a routing service are integrated, so that the docking between the blockchain and the service system is simplified, and meanwhile, the independent deployment is wider in applicability and convenient to upgrade and manage.
In one embodiment, the middleware gateway is integrally deployed in a blockchain network.
As described above, the middleware gateway is independently deployed in the blockchain network, and this deployment can improve the integration of the whole blockchain system. The integrated deployment means that the middleware gateway is integrated in a blockchain network system in a functional module form, provides an http interface for a service system, integrates a blockchain SDK, and integrates certificate management service, service system account service and routing service.
According to the block chain service system docking method based on the middleware gateway, the interface exposed in a common web form is provided for the service system in the form of the middleware gateway, the service system does not need to repeatedly consider how to integrate each module of the block chain, and the problem of extra data management is not needed to be solved, so that the threshold of developers for docking the block chain is reduced, the complexity of the service system for docking the block chain is reduced, the service speed of enterprises for developing the block chain can be increased, the efficiency is improved, and the cost is reduced.
Referring to fig. 2, an embodiment of the present application further provides a device for interfacing a blockchain service system based on a middleware gateway, including:
the system comprises a sending module 1, a middleware gateway and a service system, wherein the sending module 1 is used for receiving a block chain network interaction request sent by the service system through an http interface by the middleware gateway and forwarding the interaction request to a block chain network, and the middleware gateway integrates a block chain SDK;
and the return module 2 is used for the middleware gateway to acquire a processing result of the block chain network for the interaction request and return the processing result to the service system through the http interface.
In one embodiment, the sending module 1 includes:
the account information acquisition module is used for acquiring the account information of a service system network interaction request initiator;
the authority identification module is used for carrying out authority identification on the account information;
the certificate inquiry module is used for inquiring the certificate in an account number and certificate mapping relation database in the middleware gateway if the certificate passes the authority identification;
and the certificate issuing module is used for accessing the block chain certificate management mechanism if the corresponding certificate is not inquired, issuing the certificate for the account and storing the mapping relation between the account and the certificate in a database.
In a specific embodiment, the privilege identification module comprises:
the identification code acquisition module is used for acquiring the identification code of the account information;
the first dynamic verification code acquisition module is used for acquiring a first dynamic verification code input by an account operator;
the second dynamic verification code acquisition module is used for inquiring a second dynamic verification code in a dynamic verification code dataset corresponding to the account information in a database according to the identity identification code;
and the judging module is used for judging whether the first dynamic verification code is matched with the second dynamic verification code, and if so, the authority identification is passed.
In one embodiment, the sending module 1 further includes:
the identification module is used for identifying the type of the block chain network interaction request sent by the service system and calling a corresponding functional interface of the middleware gateway;
and the interactive request sending module is used for sending the interactive request to a corresponding node in the block chain through the corresponding functional interface.
As described above, it can be understood that each component of the device for interfacing a blockchain service system based on a middleware gateway provided in the present application may implement the function of any one of the above methods for interfacing a blockchain service system based on a middleware gateway, and the detailed structure is not described again.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used for data related to a block chain business system docking method based on the middleware gateway. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a middleware gateway based blockchain business system docking method.
The processor executes the above block chain service system docking method based on the middleware gateway, including: a middleware gateway receives a block chain network interaction request sent by a service system through an http interface and forwards the interaction request to a block chain network, wherein the middleware gateway integrates a block chain SDK; and the middleware gateway acquires the processing result of the block chain network for the interactive request and returns the processing result to the service system through the http interface.
In one embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system includes: acquiring account information of a service system network interaction request initiator; performing authority identification on the account information; if the authority passes the authority identification, inquiring the certificate in an account number and certificate mapping relation database in the middleware gateway; and if the corresponding certificate is not inquired, accessing a block chain certificate management mechanism, signing a certificate for the account and storing the mapping relation between the account and the certificate in a database.
In a specific embodiment, the step of performing authority authentication on the account information includes: acquiring an identity identification code of the account information; acquiring a first dynamic verification code input by an account operator; inquiring a second dynamic verification code in a dynamic verification code dataset corresponding to the account information in a database according to the identity identification code; and judging whether the first dynamic verification code is matched with the second dynamic verification code, and if so, passing the authority authentication.
In one embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system further includes: identifying the type of a block chain network interaction request sent by the service system, and calling a corresponding function interface of the middleware gateway; and sending the interaction request to a corresponding node in a block chain through the corresponding functional interface.
In a specific embodiment, the middleware gateway is deployed independently outside the blockchain network.
In one embodiment, the middleware gateway is integrally deployed in a blockchain network.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a method for interfacing a blockchain service system based on a middleware gateway, including the steps of: a middleware gateway receives a block chain network interaction request sent by a service system through an http interface and forwards the interaction request to a block chain network, wherein the middleware gateway integrates a block chain SDK; and the middleware gateway acquires the processing result of the block chain network for the interactive request and returns the processing result to the service system through the http interface.
In one embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system includes: acquiring account information of a service system network interaction request initiator; performing authority identification on the account information; if the authority passes the authority identification, inquiring the certificate in an account number and certificate mapping relation database in the middleware gateway; and if the corresponding certificate is not inquired, accessing a block chain certificate management mechanism, signing a certificate for the account and storing the mapping relation between the account and the certificate in a database.
In a specific embodiment, the step of performing authority authentication on the account information includes: acquiring an identity identification code of the account information; acquiring a first dynamic verification code input by an account operator; inquiring a second dynamic verification code in a dynamic verification code dataset corresponding to the account information in a database according to the identity identification code; and judging whether the first dynamic verification code is matched with the second dynamic verification code, and if so, passing the authority authentication.
In one embodiment, the step of sending to the blockchain network through the middleware gateway when receiving the blockchain network interaction request sent by the service system further includes: identifying the type of a block chain network interaction request sent by the service system, and calling a corresponding function interface of the middleware gateway; and sending the interaction request to a corresponding node in a block chain through the corresponding functional interface.
In a specific embodiment, the middleware gateway is deployed independently outside the blockchain network.
In one embodiment, the middleware gateway is integrally deployed in a blockchain network.
According to the block chain service system docking method based on the middleware gateway, the interface exposed in a common web form is provided for the service system in the form of the middleware gateway, the service system does not need to repeatedly consider how to integrate each module of the block chain, and the problem of extra data management is not needed to be solved, so that the threshold of developers for docking the block chain is reduced, the complexity of the service system for docking the block chain is reduced, the service speed of an enterprise for developing the block chain can be increased, the efficiency is improved, and the cost is reduced.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.