Block chain data acquisition and real-time synchronization method and device, and medium
Through the open optimal oracle selection protocol and multi-channel data segmentation protocol, combined with the vertical and horizontal message routing mechanism, the real-time problem of blockchain data synchronization is solved, and efficient and secure data transmission is achieved.
Patent Information
- Application Number
- CN202510439475.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, the oracle model of blockchain cannot guarantee the real-time nature of data on-chain and on-chain propagation, resulting in a lack of real-time nature of data synchronization methods, affecting the performance optimization of blockchain.
The open optimal oracle selection protocol and multi-channel data segmentation protocol are adopted, combined with vertical and horizontal message routing mechanisms, real-time data synchronization is achieved through data scoring, signature encryption, data segmentation and access control.
It improves the real-time nature of data collection and linking, ensures the security and accuracy of data transmission, and meets the data requirements of high timeliness and high credibility.
Smart Images

Figure CN120296093A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for synchronizing on-chain and off-chain data in a blockchain, and particularly to a method for collecting and real-time synchronizing blockchain data. Background Art
[0002] The function of an oracle is to write external information into the blockchain to complete the data interconnection between the blockchain and the real world. It allows deterministic smart contracts to respond to the uncertain external world. It is the only way for smart contracts to interact with the outside world and is also the interface for the blockchain to interact with the real world. However, based on the blockchain oracle model, although it can ensure the secure collection of data, it cannot guarantee the real-time performance of data uploading and on-chain propagation.
[0003] Currently, the existing technologies for on-chain and off-chain data synchronization methods in the blockchain are relatively scarce. Most methods only simply ensure data security rather than achieving real-time performance. Therefore, the data real-time synchronization method is of great significance for optimizing the performance of the blockchain. Summary of the Invention
[0004] To make up for the lack of the traditional oracle model in real-time uploading and the problem of poor timeliness of on-chain data propagation, the present invention makes full use of the advantages of the open optimal oracle selection protocol and the multi-channel data segmentation protocol to further improve the real-time performance of the traditional oracle model.
[0005] To solve the above technical problems, the present invention proposes a method for collecting and real-time synchronizing blockchain data, including the following steps: S1, the review module scores the original data of the data source, and filters the original data according to the score to complete the data collection from the data source to the oracle; S2, the signature encryption module signs the filtered original data, packs and encrypts the original data and the data signature to further obtain encrypted data; S3, the data uploading module uploads the encrypted data to the blockchain to achieve the data transmission from the oracle to the blockchain; S4, the data segmentation module segments, reorganizes and obtains the uploaded data; S5, the access control module authorizes the access qualifications of the members accessing the data and determines the access permissions of the members; S6, sends the uploaded data to the members with access qualifications.
[0006] Among them, steps S1 to S3 ensure the real-time nature of data dissemination from the data source to the blockchain through a vertical routing mechanism. Steps S4 and S5 ensure the real-time nature of data transfer among various members on the blockchain through a horizontal routing mechanism. The vertical routing mechanism and the horizontal routing mechanism jointly constitute a horizontal and vertical message routing module to complete the real-time synchronization of blockchain data.
[0007] Furthermore, the data scoring and screening of the original data in step S1 include: The review module includes a subjective and objective mixed data review module and an open optimal oracle selection protocol. Among them, the subjective and objective mixed data review module comprehensively evaluates the data quality from both subjective and objective perspectives. The objective evaluation includes quantitatively evaluating the data in terms of data accuracy, consistency, timeliness, and reliability. The subjective evaluation is carried out from two perspectives: the objective evaluation score and the data completion degree for the task. The scores of the subjective evaluation and the objective evaluation are calculated with a mixed weight to obtain the initial data score. Further, the open optimal oracle selection protocol is used to calculate the final score of the data by combining the initial data score and the mixed weight of the distance from the data source to the oracle. The data sources and original data with the top 10% - 15% of the final scores are screened according to the final score of the data, completing the screening and scoring of the data to obtain high-quality and nearby data sources and data.
[0008] Furthermore, the processing of the data by the signature encryption module in step S2 includes: generating keys, signing, and verifying.
[0009] Furthermore, the data uploading module in step S3 includes an oracle smart contract and a blockchain smart contract. The process of data uploading is that the blockchain smart contract sends a user data request to the oracle smart contract, where the user data request includes a data request and a data source request. After receiving the user data request, the oracle smart contract sends the previously screened and encrypted data to the blockchain smart contract to complete the data uploading.
[0010] Furthermore, the process of data splitting, reorganizing, and obtaining by the data splitting module in step S4 includes: Splitting the uploaded data into block data; Assigning a unique content identifier to each of the block data as the fingerprint of the block data through a hash encryption algorithm, and then transmitting the block data with the fingerprint to the blockchain nodes; When blockchain members need to obtain the uploaded data, the blockchain nodes communicate with each other, stating the block data they own and the need for other block data, so as to find all the block data and reorganize them to achieve the real-time nature of data transfer among various members on the blockchain.
[0011] Preferably, in step S5, the access control module is a multi-channel access control module. The channels isolate information between different members. The process of authorizing the access requests of members in different channels through the multi-channel access control module includes: The on-chain member encrypts the on-chain data to construct an authorization ciphertext, obtains the channel where the member is located according to the public key list of the receiving members, and then distributes the authorization ciphertext to the channels where each receiving member is located; Construct an access control list according to the attributes of the channel. At the same time, establish a message index ciphertext, encrypt the message index ciphertext and the distribution list to generate a message ciphertext, and then embed the access control list into the message ciphertext; Save the ciphertext digest, signature and the message ciphertext to the blockchain.
[0012] In this process, for the embedded access control list, only the blockchain node or on-chain member with the private key can decrypt it normally to obtain the indexed message ciphertext and the distribution list, otherwise it cannot be decrypted, ensuring the security of the data.
[0013] The second aspect of the present invention provides a blockchain data collection and real-time synchronization device, including: A review module for scoring and screening the data of the data source; A signature encryption module for performing data signature and encryption on the data; A data on-chain module for putting the data on the chain; A data segmentation module for segmenting, reorganizing and obtaining the on-chain data; An access control module for authorizing the access qualifications of members accessing the data; A data distribution module for distributing the on-chain data to the members who have obtained the access qualifications.
[0014] The third aspect of the present invention provides a computer-readable storage medium storing a computer program, characterized in that the computer program executes the above method when running.
[0015] Compared with the prior art, the present invention has the following beneficial effects: 1. The blockchain data real-time synchronization method proposed by the present invention improves the real-time performance of data collection and data on-chain based on horizontal and vertical message routing, designing an open optimal oracle selection protocol and a multi-channel data segmentation protocol. At the same time, it combines the oracle and encryption algorithms to ensure the security of data collection and data on-chain; 2. Through vertical message routing, data sources with higher data quality and closer distances are preferentially selected for data collection, meeting the requirements of high timeliness and high credibility data. While implementing on-chain user access control, a horizontal routing mechanism is used to achieve secure storage, real-time uploading and downloading of on-chain data, improving the accuracy and security of data dissemination among users. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of blockchain data collection and real-time synchronization of the present invention.
[0017] Figure 2 It is a flowchart of data collection, on-chain and dissemination according to message routing of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0018] The present invention will be further described below in conjunction with the drawings and specific embodiments.
[0019] As Figures 1 - 2 shown, a blockchain data collection and real-time synchronization method according to this embodiment has the following steps: S1. Use a subjective and objective mixed data review module to score the raw data for different data sources. Specifically: The subjective and objective mixed data review module quantitatively evaluates the data quality from both subjective and objective perspectives. The objective evaluation includes quantitatively evaluating the data from aspects such as data accuracy, consistency, timeliness, and reliability. The subjective evaluation is carried out from two perspectives: the objective evaluation score and the task-oriented data completion degree. The scores of the subjective evaluation and the objective evaluation are calculated with a mixed weight to obtain the initial data score ; further calculate the final data score through an open optimal oracle selection protocol , specifically: Combine the initial data score and the distance from the data source to the oracle to calculate the mixed weight. The formula is:
[0020] Where represents the weight, and the subscripts 1 and 2 represent different or the same weights; According to the calculated final data score , select to establish connections with the top 10% - 15% of the data sources for data collection; preferably the top 10%; S2. Use a signature encryption module to sign the raw data, and then package and encrypt the data signature and the raw data to obtain encrypted data. The operations of the signature encryption module on the raw data include: generating keys, signing, and verifying, Generating keys includes: randomly generating two different prime numbers , , then calculate the product and the Euler's totient function , then randomly select an integer less than , and calculate the multiplicative inverse of modulo , and finally obtain the user's public key and private key ; The signing process includes: using the obtained private key and the information to be signed as input data, and outputting a preliminary signature ; The verification process includes: first calculating , then comparing with . If they are equal, the verification is successful. After successful verification, input the public key , the preliminary signature and the information to be signed to implement nested aggregated signature; where is the verification data relative to the information to be signed ; S3. Through the data on-chain module, the encrypted data is uploaded to the chain to obtain the on-chain data. The data on-chain module includes a blockchain smart contract and an oracle smart contract. The process of data on-chain is as follows: The blockchain smart contract sends a user data request to the oracle smart contract, where the user data request includes the data request and the data source request ; After the oracle smart contract receives , it sends the encrypted data to the blockchain smart contract to complete the real-time on-chain of the data; S4. Through the multi-channel data segmentation protocol, the on-chain data is segmented, recombined, and retrieved. The segmentation of the data facilitates the upload and download of the data and includes: After the data is on-chain, it will be segmented into block data through the multi-channel data segmentation protocol, expressed as:
[0021] where represents the on-chain data; The block data is encrypted using the SHA-256 hash encryption algorithm and is assigned a unique content identifier Used as the fingerprint of the block data, all block data is transmitted to the nearest node to achieve the purpose of quickly storing the data on the chain; When blockchain members need to obtain the data on the chain, the blockchain nodes communicate with each other about the block data they have , and each node has its own required block list and the owned block list . By comparing the required block list and the owned block list , all block data of the data on the chain can finally be found . All block data is recombined and restored, and then sent to other members in the channel. By splitting the data, fast uploading and downloading are achieved.
[0022] S5. The multi-channel access control module authorizes the access requests of members in different channels. Through the channel, information isolation is performed on different members. The process of qualification authorization includes: Members on the chain use the data on the chain as input, construct an authorization ciphertext using the above data encryption scheme, and distribute the authorization ciphertext to the channels where each receiving member is located; The blockchain obtains the channels where the members are located according to the public key list of the receiving members, and generates an access control list according to the attributes of the channels. The access control list defines the access members in the channel. Then, the message index ciphertext and the distribution list are encrypted to generate a message ciphertext, and the access control list is also embedded in the message ciphertext; Finally, the digest, signature, and message ciphertext are saved to the blockchain to complete the distribution of the message ciphertext.
[0023] In this process, for the embedded access control list, only the private key of the institutional node that meets the list can normally decrypt and obtain the indexed message ciphertext and the distribution list, otherwise it cannot be decrypted.
[0024] S6. Distribute data.
[0025] The above is only the preferred embodiment of the present application and is not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0026] Although the specific implementation manners of the present invention are described above, it is not a limitation to the protection scope of the present invention. Those skilled in the art should understand that based on the technical solution of the present invention, various modifications or deformations that do not require creative labor by those skilled in the art are still within the protection scope of the present invention.
Claims
1. A blockchain data collection and real-time synchronization method, characterized in that, It includes the following steps: S1, the review module scores the original data of the data source and filters the original data according to the scores; S2, the signature encryption module signs the filtered original data, packs and encrypts the original data and the data signature to obtain encrypted data; S3, the data on-chain module uploads the encrypted data to the chain to obtain on-chain data; S4, the data splitting module splits, reorganizes and obtains the on-chain data; S5, the access control module authorizes the access qualifications of the members accessing the data; S6, the data distribution module distributes the on-chain data to the members who have obtained access qualifications.
2. The blockchain data collection and real-time synchronization method according to claim 1, wherein, The data scoring and filtering of the original data in step S1 include: The review module includes a subjective and objective mixed data review module and an open optimal oracle selection protocol, The subjective and objective mixed data review module scores the original data to obtain an initial score, and the optimal oracle selection protocol calculates a final score in combination with the initial score. The review module filters the original data according to the final score.
3. A blockchain data collection and real-time synchronization method as claimed in claim 1, wherein, In step S2, the signature encryption module includes generating keys, signing and verifying the original data.
4. A blockchain data collection and real-time synchronization method according to claim 1, characterized in that, In step S3, the on-chain module includes an oracle smart contract and a blockchain smart contract; The packaged data is sent to the blockchain smart contract through the oracle smart contract to complete the process of uploading the data to the chain.
5. A blockchain data collection and real-time synchronization method according to claim 2, characterized in that, Calculating the final score of the data and filtering the original data include the following process: S11, calculate the mixed weight according to the initial score and the distance from the data source to the oracle to obtain the final score; S12, select the data sources with the top 10% - 15% of the final scores to establish connections to complete the filtering of the original data.
6. A blockchain data collection and real-time synchronization method as described in claim 4, characterized in that The steps of data on-chain include: S21, the blockchain smart contract sends a user data request to the oracle smart contract, where the user data request includes a data request and a data source request; S22, after receiving the user data request, the oracle smart contract sends the encrypted data to the blockchain smart contract according to the user data request.
7. The blockchain data acquisition and real-time synchronization method according to claim 1, characterized in that The process of the data splitting module splitting, reorganizing and obtaining the on-chain data includes: S31, split the on-chain data into block data; S32, assign a unique content identifier as the fingerprint of each block data through the hash encryption algorithm, and then transmit the block data with the fingerprint to the blockchain nodes; S33, when obtaining the on-chain data, the blockchain nodes communicate with each other about the block data they own, and finally find all the block data and reorganize the block data to restore it to the on-chain data.
8. A blockchain data collection and real-time synchronization method according to claim 1, characterized in that, The access control module is a multi-channel access control module. The process of the multi-channel access control module authorizing the access qualifications of users on different channels includes: S41, the channel isolates the information between different members. The on-chain members construct an authorized ciphertext through data encryption for the on-chain data, obtain the channels where the receiving members are located according to the public key list of the receiving members, and then distribute the authorized ciphertext to the channels where each receiving member is located; S42. Construct an access control list according to the attributes of the channel. At the same time, establish a message index ciphertext, encrypt the message index ciphertext and the distribution list to generate a message ciphertext, and then embed the access control list into the message ciphertext; S43. Save the ciphertext digest, signature and the message ciphertext to the blockchain.
9. A blockchain data collection and real-time synchronization device, characterized in that, Comprising: A review module for scoring and screening the data of the data source; A signature encryption module for performing data signature and encryption on the data; A data on-chain module for putting the data on the chain; A data splitting module for splitting, reorganizing and obtaining the on-chain data; An access control module for authorizing the access qualifications of the members accessing the data; A data distribution module for distributing the on-chain data to the members who have obtained the access qualifications.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program runs, it executes a blockchain data collection and real-time synchronization method according to any one of claims 1 to 8.