An off-chain data acquisition method, device, equipment and storage medium

By using a mechanism of encrypted random numbers and negotiated keys between the oracle service platform and the data provider, the problem of off-chain data tampering is solved, and the credibility and security of data transmission are achieved.

CN115859376BActive Publication Date: 2026-06-12ZHONGCHAO CREDIT CARD IND DEV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHONGCHAO CREDIT CARD IND DEV
Filing Date
2022-12-14
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

In centralized oracle implementations, off-chain data is at risk of being tampered with by the oracle service platform, leading to data unreliability issues.

Method used

By using encrypted random numbers and negotiated keys during data transmission, the security of communication between the data requester and the data provider is ensured. The oracle service platform cannot obtain the decryption key, thus preventing data tampering.

🎯Benefits of technology

It improves the reliability of data during off-chain data transmission and ensures the security and integrity of the data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115859376B_ABST
    Figure CN115859376B_ABST
Patent Text Reader

Abstract

The application discloses an off-chain data acquisition method and device, equipment and a storage medium, and relates to the technical field of blockchains. The method comprises the following steps: acquiring encrypted random numbers and requester data from a blockchain; the encrypted random numbers are obtained by encrypting first random numbers by a data requester using a public key; the encrypted random numbers and the requester data are sent to a data provider, so that the data provider determines target off-chain data, decrypts the encrypted random numbers using a private key to obtain the first random numbers, and encrypts the target off-chain data using a negotiation key generated based on the first random numbers to obtain encrypted off-chain data; the encrypted off-chain data is acquired and reported to the blockchain, so that the blockchain decrypts the encrypted off-chain data using the negotiation key to obtain the target off-chain data. In this way, in the off-chain data acquisition process, the oracle service platform cannot acquire the negotiation key and the target off-chain data, thereby improving the off-chain data credibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and in particular to a method, apparatus, device, and storage medium for acquiring off-chain data. Background Technology

[0002] Blockchain is a deterministic and closed system environment. The execution of smart contracts must produce consistent results, so the virtual machine cannot allow smart contracts to make network calls; otherwise, the results would be unpredictable. Smart contracts cannot directly access real-world data outside the blockchain, resulting in a disconnect between the blockchain and the real world, which greatly limits the application scenarios of blockchain. In the field of blockchain technology, the mechanism of writing information from outside the blockchain into the blockchain is generally called an oracle. Oracles can input real-world data into the blockchain, providing smart contracts with connectivity to the external world. In centralized oracle service use cases, there are three roles: the data requester, the oracle platform provider, and the data provider.

[0003] In current centralized oracle implementations, the process of acquiring off-chain data is as follows: Figure 1 As shown, when a data requesting smart contract within the blockchain needs off-chain data, it initiates an off-chain data request to the oracle service platform smart contract. After the oracle service platform detects an off-chain data request, it sends a data request to the data provider. Upon receiving the request, the data provider returns the data corresponding to the request. The oracle service platform then passes the returned off-chain data to its own smart contract, which in turn sends the data to the data requesting smart contract. In this scenario, the off-chain data is sent to the blockchain via the oracle service platform, which carries the risk of data tampering with the data, potentially leading to unreliable off-chain data. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and storage medium for acquiring off-chain data, which can solve the problem of data unreliability caused by the potential tampering of off-chain data by oracle platforms. The specific solution is as follows:

[0005] Firstly, this application provides a method for obtaining off-chain data, applied to an oracle service platform, including:

[0006] The encrypted random number and the requester's data are obtained from the blockchain; the encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider.

[0007] The encrypted random number and the requester data are sent to the data provider so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number. The data provider then uses the negotiation key generated based on the first random number to encrypt the target off-chain data to obtain the encrypted off-chain data.

[0008] The encrypted off-chain data returned by the data provider is obtained, and the encrypted off-chain data is reported to the blockchain so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester, and obtain the target off-chain data.

[0009] Optionally, obtaining the encrypted random number sent by the data requester and the requester's data from the blockchain includes:

[0010] The encrypted random number and encrypted requester data sent by the data requester are obtained from the smart contract of the blockchain oracle service platform; the encrypted requester data is the data obtained by encrypting the initial requester data using the negotiation key generated based on the first random number.

[0011] Accordingly, sending the encrypted random number and the requester's data to the data provider includes:

[0012] The encrypted random number and the encrypted requester data are sent to the data provider so that the data provider can decrypt the encrypted requester data using the negotiation key generated based on the first random number and determine the target off-chain data corresponding to the initial requester data obtained after decryption.

[0013] Optionally, before obtaining the encrypted random number sent by the data requester and the encrypted requester data from the blockchain oracle service platform smart contract, the method further includes:

[0014] The oracle service platform smart contract sends a target notification generated after a handshake operation with the data provider. The target notification includes a second random number generated by the oracle itself during the handshake operation and a third random number generated by the data provider. This allows the data requester to obtain the target notification from the oracle service platform smart contract through the data requester smart contract and generate the negotiation key using the first random number, the second random number, and the third random number in the target notification. The initial requester data is then encrypted using the negotiation key to obtain the encrypted requester data.

[0015] Optionally, before sending the target notification generated after the handshake with the data provider to the oracle service platform smart contract, the method further includes:

