Blockchain-based data sharing method and device, storage medium and electronic device

By segmenting large data files into target data blocks and storing them in a distributed storage system, the problem of sharing large data files on the blockchain is solved, achieving the effect of sharing large data files on the blockchain while ensuring data security and access rights for legitimate users.

CN115017123BActive Publication Date: 2026-05-05Fisherman Information Technology Co Ltd
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Fisherman Information Technology Co Ltd
Filing Date
2022-04-29
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing technologies make it difficult to share large data files on the blockchain, as the storage capacity of the blockchain cannot directly store large data files such as images, audio, and video.

Method used

The big data file is divided into target data blocks, stored in a distributed storage system, and its location identifier is recorded on the blockchain. The target application then obtains the data block address to reconstruct the file.

Benefits of technology

It enables the sharing of large data files on the blockchain, reduces the storage pressure on the blockchain, and ensures data security and access rights for legitimate users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115017123B_ABST
    Figure CN115017123B_ABST
Patent Text Reader

Abstract

This application discloses a data sharing method, apparatus, storage medium, and electronic device based on blockchain. The method includes: obtaining the location identifier of a target file from the blockchain ledger through a target application; determining the address of each target data block based on the location identifier of the target file and a target mapping relationship, wherein the target mapping relationship indicates the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block resides; obtaining the corresponding target data block from a distributed storage system based on the address of each target data block, obtaining at least one target data block; and determining the target file through the at least one target data block. This application solves the problem of difficulty in sharing large data files on a blockchain in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and more specifically, to a blockchain-based data sharing method, apparatus, storage medium, and electronic device. Background Technology

[0002] Because blockchain features data that is difficult to tamper with and is decentralized, the information recorded is more authentic and reliable. Blockchain can be used to store data and help solve the problem of mutual distrust between parties.

[0003] It should be noted that, due to the small capacity of data blocks on the blockchain, in related technologies, blockchains for virtual assets mainly store transaction information, while blockchains for information traceability can only store traceability information for sharing. It is difficult to share large data files such as images, audio, and video through the blockchain.

[0004] There is currently no effective solution to the problem of sharing large data files on the blockchain in related technologies. Summary of the Invention

[0005] This application provides a data sharing method, apparatus, storage medium, and electronic device based on blockchain to solve the problem of difficulty in sharing big data files on the blockchain in related technologies.

[0006] According to one aspect of this application, a blockchain-based data sharing method is provided. The method includes: obtaining a location identifier of a target file from a blockchain ledger via a target application, wherein the target file includes at least one target data block, each target data block being stored in a node of a distributed storage system; determining the address of each target data block based on the location identifier of the target file and a target mapping relationship, wherein the target mapping relationship indicates the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block resides; obtaining the corresponding target data block from the distributed storage system based on the address of each target data block, thereby obtaining at least one target data block; and determining a target file using the at least one target data block.

[0007] Optionally, the target server stores multiple mapping relationships corresponding to multiple files, and the multiple mapping relationships include the target mapping relationship corresponding to the target file. Before determining the address of each target data block according to the location identifier of the target file and the target mapping relationship, the method further includes: obtaining the target mapping relationship from the multiple mapping relationships stored in the target server according to the location identifier of the target file.

[0008] Optionally, each target data block is a data block encrypted with a first key. Determining the target file through at least one target data block includes: decrypting the target data block with the first key to obtain a decrypted data block; if there is only one decrypted data block, determining the decrypted data block as the target file; if there are two or more decrypted data blocks, combining all the decrypted data blocks into one data block and determining the combined data block as the target file.

[0009] Optionally, the target file is a file encrypted with the second key. If there is only one decrypted data block, determining the decrypted data block as the target file includes: decrypting the data block with the second key to obtain the target file. If there are two or more decrypted data blocks, combining all the decrypted data blocks into one data block and determining the combined data block as the target file includes: decrypting the combined data block with the second key to obtain the target file.

