An on-chain routing method for algorithm sharing
By storing data indexes on the blockchain and encapsulating algorithms into smart contracts, the problems of easy data leakage and tampering in traditional data sharing are solved, and secure and efficient algorithm sharing and computation routing are achieved.
Patent Information
- Application Number
- CN202310472220.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-27
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-04-27
AI Technical Summary
Traditional data sharing methods are prone to data leakage and tampering, especially in centralized computing processes, where data poses security risks during transmission and aggregation.
By employing blockchain technology, a Fabric blockchain is used as a directory chain to store data indexes, and algorithms are encapsulated through smart contracts to enable the algorithms to run on designated nodes, preventing data from leaving the local scope, and using the decentralized mechanism of blockchain for evidence storage and traceability.
While ensuring the security of algorithms and data, algorithm sharing was achieved, avoiding the risks of data leakage and tampering, and improving data security and computing efficiency.
Smart Images

Figure CN116340429B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application provides an on-chain routing method for algorithm sharing, and belongs to the application field of a blockchain smart contract technology. BACKGROUND
[0002] With the continuous development of technologies such as the Internet and big data, we have entered the era of big data, and the cross-computation of massive data can provide better service support for various industries in society. However, the primary prerequisite for data cross-computation is data sharing, and therefore various data sharing technologies have gradually developed, which has also brought about the problem of data leakage. Many enterprises or organizations do not open their internal data to the outside world due to considerations of information security or interests, but this also brings about the problem of 'information islands', which hinders the collaborative computation of data.
[0003] The traditional data cross-computation method is mainly implemented through a data sharing system integrated in a distributed processing framework. The entire data sharing system mainly adopts a B / S architecture and uses a unified process management view. Generally, it is composed of a management center, a data processing subsystem, a data transmission subsystem, a data security subsystem, an algorithm interface subsystem and multiple sub-user access node ports. The distributed processing framework is used to share the storage load, improve the reliability, availability and access efficiency of the system, and is also easy to expand. The system nodes are mainly divided into a master node Master and a working node Slave. The master node Master end is responsible for the creation and distribution of tasks, and dynamically predicts and allocates tasks according to the working state of each working node (Slave), thereby ultimately improving the running efficiency of the entire system. The working node Slave is responsible for the execution of each task, can establish multiple execution ends according to the task situation, and can be dynamically expanded horizontally to form a distributed running network, thereby ultimately realizing the improvement of the execution efficiency and running performance of the entire system. The Slave node actively applies for a certain amount of tasks to the Master according to the use situation of the Slave's own resources during running, thereby ensuring the full use of the Slave's resources and the healthy running of the Slave. On this basis, the distributed deployment architecture is: multiple Slave node servers are deployed on the same physical server for load balancing configuration, and the Slave servers are deployed on multiple physical servers to realize the physical separation of applications and ensure that the Master server can provide uninterrupted services.
[0004] Traditional methods of cross-processing data computation involve a central Master node as the control server, with multiple user hosts deploying Slave nodes. These Slave nodes interact with the Master node to perform computations. In this approach, each Slave node providing computational data transmits its data to the Master node for further processing. The Master node then performs the computation and returns the results to the node that initiated the computation. This process involves data transmission from Slave nodes to the Master node, computation within the Master node, and the return of the results to the Slave nodes. This entire data interaction and computation process is inherently risky due to the potential for data leakage and tampering, making the resulting security issues difficult to resolve. Summary of the Invention
[0005] The technical problem solved by this invention is to overcome the problems of easy data leakage and tampering in existing traditional data sharing methods, and to provide an on-chain routing method for algorithm sharing. Based on blockchain technology, it can share algorithms while ensuring the security and privacy of algorithms and data.
[0006] Technical solution of the present invention:
[0007] In a first aspect, the present invention provides an on-chain routing method for algorithm sharing, comprising the following:
[0008] Step 1: Use a Fabric blockchain as a directory chain to store data indexes; the data owners of the data required for the algorithm to run upload the index items of their data to this directory chain to complete the storage of data indexes, so that the node where the data is located can be found through the data index in the directory chain;
[0009] Step Two: Modify the smart contract execution node to complete on-chain routing for algorithm sharing. The initiator of the algorithm call ensures that the called algorithm has been encapsulated as a smart contract. When calling the algorithm, first query the directory chain to find which blockchain node contains the data required by the algorithm to be run. After obtaining the index of this node, modify the endorsing node of the smart contract corresponding to this algorithm to specify the running node of this smart contract as the blockchain node with the data found in the directory chain. After the algorithm runs on this blockchain node, the algorithm running result is returned to the algorithm calling node through the smart contract, thereby completing the on-chain routing for algorithm sharing.
[0010] Furthermore, in step one, the data owner of the data required for the algorithm to run uploads the index items of the data they own to this directory chain, and the Fabric chain that stores the data index is called the directory chain;
[0011] The data owner will complete the data uploading operation on the chain in the form of a transaction, first propose a transaction through chaincode, and specify the endorsement strategy and endorsement node. The client application submits a transaction to the chaincode and submits it to the required endorsement node. The endorsement node executes the transaction and signs the transaction to authenticate the correctness of the transaction result. Then the transaction is sorted by the ordering node. The application submits the response of the endorsement node to the ordering node. The ordering and application submission occur in parallel in the Fabric architecture. The ordering node is delivered to the ledger node. The ordering service packages all transactions into blocks and then distributes them to the ledger node. The ledger node delivers to other ledger nodes. The ledger node verifies the transaction. Each ledger node verifies according to the endorsement strategy. The ledger node notifies the application when the transaction is successful or fails, and when the block is added to the ledger. The application will receive a notification from the connected ledger node.
[0012] Further, the second step of modifying the smart contract execution node to realize the algorithm-sharing-oriented on-chain routing is specifically implemented as follows:
[0013] The node responsible for running the chaincode and verifying the chaincode running result in the blockchain node is called the endorsement node. Each chaincode has an endorsement strategy, which specifies a set of Peer nodes on the channel that must execute the chaincode and endorse the execution result to prove that the transaction is valid. That is, Fabric specifies the endorsement node through the endorsement strategy, thereby specifying the chaincode running node;
[0014] After the user logs in to the on-chain node and initiates an algorithm calculation request, the directory chain is first queried, and the index data is transmitted in the form of a chaincode parameter. The directory chain is queried through the chaincode to obtain the location of the data node. In Fabric, the execution node of the chaincode adjusts the node name of the data node in the form of a string array and transmits it as a parameter when calling the chaincode, and sets the chaincode execution node as the data node. Then, under the blockchain mechanism, the data node automatically runs the chaincode encapsulating the algorithm, achieving the effect of algorithm routing. The algorithm execution result is returned to the algorithm calling node through the smart contract, thereby completing the algorithm-sharing-oriented on-chain routing.
[0015] In a second aspect, the present application provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
[0016] The memory is used to store computer programs.
[0017] The processor is used to execute the computer programs stored on the memory, and when executed, the above-mentioned algorithm-sharing-oriented on-chain routing method is realized.
[0018] In a third aspect, the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the above-mentioned algorithm-sharing-oriented on-chain routing method.
[0019] Compared with the prior art, the present application has the following advantages:
[0020] (1) The present application uses a blockchain as a directory chain. By storing data indexes on the directory chain, the data owner ensures that the data owned by the data owner does not leave the local range, and also informs other participants of the data owned by the data owner, achieving a safe and memory-saving effect. When calling an algorithm, unlike traditional centralized computing methods, the algorithm to be called is encapsulated as a smart contract, and the designated smart contract running node is used to achieve algorithm running on the designated node, achieving the effect of data not leaving the local range and algorithm routing to the data node, and using the blockchain mechanism for notarization and facilitating traceability.
[0021] (2) The present application chains algorithm data and uses the decentralized mechanism in the blockchain network to ensure that the algorithm data on the chain is not tamperable and is easy to trace. The smart contract, as a kind of on-chain computing logic, can run independently in each blockchain node and be notarized in different nodes according to different strategies. Therefore, on the basis of managing the on-chain mechanism by means of the blockchain mechanism, the originally centralized computing program is distributed to each node in the form of a smart contract, the designated computing node calls the on-chain smart contract for local calculation, and the calculation result is returned, thereby realizing algorithm decentralization, on-chain algorithm routing sharing mechanism with original data not leaving the local range. In the traditional data calculation method, the central host node and other user nodes are often composed, and the node that owns the data required for data calculation needs to send the data to the central node, and then the central node collects the data and completes the calculation and returns the result to the calculation initiating node. In this process, since the data needs to be transmitted over the network and collected in the central host node, there is a risk of data tampering and leakage in the transmission process and in the central node data collection, which will bring security risks. In the present application, based on the blockchain mechanism, the data calculation algorithm is encapsulated by means of a smart contract, and the smart contract running node is designated as the computing data owning node, achieving the effect of data not leaving the local range, thereby avoiding the risk of data tampering and leakage. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is the flowchart of the implementation of the present application;
[0023] Figure 2 is the flowchart of the implementation of the present application;
[0024] Figure 3This is a comparison diagram of the algorithm call flow between the method of this invention and the traditional method. Detailed Implementation
[0025] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] The following section will first explain the relevant terminology used in this invention:
[0027] Fabric
[0028] It is an abbreviation for Hyperledger Fabric, an open-source licensed blockchain framework.
[0029] On-chain
[0030] This refers to the process of uploading data to the blockchain.
[0031] Chaincode
[0032] In Fabric, smart contracts are a special term for blockchains. They are a special mechanism that encapsulates algorithms and runs on a specified blockchain node.
[0033] Peer
[0034] A blockchain network is primarily composed of peer nodes (or simply peers). Peers are the fundamental elements of the network.
[0035] Blockchain Node
[0036] A blockchain node typically refers to a computer. To use this blockchain through a computer, you need to become a blockchain node first (simply put, a blockchain node is equivalent to a blockchain user).
[0037] Endorsement strategies and endorsement nodes
[0038] Endorsement policy is a technical term in Fabric, and each chaincode has a corresponding endorsement policy. The endorsement policy specifies which blockchain nodes the chaincode will run on; those nodes that run the chaincode are called endorsing nodes.
[0039] Sort nodes and accounting nodes
[0040] Both sorting nodes and ledger nodes are special blockchain nodes in Fabric. Sorting nodes are used to provide consensus services, while ledger nodes are used to verify and store transaction data.
[0041] Block
[0042] A data structure in blockchain used for storing data.
[0043] algorithm
[0044] The solution to a certain user demand can be encapsulated in the form of a computer program.
[0045] As Figure 1 The method according to the present application is implemented as follows:
[0046] Step one: carry out basic environment configuration, build the entire invention required underlying environment mechanism, including development language underlying environment building, development tool downloading and configuration. Then download Fabric source code, and deploy Fabric environment and Fabric blockchain mechanism. Finally, start the blockchain node in the already deployed Fabric environment, and start the blockchain network;
[0047] Step two: take a blockchain as a directory chain, and all parties required by the algorithm to call data upload the data index owned by themselves to the directory chain, and can find the node where the data is located through the directory chain, and the specific implementation manner is:
[0048] The data owner will complete the operation of uploading the data index to the directory chain in the form of a blockchain transaction. First, propose a transaction through the chain code, add the data index carried by the directory chain to the chain code in the form of a chain code parameter, and specify the endorsement policy and endorsement node. The client application submits a transaction for the chain code, and submits it to the required endorsement node. The endorsement node executes the transaction and signs the transaction to authenticate the correctness of the transaction result. Then sort the transaction. The sorting node sorts the transaction. The application program submits the response of the endorsement node to the sorting node. The sorting and application program submission occur in parallel on Fabric. The sorting node is delivered to the accounting node. The sorting service packages all transactions into a block, and then distributes them to the accounting node. The accounting node delivers to other accounting nodes. The accounting node verifies the transaction. Each accounting node will verify according to the endorsement policy. The accounting node notifies the application program when the transaction is successful or fails, and when the block is added to the ledger. The application program will receive the notification of the connected accounting node.
[0049] After the transaction is verified successfully, the blockchain ledger will be modified. Here, according to the parameters carried by the chain code, that is, the data index, the blockchain ledger will be modified. The information contained in the ledger is modified to data index information, thereby completing the process of uploading the data index to the directory chain. All nodes that own data on this directory chain will perform this operation and complete the entire directory chain building process.
[0050] Step 3: After the algorithm call is initiated, the called algorithm needs to be encapsulated into chaincode (i.e., a smart contract). Smart contracts are also written as computer programs, compiled into bytecode by a compiler. Their core principle is similar to that of algorithms, and smart contracts can route execution by specifying execution nodes, thus enabling certain nodes to execute specific smart contracts. Developers develop algorithms, compile them into bytecode, encapsulate the algorithm into a smart contract in the form of a transaction, and publish it on the blockchain.
[0051] Step Four: Modify the smart contract execution node to complete on-chain routing for algorithm sharing. The initiator of the algorithm call ensures that the called algorithm has been encapsulated as a smart contract. When calling the algorithm, it first queries the directory chain, passing the data index as a chaincode parameter. The chaincode is then used to query the directory chain to find the blockchain node where the data required by the algorithm is located, and obtains the index of that node. In Fabric, the execution node of the chaincode can be adjusted by specifying the endorsing node. The node index obtained from the directory chain query is passed as a parameter when calling the chaincode, allowing the execution node to be set to the node where the algorithm's execution data resides. Then, under the blockchain mechanism, the node containing the data will automatically run the smart contract encapsulating the algorithm, achieving algorithm routing. The algorithm execution result is then returned to the requesting node via the chaincode.
[0052] The specific steps of this invention will be illustrated through an example scenario. The example scenario is defined as follows: After a patient is diagnosed at a hospital, the hospital prescribes a multi-phase prescription for medication, but only one phase is issued at a time. The patient has now finished the previous phase of medication and needs to go to the hospital to obtain the next phase. Meanwhile, pharmacies near the patient's home have the prescription, but cannot issue it because they do not have the hospital's prescription list. This invention utilizes the on-chain algorithm routing model to construct a blockchain platform. By sharing prescriptions between the hospital and pharmacies, the patient can obtain the medication from a pharmacy near their home without needing to go to the hospital.
[0053] The model flow of this invention is as follows Figure 2 As shown, firstly, following the operations mentioned in Step One, the basic construction of the blockchain platform based on the Fabric architecture is completed. The hospital and pharmacy each register as a blockchain peer node on the Fabric chain within this blockchain platform. Using a blockchain as a directory chain, the hospital node generates a data index based on its prescription history data. Following the details described in Step Two, after the sorting node and consensus node verify the transactions, the data index is uploaded to this directory chain and stored in a block, completing the on-chain operation. Simultaneously, the pharmacy node will write algorithms for the index directory chain, hospital registration, and prescription query. These three algorithms, as detailed in Step Three, are encapsulated into chaincode and published to the directory chain.
[0054] After the patient first sends an application to obtain a certain period of prescription drugs on this platform, and submits his own medical information for searching the patient's prescription data in the hospital. After receiving the patient's request, the blockchain platform first runs the index directory chain code to query the link address of the hospital node that owns the patient's prescription data. After obtaining the address, the registration chain code of the hospital is run, and the endorsement strategy is modified and the endorsement node is specified. The running node of the chain code is the hospital node. According to the running mechanism of the Fabric chain code, the registration chain code will be automatically completed in the hospital node, which ensures that other data involved in the hospital registration will not flow out of the hospital node domain, and only the registration result is returned to the blockchain platform. After obtaining the registration result, the platform waits for the corresponding number of the registration, and also runs the query prescription chain code, and adjusts the endorsement strategy and the endorsement node to specify the chain code running node as the hospital node. The query prescription chain code will be calculated in the hospital node, and the patient's prescription drug information will be returned. The query prescription process is all performed in the hospital node, which ensures the security of the hospital stored prescription database information and avoids the possibility of database leakage and tampering. After obtaining the prescription drug information, the blockchain platform returns the information to the pharmacy node, and finally the patient can conveniently purchase the next period of prescription drugs in the pharmacy.
[0055] As Figure 3 shown, it is a comparison chart of traditional algorithm calling process and the present application. The left side is the traditional algorithm, and the right side is the method of the present application. It can be seen that for the traditional data routing, each data node needs to collect the data it owns to a certain central node, and then the central node performs algorithm calling or operation. In this process, the algorithm does not "route", but the data needs to be out of the local range of the data owner and propagate in the network, so there is a risk of leakage and tampering. In the algorithm calling method proposed in the present application, the data does not need to be out of the local range of the data owner, but the algorithm "routes" to the data owner domain and calculates in the local range of the data owner, which greatly protects the data security and reduces the risk of data tampering and leakage.
[0056] Based on the same inventive concept, another embodiment of the present application provides an electronic device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present application.
[0057] Based on the same inventive concept, another embodiment of the present application provides a computer readable storage medium (such as ROM / RAM, magnetic disk, optical disk) storing a computer program, which, when executed by a computer, implements each step of the method of the present application.
[0058] The above embodiments are provided only for the purpose of describing the present application, and are not intended to limit the scope of the present application. The scope of the present application is defined by the appended claims. Various equivalent substitutions and modifications made without departing from the spirit and principle of the present application shall be encompassed within the scope of the present application.
Claims
1. A method for on-chain routing towards algorithm sharing, characterized in that, Comprise the following contents: Step one: take a blockchain as a directory chain, store data index; the data owner of the data required by the algorithm runs the index item of the owned data to the directory chain to complete the storage of the data index, so that the data node where the data is located can be found through the data index in the directory chain; Step two: modify the smart contract execution node to complete the on-chain routing for algorithm sharing. The initiator of the algorithm call ensures that the called algorithm has been encapsulated as a smart contract. When the algorithm is called, first query the directory chain to find out where the data required by the to-be-run algorithm is in which blockchain node, obtain the index of this node, and then specify the running node of the smart contract as the blockchain node that owns the data found by the directory chain by modifying the endorsement node of the smart contract corresponding to the algorithm. After the algorithm is run in this blockchain node, the algorithm running result is returned to the algorithm calling node through the smart contract, thereby completing the on-chain routing for algorithm sharing; The step two, modifying the smart contract endorsement node to complete the on-chain routing for algorithm sharing is specifically implemented as: The node responsible for running chaincode and verifying the smart contract running result in the blockchain node is called an endorsement node. Each smart contract has an endorsement policy, which specifies a group of Peer nodes on the channel that must execute the smart contract and endorse the execution result to prove that the transaction is valid. That is, Fabric specifies the endorsement node through the endorsement policy, thereby completing the specification of the endorsement policy running node; After the user initiates an algorithm calculation request, first query the directory chain, and pass the index data into the smart contract parameter form. Through the smart contract, query the directory chain to obtain the location of the data node. In Fabric, the execution node of the smart contract adjusts the node name of the data node in the form of a string array by specifying the endorsement node, and passes it as a parameter when calling the smart contract. Set the smart contract execution node to the data node. Then under the blockchain mechanism, the data node automatically runs the smart contract encapsulating the algorithm, achieves the effect of algorithm routing, and returns the algorithm execution result to the algorithm calling node through the smart contract, thereby completing the on-chain routing for algorithm sharing.
2. The on-chain routing method for algorithm sharing according to claim 1, wherein: In the step one, the data owner of the data required by the algorithm runs the index item of the owned data to the directory chain, which is specifically implemented as: The data owner will complete the data upload to the chain in the form of a transaction, first propose a transaction through a smart contract, and specify the endorsement strategy and endorsement node of the smart contract. The client application submits a transaction for the smart contract and submits it to the required endorsement nodes. The endorsement nodes execute the transaction and sign the transaction to authenticate the correctness of the transaction result. Then the transaction is sorted. The ordering node sorts the transaction. The application submits the response of the endorsement node to the ordering node. The ordering and application submission occur in parallel on the Fabric. The ordering node is delivered to the ledger node. The ordering service packages all transactions into blocks and then distributes them to the ledger node. The ledger node delivers to other ledger nodes. The ledger node verifies the transaction. Each ledger node verifies according to the endorsement strategy. The ledger node notifies the application when the transaction is successful or fails, and when the block is added to the ledger. The application will receive a notification from the connected ledger node.
3. An electronic device, comprising: The computer device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory can communicate with each other through the communication bus; The memory is used for storing a computer program; The processor is used for executing the computer program stored in the memory, and when the computer program is executed, the method in any one of claims 1-2 is implemented.
4. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1-2.
Citation Information
Patent Citations
Block chain-based data storage method in a fog computing environment
CN109523243A
Data sharing method, device and system and electronic device
CN110059495A