[0016] A polling operation is initiated to the oracle service platform smart contract to check whether there are any off-chain data requests in the oracle service platform smart contract; the off-chain data request is a request generated and sent to the oracle service platform smart contract after the data requester's smart contract responds to the business request initiated by the data requester;

[0017] If the oracle service platform smart contract is polled and an off-chain data request is found, the handshake operation with the data provider is triggered.

[0018] Optionally, reporting the encrypted off-chain data to the blockchain includes:

[0019] The encrypted off-chain data is reported to the oracle service platform smart contract, so that the data requester smart contract can obtain the encrypted off-chain data from the oracle service platform smart contract, and obtain the first random number sent by the data requester after the encrypted off-chain data appears on the data requester smart contract in the polling. Then, the encrypted off-chain data is decrypted using the negotiation key generated based on the first random number to obtain the target off-chain data.

[0020] Secondly, this application provides an off-chain data acquisition method, applicable to data providers, including:

[0021] The system receives encrypted random numbers obtained from the blockchain and requester data from the oracle service platform; the encrypted random number is data obtained by the data requester using the public key of the data provider to encrypt a first random number and then sending it to the blockchain.

[0022] The target off-chain data corresponding to the requester's data is determined, and the first random number is obtained by decrypting the encrypted random number using its own private key. The target off-chain data is then encrypted using a negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0023] The encrypted off-chain data is returned to the oracle service platform so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data.

[0024] Thirdly, this application provides an off-chain data acquisition device for use in an oracle service platform, comprising:

[0025] The first data acquisition module is used to acquire the encrypted random number sent by the data requester and the requester's data from the blockchain; the encrypted random number is obtained by the data requester encrypting the first random number using the public key of the data provider;

[0026] The data sending module is used to send the encrypted random number and the requester data to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number, and encrypt the target off-chain data using the negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0027] The second data acquisition module is used to acquire the encrypted off-chain data returned by the data provider;

[0028] The data upload module is used to report the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester, and obtain the target off-chain data.

[0029] Fourthly, this application provides an off-chain data acquisition device, applied to a data provider, comprising:

[0030] The data receiving module is used to receive encrypted random numbers obtained from the blockchain and requester data sent by the oracle service platform; the encrypted random number is data obtained by the data requester using the public key of the data provider to encrypt a first random number and then sending it to the blockchain.

[0031] The data encryption module is used to determine the target off-chain data corresponding to the requester's data, and to decrypt the encrypted random number using its own private key to obtain the first random number, and to encrypt the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0032] The data return module is used to return the encrypted off-chain data to the oracle service platform, so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data.

[0033] Fifthly, this application provides an electronic device, comprising:

[0034] Memory, used to store computer programs;

[0035] A processor is used to execute the computer program to implement the aforementioned off-chain data acquisition method.

[0036] Sixthly, this application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned off-chain data acquisition method.

[0037] In this application, the oracle service platform obtains an encrypted random number and requester data sent by a data requester from the blockchain. The encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider. The encrypted random number and the requester data are then sent to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number. The data provider then encrypts the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data. The oracle service platform obtains the encrypted off-chain data returned by the data provider and reports the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. Therefore, before reporting the target off-chain data to the blockchain through the oracle service platform, this application first encrypts the target off-chain data using a negotiation key generated based on the first random number. Simultaneously, the first random number is also encrypted to obtain an encrypted first random number. The private key used to decrypt the encrypted first random number is held only by the data provider. This ensures that the oracle service platform never obtains the first random number or the negotiation key during off-chain data transmission. Consequently, the oracle service platform cannot use the negotiation key to decrypt the encrypted off-chain data, meaning it cannot obtain the target off-chain data and therefore cannot tamper with it, thus improving the data reliability during off-chain data transmission. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0039] Figure 1 This is a timing diagram of an existing off-chain data acquisition method.

[0040] Figure 2 A flowchart of an off-chain data acquisition method provided in this application;

[0041] Figure 3 A flowchart illustrating a specific off-chain data acquisition method provided in this application;

[0042] Figure 4 A flowchart of an off-chain data acquisition method provided in this application;

[0043] Figure 5 A timing diagram of a specific off-chain data acquisition method provided in this application;

[0044] Figure 6 A schematic diagram of an off-chain data acquisition device provided in this application;

[0045] Figure 7 A schematic diagram of an off-chain data acquisition device provided in this application;

[0046] Figure 8 This application provides a structural diagram of an electronic device. Detailed Implementation

[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] In current centralized oracle implementations, when a smart contract requesting data within the blockchain needs off-chain data, the off-chain data provider sends the data to the blockchain via an oracle service platform. During this process, the data may be tampered with by the oracle service platform, leading to unreliability issues with the off-chain data. Therefore, this application provides a method for obtaining off-chain data, which can improve the reliability of data during off-chain data transmission.

[0049] See Figure 2 As shown in the figure, this application discloses an off-chain data acquisition method, applied to an oracle service platform, including:

[0050] Step S11: Obtain the encrypted random number sent by the data requester and the requester's data from the blockchain; the encrypted random number is obtained by the data requester encrypting the first random number using the public key of the data provider.