[0010] Optionally, obtaining the location identifier of the target file from the blockchain ledger through the target application includes: detecting whether the target application has file access permission, wherein the file access permission is the access permission to the target file; if the target application has file access permission, obtaining a first key and a second key, and obtaining the location identifier of the target file from the blockchain ledger.

[0011] Optionally, before obtaining the location identifier of the target file from the blockchain ledger through the target application, the method further includes: receiving the file to be stored, determining at least one data block smaller than a preset capacity based on the file to be stored, and storing each data block in a node of the distributed storage system; determining the location identifier of the file to be stored, determining the address of the node where the data block is located as the address of the data block, and establishing a mapping relationship between the location identifier of the file to be stored and the address of at least one data block; and storing the location identifier of each file to be stored in a block of the blockchain.

[0012] Optionally, receiving a file to be stored and determining at least one data block smaller than a preset capacity based on the file to be stored includes: determining whether the data volume of the file to be stored is greater than the preset capacity; if the data volume of the file to be stored is greater than the preset capacity, dividing the file to be stored into at least one data block smaller than the preset capacity; if the data volume of the file to be stored is less than or equal to the preset capacity, determining the file to be stored as a single data block.

[0013] According to another aspect of this application, a blockchain-based data sharing device is provided. The device includes: a first acquisition unit, configured to acquire a location identifier of a target file from a blockchain ledger via a target application, wherein the target file includes at least one target data block, and each target data block is stored in a node of a distributed storage system; a first determination unit, configured to determine the address of each target data block based on the location identifier of the target file and a target mapping relationship, wherein the target mapping relationship indicates the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block is located; a second acquisition unit, configured to acquire corresponding target data blocks from the distributed storage system according to the addresses of each target data block, thereby obtaining at least one target data block; and a second determination unit, configured to determine a target file based on the at least one target data block.

[0014] According to another aspect of the present invention, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored program, wherein the program, when running, controls the device where the non-volatile storage medium is located to execute a blockchain-based data sharing method.

[0015] According to another aspect of the present invention, an electronic device is also provided, comprising a processor and a memory; the memory stores computer-readable instructions, and the processor is used to execute the computer-readable instructions, wherein the computer-readable instructions execute a blockchain-based data sharing method.

[0016] This application employs the following steps: A target application obtains the location identifier of a target file from the blockchain ledger, wherein the target file includes at least one target data block, and each target data block is stored in a node of a distributed storage system; the address of each target data block is determined based on the location identifier of the target file and a target mapping relationship, wherein the target mapping relationship indicates the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block resides; the corresponding target data block is retrieved from the distributed storage system based on the address of each target data block, resulting in at least one target data block; the target file is determined using at least one target data block, thus solving the problem of sharing large data files on a blockchain in related technologies. By dividing a large data file into target data blocks, storing the target data blocks in a distributed storage system, and uploading the location information of the target data blocks to the blockchain, the effect of sharing large data files on the blockchain is achieved. Attached Figure Description

[0017] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a flowchart of a blockchain-based data sharing method provided according to an embodiment of this application;

[0019] Figure 2 This is a schematic diagram of the storage of the target file according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of a blockchain-based data sharing device provided according to an embodiment of this application. Detailed Implementation

[0021] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0024] According to an embodiment of this application, a blockchain-based data sharing method is provided.

[0025] Figure 1 This is a flowchart of a blockchain-based data sharing method according to an embodiment of this application. Figure 1 As shown, the method includes the following steps:

[0026] Step S102: Obtain the location identifier of the target file from the blockchain ledger through the target application, wherein the target file includes at least one target data block, and each target data block is stored in a node of the distributed storage system.

[0027] Specifically, the target file can be a large data file shared by the user to the blockchain. The blockchain ledger can share the data uploaded by the user with all blocks on the blockchain. Due to the capacity limitation of data storage on the blockchain, it is not possible to directly share large data files to the blockchain. Therefore, this application embodiment combines a distributed storage system to divide the large data file and store it in the distributed storage system. The location identifier of the large data file is recorded. This location identifier can identify the location information of each target data block of the large data file after it is divided and stored in the distributed storage system. The location identifier of the large data file is shared with the blockchain ledger to realize the sharing of large data files on the blockchain.

