Data processing method and device based on block chain, electronic equipment and storage medium

By splitting and encrypting large amounts of data and leveraging the distributed storage characteristics of blockchain, the problems of data security and inefficiency in blockchain storage are solved, achieving efficient and secure data storage and management.

CN119311219APending Publication Date: 2025-01-14CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411355316.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In existing technologies, when storing and managing large amounts of data, blockchain cannot fully guarantee data security, and traditional storage methods are inefficient and cannot meet real-time requirements.

Method used

By splitting the data to be processed, multiple data blocks of preset size are generated. The locations of the sub-data blocks are not contiguous. The distributed storage characteristics of the blockchain are used to save the data blocks on the blockchain. At the same time, a random selection encryption algorithm is used to encrypt the data blocks.

Benefits of technology

It improves data security and storage efficiency, increases the difficulty of data restoration, enables efficient uploading and fast saving, and enhances the data's resistance to attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311219A_ABST
    Figure CN119311219A_ABST
Patent Text Reader

Abstract

The invention provides a data processing method and device based on a block chain, electronic equipment and a storage medium. The method comprises the following steps: acquiring to-be-processed data; splitting the to-be-processed data to obtain a plurality of data blocks with preset sizes; wherein the data block comprises a plurality of sub-data blocks, one sub-data block corresponds to data in a section of position range in the to-be-processed data, the sum of the data sizes of all the sub-data blocks is the data size of the to-be-processed data, and the position ranges of different sub-data blocks in the data block are discontinuous; and storing the data block on the block chain. According to the method provided by the invention, the cracking difficulty is increased by acquiring the discontinuous sub-data blocks in the position range, so that the security of data storage is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain, and in particular to a data processing method, device, electronic device, and storage medium based on blockchain. Background Art

[0002] With the rapid development of information technology, data volume is growing at an explosive rate. Traditional data storage and management methods face numerous challenges, including low data security, vulnerability to attacks, high storage costs, and inefficient management. Blockchain technology, as an emerging data storage and management technology, offers new solutions for large-scale data storage and management, thanks to its decentralized, tamper-proof, transparent, and anonymous nature.

[0003] However, when storing and managing large amounts of data on a blockchain, data security cannot be fully guaranteed. Therefore, improving the security of data on the blockchain is an urgent issue that needs to be addressed. Summary of the Invention

[0004] This application provides a blockchain-based data processing method, device, electronic device, and storage medium to improve the security of data on the blockchain.

[0005] In a first aspect, the present application provides a data processing method based on blockchain, comprising:

[0006] Get the data to be processed;

[0007] Splitting the data to be processed to obtain multiple data blocks of preset sizes; wherein each data block includes multiple sub-data blocks, each sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges of different sub-data blocks in the data block are discontinuous;

[0008] Save the data block to the blockchain.

[0009] Optionally, in the above method, the data to be processed is split to obtain multiple data blocks of preset sizes, including:

[0010] For each data block of a preset size, splitting a first sub-data block from the data to be processed according to the preset size of the data block, and writing the first sub-data block into the data block;

[0011] If the data size of the first sub-data block is smaller than the preset size of the data block, a second sub-data block is split from the data to be processed and the second sub-data block is written into the data block until the sum of the data sizes of the sub-data blocks in the data block is equal to the preset size of the data block, thereby obtaining a data block of the preset size.

[0012] Optionally, in the above method, for each data block of a preset size, splitting the first sub-data block from the data to be processed according to the preset size of the data block includes:

[0013] For each data block of a preset size, determining a starting position of a character position that has not been currently split in the data to be processed as a first starting position;

[0014] According to the preset size of the data block, starting from the first starting position of the data to be processed, the first sub-data block is split out.

[0015] Optionally, in the above method, if the data size of the first sub-data block is smaller than the preset size of the data block, splitting the second sub-data block from the data to be processed includes:

[0016] If the data size of the first sub-data block is smaller than the preset size of the data block, determining an end position in the position range corresponding to the first sub-data block as a first end position;

[0017] Randomly select a character position from the currently unsplit character positions after the first end position as the second starting position;

[0018] Determine the size to be written according to the data size of the first sub-data block and the preset size of the data block;

[0019] According to the size to be written, starting from the second starting point, split out the second sub-data block.

[0020] Optionally, the above method further includes:

[0021] The sub-data blocks split and written into any data block are determined as historical sub-blocks;

[0022] If the position range of the currently split sub-data block overlaps with the position range of the historical sub-block, the data of the overlapping portion in the currently split sub-data block will be removed.

[0023] Optionally, the above method further includes:

[0024] Determine the data type of the data to be processed;

[0025] According to the association relationship between the preset data type and the data block size, the data block size corresponding to the data type of the data to be processed is determined as the preset size of the data block.

[0026] Optionally, the above method further includes:

[0027] The number of data blocks corresponding to the data to be processed is determined according to the data size of the data to be processed and the preset size.