[0051] In this embodiment, the oracle service platform obtains the encrypted random number and requester data sent by the data requester from the blockchain. The requester data represents demand information data representing the data information needed by the blockchain. The encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider. That is, the data requester responds to an off-chain data request within the blockchain by generating requester data and a first random number, encrypts the first random number using the public key of the data provider to obtain the encrypted random number, and then sends the encrypted random number and the requester data to the blockchain. The oracle service platform then obtains the encrypted random number and the requester data from the blockchain.

[0052] Understandably, the data requester encrypts the first random number using the data provider's public key, while the private key required to decrypt the encrypted first random number is held only by the data provider. In this way, the oracle service platform cannot decrypt the encrypted random number after obtaining it, thus ensuring the security of data transmission.

[0053] Step S12: Send the encrypted random number and the requester data to the data provider so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number, and encrypt the target off-chain data using the negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0054] In this embodiment, the oracle service platform sends the encrypted random number and the requester data to the data provider. The data provider determines the target off-chain data corresponding to the requester data, and simultaneously decrypts the obtained encrypted random number using its private key, and encrypts the target off-chain data using a negotiation key generated based on the first random number, thus obtaining the encrypted off-chain data.

[0055] Step S13: Obtain the encrypted off-chain data returned by the data provider and report the encrypted off-chain data to the blockchain so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data.

[0056] In this embodiment, the oracle service platform obtains the encrypted off-chain data returned by the data provider and reports the encrypted off-chain data to the blockchain. The blockchain then uses a negotiation key generated based on the first random number sent by the data requester to decrypt the encrypted off-chain data, obtaining the target off-chain data. Specifically, when the data requester detects that the blockchain has obtained the encrypted off-chain data, it sends the first random number to the blockchain. After obtaining the first random number and the encrypted off-chain data, the blockchain first generates the negotiation key based on the first random number, and then uses the negotiation key to decrypt the encrypted off-chain data to obtain the target off-chain data. In this way, the oracle service platform, during the off-chain data acquisition process, does not obtain the first random number and cannot decrypt the encrypted off-chain data, thus preventing tampering with the target off-chain data and ensuring the security and reliability of the off-chain data.

[0057] In this embodiment, the oracle service platform obtains an encrypted random number and requester data sent by the data requester from the blockchain. The encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider. The data provider then sends the encrypted random number and the requester data to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number. The data provider then encrypts the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data. The oracle service platform obtains the encrypted off-chain data returned by the data provider and reports the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. Therefore, before reporting the target off-chain data to the blockchain through the oracle service platform, this application first encrypts the target off-chain data using a negotiation key generated based on the first random number. Simultaneously, the first random number is also encrypted to obtain an encrypted first random number. The private key used to decrypt the encrypted first random number is held only by the data provider. This ensures that the oracle service platform never obtains the first random number or the negotiation key during off-chain data transmission. Consequently, the oracle service platform cannot use the negotiation key to decrypt the encrypted off-chain data, meaning it cannot obtain the target off-chain data and therefore cannot tamper with it, thus improving the data reliability during off-chain data transmission.

[0058] See Figure 3As shown in the figure, this application discloses a specific method for obtaining off-chain data, applied to an oracle service platform, including:

[0059] Step S21: Initiate a polling operation to the oracle service platform smart contract of the blockchain to check whether there is an off-chain data request in the oracle service platform smart contract; the off-chain data request is a request generated and sent to the oracle service platform smart contract after the data requester's smart contract responds to the business request initiated by the data requester.

[0060] In this embodiment, the data requester's smart contract receives and responds to a business request sent by the data requester, generating the off-chain data request and sending it to the oracle service platform smart contract. The oracle service platform initiates a polling operation with the blockchain's oracle service platform smart contract to check whether an off-chain data request exists in the oracle service platform smart contract. The business request is a request to obtain off-chain data.

[0061] Step S22: If an off-chain data request is found in the oracle service platform smart contract, a handshake operation is triggered with the data provider.

[0062] When the oracle service platform polls and finds an off-chain data request in the blockchain's oracle service platform smart contract, it triggers a handshake operation with the data provider; if the oracle service platform does not find an off-chain data request in the oracle service platform smart contract, it does not trigger the handshake operation with the data provider.

[0063] Step S23: Send a target notification generated after the handshake operation with the data provider to the oracle service platform smart contract. The target notification includes a second random number generated by the requester during the handshake operation and a third random number generated by the data provider. This allows the data requester to obtain the target notification from the oracle service platform smart contract through the data requester smart contract and generate a negotiation key using its own first random number and the second and third random numbers in the target notification. Then, the requester uses the negotiation key to encrypt the initial requester data to obtain the encrypted requester data.

[0064] In this embodiment, the oracle service platform sends a target notification generated after a handshake operation with the data provider to its smart contract. The target notification includes a second random number generated by the oracle service platform itself during the handshake operation and a third random number generated by the data provider. Specifically, the oracle service platform first establishes a communication channel with the data provider, then sends the second random number generated during the communication establishment process, the third random number generated by the data provider, and the target notification to the oracle service platform smart contract. This allows the data requester to obtain the target notification from the oracle service platform smart contract through its smart contract, and use the first random number, the second random number, and the third random number in the target notification to generate the negotiation key. The data requester then uses the negotiation key to encrypt the initial requester data, obtaining the encrypted requester data. In this way, the data requester generates a negotiation key using a first random number, a second random number, and a third random number, and uses the negotiation key to encrypt the initial requester data to obtain the encrypted requester data. Since the first random number is generated by the data requester itself, the oracle service platform cannot obtain the first random number and the negotiation key, and cannot decrypt the encrypted requester data to obtain the initial requester data, thereby improving the security and reliability of off-chain data during the off-chain data acquisition process.