[0028] For example, user A shares a video file on the blockchain through a corresponding application. Specifically, after the video file is divided into at least one target data block, each target data block is stored in a node of a distributed storage system. At the same time, the location identifier of the video file is stored in the blockchain ledger. This location identifier can identify the address of all target data blocks in the distributed storage system. When user B reads the video file shared by user A, the target application retrieves the location identifier of the video file from the blockchain ledger.

[0029] In addition, it should be noted that the amount of data in the target file shared by users varies. When the amount of data in the shared file is less than or equal to the size of the target data block, it is not necessary to split the target file. The target file can be stored as a single target data block on one node of the distributed storage system. When the amount of data in the shared target file is greater than the size of the target data block, the target file needs to be split into two or more target data blocks and stored on different nodes of the distributed system respectively.

[0030] Step S104: Determine the address of each target data block according to the location identifier of the target file and the target mapping relationship. The target mapping relationship is used to indicate the relationship between the location identifier of the target file and the address of the target data block. The address of the target data block is the address of the node where the target data block is located.

[0031] Specifically, there is a target mapping relationship between the location identifier and the address of all target data blocks in the distributed storage system. After obtaining the location identifier, it is necessary to resolve the specific address of the target data block in the distributed storage system based on the location identifier. That is, the address of the target data block corresponding to the location identifier is determined through the target mapping relationship.

[0032] Step S106: Obtain the corresponding target data block from the distributed storage system according to the address of each target data block, and obtain at least one target data block.

[0033] Specifically, since the file is divided into at least one target data block, and each target data block is stored on different nodes in the distributed system, the address of the target data block is the address of the node where the target data block is stored. Therefore, when other users obtain the shared target file, they obtain the target data block from the node of the distributed storage system based on the address of the target data block obtained.

[0034] Step S108: Determine the target file using at least one target data block.

[0035] Specifically, when there is only one target data block corresponding to the shared target file in the distributed storage system, obtaining the target data block is equivalent to obtaining the target file. When there are multiple target data blocks corresponding to the shared target file in the distributed storage system, the target data blocks corresponding to all target files are first combined into one data block to obtain the target file.

[0036] The blockchain-based data sharing method provided in this application obtains the location identifier of a target file from the blockchain ledger through a target application. The target file includes at least one target data block, each stored in a node of a distributed storage system. The method determines the address of each target data block based on the target file's location identifier and a target mapping relationship. The target mapping relationship indicates the relationship between the target file's location identifier and the target data block's address, where the address of the target data block is the address of the node where the target data block resides. The method retrieves the corresponding target data block from the distributed storage system based on each target data block's address, obtaining at least one target data block. By identifying the target file through at least one target data block, this method solves the problem of sharing large data files on a blockchain in related technologies. By dividing a large data file into target data blocks, storing the target data blocks in a distributed storage system, and uploading the location information of the target data blocks to the blockchain, the method achieves the effect of sharing large data files on the blockchain.

[0037] To reduce the storage pressure on the blockchain, the location identifier of the target file is stored in the blockchain, but the specific addresses of each target block corresponding to the target file are not stored in the blockchain. When a user obtains a shared file, after obtaining the location identifier of the target file, it needs to obtain the target mapping relationship between the location information and the target blocks, and determine the address of the target block based on the target mapping relationship. Optionally, in the blockchain-based data sharing method provided in this application embodiment, multiple mapping relationships corresponding to multiple files are stored in the target server, and the multiple mapping relationships include the target mapping relationship corresponding to the target file. Before determining the address of each target data block based on the location identifier of the target file and the target mapping relationship, the method further includes: obtaining the target mapping relationship from the multiple mapping relationships stored in the target server based on the location identifier of the target file.