[0028] Optionally, the method above saves the data block to the blockchain, including:

[0029] For each data block, an encryption algorithm is randomly determined from a preset encryption algorithm database as a target encryption algorithm, and an encryption key corresponding to the target encryption algorithm is determined;

[0030] Encrypt the data block according to the target encryption algorithm and encryption key to obtain an encrypted data block;

[0031] The encrypted data block, as well as the target encryption algorithm and encryption key, are saved on the blockchain.

[0032] Optionally, the above method further includes:

[0033] Get the target encryption algorithm and encryption key from the blockchain;

[0034] According to the target encryption algorithm and encryption key, the encrypted data block is decrypted to obtain a data block.

[0035] Optionally, the above method further includes:

[0036] Obtain sub-data blocks from each data block;

[0037] According to the position range corresponding to the sub-data blocks, each sub-data block is spliced ​​to obtain the data to be processed.

[0038] In a second aspect, the present application provides a data processing device based on blockchain, comprising:

[0039] In a third aspect, the present application provides an electronic device, comprising:

[0040] processor and memory;

[0041] Memory stores computer-executable instructions;

[0042] The processor executes the computer-executable instructions stored in the memory, so that the electronic device performs a blockchain-based data processing method according to any one of the first aspects.

[0043] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement a blockchain-based data processing method as described in any one of the first aspects.

[0044] The blockchain-based data processing method, device, electronic device and storage medium provided by the present application obtain data to be processed; split the data to be processed to obtain multiple data blocks of preset sizes; wherein the data block includes multiple sub-data blocks, one sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges between different sub-data blocks in the data block are discontinuous; by obtaining data in different ranges from the data to be processed as sub-data blocks, and then obtaining data blocks through the sub-data blocks, the difficulty of restoring the data to be processed through the data blocks can be increased, thereby improving the security of the data, and the data blocks are saved on the blockchain. By obtaining sub-data blocks with discontinuous position ranges, the difficulty of cracking is increased, thereby improving the security of data storage, and at the same time, the data blocks to be processed are split and saved, and the distributed storage characteristics of the blockchain are utilized to achieve efficient uploading and rapid saving. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0046] Figure 1 A flowchart of a blockchain-based data processing method provided in an embodiment of the present application;

[0047] Figure 2 A flowchart of another blockchain-based data processing method provided in an embodiment of the present application;

[0048] Figure 3 A flowchart of a method for obtaining a data block provided in an embodiment of the present application;

[0049] Figure 4 A flowchart of a method for encrypting a data block using an encryption algorithm provided in an embodiment of the present application;

[0050] Figure 5 A schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of the present application;

[0051] Figure 6 A schematic diagram of the electronic device structure provided in an embodiment of the present application.

[0052] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0053] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0054] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0055] Currently, existing blockchain storage and management solutions for single, large-capacity data still have some shortcomings. Firstly, due to the characteristics of single, large-capacity data, traditional blockchain storage methods can lead to low data transmission and storage efficiency, making it difficult to meet real-time requirements. Secondly, existing data encryption methods are often fixed and easily cracked, making it difficult to fully guarantee data security.

[0056] The blockchain-based data processing method, device, electronic device and storage medium provided by the present application obtain data to be processed; split the data to be processed and obtain multiple data blocks of preset sizes; wherein the data block includes multiple sub-data blocks, one sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges between different sub-data blocks in the data block are discontinuous; by obtaining data in different ranges from the data to be processed as sub-data blocks, and then obtaining data blocks through the sub-data blocks, the difficulty of restoring the data to be processed through the data blocks can be increased, thereby improving the security of the data, and the data blocks are saved on the blockchain. By obtaining sub-data blocks with discontinuous position ranges, the difficulty of cracking is increased, thereby improving the security of data storage, and at the same time, the data blocks to be processed are split and saved, and the distributed storage characteristics of the blockchain are utilized to achieve efficient uploading and fast saving.

[0057] The execution entity of a blockchain-based data processing method provided in an embodiment of the present application can be a server. The server can be any server. This embodiment does not impose any particular restrictions on the implementation of the execution entity, as long as the execution entity can obtain the data to be processed; split the data to be processed into multiple data blocks of preset sizes; wherein each data block includes multiple sub-data blocks, each sub-data block corresponds to data within a range of positions in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges of different sub-data blocks in the data block are discontinuous; and the data blocks are stored on the blockchain.

[0058] Among them, blockchain is a distributed ledger technology whose core features include decentralization, transparency, security and immutability.

[0059] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0060] Figure 1 A data processing method based on blockchain is provided in the embodiment of this application. Figure 1 As shown, the method body can be a server, and this embodiment does not make any special restrictions here. Figure 1 As shown, the method includes:

[0061] S101: Obtain data to be processed.

[0062] Among them, the data to be processed refers to the data that needs to be uploaded to the chain, which is the data uploaded by the user.