[0065] Step S24: Obtain the encrypted random number sent by the data requester and the encrypted requester data from the oracle service platform smart contract.

[0066] In this embodiment, the oracle service platform obtains the encrypted random number and encrypted requester data sent by the data requester from the blockchain's oracle service platform smart contract. The encrypted random number is obtained by the data requester encrypting a first random number using the data provider's public key. That is, the data requester generates the negotiation key based on the first, second, and third random numbers, and uses the negotiation key to encrypt the initial requester data to obtain encrypted requester data. Then, it encrypts the first random number using the data provider's public key to obtain the encrypted random number. The encrypted requester data and the encrypted random number are then sent to the blockchain's oracle service platform smart contract, and the oracle service platform obtains the encrypted random number and the encrypted requester data from the blockchain's oracle service platform smart contract.

[0067] Step S25: Send the encrypted random number and the encrypted requester data to the data provider so that the data provider can decrypt the encrypted random number using its own private key to obtain the first random number, and use the first random number, the second random number sent by the oracle service platform during the handshake process, and the third random number generated by itself to generate the negotiation key. Then, use the negotiation key to decrypt the encrypted requester data, determine the target off-chain data corresponding to the decrypted initial requester data, and use the negotiation key to encrypt the target off-chain data to obtain the encrypted off-chain data.

[0068] In this embodiment, the oracle service platform sends the encrypted random number and the encrypted requester data to the data provider, so that the data provider can use its own private key to decrypt the encrypted random number to obtain a first random number, and use the negotiation key generated based on the first random number, the second random number sent by the oracle service platform during the handshake process, and a third random number generated by itself to decrypt the encrypted requester data, determine the target off-chain data corresponding to the decrypted initial requester data, and then use the negotiation key generated based on the first random number to encrypt the target off-chain data to obtain the encrypted off-chain data. That is, the oracle service platform sends the encrypted random number and the encrypted requester data to the data provider. The data provider first decrypts the encrypted random number using its own private key to obtain the first random number, generates the negotiation key based on the first random number, and uses the negotiation key to decrypt the encrypted requester data to obtain the initial requester data. Then, it determines the target off-chain data corresponding to the initial requester data and uses the negotiation key to encrypt the target off-chain data to obtain the encrypted off-chain data.

[0069] Step S26: The encrypted off-chain data is reported to the oracle service platform smart contract so that the data requester smart contract can obtain the encrypted off-chain data from the oracle service platform smart contract, and obtain the first random number sent by the data requester after the encrypted off-chain data appears on the data requester smart contract during polling, and generate the negotiation key using the first random number, the second random number and the third random number in the target notification obtained from the oracle service platform smart contract, and decrypt the encrypted off-chain data using the negotiation key to obtain the target off-chain data.

[0070] In this embodiment, the oracle service platform reports encrypted off-chain data to its smart contract. This allows the data requester's smart contract to retrieve the encrypted off-chain data from the oracle service platform's smart contract. The data requester also retrieves the first random number sent by the data requester after detecting the encrypted off-chain data in its polling of the data requester's smart contract. Then, it decrypts the encrypted off-chain data using a negotiation key generated based on the first, second, and third random numbers to obtain the target off-chain data. Specifically, after receiving the encrypted off-chain data from the oracle service platform, the oracle service platform's smart contract sends it to the data requester's smart contract. When the data requester outside the blockchain detects that the data requester's smart contract has obtained the encrypted off-chain data, it sends the first random number to the data requester's smart contract. The data requester's smart contract then generates the negotiation key based on the acquired first, second, and third random numbers and uses this negotiation key to decrypt the encrypted off-chain data to obtain the target off-chain data. In this way, the oracle service platform does not obtain the first random number and the negotiation key during the off-chain data acquisition process, and therefore cannot decrypt the encrypted off-chain data, nor can it tamper with the target off-chain data, thus ensuring the security and trustworthiness of the off-chain data.