[0038] Specifically, the target server can be a node mapping server, used to store the mapping relationships corresponding to files shared by different users in the blockchain. The mapping relationship is the correspondence between the location identifiers of multiple shared files and the addresses of the corresponding data blocks. When a user obtains a shared file, they first determine the location identifier of the target file, then log in to the node mapping server, find the corresponding target mapping relationship in the node mapping server based on the target file's location identifier, and then obtain the storage address of each target data block in the distributed storage system based on the target mapping relationship. This embodiment, by determining the location identifier and obtaining the corresponding mapping relationship in the node mapping server, can obtain the specific address of the target data block, avoiding the problem of insufficient data storage capacity in the block caused by directly uploading the specific address to the blockchain.

[0039] After obtaining the target mapping relationship, the target data block can be obtained according to the address of the target data block corresponding to the location identifier. The target data block is an encrypted data block that needs to be decrypted. Optionally, in the blockchain-based data sharing method provided in this application embodiment, each target data block is a data block encrypted with a first key. Determining the target file through at least one target data block includes: decrypting the target data block with the first key to obtain a decrypted data block; if there is only one decrypted data block, determining the decrypted data block as the target file; if there are two or more decrypted data blocks, combining all the decrypted data blocks into one data block and determining the combined data block as the target file.

[0040] Specifically, the first key can be the key used by the symmetric encryption algorithm. After the shared file is divided into target data blocks, each target data block is encrypted with the first key to ensure the security of data storage. When a user obtains a shared file, after obtaining the target data block, the user also needs to decrypt the target data block with the first key to obtain the decrypted data block. At this time, the target file is determined based on the decrypted data block. If there are multiple decrypted data blocks, all the decrypted data blocks are merged first to obtain the target file.

[0041] To further improve the storage security of the target file, it can be encrypted before segmenting the target file. Optionally, in the blockchain-based data sharing method provided in this application embodiment, the target file is a file encrypted with a second key. If there is only one decrypted data block, determining the decrypted data block as the target file includes: decrypting the data block with the second key to obtain the target file; if there are two or more decrypted data blocks, combining all the decrypted data blocks into one data block and determining the combined data block as the target file includes: decrypting the combined data block with the second key to obtain the target file.

[0042] Specifically, the second key can be the key used in a symmetric encryption algorithm. To ensure the security of the target file, it is encrypted using the second key before being segmented into target data blocks. Therefore, after obtaining the decrypted data blocks, if the decrypted data block contains only one block, it needs to be decrypted using the second key to obtain the target file. If the decrypted data block contains two or more blocks, they need to be combined and then decrypted using the second key to obtain the target file. In this embodiment, the second key is used to decrypt the decrypted data blocks to obtain the target file, thus ensuring data security during the sharing process.

[0043] To ensure the security of data acquisition, only authorized users can access the target file. Optionally, in the blockchain-based data sharing method provided in this application embodiment, obtaining the location identifier of the target file from the blockchain ledger through the target application includes: detecting whether the target application has file access permission, wherein the file access permission is the access permission of the target file; if the target application has file access permission, obtaining a first key and a second key, and obtaining the location identifier of the target file from the blockchain ledger.

[0044] Specifically, file access permission allows a user to obtain access to a target file on the blockchain. When a user tries to access a shared target file on the blockchain, the blockchain first needs to determine whether the user's target application is on a blockchain node to ascertain whether the user has the necessary permissions. If the target application is on a blockchain node, the user can obtain the target file's location identifier and corresponding first and second keys through the blockchain ledger, laying the data foundation for file access. By determining whether the target application has the necessary permissions, malicious theft of shared files can be prevented.

[0045] Before a user can access a shared file, another user needs to share the target file to the blockchain. Optionally, in the blockchain-based data sharing method provided in this application embodiment, before the target application obtains the location identifier of the target file from the blockchain ledger, the method further includes: receiving a file to be stored; determining at least one data block smaller than a preset capacity based on the file to be stored; and storing each data block in a node of the distributed storage system; determining the location identifier of the file to be stored; determining the address of the node where the data block is located as the address of the data block; and establishing a mapping relationship between the location identifier of the file to be stored and the address of at least one data block; and storing the location identifier of each file to be stored in a block of the blockchain.

