Search

CN-115017123-B - Block chain-based data sharing method and device, storage medium and electronic device

CN115017123BCN 115017123 BCN115017123 BCN 115017123BCN-115017123-B

Abstract

The application discloses a data sharing method and device based on a blockchain, a storage medium and an electronic device. The method comprises the steps of obtaining position identifiers of target files from an account book of a blockchain through a target application program, determining addresses of all target data blocks according to the position identifiers of the target files and a target mapping relation, wherein the target mapping relation is used for indicating the relation between the position identifiers of the target files and the addresses of the target data blocks, the addresses of the target data blocks are the addresses of nodes where the target data blocks are located, obtaining at least one target data block from the corresponding target data blocks obtained from a distributed storage system according to the addresses of all the target data blocks, and determining the target file through the at least one target data block. The application solves the problem that the large data file is difficult to share on the blockchain in the related technology.

Inventors

  • SONG ZHIHUA
  • FANG BAOLONG
  • LIU XINTIAN

Assignees

  • 渔翁信息技术股份有限公司

Dates

Publication Date
20260505
Application Date
20220429

Claims (7)

  1. 1. A blockchain-based data sharing method, comprising: Acquiring a position identification of a target file from an account book of a blockchain through a target application program, wherein the target file is a file encrypted through a second key and comprises at least one target data block, and each target data block is respectively stored in one node of a distributed storage system; determining the address of each target data block according to the position identification of the target file and a target mapping relation, wherein the target mapping relation is used for indicating the relation between the position identification 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; wherein, a plurality of mapping relations corresponding to a plurality of files are stored in a target server, and the plurality of mapping relations comprise the target mapping relation corresponding to the target file; Before determining the address of each target data block according to the position identification of the target file and the target mapping relation, acquiring the target mapping relation from the plurality of mapping relations stored in the target server according to the position identification of the target file; obtaining at least one target data block from the corresponding target data blocks obtained from the distributed storage system according to the address of each target data block, wherein each target data block is a data block encrypted by a first key; Determining the target file through at least one target data block, wherein the target file comprises the steps of decrypting the target data block through the first key to obtain decrypted data blocks, determining the decrypted data blocks as the target file when the decrypted data blocks are one, combining all the decrypted data blocks as one data block when the decrypted data blocks are more than or equal to two, and determining the combined data blocks as the target file; the decrypted data block is determined to be the target file, and the target file is obtained by decrypting the decrypted data block through the second key; And combining all the decrypted data blocks into one data block, and determining the combined data block as the target file, wherein the step of decrypting the combined data block through the second key comprises the step of obtaining the target file.
  2. 2. The method of claim 1, wherein obtaining, by the target application, the location identification of the target file from the ledger of the blockchain comprises: Detecting whether the target application program has file acquisition permission, wherein the file acquisition permission is the acquisition permission of the target file; And under the condition that the target application program has the file acquisition authority, acquiring the first key and the second key, and acquiring the position identification of the target file from the account book of the blockchain.
  3. 3. The method of claim 1, wherein prior to obtaining, by the target application, the location identification of the target file from the ledger of the blockchain, the method further comprises: Receiving a file to be stored, determining at least one data block smaller than a preset capacity according to the file to be stored, and storing each data block into one node of the distributed storage system; Determining the position identification 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 relation between the position identification of the file to be stored and the address of at least one data block; and respectively storing the position identification of each file to be stored into one block of the block chain.
  4. 4. A method according to claim 3, wherein receiving a file to be stored, determining at least one data block from the file to be stored that is less than a preset capacity comprises: Judging whether the data volume of the file to be stored is larger than the preset capacity or not; dividing the file to be stored into at least one data block smaller than a preset capacity under the condition that the data volume of the file to be stored is larger than the preset capacity; and determining the file to be stored as one data block under the condition that the data volume of the file to be stored is smaller than or equal to the preset capacity.
  5. 5. A blockchain-based data sharing apparatus, comprising: The first acquisition unit is used for acquiring the position identification of a target file from the account book of the blockchain through a target application program, wherein the target file is an encrypted file through a second key and comprises at least one target data block, and each target data block is respectively stored in one node of the distributed storage system; The first determining unit is used for determining the address of each target data block according to the position identification of the target file and a target mapping relation, wherein the target mapping relation is used for indicating the relation between the position identification 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; wherein, a plurality of mapping relations corresponding to a plurality of files are stored in a target server, and the plurality of mapping relations comprise the target mapping relation corresponding to the target file; A third obtaining unit, configured to obtain, according to the location identifier of the target file, the target mapping relationship from the plurality of mapping relationships stored in the target server; The second acquisition unit is used for acquiring the corresponding target data blocks from the distributed storage system according to the addresses of the target data blocks to obtain at least one target data block, wherein each target data block is a data block encrypted by a first key; A second determining unit configured to determine the target file through at least one of the target data blocks; The second determining unit comprises a decryption module, a first determining module and a second determining module, wherein the decryption module is used for decrypting the target data block through the first key to obtain a decrypted data block, the first determining module is used for determining the decrypted data block as the target file when the decrypted data block is one, and the second determining module is used for combining all the decrypted data blocks into one data block and determining the combined data block as the target file when the decrypted data block is more than or equal to two; the first determining module comprises a first decryption sub-module, a second determining module and a first determining module, wherein the first decryption sub-module is used for decrypting the decrypted data block through the second key to obtain the target file; the second determining module comprises a second decryption sub-module, which is used for decrypting the data blocks obtained by the combination through the second secret key to obtain the target file.
  6. 6. A non-volatile storage medium, characterized in that the non-volatile storage medium comprises a stored program, wherein the program, when run, controls a device in which the non-volatile storage medium is located to perform the blockchain-based data sharing method of any of claims 1 to 4.
  7. 7. An electronic device comprising a processor and a memory, the memory having stored therein computer readable instructions for executing the computer readable instructions, wherein the computer readable instructions when executed perform the blockchain-based data sharing method of any of claims 1-4.