[0071] In this embodiment, the oracle service platform sends a target notification generated after a handshake operation with the data provider to its smart contract. The target notification includes a second random number generated by the platform itself during the handshake operation and a third random number generated by the data provider. This allows the data requester to obtain the target notification from the oracle service platform smart contract via its smart contract and generate a negotiation key using the first random number, the second random number, and the third random number in the target notification. The initial requester data is then encrypted using the negotiation key to obtain the encrypted requester data. The encrypted random number and the encrypted requester data are then retrieved from the blockchain's oracle service platform smart contract. The encrypted random number is obtained by encrypting the first random number using the data provider's public key. The encrypted requester data is the data obtained by encrypting the initial requester data using the negotiation key generated based on the first, second, and third random numbers. The oracle service platform sends the encrypted random number and the encrypted requester data to the data provider. The data provider then uses its private key to decrypt the encrypted random number to obtain the first random number and uses the negotiation key generated based on the first, second, and third random numbers to decrypt the encrypted requester data. It then determines the target off-chain data corresponding to the decrypted initial requester data. Next, it encrypts the target off-chain data using the negotiation key generated based on the first, second, and third random numbers to obtain the encrypted off-chain data. The encrypted off-chain data is reported to the oracle service platform smart contract. The data requester smart contract then retrieves the encrypted off-chain data from the oracle service platform smart contract and obtains the first random number sent by the data requester after the encrypted off-chain data appears in the data requester smart contract's polling. Finally, it decrypts the encrypted off-chain data using the negotiation key generated based on the first, second, and third random numbers to obtain the target off-chain data. In this way, during the process of obtaining off-chain data from the blockchain, the oracle service platform cannot obtain the negotiation key, and therefore cannot decrypt the encrypted off-chain data to obtain the target off-chain data. Consequently, it cannot tamper with the target off-chain data, thus improving the credibility and security of the off-chain data. At the same time, the first random number, the second random number, the third random number, the encrypted requester data, and the encrypted off-chain data are all verifiable on the blockchain, which further enhances the credibility of the data.

[0072] See Figure 4As shown in the figure, this application discloses an off-chain data acquisition method, applied to a data provider, including:

[0073] Step S31: Receive the encrypted random number obtained from the blockchain and the requester's data sent by the oracle service platform; the encrypted random number is the data obtained by the data requester encrypting the first random number using the public key of the data provider and sending it to the blockchain.

[0074] In this embodiment, the data requester uses the data provider's public key to encrypt a first random number to obtain an encrypted random number. Then, the encrypted random number and the requester's data are reported to the blockchain. The oracle service platform retrieves the encrypted random number and the requester's data from the blockchain and sends them to the data provider. During this process, the oracle service platform obtains the encrypted random number and the requester's data, but does not obtain the data provider's private key, and therefore cannot decrypt the encrypted random number to obtain the first random number.

[0075] Step S32: Determine the target off-chain data corresponding to the requester's data and decrypt the encrypted random number using your own private key to obtain the first random number, and encrypt the target off-chain data using the negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0076] In this embodiment, the data requester determines the target off-chain data corresponding to the requester's data, decrypts the encrypted random number using its own private key to obtain the first random number, generates a negotiation key based on the obtained first random number, and uses the negotiation key to encrypt the target off-chain data to obtain the encrypted off-chain data.

[0077] Step S33: Return the encrypted off-chain data to the oracle service platform so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data.

[0078] In this embodiment, the data provider returns the encrypted off-chain data to the oracle service platform. The oracle service platform then reports the encrypted off-chain data to the blockchain. Upon receiving the encrypted off-chain data, the blockchain obtains a first random number sent by the data requester, generates a negotiation key based on the first random number, and uses the negotiation key to decrypt the encrypted off-chain data to obtain the target off-chain data. During this process, the oracle service platform receives the encrypted off-chain data but does not obtain the first random number and the negotiation key, making it unable to decrypt the encrypted off-chain data to obtain the target off-chain data. Therefore, it cannot tamper with the target off-chain data, thereby improving the security and reliability of off-chain data acquisition.

[0079] In this embodiment, the data provider receives encrypted random numbers obtained from the blockchain and requester data from an oracle service platform. The encrypted random numbers are data obtained by the data requester using the data provider's public key to encrypt a first random number and then sending it to the blockchain. The data provider then determines the target off-chain data corresponding to the requester data and decrypts the encrypted random numbers using its own private key to obtain the first random number. It then encrypts the target off-chain data using a negotiation key generated based on the first random number, obtaining encrypted off-chain data. The data provider returns the encrypted off-chain data to the oracle service platform so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt it using the negotiation key generated based on the first random number sent by the data requester, obtaining the target off-chain data. Therefore, before reporting the target off-chain data to the blockchain through the oracle service platform, this application first encrypts the target off-chain data using a negotiation key generated based on the first random number. Simultaneously, the first random number is also encrypted to obtain an encrypted first random number. The private key used to decrypt the encrypted first random number is held only by the data provider. This ensures that the oracle service platform never obtains the first random number or the negotiation key during off-chain data transmission. Consequently, the oracle service platform cannot use the negotiation key to decrypt the encrypted off-chain data, meaning it cannot obtain the target off-chain data and therefore cannot tamper with it, thus improving the data reliability during off-chain data transmission.

[0080] The following is combined with Figure 5 The timing diagram of a specific off-chain data acquisition method disclosed in the present application provides a detailed description of the technical solution of the embodiments of this application.

[0081] In this embodiment, the data requester initiates a business call to its smart contract. When the data requester's smart contract executes the business and detects the need for off-chain data, it sends an off-chain data request to the oracle service platform's smart contract. After the oracle service platform detects the existence of an off-chain data request through its smart contract, it establishes a communication channel with the data provider, begins the handshake process, and sends a client hello message to the data provider, which carries a random number r1. The data provider returns a server hello message to the oracle service platform, which carries a random number r2. The oracle service platform collects the random numbers r1 and r2, generates a data notification, and sends the random numbers r1 and r2 to the oracle service platform's smart contract.