[0046] Specifically, the file to be stored can be a target file, and the preset capacity can be the data storage capacity of data blocks in the distributed storage system. Figure 2 This is a schematic diagram illustrating the storage of the target file according to an embodiment of this application. For example... Figure 2 As shown, when a user shares a file, the number of target data blocks is determined based on the size of the target file. The target file is then divided into the corresponding number of target data blocks, which are randomly stored on data nodes of the distributed storage system. The addresses of all target data blocks are obtained. A target mapping relationship is established between the location identifiers of the target file and the addresses of the target data blocks on the node mapping server. The location identifiers are then shared in the blockchain ledger, laying the data foundation for users to retrieve data blocks stored in the distributed storage system using the location identifiers in the blockchain ledger. This embodiment achieves the goal of sharing large data files on the blockchain by dividing large data files into target data blocks, storing the target data blocks in the distributed storage system, and uploading the location information of the target data blocks to the blockchain.

[0047] When storing a target file in a distributed storage system, the number of data blocks is determined by comparing the size of the target file with a preset capacity. Optionally, in the blockchain-based data sharing method provided in this application embodiment, receiving a file to be stored and determining at least one data block smaller than the preset capacity based on the file to be stored includes: determining whether the data volume of the file to be stored is greater than the preset capacity; if the data volume of the file to be stored is greater than the preset capacity, dividing the file to be stored into at least one data block smaller than the preset capacity; if the data volume of the file to be stored is less than or equal to the preset capacity, determining the file to be stored as a single data block.

[0048] For example, if the video file to be stored is 5MB and the data node capacity is 10MB, then there is no need to split the file; it can be directly stored in one data node of the distributed storage system. However, if the video file to be stored is 50MB, then it needs to be split into 5 data blocks and stored in 5 data nodes of the distributed storage system. By splitting files exceeding the preset capacity and storing them in the distributed storage system, large data files can be stored.

[0049] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0050] This application also provides a blockchain-based data sharing device. It should be noted that the blockchain-based data sharing device of this application can be used to execute the blockchain-based data sharing method provided in this application. The following describes the blockchain-based data sharing device provided in this application.

[0051] Figure 3 This is a schematic diagram of a blockchain-based data sharing device provided according to an embodiment of this application. Figure 3 As shown, the device includes:

[0052] The first acquisition unit 10 is used to obtain the location identifier of the target file from the ledger of the blockchain through the target application, wherein the target file includes at least one target data block, and each target data block is stored in a node of the distributed storage system.

[0053] The first determining unit 20 is used to determine the address of each target data block according to the location identifier of the target file and the target mapping relationship, wherein the target mapping relationship is used to indicate the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block is located.

[0054] The second acquisition unit 30 is used to acquire the corresponding target data block from the distributed storage system according to the address of each target data block, so as to obtain at least one target data block.

[0055] The second determining unit 40 is used to determine the target file through at least one target data block.

[0056] The blockchain-based data sharing device provided in this application embodiment, through a first acquisition unit 10, obtains the location identifier of a target file from the blockchain ledger through a target application. The target file includes at least one target data block, each of which is stored in a node of a distributed storage system. A first determination unit 20 determines the address of each target data block based on the location identifier of the target file and a target mapping relationship. The target mapping relationship indicates the relationship between the location identifier of the target file and the address of the target data block, where the address of the target data block is the address of the node where the target data block is located. A second acquisition unit 30 obtains the corresponding target data block from the distributed storage system based on the address of each target data block, thus obtaining at least one target data block. A second determination unit 40 determines the target file through at least one target data block. This solves the problem of sharing large data files on the blockchain in related technologies by dividing the large data file into target data blocks, storing the target data blocks in a distributed storage system, and uploading the location information of the target data blocks to the blockchain, thereby achieving the effect of sharing large data files on the blockchain.

[0057] Optionally, in the blockchain-based data sharing device provided in the embodiments of this application, the device further includes: a third acquisition unit, used to acquire a target mapping relationship from multiple mapping relationships stored in the target server according to the location identifier of the target file.

