Node implementation method and system for on-chain and off-chain cooperative distributed oracle machine
By establishing a distributed collaboration mechanism between blockchain oracle nodes and consensus nodes, the problems of single point failure risk and high dependence on the master node in the existing technology are solved, and higher system stability and verifiability are achieved.
Patent Information
- Application Number
- CN202411705390.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
The existing blockchain oracle node implementation method has a single point of failure risk and a high dependence on the master node, resulting in poor system verifiability, transparency and stability.
By establishing a distributed collaboration mechanism between the oracle node and the consensus node, multiple nodes jointly verify and sign external data, reducing dependence on the master node, and ensuring the authenticity and integrity of the data through hash value and signature mechanisms.
It effectively eliminates the risk of single point failure of oracle nodes, enhances the resilience and stability of the blockchain system, and reduces dependence on the master node, improving the verifiability and transparency of the system.
Smart Images

Figure CN119652532A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain technology, and in particular to a node implementation method and system for on-chain and off-chain collaborative distributed oracles. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] In traditional blockchains, smart contracts can usually only access data within the blockchain and cannot directly obtain external data, which limits the scope of application of smart contracts. In order to expand the functionality and practicality of blockchains, blockchain oracles have been developed to serve as a bridge between blockchains and external data sources. Blockchain oracles play a vital role in the blockchain ecosystem. They enable smart contracts to access and process information from the outside world by obtaining data from the real world and introducing it into the blockchain network. This mechanism provides decentralized applications with the ability to interact with the outside world, thereby solving the data acquisition and verification problems faced by many blockchain-based applications.
[0004] However, the inventors found that the existing blockchain oracle has some technical problems in the node implementation, such as:
[0005] (1) At present, most alliance chain oracle nodes are implemented in a centralized manner, and the information in this way is only provided by a few or even one node, which makes the verifiability and transparency of the entire system poor, thereby reducing the authenticity and integrity of the data. At the same time, if a single point of failure occurs in this way, that is, when the data is disturbed or tampered with, it will seriously affect the credibility of the entire system, resulting in poor stability of the entire blockchain system.
[0006] (2) For example, the oracle node implementation method proposed in the research on distributed oracle technology for alliance chains with DOI 10.12379 / j.issn.2096-1057 mainly relies on the master node to perform node verification and judgment operations. When the oracle master node fails, the oracles need to switch the master node, which increases the complexity of the blockchain system. Summary of the invention
[0007] In order to overcome the deficiencies of the above-mentioned prior art, the present invention provides a node implementation method and system for on-chain and off-chain collaborative distributed oracles, which can reduce the oracle's dependence on the master node while avoiding the risk of single point failure, thereby enhancing the stability of the blockchain system.
[0008] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:
[0009] The first aspect of the present invention provides a node implementation method for on-chain and off-chain collaborative distributed oracles.
[0010] The node implementation method for on-chain and off-chain collaborative distributed oracles includes:
[0011] Call the data acquisition interface in the oracle contract to obtain the external data address parameters;
[0012] Send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value and sign the first Hash value with the private key of the consensus node;
[0013] Send the request block, the first Hash value and the signature to the oracle node together; verify the correctness of the first Hash value and the signature, and if the verification passes, parse the request block and call the external data content corresponding to the external data address parameter;
[0014] Based on the oracle node, the obtained external data content is encapsulated into a reply block, the reply block is converted into a second Hash value and the second Hash value is signed with the private key of the oracle node; the reply block, the second Hash value and the signature are sent to the consensus node together; the correctness of the signature is verified using the public key of the oracle node; if the verification passes, the reply block is parsed and the receiving data interface in the oracle contract is called to call back the parsed data to the oracle contract for processing.
[0015] Furthermore, the request block includes a request unique identifier, external data source request content, callback contract address, callback function signature, request timeout period and additional metadata.
[0016] Furthermore, verifying the correctness of the first Hash value and signature includes: verifying the correctness of the signature using the public key of the consensus node; at the same time, re-converting the request block into a Hash value, and recording the converted Hash value as a third Hash value; if the third Hash value is consistent with the first Hash value, it is considered that the consensus node has passed the verification.
[0017] Furthermore, the consensus node is composed of 3f+1 nodes; where f represents the number of consensus node errors allowed; the oracle node can only parse the request block when it receives node verification from no less than 2f+1 consensus nodes.
[0018] Furthermore, the reply block includes the request unique identifier, the acquired data, the collected signatures, the callback contract address, the callback function signature, and additional metadata.
[0019] Furthermore, the correctness of the signature is verified using the public key of the oracle node, including: aggregating the public keys of the oracle nodes to generate an aggregated public key; if the aggregated public key is consistent with the signature, the oracle node is considered to have passed the verification.
[0020] Furthermore, the oracle node is composed of 2t+1 nodes; where t represents the number of oracle node errors allowed; the consensus node can only parse the reply block when it receives node verification from no less than t+1 oracle nodes.
[0021] The second aspect of the present invention provides a node implementation system for on-chain and off-chain collaborative distributed oracles.
[0022] A node implementation system for on-chain and off-chain collaborative distributed oracles, including:
[0023] The data acquisition module is configured to: call the data acquisition interface in the oracle contract to obtain external data address parameters;
[0024] The request verification module is configured to: send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value and sign the first Hash value with the private key of the consensus node; send the request block, the first Hash value and the signature to the oracle node; verify the correctness of the first Hash value and the signature, and if the verification passes, parse the request block and call the external data content corresponding to the external data address parameter;
[0025] The reply verification module is configured to: encapsulate the obtained external data content into a reply block based on the oracle node, convert the reply block into a second Hash value and sign the second Hash value with the private key of the oracle node; send the reply block, the second Hash value and the signature to the consensus node together; use the public key of the oracle node to verify the correctness of the signature; if the verification passes, parse the reply block and call the receiving data interface in the oracle contract to call back the parsed data to the oracle contract for processing.
[0026] The third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles as described in the first aspect of the present invention.
[0027] The fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles are implemented as described in the first aspect of the present invention.
[0028] One or more of the above technical solutions have the following beneficial effects:
[0029] (1) The present invention encapsulates the external data content into a reply block based on the oracle node, converts the reply block into a second Hash value and signs the second Hash value with the private key of the oracle node; then sends the reply block, the second Hash value and the signature to the consensus node, and uses the public key of the oracle node to verify the correctness of the signature; only after the verification is passed can the reply block be parsed and the receiving data interface in the oracle contract be called. In the present invention, the oracle is composed of multiple nodes, so the single point failure risk of the centralized oracle node can be eliminated, and the resilience and stability of the entire system can be enhanced.
[0030] (2) In the present invention, the oracle nodes are parallel nodes, and each oracle node exists independently. In other words, there is no concept of master-slave nodes between oracle nodes. All nodes work independently and obtain data from the same data source. Finally, the consensus node verifies the correctness of the oracle node. Therefore, the present invention can effectively reduce the oracle's dependence on the master node, which is more concise and efficient than the prior art.
[0031] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0033] Figure 1 This is a flowchart of the node implementation method for on-chain and off-chain collaborative distributed oracles in Example 1 of the present invention.
[0034] Figure 2 Schematic diagram of the number and relationship of oracle nodes and consensus nodes in Example 1 of the present invention. DETAILED DESCRIPTION
[0035] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0036] It should be noted that the terms used herein are for describing specific embodiments only and are not intended to be limiting of exemplary embodiments according to the present invention.
[0037] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0038] Embodiment 1
[0039] This embodiment discloses a node implementation method for on-chain and off-chain collaborative distributed oracles.
[0040] like Figure 1 As shown, the node implementation method for on-chain and off-chain collaborative distributed oracle includes:
[0041] Step S1: Call the data acquisition interface in the oracle contract to obtain external data address parameters;
[0042] Step S2: Send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value, and sign the first Hash value with the private key of the consensus node;
[0043] Step S3: Send the request block, the first Hash value and the signature to the oracle node together; verify the correctness of the first Hash value and the signature. If the verification passes, parse the request block and call the external data content corresponding to the external data address parameter;
[0044] Step S4: Based on the oracle node, encapsulate the obtained external data content into a reply block, convert the reply block into a second Hash value and sign the second Hash value with the private key of the oracle node; send the reply block, the second Hash value and the signature to the consensus node together; use the public key of the oracle node to verify the correctness of the signature; if the verification passes, parse the reply block and call the receiving data interface in the oracle contract to call back the parsed data to the oracle contract for processing.
[0045] Based on the above process, the present invention can reduce the reliance of the oracle on the master node while avoiding the risk of single point failure, thereby enhancing the stability of the blockchain system. To facilitate understanding of the technical solution of the present invention, the specific implementation steps of the technical solution of the present invention are further explained and illustrated below.
[0046] Step S1: Call the data acquisition interface in the oracle contract to obtain the external data address parameters.
[0047] The user calls the data retrieval interface in the oracle contract through the SDK interface. After the oracle contract is executed in the contract virtual machine, the parameters of the external data address can be obtained and sent to the corresponding chain event.
[0048] Step S2: After sending the external data address parameters to the corresponding chain event, encapsulate the external data address parameters into a request block based on the chain event, convert the request block into a first Hash value, and sign the first Hash value with the private key of the consensus node.
[0049] When the chain event receives the call oracle event, the external data address parameters are first encapsulated into a request block; the content of the request block includes the request unique identifier, external data source request content, callback contract address, callback function signature, request timeout and additional metadata.
[0050] Subsequently, the request block is converted into a Hash value H(Request). For easy distinction, the converted Hash value of the request block is recorded as the first Hash value. The Hash value (first Hash value) is signed Sign(sk, Hash) with the private key of the consensus node. Finally, the consensus node sends the request block (Request), the first Hash value (H(Request)) and the signature (Sign(sk, Hash)) to the oracle node.
[0051] Step S3: After sending the request block, the first Hash value and the signature to the oracle node, the correctness of the first Hash value and the signature needs to be verified. Only if the verification passes can the request block be parsed and the external data content corresponding to the external data address parameter be called.
[0052] like Figure 2 As shown in the figure, all consensus nodes need to be interconnected with all oracles, and the consensus nodes are composed of 3f+1 nodes; where f represents the number of consensus node errors allowed. It can be understood that if f=1, at least 4 consensus nodes are required to ensure the normal operation of the system.
[0053] When the oracle node receives the request, it uses the public key of the consensus node to verify the correctness of the signature; at the same time, the request block is converted to a hash value again. For easy distinction, the converted hash value is recorded as the third hash value. During verification, if the third hash value is consistent with the first hash value, the consensus node is considered to have passed the verification. Specifically, during verification, only when the oracle node receives no less than 2f+1 node verifications from consensus nodes, is it allowed to parse the request block to obtain the external data source request content parameters, and call the parameters of the external data address to obtain the corresponding data content; if the oracle node receives less than 2f+1 nodes that have passed the node verification on the consensus node, the request is considered invalid and the request block is not parsed.
[0054] Furthermore, in order to ensure the authenticity of the external data obtained, the oracle node needs to obtain data from multiple external data sources and aggregate them. Assume that the external data source is S = {s1, ..., s n}, the data obtained from all data sources is V = {v1, ..., v n}, all data sources need to sign the data, and the collected signatures are recorded as Sign = {sig1, ..., sign}.
[0055] Step S4: Based on the oracle node, encapsulate the obtained external data content into a reply block, convert the reply block into a second Hash value and sign the second Hash value with the private key of the oracle node; send the reply block, the second Hash value and the signature to the consensus node together; use the public key of the oracle node to verify the correctness of the signature; if the verification passes, parse the reply block and call the receiving data interface in the oracle contract to call back the parsed data to the oracle contract for processing.
[0056] Step S4-1, based on the oracle node, encapsulate the obtained external data content into a reply block Reply; wherein the content of the reply block Reply includes the request unique identifier, the obtained data V = {v1, ..., vn}, the collected signature Sign = {sig1, ..., sign}, the callback contract address, the callback function signature and additional metadata.
[0057] Step S4-2: Convert the reply block Reply into a second Hash value and sign the second Hash value with the private key of the oracle node, and send the reply block, the second Hash value and the signature to the consensus node together.
[0058] First, the reply block Reply is converted into a Hash value H(Reply). For easy distinction, the converted Hash value of the reply block is recorded as the second Hash value. The Hash value (second Hash value) is signed Sign(sk, Hash) with the private key of the oracle node, and the reply block Reply, the second Hash value (H(Reply)) and the signature (Sign(sk, Hash)) are sent to other oracle nodes.
[0059] Subsequently, when other oracle nodes receive the reply block Reply, the second Hash value (H(Reply)) and the signature (Sign(Hash)), they aggregate the collected signatures into one signature, i.e. Finally, the reply block Reply, Hash value (H(Reply)) and the aggregated signature are Sent to consensus nodes.
[0060] Step S4-3: Use the public key of the oracle node to verify the correctness of the signature.
[0061] like Figure 2 As shown, the oracle node consists of 2t+1 nodes; t represents the number of oracle node errors allowed. It can be understood that if t=1, at least 3 oracle nodes are required to ensure the normal operation of the system.
[0062] When the consensus node receives the reply, first, the consensus node aggregates the public keys of the oracle nodes to generate an aggregated public key, that is, Then, the received signature is obtained through the aggregated public key. Verify. If the aggregated public key is consistent with the signature, the oracle node is considered to have passed the verification;
[0063] Specifically, the formula for verifying whether the aggregated public key and signature are consistent is:
[0064] verify(PK agg ,H(Reply),S agg );
[0065] Among them, verify() represents the verification function, that is, verifying whether the signature content is legal through the public key. If the aggregated public key is consistent with the signature, the oracle node is considered to have passed the verification. Specifically, during the verification, only when the consensus node receives no less than t+1 node verifications from the oracle nodes, can the reply block be parsed and the receiving data interface in the oracle contract be called to call back the parsed data to the oracle contract for processing; if the verification fails, that is, the number of nodes that the consensus node receives from the oracle node that have passed the node verification is less than t+1, the reply is considered invalid and the reply block is not parsed.
[0066] Furthermore, when the parsed data is called back to the oracle contract for processing, the smart contract will receive the acquired data V = {v1, v2, ..., v n}、Collect signatures Sign = {sign1, sign2, ..., sign n}. In order to ensure the data reliability of the data source, the public key of the data source will be used to verify the data in the smart contract. The verified data is used as the candidate value W = {w1, w2, ..., w n}; Finally, the median (W) of all the candidate values is calculated as the processing data of the contract.
[0067] Based on the above process, the present invention can reduce the oracle's dependence on the master node while avoiding the risk of single point failure, thereby enhancing the stability of the blockchain system.
[0068] Embodiment 2
[0069] This embodiment discloses a node implementation system for on-chain and off-chain collaborative distributed oracles.
[0070] A node implementation system for on-chain and off-chain collaborative distributed oracles, including:
[0071] The data acquisition module is configured to: call the data acquisition interface in the oracle contract to obtain external data address parameters;
[0072] The request verification module is configured to: send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value and sign the first Hash value with the private key of the consensus node; send the request block, the first Hash value and the signature to the oracle node; verify the correctness of the first Hash value and the signature, and if the verification passes, parse the request block and call the external data content corresponding to the external data address parameter;
[0073] The reply verification module is configured to: encapsulate the obtained external data content into a reply block based on the oracle node, convert the reply block into a second Hash value and sign the second Hash value with the private key of the oracle node; send the reply block, the second Hash value and the signature to the consensus node together; use the public key of the oracle node to verify the correctness of the signature; if the verification passes, parse the reply block and call the receiving data interface in the oracle contract to call back the parsed data to the oracle contract for processing.
[0074] Embodiment 3
[0075] The purpose of this embodiment is to provide a computer-readable storage medium.
[0076] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles as described in the first embodiment of the present disclosure.
[0077] Embodiment 4
[0078] The purpose of this embodiment is to provide an electronic device.
[0079] An electronic device comprises a memory, a processor and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles are implemented as described in the first embodiment of the present disclosure.
[0080] The steps involved in the apparatuses of the above embodiments 2, 3 and 4 correspond to the method embodiment 1, and the specific implementation methods can refer to the relevant description part of embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood to include any medium that can store, encode or carry an instruction set for execution by a processor and enable the processor to execute any method in the present invention.
[0081] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.
[0082] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A node implementation method for on-chain and off-chain collaborative distributed oracle, characterized in that: include: Call the data acquisition interface in the oracle contract to obtain the external data address parameters; Send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value and sign the first Hash value with the private key of the consensus node; Send the request block, the first Hash value and the signature to the oracle node together; verify the correctness of the first Hash value and the signature, and if the verification passes, parse the request block and call the external data content corresponding to the external data address parameter; Based on the oracle node, the obtained external data content is encapsulated into a reply block, the reply block is converted into a second Hash value and the second Hash value is signed with the private key of the oracle node; the reply block, the second Hash value and the signature are sent to the consensus node together; the correctness of the signature is verified using the public key of the oracle node; if the verification passes, the reply block is parsed and the receiving data interface in the oracle contract is called to call back the parsed data to the oracle contract for processing.
2. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 1, characterized in that: The request block includes a request unique identifier, external data source request content, callback contract address, callback function signature, request timeout, and additional metadata.
3. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 1 is characterized in that: Verifying the correctness of the first Hash value and signature includes: The correctness of the signature is verified using the public key of the consensus node. At the same time, the request block is reconverted into a hash value, and the converted hash value is recorded as the third hash value. If the third hash value is consistent with the first hash value, the consensus node is considered to have passed the verification.
4. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 3 is characterized in that: The consensus node consists of 3f+1 nodes; where f represents the number of consensus node errors allowed; the oracle node can only parse the request block when it receives node verification from no less than 2f+1 consensus nodes.
5. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 1, characterized in that: The reply block includes the request unique identifier, the acquired data, the collected signatures, the callback contract address, the callback function signature, and additional metadata.
6. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 1, characterized in that: Use the public key of the oracle node to verify the correctness of the signature, including: The public keys of the oracle nodes are aggregated to generate an aggregated public key; if the aggregated public key is consistent with the signature, the oracle node is considered to have passed the verification.
7. The node implementation method for on-chain and off-chain collaborative distributed oracle according to claim 1, characterized in that: The oracle node consists of 2t+1 nodes; t represents the number of oracle node errors allowed; the consensus node can only parse the reply block when it receives node verification from no less than t+1 oracle nodes.
8. A node implementation system for on-chain and off-chain collaborative distributed oracles, characterized in that: include: The data acquisition module is configured to: call the data acquisition interface in the oracle contract to obtain external data address parameters; The request verification module is configured to: send the external data address parameter to the corresponding chain event, encapsulate the external data address parameter into a request block based on the chain event, convert the request block into a first Hash value and sign the first Hash value with the private key of the consensus node; send the request block, the first Hash value and the signature to the oracle node; verify the correctness of the first Hash value and the signature, and if the verification passes, parse the request block and call the external data content corresponding to the external data address parameter; The reply verification module is configured to: encapsulate the obtained external data content into a reply block based on the oracle node, convert the reply block into a second Hash value and sign the second Hash value with the private key of the oracle node; send the reply block, the second Hash value and the signature to the consensus node together; use the public key of the oracle node to verify the correctness of the signature; if the verification passes, parse the reply block and call the receiving data interface in the oracle contract to call back the parsed data to the oracle contract for processing.
9. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, it implements the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles as described in any one of claims 1-7.
10. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, it implements the steps in the node implementation method for on-chain and off-chain collaborative distributed oracles as described in any one of claims 1-7.
Citation Information
Cited By
Oracle machine consensus method, system and device and nonvolatile storage medium
CN120856301A