[0082] The data requester polls the blockchain and, upon detecting a data request, obtains random numbers r1 and r2, and generates a random number r3. It then uses a PRF (Pseudo Random Function) (r1, r2, r3) to obtain a negotiation key (master secret). The master secret is used to encrypt the client data to be sent to the data provider. The data requester then uses the public key from the data provider's CA certificate to encrypt random number r3 and sends the encrypted r3 and client data to the oracle service platform's smart contract to complete data generation. Upon detecting data generation completion, the oracle service platform obtains the encrypted r3 and client data. Finally, the oracle service platform sends a client key exchange message to the data provider, carrying the encrypted r3. After completing the remaining handshake process, the data requester and the data provider have completed key negotiation. Both parties have obtained the random numbers r1, r2, and r3 required to calculate the negotiated master secret. The data provider obtains the random number r3 by decrypting the encrypted r3 ciphertext using the private key in the certificate. The oracle service platform knows the random numbers r1 and r2, but not r3, and therefore cannot calculate the negotiated key.

[0083] The oracle service platform sends encrypted client data to the data provider. The data provider obtains the negotiation key, master secret, using random numbers r1, r2, and r3. Using this master secret, the provider decrypts the client data to determine the corresponding server data. The data provider then encrypts the server data to be returned and sends it back to the oracle service platform using the master secret. The oracle service platform transmits the encrypted server data to its smart contract. The smart contract then sends the encrypted server data to the data requester's smart contract. When the data requester detects that the encrypted server data has been returned, it sends the previously obtained random number r3 to its smart contract. The data requester's smart contract, now possessing random numbers r1, r2, and r3, can calculate the negotiation key and use it to decrypt the server data to obtain the required data. The data requester's smart contract then continues executing its business logic. In this way, during the off-chain data acquisition process, key negotiation is completed before the data requester and the data provider. The oracle service platform cannot obtain the negotiated master secret, and therefore cannot tamper with the data, improving the credibility of off-chain data. At the same time, random numbers r1, r2, and r3, client data ciphertext, and server data ciphertext are verifiable on the blockchain, further enhancing data credibility. Moreover, the off-chain data acquisition process follows the HTTPS (Hypertext Transfer Protocol over Secure Socket Layer) protocol, so the data provider does not need to modify the corresponding functional modules, reducing human and technical costs.

[0084] See Figure 6 As shown in the embodiments, this application also discloses an off-chain data acquisition device, applied to an oracle service platform, comprising:

[0085] The first data acquisition module 11 is used to acquire the encrypted random number sent by the data requester and the requester's data from the blockchain; the encrypted random number is obtained by the data requester encrypting the first random number using the public key of the data provider;

[0086] The data sending module 12 is used to send the encrypted random number and the requester data to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number, and encrypt the target off-chain data using the negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0087] The second data acquisition module 13 is used to acquire the encrypted off-chain data returned by the data provider;

[0088] The data upload module 14 is used to report the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester, and obtain the target off-chain data.

[0089] In this embodiment, the oracle service platform obtains an encrypted random number and requester data sent by the data requester from the blockchain. The encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider. The data provider then sends the encrypted random number and the requester data to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number. The data provider then encrypts the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data. The oracle service platform obtains the encrypted off-chain data returned by the data provider and reports the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. Therefore, before reporting the target off-chain data to the blockchain through the oracle service platform, this application first encrypts the target off-chain data using a negotiation key generated based on the first random number. Simultaneously, the first random number is also encrypted to obtain an encrypted first random number. The private key used to decrypt the encrypted first random number is held only by the data provider. This ensures that the oracle service platform never obtains the first random number or the negotiation key during off-chain data transmission. Consequently, the oracle service platform cannot use the negotiation key to decrypt the encrypted off-chain data, meaning it cannot obtain the target off-chain data and therefore cannot tamper with it, thus improving the data reliability during off-chain data transmission.

[0090] In some specific embodiments, the first data acquisition module 11 may specifically include:

[0091] The requester data encryption unit is used by the data requester to encrypt the initial requester data using the negotiation key generated based on the first random number;

[0092] The requester data decryption unit is used by the data provider to decrypt the encrypted requester data using the negotiation key generated based on the first random number.

[0093] In some specific embodiments, the off-chain data acquisition device may further include:

[0094] The target notification sending module is used to send a target notification generated after a handshake operation with the data provider to the oracle service platform smart contract. The target notification includes a second random number generated by itself during the handshake operation and a third random number generated by the data provider. This allows the data requester to obtain the target notification from the oracle service platform smart contract through the data requester smart contract and generate the negotiation key using the first random number, the second random number, and the third random number in the target notification. Then, the negotiation key is used to encrypt the initial requester data to obtain the encrypted requester data.

[0095] In some specific embodiments, the off-chain data acquisition device may further include:

[0096] The polling request module is used to initiate a polling operation to the oracle service platform smart contract to poll whether there is an off-chain data request in the oracle service platform smart contract; the off-chain data request is a request generated and sent to the oracle service platform smart contract after the data requester's smart contract responds to the business request initiated by the data requester;

[0097] The condition judgment module is used to determine whether the off-chain data request exists in the smart contract of the oracle service platform;

[0098] The operation triggering module is used to trigger the handshake operation with the data provider when the oracle service platform smart contract is polled to find that there is an off-chain data request.