[0063] S102. Split the data to be processed to obtain multiple data blocks of preset sizes; wherein the data block includes multiple sub-data blocks, each sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges between different sub-data blocks in the data block are discontinuous.

[0064] The preset data block size is user-defined and can be 500kb, 1M, etc. Different data block sizes can be preset for different types of data. For example, if the data to be processed is text data, the preset data block size is 500kb; if the data to be processed is audio data, the preset data block size is 1M.

[0065] The sizes of the data blocks may be consistent or inconsistent. For example, the data to be processed may be evenly divided according to a preset size to obtain the number of data blocks. Specifically, the number of data blocks may be calculated by dividing the size of the data to be processed by the preset size of the data blocks.

[0066] Sub-data blocks can be of the same or different sizes. Sub-data blocks represent data to be processed at different locations, and the locations of different sub-data blocks within a data block can be discontinuous. For example, a data block may contain two sub-data blocks: the first sub-data block contains bytes 0 to 6 of the data to be processed, and the second sub-data block contains bytes 10 to 18 of the data to be processed.

[0067] Among them, in the embodiment of this application, it also includes:

[0068] Determine the data type of the data to be processed;

[0069] According to the association relationship between the preset data type and the data block size, the data block size corresponding to the data type of the data to be processed is determined as the preset size of the data block.

[0070] The data type of the data to be processed may be a picture type, a video type, etc. Image type files are smaller than video type files, so the preset data block size of image type files may be smaller than the preset data block size of video type files.

[0071] The preset size of the data block can be any size, as long as the preset size of the data block is smaller than the size of the data to be processed.

[0072] When the data type to be processed is an image type, the data block size is 500kb. When the data type to be processed is a video type, the data block size is 1M.

[0073] The benefit of this setting is that by selecting the appropriate data block size based on the data type, more efficient and flexible data processing and storage can be achieved, thereby improving the overall performance of the system and user experience.

[0074] Among them, in the embodiment of this application, it also includes:

[0075] The number of data blocks corresponding to the data to be processed is determined according to the data size of the data to be processed and the preset size.

[0076] If the data blocks are of the same size, that is, the data to be processed is divided equally to obtain data blocks, then the data size of the data to be processed is divided by the preset size to obtain the number of data blocks corresponding to the data to be processed. If the data size of the data to be processed is 10M and the preset size is 1M, then the number of data blocks corresponding to the data to be processed is 10M divided by 1M, which is 10, so the number of data blocks corresponding to the data to be processed is 10. If the data size of the data to be processed is 10.5M and the preset size is 1M, then the number of data blocks corresponding to the data to be processed is 10M divided by 1M, which is 10.5, so the number of data blocks corresponding to the data to be processed is 11, and the last data block is 0.5M in size.

[0077] If the sizes of the data blocks are inconsistent, that is, the data to be processed is not evenly divided to obtain data blocks, the preset size can be any value, as long as the sum of all data blocks of the preset sizes is the size of the data to be processed. For example, if the data size of the data to be processed is 5M, and the preset sizes are 1M, 500kb, 500kb, and 2M, then the number of data blocks corresponding to the data to be processed is 4.

[0078] The advantage of this setting is that it can flexibly adjust the number of data blocks according to the preset size and the size of the data to be processed, thereby achieving more efficient and flexible data processing and storage, thereby improving the overall performance of the system and user experience.

[0079] In the embodiment of the present application, the data to be processed is split into multiple data blocks of preset sizes, including:

[0080] For each data block of a preset size, splitting a first sub-data block from the data to be processed according to the preset size of the data block, and writing the first sub-data block into the data block;

[0081] If the data size of the first sub-data block is smaller than the preset size of the data block, a second sub-data block is split from the data to be processed and the second sub-data block is written into the data block until the sum of the data sizes of the sub-data blocks in the data block is equal to the preset size of the data block, thereby obtaining a data block of the preset size.

[0082] Among them, the sizes of the first sub-data block and the second sub-data block, as well as the subsequent sub-data blocks, can be different or the same, but the first sub-data block, the second sub-data block, and the other sub-data blocks all need to be smaller than the size of the data to be processed. For example, if the data to be processed can be 1M, the first sub-data block is 500kb, the second sub-data block is 300kb, and the other sub-data blocks are 200kb. It can also be: if the data to be processed can be 1M, the first sub-data block is 500kb, and the second sub-data block is 500kb.

[0083] The size of the sub-data block also needs to be smaller than the preset size of the data block. If the preset size of the data block is 1M, a 50kb data block can be split from the data to be processed as the first sub-data block. Since the 50kb data block is smaller than 1M, a 100kb data block is split from the data to be processed as the second sub-data block, and so on, until the sum of the sizes of all sub-data blocks is equal to 1M.

[0084] The advantage of this setting is that by gradually filling the data blocks, it can ensure that each data block is fully utilized, reducing idleness and waste in data processing, and at the same time ensuring that the size of the obtained data block meets the preset size of the data block.

[0085] In the embodiment of the present application, for each data block of a preset size, splitting the first sub-data block from the data to be processed according to the preset size of the data block includes:

[0086] For each data block of a preset size, determining a starting position of a character position that has not been currently split in the data to be processed as a first starting position;

[0087] According to the preset size of the data block, starting from the first starting position of the data to be processed, the first sub-data block is split out.

[0088] The character position represents the position of the nth byte in the data to be processed, where n can be any positive integer that does not exceed the range of the data to be processed. The first starting position represents the position of the first byte of the data to be processed. For example, if the range of the data to be processed is 0kb-1024kb, then 0kb is the first starting position.

[0089] If the size of the data to be processed is 2M, the position range of the data to be processed is 0kb-2048kb, the preset size of the data block is 1M, and the size of the first sub-data block is 50kb, then starting from 0kb of the data to be processed, take bytes 0kb-50kb as the first sub-data block.

[0090] The advantage of such a setting is that by splitting from the first starting position, all the data to be processed can be split, thus avoiding omission of data.

[0091] In this embodiment of the present application, if the data size of the first sub-data block is smaller than the preset size of the data block, splitting the second sub-data block from the data to be processed includes:

[0092] If the data size of the first sub-data block is smaller than the preset size of the data block, determining an end position in the position range corresponding to the first sub-data block as a first end position;

[0093] Randomly select a character position from the currently unsplit character positions after the first end position as the second starting position;

[0094] Determine the size to be written according to the data size of the first sub-data block and the preset size of the data block;

[0095] According to the size to be written, starting from the second starting point, split out the second sub-data block.

[0096] Among them, if the data size of the first sub-data block is equal to the preset size of the data block, then the first data block is used as the data block. For example: if the preset size of the data block is 500kb and the data size of the first sub-data block is 500kb, then the first sub-data block is used as the data block.

[0097] If the data size of the first sub-data block is smaller than the preset size of the data block, it is necessary to confirm the second starting position to obtain the second sub-data block. For example, the first end position can be moved back by the data size of the first sub-data as the first end position. For example, if the size of the data to be processed is 2M, the position range of the data to be processed is 0kb-2048kb, the preset size of the data block is 1M, and the size of the first sub-data block is 50kb, then starting from 0kb of the data to be processed, take 50kb of bytes, that is, 0kb-49kb of bytes as the first sub-data block, then the position of 50kb in the data to be processed is the first end position. 50kb-2048kb is the position of the unsplit characters. Select any character position from the remaining 50kb-2048kb as the second starting position, for example, it can be 53kb. If the size of the second sub-data block is 30kb, then starting from 53kb, take 30kb of bytes, that is, 53kb-83kb, as the second sub-data block.

[0098] The advantage of this setting is that the location range of the sub-data blocks in each data block is not continuous, which can increase the difficulty of restoration and enhance data security. At the same time, it reserves space for subsequent operations such as encryption of location information, which can further protect the data.

[0099] Among them, in the embodiment of this application, it also includes:

[0100] The sub-data blocks split and written into any data block are determined as historical sub-blocks;

[0101] If the position range of the currently split sub-data block overlaps with the position range of the historical sub-block, the data of the overlapping portion in the currently split sub-data block will be removed.

[0102] A historical sub-block refers to a data sub-block that already exists in other data blocks and has been split into part of other data blocks. For example, if the size of the data to be processed is 2MB, the position range of the data to be processed is 0kb-2048kb (excluding 2048kb), the preset size of the data block is 500kb, and the size of the first sub-block is 270kb, then starting from 0kb of the data to be processed, 270kb of bytes, that is, bytes 0kb-269kb, are taken as the first sub-block. At the same time, the size of the second sub-data block is 230kb, so you can arbitrarily select a position from the remaining 270kb-2048kb (excluding 2048kb) as the starting point of the second sub-data block (for example, 279kb), and take bytes with a length of 230kb, that is, 279kb (including 279kb)-508kb (including 508kb), as the second sub-data block. The sum of the sizes of the first sub-data block and the second sub-data block is equal to the first data block. At this time, the first sub-data block and the second sub-data block are both historical sub-blocks. At this time, when it is necessary to obtain the second data block, if the size of the second data block is 500kb and the size of the third sub-data block is 11kb, then theoretically, 11kb is taken starting from 270kb, that is, 270kb (inclusive) - 280kb (inclusive) is taken as the third sub-data block. However, 279kb (inclusive) - 280kb (inclusive) is already included in the second sub-data block, and the second sub-data block is a historical sub-block. Therefore, the position range of the currently split sub-data block overlaps with the position range of the historical sub-block. Therefore, 279kb (inclusive) - 280kb (inclusive) needs to be removed, and 270kb (inclusive) - 278kb (inclusive) and 509kb (inclusive) - 510kb (inclusive) are taken as the third sub-data block.

[0103] The benefit of this setting is to prevent the position range of the currently split sub-data block from overlapping with the position range of the historical sub-block, which would cause the data in the data block to become invalid.