[0058] Optionally, in the blockchain-based data sharing device provided in the embodiments of this application, the second determining unit 40 includes: a decryption module, used to decrypt the target data block using a first key to obtain a decrypted data block; a first determining module, used to determine the decrypted data block as the target file when there is only one decrypted data block; and a second determining module, used to combine all the decrypted data blocks into one data block when there are two or more decrypted data blocks, and determine the combined data block as the target file.

[0059] Optionally, in the blockchain-based data sharing device provided in this application embodiment, the first determining module includes: a first decryption submodule, used to decrypt the data block using a second key to obtain a target file; the second determining module includes: a second decryption submodule, used to decrypt the combined data block using a second key to obtain a target file.

[0060] Optionally, in the blockchain-based data sharing device provided in this application embodiment, the first acquisition unit 10 includes: a detection module, used to detect whether the target application has file acquisition permission, wherein the file acquisition permission is the acquisition permission of the target file; and an acquisition module, used to acquire a first key and a second key when the target application has file acquisition permission, and to acquire the location identifier of the target file from the blockchain ledger.

[0061] Optionally, in the blockchain-based data sharing device provided in the embodiments of this application, the device further includes: a receiving unit, configured to receive a file to be stored, determine at least one data block smaller than a preset capacity based on the file to be stored, and store each data block in a node of a distributed storage system; a third determining unit, configured to determine the location identifier of the file to be stored, determine the address of the node where the data block is located as the address of the data block, and establish a mapping relationship between the location identifier of the file to be stored and the address of at least one data block; and a storage unit, configured to store the location identifier of each file to be stored in a block of the blockchain.

[0062] Optionally, in the blockchain-based data sharing device provided in this application embodiment, the second acquisition unit 30 includes: a judgment module, used to judge whether the data volume of the file to be stored is greater than a preset capacity; a segmentation module, used to segment the file to be stored into at least one data block smaller than the preset capacity when the data volume of the file to be stored is greater than the preset capacity; and a third determination module, used to determine the file to be stored as a data block when the data volume of the file to be stored is less than or equal to the preset capacity.

[0063] The aforementioned blockchain-based data sharing device includes a processor and a memory. The first acquisition unit 10, the first determination unit 20, the second acquisition unit 30, and the second determination unit 40 are all stored in the memory as program units. The processor executes the aforementioned program units stored in the memory to realize the corresponding functions.

[0064] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, the ability to share large data files on the blockchain can be achieved.

[0065] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0066] This application also provides a non-volatile storage medium, which includes a stored program, wherein the program, when running, controls the device where the non-volatile storage medium is located to execute a blockchain-based data sharing method.

[0067] This application also provides an electronic device comprising a processor and a memory; the memory stores computer-readable instructions, and the processor executes the computer-readable instructions, wherein the computer-readable instructions, when executed, perform a blockchain-based data sharing method. The electronic device described herein may be a server, PC, PAD, mobile phone, etc.

[0068] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0069] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable blockchain-based data sharing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable blockchain-based data sharing device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0070] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable blockchain-based data-sharing device to function in a specific manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0071] These computer program instructions can also be loaded onto a computer or other programmable blockchain-based data-sharing device, causing a series of operational steps to be executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0072] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0073] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0074] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0075] It should also be noted that 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 process, method, article, or apparatus. Unless otherwise specified, 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 that element.