[0099] See Figure 7 As shown in the embodiments, this application also discloses an off-chain data acquisition device, applied to a data provider, including:

[0100] Data receiving module 21 is used to receive encrypted random numbers obtained from the blockchain and requester data sent by the oracle service platform; the encrypted random number is data obtained by the data requester using the public key of the data provider to encrypt a first random number and then sending it to the blockchain.

[0101] The data encryption module 22 is used to determine the target off-chain data corresponding to the requester's data, and to decrypt the encrypted random number using its own private key to obtain the first random number, and to encrypt the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data.

[0102] The data return module 23 is used to return the encrypted off-chain data to the oracle service platform, so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data.

[0103] Therefore, in this embodiment, the data provider receives encrypted random numbers obtained from the blockchain and requester data sent by the oracle service platform. The encrypted random number is data obtained by the data requester using the data provider's public key to encrypt a first random number and then sending it to the blockchain. The data provider then determines the target off-chain data corresponding to the requester data and decrypts the encrypted random number using its own private key to obtain the first random number. It then encrypts the target off-chain data using a negotiation key generated based on the first random number, obtaining the encrypted off-chain data. The data provider returns the encrypted off-chain data to the oracle service platform so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt it using the negotiation key generated based on the first random number sent by the data requester, obtaining the target off-chain data. Therefore, before reporting the target off-chain data to the blockchain through the oracle service platform, this application first encrypts the target off-chain data using a negotiation key generated based on the first random number. Simultaneously, the first random number is also encrypted to obtain an encrypted first random number. The private key used to decrypt the encrypted first random number is held only by the data provider. This ensures that the oracle service platform never obtains the first random number or the negotiation key during off-chain data transmission. Consequently, the oracle service platform cannot use the negotiation key to decrypt the encrypted off-chain data, meaning it cannot obtain the target off-chain data and therefore cannot tamper with it, thus improving the data reliability during off-chain data transmission.

[0104] Furthermore, embodiments of this application also disclose an electronic device, Figure 8 This is a structural diagram of an electronic device 30 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0105] Figure 8 This is a schematic diagram of the structure of an electronic device 30 provided in an embodiment of this application. Specifically, the electronic device 30 may include: at least one processor 31, at least one memory 32, a power supply 33, a communication interface 34, an input / output interface 35, and a communication bus 36. The memory 32 stores a computer program, which is loaded and executed by the processor 31 to implement the relevant steps in the off-chain data acquisition method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 30 in this embodiment may specifically be an electronic computer.

[0106] In this embodiment, the power supply 33 is used to provide operating voltage for each hardware device on the electronic device 30; the communication interface 34 can create a data transmission channel between the electronic device 30 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 35 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0107] In addition, the memory 32, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 321, computer program 322, etc., and the storage method can be temporary storage or permanent storage.

[0108] The operating system 321 is used to manage and control the various hardware devices on the electronic device 30 and the computer program 322, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the off-chain data acquisition method executed by the electronic device 30 as disclosed in any of the foregoing embodiments, the computer program 322 may further include a computer program capable of performing other specific tasks.

[0109] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed off-chain data acquisition method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0111] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0112] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0113] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0114] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for acquiring off-chain data, characterized in that, Applications to oracle service platforms include: The encrypted random number and the requester's data are obtained from the blockchain; the encrypted random number is obtained by the data requester encrypting a first random number using the public key of the data provider. The encrypted random number and the requester data are sent to the data provider so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number. The data provider then uses the negotiation key generated based on the first random number to encrypt the target off-chain data to obtain the encrypted off-chain data. The encrypted off-chain data returned by the data provider is obtained, and the encrypted off-chain data is reported to the blockchain so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester, and obtain the target off-chain data. Before obtaining the encrypted random number sent by the data requester and the requester's data from the blockchain, the process also includes: A polling operation is initiated to the oracle service platform smart contract to check whether there is an off-chain data request in the oracle service platform smart contract. The off-chain data request is a request generated and sent to the oracle service platform smart contract after the data requester's smart contract responds to the business request initiated by the data requester. If the off-chain data request is found in the oracle service platform smart contract, a handshake operation is triggered with the data provider. A target notification based on the handshake operation with the data provider is sent to the oracle service platform smart contract. The target notification includes a second random number generated by itself in the handshake operation and a third random number generated by the data provider. This allows the data requester to obtain the target notification from the oracle service platform smart contract through the data requester's smart contract and generate the negotiation key using the first random number and the second and third random numbers in the target notification. Then, the negotiation key is used to encrypt the initial requester data to obtain the encrypted requester data.

2. The off-chain data acquisition method according to claim 1, characterized in that, The step of obtaining the encrypted random number sent by the data requester and the requester's data from the blockchain includes: The encrypted random number and encrypted requester data sent by the data requester are obtained from the smart contract of the blockchain oracle service platform; the encrypted requester data is the data obtained by encrypting the initial requester data using the negotiation key generated based on the first random number. Accordingly, sending the encrypted random number and the requester's data to the data provider includes: The encrypted random number and the encrypted requester data are sent to the data provider so that the data provider can decrypt the encrypted requester data using the negotiation key generated based on the first random number and determine the target off-chain data corresponding to the initial requester data obtained after decryption.