[0104] S103: Save the data block to the blockchain.

[0105] Among them, data blocks can be stored on the blockchain, or traditional centralized storage systems or distributed file systems (such as HDFS (Hadoop Compatible File System) and Ceph (Ceph Storage Cluster)) can be used instead of blockchain storage.

[0106] In this embodiment of the present application, saving the data block to the blockchain includes:

[0107] For each data block, an encryption algorithm is randomly determined from a preset encryption algorithm database as a target encryption algorithm, and an encryption key corresponding to the target encryption algorithm is determined;

[0108] Encrypt the data block according to the target encryption algorithm and encryption key to obtain an encrypted data block;

[0109] The encrypted data block, as well as the target encryption algorithm and encryption key, are saved on the blockchain.

[0110] Among them, the encryption algorithm database may include multiple symmetric encryption algorithms, such as: AES-256 algorithm (Advanced Encryption Standard 256-bit), 3DES algorithm (Triple Data Encryption Standard), Blowfish algorithm, Twofish algorithm, RC4 (Rivest Cipher 4, Rivest encryption algorithm 4) algorithm.

[0111] The encryption algorithm database may also include a variety of asymmetric encryption algorithms, such as: RSA (Rivest-Shamir-Adleman) algorithm, ECC (Elliptic Curve Cryptography), DSA (Digital Signature Algorithm) algorithm, ElGamal algorithm, and Diffie-Hellman (Diffie-Hellman key exchange algorithm) algorithm.

[0112] The encryption algorithm database can also be a mixture of symmetric encryption algorithms and asymmetric encryption algorithms.

[0113] Different data blocks can have different encryption algorithms. For example, the first data block may have an encryption algorithm of AES-256 and the second data block may have an encryption algorithm of RC4. The encryption algorithm for each data block can be randomly determined from a preset encryption algorithm database and used as the target encryption algorithm for that data block.

[0114] After confirming the target encryption algorithm, the encryption key corresponding to the target encryption algorithm can be obtained by calling the encryption algorithm library. For symmetric encryption algorithms, the secret key includes a public key and a private key pair. For example, if the target encryption algorithm is RC4, the RC4 algorithm library is called to obtain the RC4 public key and RC4 private key. The RC4 public key is used to encrypt the data block to obtain the encrypted data block. The RC4 private key, the name of the RC4 algorithm, and the encrypted data block are then saved to the blockchain so that the encrypted data block can be decrypted using the RC4 private key to obtain the data block. For symmetric encryption algorithms, the secret key includes the public key. For example, if the target encryption algorithm is RSA, the RSA algorithm library is called to obtain the RSA public key and RSA private key. The RSA public key is used to encrypt the data block to obtain the encrypted data block. The RSA public key, RSA private key, the name of the RSA algorithm, and the encrypted data block are then saved to the blockchain so that the encrypted data block can be decrypted using the RSA public key.

[0115] Time and other parameters can be input as parameters to call the corresponding algorithm and obtain the key. The input parameters can be different each time, so that even if the same algorithm is used, different keys can be generated, thereby increasing the difficulty of data decryption and protecting data security.

[0116] The advantage of this setting is that by selecting different encryption algorithms for different data blocks, the difficulty of deciphering the encrypted data blocks is increased, which can better protect data from being leaked and stolen.

[0117] Among them, in the embodiment of this application, it also includes:

[0118] Get the target encryption algorithm and encryption key from the blockchain;

[0119] According to the target encryption algorithm and encryption key, the encrypted data block is decrypted to obtain a data block.

[0120] Among them, the target encryption algorithm and encryption key can be saved together with the data block or separately. For example, the encryption key, target encryption algorithm and encryption key are saved through database A on the blockchain, and the data block is saved through data block B on the blockchain.

[0121] The encryption key and target encryption algorithm can be saved through database A on the blockchain, and the data blocks can be saved through traditional centralized storage. The encryption key and target encryption algorithm can be saved through traditional centralized storage.

[0122] The benefits of this setup include: improving data security and privacy, preventing unauthorized access and tampering; streamlining the decryption process, improving data processing efficiency, and enabling real-time decryption and processing; supporting dynamic updates and diverse encryption algorithms and key management methods, enhancing system flexibility and adaptability; and leveraging the distributed consensus and immutability of blockchain to improve system reliability and fault tolerance.

[0123] Among them, in the embodiment of this application, it also includes:

[0124] Obtain sub-data blocks from each data block;

[0125] According to the position range corresponding to the sub-data blocks, each sub-data block is spliced ​​to obtain the data to be processed.

[0126] In response to a user's request to obtain original data (ie, data to be processed), all data blocks corresponding to the original data are obtained, and all sub-data blocks are obtained from the data blocks.