Description

Block chain-based data sharing method and device, storage medium and electronic device Technical Field The present application relates to the field of blockchain technologies, and in particular, to a blockchain-based data sharing method, a blockchain-based data sharing device, a storage medium, and an electronic device. Background Because the blockchain has the characteristics that the data is difficult to tamper and decentralize, the recorded information is more real and reliable, and the blockchain can be used for storing the data, so that the problem that the two parties are mutually not trusted is solved. It should be noted that, because the block storage data information capacity on the blockchain is small, in the related art, the blockchain of the virtual asset class mainly places some transaction information into the blockchain, and the blockchain of the information tracing class can only place tracing information into the blockchain for sharing, so that large data files such as pictures, audio, video and the like are difficult to share through the blockchain. Aiming at the problem that large data files are difficult to share on a blockchain in the related art, no effective solution is proposed at present. Disclosure of Invention The application provides a data sharing method and device based on a blockchain, a storage medium and an electronic device, which are used for solving the problem that large data files are difficult to share on the blockchain in the related technology. According to one aspect of the present application, a blockchain-based data sharing method is provided. The method comprises the steps of obtaining a position identification of a target file from an account book of a blockchain through a target application program, wherein the target file comprises at least one target data block, each target data block is stored in one node of a distributed storage system, determining the address of each target data block according to the position identification of the target file and a target mapping relation, wherein the target mapping relation is used for indicating the relation between the position identification 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, obtaining at least one target data block from the corresponding target data block obtained from the distributed storage system according to the address of each target data block, and determining the target file through the at least one target data block. Optionally, a plurality of mapping relations corresponding to the plurality of files are stored in the target server, the plurality of mapping relations comprise target mapping relations corresponding to the target files, and before the addresses of the target data blocks are determined according to the position identifiers of the target files and the target mapping relations, the method further comprises the step of obtaining the target mapping relations from the plurality of mapping relations stored in the target server according to the position identifiers of the target files. Optionally, each target data block is a data block encrypted through a first key, and determining the target file through at least one target data block includes decrypting the target data block through the first key to obtain a decrypted data block, determining the decrypted data block as the target file when the decrypted data block is one, combining all the decrypted data blocks as one data block when the decrypted data block is greater than or equal to two, and determining the combined data block as the target file. Optionally, the target file is a file encrypted by the second key, the decrypted data blocks are determined to be the target file when the decrypted data blocks are one, the target file is obtained by decrypting the data blocks by the second key, and when the decrypted data blocks are more than or equal to two, all the decrypted data blocks are combined into one data block, and the combined data blocks are determined to be the target file, wherein the target file is obtained by decrypting the combined data blocks by the second key. Optionally, the step of acquiring the location identifier of the target file from the ledger of the blockchain through the target application program comprises detecting whether the target application program has file acquisition permission, wherein the file acquisition permission is that of the target file, acquiring a first key and a second key under the condition that the target application program has file acquisition permission, and acquiring the location identifier of the target file from the ledger of the blockchain. Optionally, before the position identification of the target file is obtained from the account book of the blockchain through the target application program, the method further comprises the steps of receiving the file to be store