[0076] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A data sharing method based on blockchain, characterized in that, include: The target application obtains the location identifier of the target file from the blockchain ledger, wherein the target file is a file encrypted with a second key, and the target file includes at least one target data block, each of which is stored in a node of a distributed storage system. The address of each target data block is determined based on the location identifier of the target file and the target mapping relationship, wherein the target mapping relationship is used to indicate the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block is located; The target server stores multiple mapping relationships corresponding to multiple files, and the multiple mapping relationships include the target mapping relationship corresponding to the target file; Before determining the address of each target data block based on the location identifier of the target file and the target mapping relationship: obtain the target mapping relationship from the plurality of mapping relationships stored in the target server based on the location identifier of the target file; Based on the address of each target data block, the corresponding target data block is obtained from the distributed storage system to obtain at least one target data block, wherein each target data block is a data block encrypted with a first key; Determining the target file by at least one target data block includes: decrypting the target data block using the first key to obtain a decrypted data block; if there is only one decrypted data block, determining the decrypted data block as the target file; if there are two or more decrypted data blocks, combining all the decrypted data blocks into one data block, and determining the combined data block as the target file. Specifically, determining the decrypted data block as the target file includes: decrypting the decrypted data block using the second key to obtain the target file; Combining all the decrypted data blocks into one data block and determining the combined data block as the target file includes: decrypting the combined data block using the second key to obtain the target file.

2. The method according to claim 1, characterized in that, The location identifier of the target file obtained from the blockchain ledger by the target application includes: Detect whether the target application has file access permission, wherein the file access permission is the access permission of the target file; If the target application has the file access permission, the first key and the second key are obtained, and the location identifier of the target file is obtained from the ledger of the blockchain.

3. The method according to claim 1, characterized in that, Before obtaining the location identifier of the target file from the blockchain ledger via the target application, the method further includes: Receive a file to be stored, determine at least one data block smaller than a preset capacity based on the file to be stored, and store each data block in a node of the distributed storage system; Determine the location identifier of the file to be stored, determine the address of the node where the data block is located as the address of the data block, and establish a mapping relationship between the location identifier of the file to be stored and the address of the at least one data block; The location identifier of each file to be stored is stored in a block of the blockchain.

4. The method according to claim 3, characterized in that, Receiving a file to be stored, and determining at least one data block smaller than a preset capacity based on the file to be stored, includes: Determine whether the data volume of the file to be stored is greater than the preset capacity; If the amount of data in the file to be stored is greater than the preset capacity, the file to be stored is divided into at least one data block smaller than the preset capacity; If the amount of data in the file to be stored is less than or equal to the preset capacity, the file to be stored is determined as a data block.

5. A data sharing device based on blockchain, characterized in that, include: The first acquisition unit is used to acquire the location identifier of the target file from the ledger of the blockchain through the target application, wherein the target file is a file encrypted with a second key, the target file includes at least one target data block, and each target data block is stored in a node of the distributed storage system. The first determining unit is configured to determine the address of each target data block according to the location identifier of the target file and the target mapping relationship, wherein the target mapping relationship is used to indicate the relationship between the location identifier of the target file and the address of the target data block, and the address of the target data block is the address of the node where the target data block is located; The target server stores multiple mapping relationships corresponding to multiple files, and the multiple mapping relationships include the target mapping relationship corresponding to the target file; The third acquisition unit is used to acquire the target mapping relationship from the plurality of mapping relationships stored in the target server according to the location identifier of the target file; The second acquisition unit is used to acquire the corresponding target data block from the distributed storage system according to the address of each target data block, and obtain at least one target data block, wherein each target data block is a data block encrypted with a first key; The second determining unit is configured to determine the target file by at least one of the target data blocks; The second determining unit includes: a decryption module, configured to decrypt the target data block using the first key to obtain a decrypted data block; a first determining module, configured to determine the decrypted data block as the target file when there is only one decrypted data block; and a second determining module, configured to combine all the decrypted data blocks into one data block when there are two or more decrypted data blocks, and determine the combined data block as the target file. The first determining module includes: a first decryption submodule, used to decrypt the decrypted data block using the second key to obtain the target file; The second determining module includes a second decryption submodule, used to decrypt the combined data block using the second key to obtain the target file.

6. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, wherein the program, when running, controls the device where the non-volatile storage medium is located to execute the blockchain-based data sharing method according to any one of claims 1 to 4.

7. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing computer-readable instructions, and the processor executing the computer-readable instructions, wherein the computer-readable instructions, when executed, perform the blockchain-based data sharing method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Storage system based on block chain

    CN108076148A