[0127] The position range indicates the position of the sub-data block in the original data, and the sub-data blocks are spliced ​​according to their position and order in the original data. For example, the original data size is 2M, the original data range is 0kb-2048kb (excluding 2048kb), and the data block includes data block A and data block B. Data block A includes: sub-data block A1 (position range is 0kb-50kb, representing the position range of sub-data block A1 in the original data), data block A2 (position range is 80kb-1000kb), and data block B includes: sub-data block B1 (position range is 51kb-79kb), sub-data block B2 (position range is 1001kb-2048kb). The original data can be obtained by splicing in the order of A1 (position range is 0kb-50kb)-B1 (position range is 51kb-79kb)-A2 (position range is 80kb-1000kb)-B2 (position range is 1001kb-2048kb).

[0128] For example, the original data size is 2MB, the original data range is 0kb-2048kb, and the data block includes data block A and data block B. Data block A contains: sub-data block A1 (position range 0kb-50kb) + (position range 80kb-90kb), data block A2 (position range 91kb-1000kb), data block B contains: sub-data block B1 (position range 51kb-79kb), sub-data block B2 (position range 1001kb-2048kb). The original data can be obtained by concatenating in the order of A1 (position range 0kb-50kb) - B1 (position range 51kb-79kb) - A1 (position range 80kb-90kb) - A2 (position range 91kb-1000kb) - B2 (position range 1001kb-2048kb). The advantage of this setting is that by splicing according to the position range of the sub-data blocks, the original data to be processed can be accurately restored, the integrity and consistency of the data can be ensured, and all sub-data blocks can be correctly spliced ​​to prevent data loss or omission, so that the original data to be processed can be successfully obtained.

[0129] The embodiment of the present application provides a blockchain-based data processing method, which increases the difficulty of restoring the data to be processed through the data blocks by obtaining data in different ranges from the data to be processed as sub-data blocks, and then obtains data blocks through the sub-data blocks, thereby improving data security. At the same time, the data blocks to be processed are split and saved, and divided into data blocks, which can utilize the distributed storage characteristics of the blockchain to achieve efficient uploading and fast saving.

[0130] Figure 2 This is a flow chart of another data processing method based on blockchain provided in an embodiment of the present application. Figure 2 As shown, the execution subject of this method can be a server, and this embodiment does not impose any special restrictions here. Figure 2 As shown, the method includes:

[0131] S201: Receive the file uploaded by the user and calculate the hash value of the file.

[0132] S202: Determine the size of the split data blocks, the number of data blocks, and the unique identifier of the data blocks according to the file type and file size.

[0133] If the file type is video, the size of the data chunk is 1M or 2M. If the file type is image, the size of the data chunk is 500kb. Other values ​​are also possible.

[0134] If the file size is 10.5M, the file type is video type, and the split data block size is 2M, then the data block sizes are 2M, 2M, 2M, 2M, 2M, and 0.5M, and the number of data blocks is 6.

[0135] A pseudo-random number generator (PRNG) is used to generate a unique identifier (such as a UUID (Universally Unique Identifier)) for each data block.

[0136] S203. Randomly generate split bytes and skip bytes for splitting the file to obtain sub-data blocks, so that when the sum of the sizes of the sub-data blocks equals the data block size, the sub-data blocks are merged to obtain data blocks and data block information.

[0137] The data block information includes the file's hash value, the data block identifier, and the location information of the sub-data blocks within the data block. The data block identifiers are obtained in the order in which they are obtained. For example, the first data block obtained is numbered 1, and the second data block obtained is numbered 2. The location information of the sub-data blocks within the first data block can range from 0 bits to 800 bits.

[0138] Figure 3 A flowchart of a method for obtaining a data block provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the number of split bytes 1 is randomly generated, and the number of bytes corresponding to the number of split bytes 1 is split from the file as split byte 1, and split byte 1 is placed in the data block. Since the size of split byte 1 is smaller than the data block size, skip byte 1 is randomly generated, and the number of bytes corresponding to the random skip byte 1 is skipped. Then, split byte 2 is randomly generated, and the number of sections corresponding to the number of split bytes 2 is split from the file as split byte 2, and split byte 2 is placed in the data block. At this time, the sum of the size of split byte 1 and the size of split byte 2 is smaller than the size of the data block, so skip byte 2 is generated. And so on. Finally, the sum of the size of split byte 1, the size of split byte 2, and the size of split byte 3 is equal to the size of the data block. Therefore, split byte 1, split byte 2, and split byte 3 are concatenated to obtain data block 1. And so on. Data block 2 is obtained from the remaining unsplit bytes of the file until the file is split and all data blocks are obtained.

[0139] S204: Randomly select an encryption algorithm from the encryption algorithm library, generate a key, and then use the key to encrypt the data block to obtain an encrypted data block.

[0140] Figure 4The embodiment of the present application provides a method for encrypting a data block using an encryption algorithm, such as Figure 4 As shown, for each generated data block, it is necessary to select any encryption algorithm from the encrypted data block, and then obtain the key according to the encryption algorithm, and encrypt the data block with the key.

[0141] S205: Save the encrypted data block, encryption algorithm, and key on the blockchain.