3. The off-chain data acquisition method according to claim 1, characterized in that, The step of reporting the encrypted off-chain data to the blockchain includes: The encrypted off-chain data is reported to the oracle service platform smart contract, so that the data requester smart contract can obtain the encrypted off-chain data from the oracle service platform smart contract, and obtain the first random number sent by the data requester after the encrypted off-chain data appears on the data requester smart contract in the polling. Then, the encrypted off-chain data is decrypted using the negotiation key generated based on the first random number to obtain the target off-chain data.

4. A method for acquiring off-chain data, characterized in that, Applied to data providers, including: The system receives encrypted random numbers obtained from the blockchain and requester data from the oracle service platform; the encrypted random number is data obtained by the data requester using the public key of the data provider to encrypt a first random number and then sending it to the blockchain. The target off-chain data corresponding to the requester's data is determined, and the first random number is obtained by decrypting the encrypted random number using its own private key. The target off-chain data is then encrypted using a negotiation key generated based on the first random number to obtain the encrypted off-chain data. The encrypted off-chain data is returned to the oracle service platform so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. Before receiving the encrypted random number obtained from the blockchain and the requester's data sent by the oracle service platform, the process also includes: The oracle service platform initiates a polling operation with its smart contract to check for the existence of off-chain data requests. If the oracle service platform detects the existence of such requests, it triggers a handshake with the oracle service platform and sends a target notification generated after the handshake with the data provider to the oracle service platform's smart contract. This target notification includes a second random number generated by the oracle service platform itself during the handshake and a third random number generated by the data provider. The data requester then retrieves the target notification from the oracle service platform's smart contract through its own smart contract and uses the first random number, the second random number, and the third random number in the target notification to generate a negotiation key. The negotiation key is then used to encrypt the initial requester data, resulting in encrypted requester data. The off-chain data request is a request generated and sent to the oracle service platform's smart contract after the data requester's smart contract responds to a business request initiated by the data requester.

5. An off-chain data acquisition device, characterized in that, Applications to oracle service platforms include: The first data acquisition module is used to acquire the encrypted random number sent by the data requester and the requester's data from the blockchain; the encrypted random number is obtained by the data requester encrypting the first random number using the public key of the data provider; The data sending module is used to send the encrypted random number and the requester data to the data provider, so that the data provider can determine the target off-chain data corresponding to the requester data and decrypt the encrypted random number using its own private key to obtain the first random number, and encrypt the target off-chain data using the negotiation key generated based on the first random number to obtain the encrypted off-chain data. The second data acquisition module is used to acquire the encrypted off-chain data returned by the data provider; The data upload module is used to report the encrypted off-chain data to the blockchain, so that the blockchain can decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. The device is further configured to initiate a polling operation on the oracle service platform smart contract to poll whether there is an off-chain data request in the oracle service platform smart contract; the off-chain data request is a request generated and sent to the oracle service platform smart contract after the data requester's smart contract responds to the business request initiated by the data requester; if the polling shows that there is an off-chain data request in the oracle service platform smart contract, a handshake operation is triggered with the data provider; a target notification based on the handshake operation with the data provider is sent to the oracle service platform smart contract, the target notification including a second random number generated by itself in the handshake operation and a third random number generated by the data provider, so that the data requester can obtain the target notification from the oracle service platform smart contract through the data requester's smart contract and generate the negotiation key using the first random number and the second and third random numbers in the target notification, and then encrypt the initial requester data using the negotiation key to obtain the encrypted requester data.

6. An off-chain data acquisition device, characterized in that, Applied to data providers, including: The data receiving module is used to receive encrypted random numbers obtained from the blockchain and requester data sent by the oracle service platform; the encrypted random number is data obtained by the data requester using the public key of the data provider to encrypt a first random number and then sending it to the blockchain. The data encryption module is used to determine the target off-chain data corresponding to the requester's data, and to decrypt the encrypted random number using its own private key to obtain the first random number, and to encrypt the target off-chain data using a negotiation key generated based on the first random number to obtain the encrypted off-chain data. The data return module is used to return the encrypted off-chain data to the oracle service platform, so that the blockchain can obtain the encrypted off-chain data from the oracle service platform and decrypt the encrypted off-chain data using the negotiation key generated based on the first random number sent by the data requester to obtain the target off-chain data. The device is further configured to initiate a polling operation on the oracle service platform smart contract through the oracle service platform to poll whether there is an off-chain data request in the oracle service platform smart contract. If the oracle service platform detects the existence of the off-chain data request in the oracle service platform smart contract, it triggers a handshake operation with the oracle service platform and sends a target notification generated after the handshake operation with the data provider to the oracle service platform smart contract. The target notification includes a second random number generated by the oracle service platform itself during the handshake operation and a third random number generated by the data provider. The data requester obtains the target notification from the oracle service platform smart contract through the data requester smart contract and uses the first random number, the second random number, and the third random number in the target notification to generate the negotiation key. Then, the data requester uses the negotiation key to encrypt the initial requester data to obtain the encrypted requester data. The off-chain data request is a request generated and sent to the oracle service platform smart contract by the data requester smart contract in response to a business request initiated by the data requester.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the off-chain data acquisition method as described in any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the off-chain data acquisition method as described in any one of claims 1 to 4.