[0142] S206: Receive a file acquisition request from the user, determine the data block from the blockchain according to the file identifier in the file acquisition request, and restore the data block to a file.

[0143] The file identifier can be a file ID or a file hash value, as long as the data block corresponding to the file on the blockchain can be confirmed.

[0144] Receive a file request from the user, determine the data block from the blockchain based on the file identifier in the file request, and restore the data block to a file as follows:

[0145] According to the file identifier in the file acquisition request, all encrypted data blocks corresponding to the file identifier are confirmed, the encrypted data blocks are decrypted using the key to obtain the data blocks, and the split bytes in the data blocks are combined in the original order of the file to restore the file.

[0146] Another blockchain-based data processing method provided in an embodiment of this application improves storage and transmission efficiency. By generating random split bytes and skip bytes, files are split into multiple small data blocks. This method leverages the distributed storage capabilities of blockchain to achieve efficient data transmission and storage. This not only improves data processing efficiency but also reduces storage costs. It also enhances data security by encrypting the split small data blocks using different encryption algorithms drawn from a library of encryption algorithms, ensuring data security during transmission and storage. This improves data resistance and security.

[0147] Figure 5 This is a diagram showing an example of the structure of a data processing device based on blockchain provided in an embodiment of the present application. Figure 5 As shown, the blockchain-based data processing device 50 includes: an acquisition module 501, a obtaining module 502, and a storage module 503.

[0148] in:

[0149] An acquisition module 501 is used to acquire data to be processed;

[0150] Obtaining module 502 is configured to split the data to be processed into a plurality of data blocks of a preset size; wherein each data block includes a plurality of sub-data blocks, each sub-data block corresponds to data within a position range of the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges of different sub-data blocks in the data block are discontinuous;

[0151] The saving module 503 is used to save the data block to the blockchain.

[0152] In one embodiment, obtaining module 502 includes:

[0153] a writing unit, configured to, for each data block of a preset size, split a first sub-data block from the data to be processed according to the preset size of the data block, and write the first sub-data block into the data block;

[0154] The first obtaining unit is used to split a second sub-data block from the data to be processed if the data size of the first sub-data block is smaller than the preset size of the data block, and write the second sub-data block into the data block until the sum of the data sizes of the sub-data blocks in the data block is equal to the preset size of the data block, thereby obtaining a data block of the preset size.

[0155] In a possible implementation, the writing unit is specifically configured to:

[0156] For each data block of a preset size, determining a starting position of a character position that has not been currently split in the data to be processed as a first starting position;

[0157] According to the preset size of the data block, starting from the first starting position of the data to be processed, the first sub-data block is split out.

[0158] In a possible implementation, the writing unit is specifically configured to:

[0159] If the data size of the first sub-data block is smaller than the preset size of the data block, determining an end position in the position range corresponding to the first sub-data block as a first end position;

[0160] Randomly select a character position from the currently unsplit character positions after the first end position as the second starting position;

[0161] Determine the size to be written according to the data size of the first sub-data block and the preset size of the data block;

[0162] According to the size to be written, starting from the second starting point, split out the second sub-data block.

[0163] In a possible implementation, the writing unit is specifically configured to:

[0164] The sub-data blocks split and written into any data block are determined as historical sub-blocks;

[0165] If the position range of the currently split sub-data block overlaps with the position range of the historical sub-block, the data of the overlapping portion in the currently split sub-data block will be removed.

[0166] In a possible implementation, the writing unit is specifically configured to:

[0167] Determine the data type of the data to be processed;

[0168] According to the association relationship between the preset data type and the data block size, the data block size corresponding to the data type of the data to be processed is determined as the preset size of the data block.

[0169] In a possible implementation, the writing unit is specifically configured to:

[0170] The number of data blocks corresponding to the data to be processed is determined according to the data size of the data to be processed and the preset size.

[0171] In one embodiment, the saving module 503 includes:

[0172] a determination unit, configured to randomly determine, for each data block, an encryption algorithm from a preset encryption algorithm database as a target encryption algorithm, and determine an encryption key corresponding to the target encryption algorithm;

[0173] The second obtaining unit is used to encrypt the data block according to the target encryption algorithm and the encryption key to obtain an encrypted data block;

[0174] The storage unit is used to save the encrypted data block, the target encryption algorithm and the encryption key to the blockchain.

[0175] In a possible implementation, the storage unit is specifically configured to:

[0176] Get the target encryption algorithm and encryption key from the blockchain;

[0177] According to the target encryption algorithm and encryption key, the encrypted data block is decrypted to obtain a data block.

[0178] In a possible implementation, the storage unit is specifically configured to:

[0179] Obtain sub-data blocks from each data block;

[0180] According to the position range corresponding to the sub-data blocks, each sub-data block is spliced ​​to obtain the data to be processed.

[0181] Figure 6This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 6 As shown, the electronic device 60 includes:

[0182] The electronic device 60 may include one or more processors 601 , one or more computer-readable storage media memories 602 , a communication component 603 , and other components. The processor 601 , the memory 602 , and the communication component 603 are connected via a bus 604 .

[0183] During the specific implementation process, at least one processor 601 executes the computer execution instructions stored in the memory 602, so that at least one processor 601 executes the above blockchain-based data processing method.

[0184] The specific implementation process of the processor 601 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.

[0185] In the above Figure 6 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASICs), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present invention may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.

[0186] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory.

[0187] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be classified into address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.

[0188] In some embodiments, a computer program product is further proposed, comprising a computer program or instructions, which, when executed by a processor, implement the steps of any of the above-mentioned blockchain-based data processing methods.

[0189] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.

[0190] It should be further noted that, although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps may be performed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but may be performed at different times. The execution order of these sub-steps or stages is not necessarily to be performed in sequence, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0191] It should be understood that the above-described device embodiments are merely illustrative, and the device of the present application may also be implemented in other ways. For example, the division of units / modules in the above-described embodiments is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0192] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present application may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules.

[0193] If the integrated unit / module is implemented in hardware, the hardware may be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0194] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0195] In the above embodiments, the description of each embodiment has its own focus. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0196] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0197] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A data processing method based on blockchain, characterized in that: The method comprises: Get the data to be processed; The data to be processed is split to obtain a plurality of data blocks of preset sizes; wherein the data block includes a plurality of sub-data blocks, one sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all the sub-data blocks is the data size of the data to be processed, and the position ranges between different sub-data blocks in the data block are discontinuous; The data block is saved on the blockchain.

2. The method according to claim 1, characterized in that The step of splitting the data to be processed to obtain a plurality of data blocks of preset sizes includes: For each data block of a preset size, splitting a first sub-data block from the data to be processed according to the preset size of the data block, and writing the first sub-data block into the data block; If the data size of the first sub-data block is smaller than the preset size of the data block, a second sub-data block is split from the data to be processed and the second sub-data block is written into the data block until the sum of the data sizes of the sub-data blocks in the data block is equal to the preset size of the data block, thereby obtaining a data block of the preset size.

3. The method according to claim 2, characterized in that For each data block of a preset size, splitting a first sub-data block from the data to be processed according to the preset size of the data block includes: For each data block of a preset size, determining a starting position of a character position that is not currently split in the data to be processed as a first starting position; According to the preset size of the data block, a first sub-data block is split out starting from the first starting position of the data to be processed.

4. The method according to claim 3, characterized in that If the data size of the first sub-data block is smaller than the preset size of the data block, splitting a second sub-data block from the data to be processed comprises: If the data size of the first sub-data block is smaller than the preset size of the data block, determining the end position in the position range corresponding to the first sub-data block as the first end position; Randomly select a character position from the currently unsplit character positions after the first end position as the second start position; Determining a size to be written according to the data size of the first sub-data block and a preset size of the data block; According to the size to be written, starting from the second starting point, a second sub-data block is split out.

5. The method according to claim 4, characterized in that Also includes: Determine the sub-data block split and written into any data block as a historical sub-block; If the position range of the sub-data block currently split out overlaps with the position range of the historical sub-block, the data of the overlapping part in the sub-data block currently split out is removed.

6. The method according to claim 1, characterized in that Also includes: Determine the data type of the data to be processed; According to the association relationship between the preset data type and the data block size, the data block size corresponding to the data type of the to-be-processed data is determined as the preset size of the data block.

7. The method according to claim 6, characterized in that Also includes: The number of data blocks corresponding to the data to be processed is determined according to the data size of the data to be processed and the preset size.

8. The method according to claim 1, characterized in that The step of saving the data block to the blockchain includes: For each data block, randomly determine an encryption algorithm from a preset encryption algorithm database as a target encryption algorithm, and determine an encryption key corresponding to the target encryption algorithm; Encrypting the data block according to the target encryption algorithm and the encryption key to obtain an encrypted data block; The encrypted data block, the target encryption algorithm and the encryption key are saved on the blockchain.

9. The method according to claim 8, characterized in that Also includes: Obtaining the target encryption algorithm and encryption key from the blockchain; The encrypted data block is decrypted according to the target encryption algorithm and the encryption key to obtain the data block.

10. The method according to claim 9, characterized in that Also includes: Acquire a sub-data block from each of the data blocks; According to the position range corresponding to the sub-data blocks, each of the sub-data blocks is spliced ​​to obtain the data to be processed.

11. A data processing device based on blockchain, characterized in that: include: An acquisition module is used to acquire data to be processed; An obtaining module is used to split the data to be processed to obtain a plurality of data blocks of preset sizes; wherein the data block includes a plurality of sub-data blocks, one sub-data block corresponds to data within a position range in the data to be processed, the sum of the data sizes of all sub-data blocks is the data size of the data to be processed, and the position ranges between different sub-data blocks in the data block are discontinuous; The saving module is used to save the data block on the blockchain.

12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 10 when executed by a processor.