WO2022028484A1 - 共享文件的方法、装置及系统 - Google Patents

共享文件的方法、装置及系统 Download PDF

Info

Publication number
WO2022028484A1
WO2022028484A1 PCT/CN2021/110594 CN2021110594W WO2022028484A1 WO 2022028484 A1 WO2022028484 A1 WO 2022028484A1 CN 2021110594 W CN2021110594 W CN 2021110594W WO 2022028484 A1 WO2022028484 A1 WO 2022028484A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data block
hash value
package
compressed package
Prior art date
Application number
PCT/CN2021/110594
Other languages
English (en)
French (fr)
Inventor
穆长春
狄刚
钱友才
卿苏德
陈庆接
杜金钊
Original Assignee
中国人民银行数字货币研究所
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中国人民银行数字货币研究所 filed Critical 中国人民银行数字货币研究所
Priority to EP21854512.7A priority Critical patent/EP4180985A1/en
Priority to US18/040,619 priority patent/US20230315692A1/en
Publication of WO2022028484A1 publication Critical patent/WO2022028484A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • G06F16/1767Concurrency control, e.g. optimistic or pessimistic approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures

Definitions

  • the present disclosure relates to the field of computer technologies, and in particular, to a method, apparatus and system for sharing files.
  • the embodiments of the present disclosure provide a method and device for sharing a file, which acquires a file to be shared, performs a concurrent blockchain upload operation on a compressed package of the shared file, and forms data according to the file name of the compressed package and its hash value.
  • the data block contains the hash value of the previous data block; the hash value of the last data block is the root hash value; according to the root hash value, obtain the file contained in the last data block, and then obtain the root hash value
  • Each file in the blockchain indicated by the value of the compressed package by compressing multiple files into a file package, the technical problem of the high burden of network resources caused by the large number of files is partially overcome. It improves the efficiency of file chaining and sharing; uses the singly linked list data structure on the blockchain to save and share files to improve the security of files.
  • a method for sharing files is provided, which is characterized by comprising: acquiring a file to be shared, and forming at least two file compression packages; Execute the blockchain on-chain operation, and obtain the hash value corresponding to the file compressed package; for the file name of the first file compressed package in the at least two file compressed packages and the hash of the first file compressed package value, generate a first data block, and perform a blockchain on-chain operation on the first data block; for the second file compressed package other than the first file compressed package in the at least two file compressed packages: According to the hash value of the previous data block, the file name of the second file compressed package, and the hash value corresponding to the second file compressed package, generate a second data block and execute a block chain on the second data block On-chain operation; take the hash value of the last second data block in the second data block as the root hash value, and send the root hash value.
  • the method for sharing files is characterized in that:
  • Obtain files to be shared within a predefined time range form at least two file packages, and determine the number of files in the file packages according to network bandwidth.
  • the method for sharing files is characterized in that:
  • Compressing and encrypting the file package are respectively performed to form the file compression package.
  • the method for sharing files is characterized in that:
  • the first data block further includes an initial data block identifier.
  • the method for sharing files is characterized in that:
  • a concurrent blockchain uploading operation is performed on the file compressed package.
  • the method for sharing files is characterized in that:
  • the hash value of the previous data block is used to generate the second data block, which further includes:
  • the file name of the second file compressed package obtain the shared file included in the second file compressed package, and perform compression and encryption operations on the shared file and the hash value of the previous data block to form an update File compressed package, perform blockchain on-chain operation on the update file compressed package, and obtain the hash value corresponding to the update file compressed package, according to the file name of the update file compressed package, the update file compressed package The hash value of the generated second data block.
  • a method for sharing files which is characterized by comprising:
  • the method for sharing files is characterized in that:
  • the current data block contains the initial data block identifier, it is indicated to complete the acquisition of each file compressed package in the blockchain indicated by the root hash value.
  • the method for sharing files is characterized in that:
  • Acquiring the files in the file compression package includes: performing decompression and decryption operations on the file compression package to obtain the files in the file compression package.
  • the method for sharing files is characterized in that:
  • a device for sharing files which is characterized by comprising: a file compression package uploading module, a file data block generating module and a root hash value generating module; in,
  • the file compressed package on-chain module is used to obtain the files to be shared, and form at least two file compressed packages; perform the blockchain on-chain operation on the file compressed package, and obtain the hash corresponding to the file compressed package value;
  • the file data block generation module is configured to generate a first data block for the file name of the first file compressed package in the at least two file compressed packages and the hash value of the first file compressed package, and to The first data block performs the blockchain on-chain operation; for the second file compression package other than the first file compression package in the at least two file compression packages: according to the hash value of the previous data block, the file name of the second file compressed package and the hash value corresponding to the second file compressed package, generate a second data block and perform a blockchain on-chain operation for the second data block;
  • the root hash value generating module is configured to use the hash value of the last second data block in the second data blocks as the root hash value, and send the root hash value.
  • the device for sharing files is characterized in that:
  • Acquiring files to be shared to form at least two file compression packages includes: acquiring files to be shared within a predefined time range, forming at least two file packages, and determining the number of files in the file packages according to network bandwidth.
  • the device for sharing files is characterized in that:
  • Acquiring the files to be shared and forming at least two file compression packages includes: respectively performing compression and encryption operations on the file packages to form the file compression packages.
  • the device for sharing files is characterized in that:
  • the first data block further includes an initial data block identifier.
  • the device for sharing files is characterized in that:
  • a concurrent blockchain uploading operation is performed on the file compressed package.
  • the device for sharing files is characterized in that:
  • the hash value of the previous data block is used to generate the second data block, which further includes:
  • the file name of the second file compressed package obtain the shared file included in the second file compressed package, and perform compression and encryption operations on the shared file and the hash value of the previous data block to form an update File compressed package, perform blockchain on-chain operation on the update file compressed package, and obtain the hash value corresponding to the update file compressed package, according to the file name of the update file compressed package, the update file compressed package The hash value of the generated second data block.
  • an apparatus for sharing files characterized in that it includes: a module for acquiring a root node file and a module for acquiring an on-chain file; wherein,
  • the obtaining the root node file module is used to receive the root hash value, obtain the last data block corresponding to the root hash value from the blockchain according to the root hash value, and obtain the data of the last data block. the file name of the included file zip package, and obtain the files in the file zip package;
  • the module for obtaining on-chain files is configured to cyclically execute the following steps until each file compressed package in the blockchain indicated by the root hash value is obtained: the previous data block contained in the last data block is obtained The hash value is taken as the current hash value, and the hash value of the previous data block, the file name of the file compression package corresponding to the current data block, and the file compression are obtained from the blockchain according to the current hash value. The file in the package; and the obtained hash value of the previous data block is used as the current hash value.
  • the device for sharing files is characterized in that:
  • the current data block contains the initial data block identifier, it is indicated to complete the acquisition of each file compressed package in the blockchain indicated by the root hash value.
  • the device for sharing files is characterized in that:
  • Acquiring the files in the file compression package includes: performing decompression and decryption operations on the file compression package to obtain the files in the file compression package.
  • the device for sharing files is characterized in that:
  • a system 900 for sharing files including the device 700 for sharing files provided in the third aspect and the device 800 for sharing files provided in the fourth aspect. .
  • an electronic device for sharing files which is characterized by comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of the above methods for sharing files.
  • a computer-readable medium on which a computer program is stored characterized in that, when the program is executed by a processor, the above-mentioned method for sharing a file is implemented any of the methods described above.
  • One embodiment of the above invention has the following advantages or beneficial effects: obtaining a file to be shared, performing a concurrent blockchain operation on the shared file compressed package, and forming a data block according to the compressed package file name and its hash value, the The data block contains the hash value of the previous data block; the hash value of the last data block is the root hash value; according to the root hash value, the file contained in the last data block is obtained, and then the data indicated by the root hash value is obtained.
  • Each file in the blockchain is compressed into a file package; by compressing multiple files into file packages, the technical problem of the high burden of network resources caused by the large number of files is partially overcome. Efficiency of file uploading and sharing; using the singly linked list data structure on the blockchain to save and share files to improve the security of files.
  • FIG. 1 is a schematic flowchart of a method for storing a shared file provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic flowchart of obtaining a shared file according to an embodiment of the present disclosure
  • FIG. 3 is a schematic diagram of a chain data structure for generating and storing shared file data blocks provided by the first embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of obtaining a shared file provided by the first embodiment of the present disclosure
  • FIG. 5 is a schematic diagram of a chain data structure for generating and storing shared file data blocks provided by the second embodiment of the present disclosure
  • FIG. 6 is a schematic flowchart of obtaining a shared file according to a second embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of an apparatus for sharing files provided by an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of an apparatus for acquiring a shared file provided by an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a system for acquiring a shared file provided by an embodiment of the present disclosure.
  • FIG. 10 is a schematic flowchart of a file sharing provided by an embodiment of the present disclosure.
  • FIG. 11 is an exemplary system architecture diagram to which embodiments of the present disclosure may be applied.
  • FIG. 12 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present disclosure.
  • an embodiment of the present disclosure provides a method for sharing files, and the method may include the following steps:
  • Step S101 Acquire a file to be shared to form at least two file compression packages; perform a blockchain on-chain operation on the file compression package, and obtain a hash value corresponding to the file compression package.
  • the file to be shared is a file generated in real time, and according to the multiple files, at least two file packages (that is, multiple file packages) are formed, and file compression packages are respectively formed; wherein, obtaining the file to be shared, Forming at least two file compression packages includes: acquiring files to be shared within a predefined time range, forming at least two file packages, and determining the number of files in the file packages according to network bandwidth.
  • the files to be shared may be generated within a predefined time range, for example, transaction files generated by an electronic bank within one hour, statement files generated by two electronic banks within half an hour, and statement files generated within one day.
  • the predefined time range can be set according to the business scenario and the number of generated documents, for example, one day, one hour, 10 minutes, etc.
  • the present disclosure does not limit the predefined time range. Further, according to the obtained total number of files to be shared, according to the network bandwidth, determine the number of files in each file package.
  • the files are then formed into multiple file packages, and the file packages are compressed respectively to form file compression packages; due to the different sizes of the files, the quantity in the file packages is variable; for example: statements between different electronic banks
  • the number of files contained in each file package is determined by obtaining the bandwidth of the network according to the total amount within a time range, and further, the file package is compressed to form multiple file compressed packages.
  • the compression method can use compression tool software, such as gzip, WinRAR, etc.; the encryption method can be encrypted using compression software, or the operating system can be used. or encryption software for encryption, the present disclosure does not limit the specific method used for compression and the specific method of encryption. That is, the compression and encryption operations are respectively performed on the file package to form the file compression package.
  • the concurrent blockchain chaining operation is performed on each file compressed package, because there is no dependent transaction relationship between each file compressed package, so the concurrent chaining operation of the file compressed package can be performed; it is understandable that due to the existence of Due to the limitation of resources such as network bandwidth, the uploading operation of multiple file compressed packages can also be performed in batches.
  • the file compressed packages in each batch are concurrently uploaded to the chain. Through the concurrent uploading operation, the efficiency of file uploading on the chain is improved. , that is, the concurrent blockchain uploading operation is performed on the file compressed package.
  • the blockchain used may be a consortium chain, a private chain, etc., and the present disclosure does not limit the type of the blockchain. The present disclosure does not limit the specific tools or methods used to perform blockchain on-chain.
  • Step S102 Generate a first data block with respect to the file name of the first file compressed package and the hash value of the first file compressed package in the at least two file compressed packages, and execute a region on the first data block.
  • Block chain on-chain operation for the second file compressed package other than the first file compressed package in the at least two file compressed packages: according to the hash value of the previous data block, the second file compressed package
  • the file name and the hash value corresponding to the compressed package of the second file are used to generate a second data block and perform a blockchain on-chain operation for the second data block.
  • the file name of the file compressed package and the hash value corresponding to the file compressed package included in the file compressed package formed according to step S101 wherein the file name of the file compressed package is used to uniquely identify the file compressed package, and the file name is used to identify the file compressed package.
  • the file compressed package corresponding to the file name can be obtained, and then the files in the compressed file package can be obtained.
  • the naming rule of the file name of the file compressed package described in the present disclosure is not limited.
  • a first data block is generated, and a region is executed for the first data block.
  • Block chain on-chain operation specifically, obtain the file name of the first file compressed package and the hash value of the first file compressed package in at least two file compressed packages, and generate a first data block; the first data block is an initial data block, and includes an identifier indicating an initial data block; that is, the first data block further includes an initial data block identifier.
  • the first data block is formed according to the file compression package 0 (ie, the first file compression package) and the hash value of the file compression package 0 (ie, the hash value corresponding to the first file compression package), so
  • the first data block is an initial data block, and the first data block includes an initial data block identifier.
  • the present disclosure does not limit the specific naming rules and contents of the initial data block identifier.
  • a second data block (node data block 1) is generated; according to the hash value of the initial data block, the file compression package 1 (that is, the file name of the second file compression package), and the hash value of the file compression package 1 (the second The hash value corresponding to the file compression package) generates the node data block 1; wherein, the initial data block hash value is the hash value of the previous data block of the node data block 1 (second data block); A second file compression package other than the first file compression package (file compression package 0) in the at least two file compression packages; that is, for the files of the first file compression package in the at least two file compression packages name and the hash value of the compressed package of the first file, generate a first data block, and perform a blockchain on-chain operation on the first data block.
  • the hash value of the previous data block is generated, and a second data block is generated and the blockchain up-chain operation is performed on the second data block.
  • the hash value of the previous data block is obtained after the previous data block is put on the chain, for example, the previous data block is put on the chain as a transaction, and the return value of the transaction is obtained as the value of the previous data block.
  • Hash value similarly, the hash value of the one or more second data blocks is obtained from the blockchain after the second data block is on the chain.
  • the initial data block since the first data block (ie, the initial data block) does not contain the hash value of the previous data block, the initial data block as the initial data block contains the initial data block identifier; wherein, except for the first data block, other The data blocks are all second data blocks; it can be understood that a singly linked list storage structure is formed based on the first data block and one or more second data blocks; further, two methods can be used to generate the second data block: The description of the first method is consistent with the description of steps S301 to S304 in the example in FIG. 3 ; the second method is consistent with the description of steps S501 to S504 in the example in FIG. 5 , and will not be repeated here.
  • Step S103 Use the hash value of the last second data block in the second data blocks as the root hash value, and send the root hash value.
  • the hash value of the last second data block in the second data blocks is used as the root hash value, and the root hash value is sent; it can be seen from the description of step S102 that the first data block and a Or multiple second data blocks form a singly linked list structure, and the linked list structure includes a first data block (initial data block) and multiple second data blocks; wherein, the last second data block in the multiple second data blocks
  • the hash value of the root hash value is sent as the root hash value.
  • the root hash value is sent to the acquirer with the permission to obtain the shared file, and the acquirer with the permission may be one or more parties;
  • the file is a statement file generated by bank A and bank B within one hour; after step S101-step S103, the root hash value is generated, then the root hash value is sent to these statement files.
  • Bank A and Bank B with access rights obviously, using this operation further improves the security of the file.
  • an embodiment of the present disclosure provides a method for acquiring a shared file, and the method may include the following steps:
  • Step S201 Receive the root hash value, obtain the last data block corresponding to the root hash value from the blockchain according to the root hash value, and obtain the file of the file compression package included in the last data block name, and obtain the files in the file archive.
  • the last data block corresponding to the root hash value is obtained from the blockchain, wherein, further, the file of the file compression package included in the last data block is obtained name, and obtain the file in the file compression package; the description of obtaining the file from the blockchain is consistent with the example described in step S401 or step S601, and will not be repeated here.
  • Step S202 Execute the following steps in a loop until each file compressed package in the blockchain indicated by the root hash value is obtained: take the hash value of the previous data block contained in the last data block as the current hash value; value, and obtain the hash value of the previous data block, the file name of the file compression package corresponding to the current data block and the file in the file compression package from the blockchain according to the current hash value; and The acquired hash value of the previous data block is used as the current hash value.
  • an embodiment of the present disclosure provides a method for storing a shared file by using a one-way chain data structure, and the method may include the following steps:
  • step S301 to step S304 it is assumed that each file compression package has been generated and uploaded to the chain.
  • Step S301 Generate a first data block.
  • the first data block is formed according to the file compression package 0 and the hash value of the file compression package 0
  • the first data block is the initial data block
  • the first data block includes the initial data block identifier.
  • the specific content of the initial data block identifier is not limited; that is, the first data block further includes an initial data block identifier.
  • file compression package 0 is the file name of the file compression package; and file compression package 0 is the first file compression package; that is, for the file of the first file compression package in the at least two file compression packages name and the hash value of the compressed package of the first file, generate a first data block, and perform a blockchain on-chain operation on the first data block.
  • Step S302 Generate a second data block (node data block 1).
  • the second data block is generated according to the hash value of the previous data block, the file name of the second file compressed package, and the hash value corresponding to the second file compressed package; as shown in the example of FIG. 3 ,
  • the node data block 1 is generated according to the hash value of the initial data block, the file compression package 1, and the hash value corresponding to the file compression package 1; wherein, the file compression package 1 is the file name of the second file compression package; the hash value of the initial data block
  • the expected value is the hash value of the previous data block of the node data block 1 (the second data block); the hash value of the file compressed package 1 is the hash value corresponding to the second file compressed package.
  • Step S303 Generate a second data block (node data block 2).
  • the node data block 2 is generated according to the hash value of the node data block 1, the file compressed package 2, and the hash value of the file compressed package 2; wherein, the file compressed package 2 is the second file compressed package
  • the hash value of the node data block 1 is the hash value of the previous data block of the node data block 2 (the second data block); the hash value of the file compressed package 2 is the hash value corresponding to the second file compressed package. Greek value.
  • Step S304 Generate a second data block (node data block 3).
  • the node data block 3 is generated according to the hash value of the node data block 2, the file compressed package 3, and the hash value of the file compressed package 3; wherein, the file compressed package 3 is the second file compressed package
  • the file name of the node data block 2; the hash value of the node data block 2 is the hash value of the previous data block of the node data block 3 (the second data block); the hash value of the file compressed package 3 is the corresponding hash value of the second file compressed package value.
  • Steps S302 to S304 describe the generation process of multiple second data blocks, that is, for the second file compression package other than the first file compression package in the at least two file compression packages: according to the previous data block
  • the hash value of the second file compression package, the file name of the second file compression package, and the hash value corresponding to the second file compression package generate a second data block and perform a blockchain on-chain operation for the second data block.
  • the node data block 3 is the last second data block
  • the node data block 3 hash value of the node data block 3 is used as the root hash value; and the root hash value is sent;
  • the hash value of the last second data block in the second data block is used as the root hash value, and the root hash value is sent.
  • steps S301 to S304 the process of generating a data block and associating two data blocks through the hash value of the data block is exemplified; further, each data block is stored by using a linked list data structure.
  • the specific content of the file compressed package included in the block is not limited.
  • an embodiment of the present disclosure provides a method for acquiring a shared file based on a one-way chain data structure, and the method may include the following steps:
  • steps S401 to S404 correspond to the examples described in steps S301 to S304 to illustrate the method for acquiring the shared file.
  • Step S401 According to the received root hash value, obtain the file contained in the last data block (node data block 3).
  • step S304 it can be known that the node data block 3 shown in FIG. 4 is the last data block, and the node data block 3 hash value of the node data block 3 is the root hash value; receiving the root hash value value; according to the root hash value, obtain the last data block (node data block 3) corresponding to the root hash value from the blockchain, and obtain the file of the file compressed package included in the node data block 3 Name (file compressed package 3 is the file name of the file compressed package), obtain the file compressed package according to the file name of the file compressed package, and then obtain each file in the file compressed package through decompression; that is, receive the root hash value, Obtain the last data block corresponding to the root hash value from the blockchain according to the root hash value, obtain the file name of the file compressed package contained in the last data block, and obtain the file compressed package files in .
  • file compressed package 3 is the file name of the file compressed package
  • Step S402 Obtain the files contained in the previous data block (node data block 2) of the last data block.
  • step S401 the hash value of the node data block 2 included in the node data block 3 (the last data block) is obtained; and the node data block 2 (the previous data of the last data block) is obtained
  • the hash value of the block) (the obtained hash value of the previous data block) is taken as the current hash value; according to the hash value of the node data block 2, the node data block 2 is obtained from the blockchain
  • the file name of the included file compression package file compression package 2
  • file compression package 2 and obtain the file in the file compression package (file compression package 2); wherein, the hash value of the node data block 2 is before the last data block.
  • Hash value of a data block; file archive 2 is the file name of the file archive.
  • Step S403 Obtain the files contained in the previous data block (node data block 1).
  • the hash value of the node data block 1 included in the node data block 2 is obtained; according to the hash value of the node data block 1, the data of the node data block 1 is obtained from the blockchain.
  • the file name of the included file compressed package (file compressed package 1), and obtain the file in the file compressed package (file compressed package 1); wherein, the hash value of the node data block 1 is the previous one of the node data block 2
  • the hash value of the data block; the hash value of the node data block 1 is used as the current hash value; the file compressed package 1 is the file name of the file compressed package.
  • Step S404 Obtain the file corresponding to the initial data block.
  • the hash value of the initial data block included in the node data block 1 is obtained; the hash value of the initial data block is used as the current hash value; according to the hash value of the initial data block value, obtain the file name of the file compression package (file compression package 0) contained in the initial data block from the blockchain, and obtain the files in the file compression package (file compression package 0);
  • the hash value is the hash value of the previous data block of node data block 1; the file compression package 0 is the file name of the file compression package.
  • the steps S401 to S404 describe the acquisition of the files in the file compressed package, that is, the following steps are performed cyclically until each file compressed package in the blockchain indicated by the root hash value is obtained: the last data
  • the hash value of the previous data block contained in the block is used as the current hash value
  • the hash value of the previous data block and the file compression corresponding to the current data block are obtained from the blockchain according to the current hash value.
  • the file name of the package and the file in the file compression package; and the obtained hash value of the previous data block is used as the current hash value.
  • the decompression and decryption operations are performed on the obtained file compressed package to obtain the files in the file compressed package.
  • the method for performing decompression and decryption operations on the file compressed package is in one-to-one correspondence with the method for compressing and encrypting the file package, and the present disclosure does not limit the specific methods of compression, decompression, encryption, and decryption.
  • an embodiment of the present disclosure provides a method for storing a shared file by using a one-way chain data structure, and the method may include the following steps:
  • Step S501 Generate a first data block (initial data block).
  • step S301 the description of generating the first data block is consistent with step S301, and details are not repeated here.
  • Step S502 Generate a second data block (node data block 1).
  • the hash value of the file compression package 1 (the hash value corresponding to the second file compression package), the hash value of the initial data block (the previous The first method of generating node data block 1 (the second data block) is as described in step S302; according to the file compression package 1 (the file name of the second file compression package), the file compression package 1 The hash value (the hash value corresponding to the second file compression package) and the hash value of the initial data block (the hash value of the previous data block) generate the first type of node data block 1 (the second data block)
  • the second method of methods is as follows:
  • the shared file included in the second file compressed package is obtained, and the data between the shared file and the previous data block (initial data block) is obtained.
  • the hash value performs compression and encryption operations to form an update file package (for example: update file package 1), perform blockchain on-chain operations on the update file package and obtain the corresponding hash value (ie, update file package 1).
  • Hash value further, a second data block (for example, node data block 1) is formed according to the update file compressed package 1 and the hash value of the update file compressed package 1.
  • Step S503 Generate a second data block (node data block 2).
  • the first method for generating node data block 2 (the second data block) (the hash value of the previous data block) is as described in step S303;
  • the second method of the first method is as follows:
  • file compressed package 2 the shared file included in the second file compressed package is obtained, and the hash of the shared file and the previous data block (node data block 1) is obtained.
  • the value performs compression and encryption operations to form an update file compression package (for example: update file compression package 2), perform blockchain on-chain operations on the update file compression package and obtain the corresponding hash value (ie update file compression package 2 Ha value), a second data block (for example, node data block 2) is formed according to the update file compressed package 2 and the hash value of the update file compressed package 2.
  • Step S504 Generate a second data block (node data block 3).
  • the hash value of the file compression package 3 (the hash value corresponding to the second file compression package), and the hash value of the node data block 2
  • the first method for generating node data block 3 (the second data block) (the hash value of the previous data block) is as described in step S304;
  • the hash value of the package 2 (the hash value corresponding to the second file compression package) and the hash value of the initial data block (the hash value of the previous data block) generate the hash value of the node data block 2 (the second data block).
  • the second method of the first method is similar to step S503 and will not be repeated here.
  • Steps S502 to S504 describe the process of generating the second data block, that is, for the second file compressed package other than the first file compressed package in the at least two file compressed packages: according to the hash of the previous data block generating a second data block by the hash value, the file name of the second file compressed package, and the corresponding hash value of the second file compressed package, and further comprising: obtaining the second data block according to the file name of the second file compressed package For the shared file included in the second file compressed package, perform compression and encryption operations on the shared file and the hash value of the previous data block to form an updated file compressed package, and execute blockchain on the updated file compressed package. The chain operation is performed, and the hash value corresponding to the update file compressed package is obtained, and a second data block is generated according to the file name of the update file compressed package and the hash value of the update file compressed package.
  • the node data block 3 is the hash of the last second data block in the second data block and the last second data block in the second data block. value as the root hash and send said root hash. That is, the hash value of the last second data block in the second data blocks is used as the root hash value, and the root hash value is sent.
  • Steps S501-S504 illustrate the second method of generating data blocks. It can be understood that the present disclosure does not limit the number of data blocks and the specific content of the file compression package included in the data blocks.
  • an embodiment of the present disclosure provides a method for acquiring a shared file based on a one-way chain data structure, and the method may include the following steps:
  • steps S601-S604 correspond to the examples described in steps S501-S504 to illustrate the method for obtaining a shared file
  • Step S601 According to the received root hash value, obtain the file contained in the last data block (node data block 3).
  • the file name of the file compressed package that is, update file compressed package 3 contained in the last data block (node data block 3)
  • decompress and decrypt the file compression package obtain the hash value of the previous data block (node data block 2) contained in the decompressed and decrypted file package, and hash the node data block 2
  • the hash value is used as the current hash value, that is, the hash value of the previous data block contained in the last data block is used as the current hash value.
  • the root hash value is received, the last data block corresponding to the root hash value is obtained from the blockchain according to the root hash value, and the file of the file compressed package contained in the last data block is obtained. name, and obtain the files in the file archive.
  • the file compressed package contains the hash value of the previous data block
  • decompression and decryption operations are performed on the file compressed package, and the hash value of the previous data block is obtained.
  • Step S602 Obtain the files included in the previous data block (node data block 2) of the last data block.
  • the hash value of the node data block 2 included in the node data block 3 (the last data block) is obtained; wherein, the node data block 2 is the previous data of the last data block.
  • block further, according to the hash value of the node data block 2, obtain the file name of the file compressed package corresponding to the node data block 2 (update the file compressed package 2); and obtain the file in the file compressed package;
  • the file compressed package (update file compressed package 2) is decompressed and decrypted, and the hash value of the previous data block (node data block 1) contained in the decompressed and decrypted file package is obtained; that is, when the file compressed package contains the When the hash value of the previous data block is obtained, the decompression and decryption operations are performed on the file compressed package to obtain the hash value of the previous data block.
  • node data block 2 hash value as the current hash value
  • hash value of data block 1 node data block 1 is the previous data block of node data block 2)
  • file name of the file compressed package corresponding to the current data block node data block 2
  • file in the file compressed package Update files in file zip 2.
  • Step S603 Obtain the files contained in the previous data block (node data block 1).
  • step S602 where the node data block 1 is the previous data block of the node data block 2, as shown in FIG. 6, the current data block (node data block 1) is obtained according to the hash value of the node data block 1 Block 1) the file name of the corresponding file zip package and the files in the file zip package (update the files in the file zip package 1).
  • Decompress and decrypt the file compressed package (update file compressed package 1), obtain the hash value of the previous data block (initial data block) contained in the decompressed and decrypted file package, and use the node data block 1 hash value.
  • the current hash value that is, when the file compressed package contains the hash value of the previous data block
  • Step S604 Obtain the files contained in the previous data block (initial data block).
  • the current data block is obtained according to the hash value of the initial data block
  • the file name of the corresponding file compression package and the files in the file compression package (files in the file compression package 0). It can be understood that the initial data block contains the initial data block identifier; further, when the current data block contains the initial data block identifier, it is indicated to complete the compression of each file in the blockchain indicated by the root hash value. Bag.
  • steps S601-S604 From the last data block to the initial data block, according to the hash value of each data block, until each file compressed package in the blockchain indicated by the root hash value is obtained. That is, the following steps are performed cyclically until each file compressed package in the blockchain indicated by the root hash value is obtained: take the hash value of the previous data block contained in the last data block as the current hash value, and obtain the hash value of the previous data block, the file name of the file compression package corresponding to the current data block and the file in the file compression package from the blockchain according to the current hash value; and obtain the The hash value of the previous data block is taken as the current hash value.
  • acquiring the files in the file compression package includes: performing decompression and decryption operations on the file compression package to obtain the files in the file compression package.
  • the method for decompressing and decrypting the file compression package corresponds to the method for compressing and encrypting the file compression package, and the present disclosure does not limit the specific methods of compression, decompression, encryption, and decryption.
  • an embodiment of the present disclosure provides an apparatus 700 for sharing files, including: a file compression package uploading module 701, a file data block generating module 702, and a root hash value generating module 703; wherein,
  • the file compression package uploading module 701 is used to obtain the files to be shared, and form at least two file compression packages; perform the blockchain chaining operation on the file compression package, and obtain the hash corresponding to the file compression package. Greek value;
  • the file data block generation module 702 is configured to generate a first data block for the file name of the first file compressed package and the hash value of the first file compressed package in the at least two file compressed packages, and to The first data block performs the blockchain on-chain operation; for the second file compressed package other than the first file compressed package in the at least two file compressed packages: according to the hash value of the previous data block, The file name of the second file compressed package and the hash value corresponding to the second file compressed package, generate a second data block and perform a blockchain on-chain operation for the second data block;
  • the root hash value generating module 703 is configured to use the hash value of the last second data block in the second data block as the root hash value, and send the root hash value.
  • the file compression package uploading module 701 is further configured to acquire files to be shared and form at least two file compression packages, including: acquiring files to be shared within a predefined time range to form at least two file packages , and determine the number of files in the file package according to the network bandwidth.
  • the file compression package uploading module 701 is further configured to acquire the files to be shared and form at least two file compression packages, including: respectively performing compression and encryption operations on the file packages to form the file compression package Bag.
  • the file data block generating module 702 further includes that the first data block further includes an initial data block identifier.
  • the file compressed package on-chain module 701 further includes performing a blockchain concurrent on-chain operation on the file compressed package.
  • the file data block generation module 702 is further configured to: for the second file compressed package other than the first file compressed package in the at least two file compressed packages: according to the hash of the previous data block value, the file name of the second file compressed package, and the hash value corresponding to the second file compressed package to generate a second data block, further comprising: obtaining the first data block according to the file name of the second file compressed package For the shared file contained in the two-file compressed package, perform compression and encryption operations on the shared file and the hash value of the previous data block to form an updated file compressed package, and perform block chain operations on the updated file compressed package. The chain operation is performed, and the hash value corresponding to the update file compressed package is obtained, and a second data block is generated according to the file name of the update file compressed package and the hash value of the update file compressed package.
  • an embodiment of the present disclosure provides an apparatus 800 for sharing files, including: a module 801 for acquiring a root node file and a module 802 for acquiring an on-chain file; wherein,
  • the obtaining root node file module 801 is configured to receive the root hash value, obtain the last data block corresponding to the root hash value from the blockchain according to the root hash value, and obtain the last data block the file name of the contained file zip package, and obtain the files in the file zip package;
  • the on-chain file acquisition module 802 is used for the on-chain file acquisition module to perform the following steps cyclically until each file compressed package in the blockchain indicated by the root hash value is acquired:
  • the hash value of the previous data block contained in the last data block is used as the current hash value, and the hash value of the previous data block is obtained from the blockchain according to the current hash value, and the current data block corresponds to The file name of the file compression package and the files in the file compression package; and the obtained hash value of the previous data block is used as the current hash value.
  • the acquiring on-chain file module 802 is further configured to indicate that when the current data block contains an initial data block identifier, the instruction is to complete the acquisition of each file compressed package in the blockchain indicated by the root hash value. .
  • the obtaining on-chain file module 802 is further configured to obtain the files in the file compressed package, including: performing decompression and decryption operations on the file compressed package to obtain the files in the file compressed package.
  • the obtaining on-chain file module 802 is further configured to perform decompression and decryption operations on the file compressed package when the file compressed package contains the hash value of the previous data block, and obtain the The hash value of the previous data block.
  • an embodiment of the present disclosure provides a process for sharing files, and the process may include the following steps:
  • the process of uploading the shared file to the chain is described by steps S1001-S1003; the process of obtaining the shared file by the acquirer of the shared file is described by step S1004-step S1005; for example, the bank that executes the uploading of the shared file
  • the acquirer of the shared file can be the cooperative bank 1 and bank 2 directly related to the shared file in business, and the shared file is the statement between the bank 1 and the bank 2; it is understandable that the bank 1 and the bank 2 is the acquirer who has permission to obtain the shared file.
  • Step S1001 Acquire the file to be shared, and form at least two file compression packages; perform a blockchain on-chain operation on the file compression package, and obtain the hash value corresponding to the file compression package.
  • step S101 the description about the formation of the file compression package and the uploading of the chain is consistent with step S101, and will not be repeated here; further, obtaining the file to be shared, and forming at least two file compression packages, including: obtaining the file within a predefined time range.
  • the files to be shared are formed into at least two file packages, and the number of files in the file packages is determined according to the network bandwidth; compression and encryption operations are performed on the file packages respectively to form the file compression package;
  • the package performs concurrent on-chain operations on the blockchain.
  • Step S1002 Generate a first data block for the file name of the first file compression package in the at least two file compression packages and the hash value of the first file compression package, and execute a region on the first data block.
  • Blockchain on-chain operations
  • the second file compression package other than the first file compression package in the at least two file compression packages according to the hash value of the previous data block, the file name of the second file compression package and the second file compression package
  • the hash value corresponding to the file compressed package is generated, and a second data block is generated and the blockchain up-chain operation is performed on the second data block.
  • the description about generating the data block is consistent with step S102, and details are not repeated here.
  • the second file compressed package other than the first file compressed package in the at least two file compressed packages according to the hash value of the previous data block, the file name of the second file compressed package and the generating a second data block by obtaining the hash value corresponding to the second file compression package, and further comprising: obtaining the shared file included in the second file compression package according to the file name of the second file compression package, The shared file and the hash value of the previous data block perform compression and encryption operations to form an update file compressed package, perform a blockchain on-chain operation on the updated file compressed package, and obtain the corresponding update file compressed package.
  • Hash value, the second data block is generated according to the file name of the compressed package of the update file and the hash value of the compressed package of the update file.
  • Step S1003 respectively perform a blockchain on-chain operation on the hash value corresponding to the file compressed package, the first data block and the corresponding hash value, the second data block and the corresponding hash value;
  • the hash value of the last second data block in the second data block is used as the root hash value, and the root hash value is sent.
  • step S103 the description about sending the root hash value is consistent with step S103, and details are not repeated here.
  • Step S1004 Receive the root hash value, obtain the last data block corresponding to the root hash value from the blockchain according to the root hash value, and obtain the file of the file compression package included in the last data block name, and obtain the files in the file archive.
  • step S201 the descriptions of the two methods for obtaining the files included in the data block according to the root hash value are consistent with step S201, and are not repeated here.
  • Step S1005 Circularly execute the following steps until each file compressed package in the blockchain indicated by the root hash value is obtained: take the hash value of the previous data block contained in the last data block as the current hash value; value, and obtain the hash value of the previous data block, the file name of the file compression package corresponding to the current data block and the file in the file compression package from the blockchain according to the current hash value; and The acquired hash value of the previous data block is used as the current hash value.
  • step S202 the descriptions of the two methods of cyclically obtaining the compressed packages of each file in the blockchain indicated by the root hash value are consistent with step S202, and are not repeated here.
  • Embodiments of the present disclosure also provide an electronic device for sharing files, including: one or more processors; and a storage device for storing one or more programs, when the one or more programs are stored by the one or more programs Each processor executes, so that the one or more processors implement the method provided by any one of the foregoing embodiments.
  • An embodiment of the present disclosure further provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, implements the method provided by any of the foregoing embodiments.
  • FIG. 11 shows an exemplary system architecture 1100 of a method for sharing a file or an apparatus for sharing a file to which embodiments of the present disclosure may be applied.
  • the system architecture 1100 may include terminal devices 1101 , 1102 , and 1103 , a network 1104 and a server 1105 .
  • the network 1104 is a medium used to provide a communication link between the terminal devices 1101 , 1102 , 1103 and the server 1105 .
  • the network 1104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
  • the user can use the terminal devices 1101, 1102, 1103 to interact with the server 1105 through the network 1104 to receive or send messages and the like.
  • Various client applications may be installed on the terminal devices 1101 , 1102 , and 1103 , such as enterprise application clients, web browser applications, search applications, instant messaging tools, and email clients.
  • the terminal devices 1101, 1102, 1103 may be various electronic devices having a display screen and supporting the running of various client applications, including but not limited to smart phones, tablet computers, laptops and desktop computers, and the like.
  • the server 1105 may be a server that provides various services, for example, a background management server that provides support for the user's request for obtaining files by using the terminal devices 1101 , 1102 , and 1103 .
  • the background management server can upload and store the file to be shared, process the request for obtaining the file, and return the file to the terminal device.
  • the method for sharing files provided by the embodiments of the present disclosure is generally executed by the server 1105 , and accordingly, the apparatus for sharing files is generally set in the server 1105 .
  • terminal devices, networks and servers in FIG. 11 are merely illustrative. There can be any number of terminal devices, networks and servers according to implementation needs.
  • FIG. 12 shows a schematic structural diagram of a computer system 1200 suitable for implementing the terminal device of the embodiment of the present disclosure.
  • the terminal device shown in FIG. 12 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
  • a computer system 1200 includes a central processing unit (CPU) 1201, which can be loaded into a random access memory (RAM) 1203 according to a program stored in a read only memory (ROM) 1202 or a program from a storage section 1208 Instead, various appropriate actions and processes are performed.
  • RAM random access memory
  • ROM read only memory
  • various programs and data required for the operation of the system 1200 are also stored.
  • the CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other through a bus 1204.
  • An input/output (I/O) interface 1205 is also connected to bus 1204 .
  • the following components are connected to the I/O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc. ; and a communication section 1209 including a network interface card such as a LAN card, a modem, and the like.
  • the communication section 1209 performs communication processing via a network such as the Internet.
  • Drivers 1210 are also connected to I/O interface 1205 as needed.
  • a removable medium 1211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 1210 as needed so that a computer program read therefrom is installed into the storage section 1208 as needed.
  • embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods illustrated in the flowcharts.
  • the computer program may be downloaded and installed from the network via the communication portion 1209, and/or installed from the removable medium 1211.
  • CPU central processing unit
  • the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two.
  • the computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples of computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), fiber optics, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take a variety of forms including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • a computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
  • Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
  • each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions.
  • the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
  • the modules and/or units involved in the embodiments of the present disclosure may be implemented in a software manner, and may also be implemented in a hardware manner.
  • the described modules and/or units can also be provided in the processor, for example, it can be described as: a processor includes a file compression package uploading module, a file data block generating module and a root hash value generating module. Among them, the names of these modules do not constitute a limitation of the module itself under certain circumstances.
  • the file data block generation module can also be described as "according to the file compression package and the hash value of the previous data block, Modules that form blocks of data". It can also be described as: a processor includes a module for acquiring a root node file and a module for acquiring an on-chain file.
  • the names of these modules do not constitute a limitation of the module itself under certain circumstances.
  • the module for obtaining the root node file can also be described as "according to the root hash value, obtain the data block corresponding to the root hash value.
  • a module containing a file can also be described as "according to the root hash value, obtain the data block corresponding to the root hash value.
  • the present disclosure also provides a computer-readable medium.
  • the computer-readable medium may be included in the device described in the above-mentioned embodiments, or it may exist alone without being assembled into the device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by a device, the device includes: acquiring the file to be shared, and executing the block chain concurrently on the chain for the compressed package of the shared file.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

一种共享文件的方法、装置和系统,主要涉及计算机技术领域。该方法包括:获取待共享的文件,对共享文件压缩包执行区块链并发上链操作,根据压缩包文件名及其哈希值形成数据块,所述数据块包含前一个数据块的哈希值并将最后一个数据块的哈希值为根哈希值;根据根哈希值,获取最后一个数据块包含的文件,进而获取根哈希值指示的区块链中的各个文件压缩包;通过将多个文件压缩成文件包,部分克服了因为文件数量大造成的网络资源负担过高的技术问题,通过将各个文件压缩包并发上链,提高了文件上链和共享的效率;利用区块链上的单向链表数据结构保存和共享文件,提高了文件的安全性。

Description

共享文件的方法、装置及系统
本申请要求于2020年8月4日提交的题为“一种共享文件的方法、装置和系统”的中国专利申请No.202010772463.5的优先权,在此全文引用上述中国专利申请公开的内容以作为本申请的一部分。
技术领域
本公开涉及计算机技术领域,尤其涉及一种共享文件的方法、装置和系统。
背景技术
在企业的业务流程中,往往需要共享业务所需要的文件,尤其是涉及到企业与企业之间的业务,随着区块链技术的发展,企业之间可以基于区块链共享文件,所采用的方法主要有:1.将所有的共享文件当作交易上链并进行广播实现共享,2.将文件保存在中心化数据库中,将文件的电子存证上链并进行广播实现共享。
在实现本公开过程中,发明人发现现有技术中至少存在如下问题:
利用方法1的方法,当文件的数量较大时,造成网络资源的使用率过高从而导致文件上链的效率减低;方法2,利用中心化的数据库保存文件,当文件为安全性较高的文件时,存在一定的安全风险。
发明内容
有鉴于此,本公开实施例提供一种共享文件的方法和装置,获取待共享的文件,对共享文件压缩包执行区块链并发上链操作,根据压缩包文件名及其哈希值形成数据块,所述数据块包含前一个数据块的哈希值;将最后一个数据块的哈希值为根哈希值;根据根哈希值,获取最后一个数据块包含的文件,进而获取根哈希值指示的区块链中的各个文件压缩包;通过将多个文件压缩成文件包,部分克服了因为文件数量大造成的网络资源负担过高的技术问题,通过将各个文件压缩 包并发上链,提高了文件上链和共享的效率;利用区块链上的单向链表数据结构保存和共享文件,提高文件的安全性。
为实现上述目的,根据本公开实施例的第一方面,提供了一种共享文件的方法,其特征在于,包括:获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值;针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作;将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
可选地,所述共享文件的方法,其特征在于,
获取待共享的文件,形成至少两个文件压缩包,包括:
获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
可选地,所述共享文件的方法,其特征在于,
获取待共享的文件,形成至少两个文件压缩包,包括:
分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
可选地,所述共享文件的方法,其特征在于,
所述第一数据块还包括初始数据块标识。
可选地,所述共享文件的方法,其特征在于,
对所述文件压缩包执行区块链并发上链操作。
可选地,所述共享文件的方法,其特征在于,
针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:
根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所 包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
为实现上述目的,根据本公开实施例的第二方面,提供了一种共享文件的方法,其特征在于,包括:
接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;
循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
可选地,所述共享文件的方法,其特征在于,
当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
可选地,所述共享文件的方法,其特征在于,
获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。
可选地,所述共享文件的方法,其特征在于,
当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
为实现上述目的,根据本公开实施例的第三方面,提供了一种共享文件的装置,其特征在于,包括:文件压缩包上链模块、文件数据块生成模块和根哈希值生成模块;其中,
所述文件压缩包上链模块,用于获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述 文件压缩包对应的哈希值;
所述文件数据块生成模块,用于针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作;
所述根哈希值生成模块,用于将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
可选地,所述共享文件的装置,其特征在于,
获取待共享的文件,形成至少两个文件压缩包,包括:获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
可选地,所述共享文件的装置,其特征在于,
获取待共享的文件,形成至少两个文件压缩包,包括:分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
可选地,所述共享文件的装置,其特征在于,
所述第一数据块还包括初始数据块标识。
可选地,所述共享文件的装置,其特征在于,
对所述文件压缩包执行区块链并发上链操作。
可选地,所述共享文件的装置,其特征在于,
针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:
根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所 述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
为实现上述目的,根据本公开实施例的第四方面,还提供了一种共享文件的装置,其特征在于,包括:获取根节点文件模块和获取链上文件模块;其中,
所述获取根节点文件模块,用于接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;
所述获取链上文件模块,用于循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
可选地,所述共享文件的装置,其特征在于,
当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
可选地,所述共享文件的装置,其特征在于,
获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。
可选地,所述共享文件的装置,其特征在于,
当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
为实现上述目的,根据本公开实施例的第五方面,提供了一种共享文件的系统900,包含上述第三方面提供的共享文件的装置700、以及上述第四方面提供的共享文件的装置800。
为实现上述目的,根据本公开实施例的第六方面,提供了一种共享文件的电子设备,其特征在于,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或 多个处理器执行,使得所述一个或多个处理器实现如上述共享文件的方法中任一所述的方法。
为实现上述目的,根据本公开实施例的第七方面,提供了一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如上述共享文件的方法中任一所述的方法。
上述发明中的一个实施例具有如下优点或有益效果:获取待共享的文件,对共享文件压缩包执行区块链并发上链操作,根据压缩包文件名及其哈希值形成数据块,所述数据块包含前一个数据块的哈希值;将最后一个数据块的哈希值为根哈希值;根据根哈希值,获取最后一个数据块包含的文件,进而获取根哈希值指示的区块链中的各个文件压缩包;通过将多个文件压缩成文件包,部分克服了因为文件数量大造成的网络资源负担过高的技术问题,通过将各个文件压缩包并发上链,提高了文件上链和共享的效率;利用区块链上的单向链表数据结构保存和共享文件,提高文件的安全性。
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。
附图说明
附图用于更好地理解本公开,不构成对本公开的不当限定。其中:
图1是本公开一个实施例提供的一种存储共享文件的方法的流程示意图;
图2是本公开一个实施例提供的一种获取共享文件的流程示意图;
图3是本公开第一实施例提供的一种生成并存储共享文件数据块链状数据结构示意图;
图4是本公开第一实施例提供的一种获取共享文件的流程示意图;
图5是本公开第二实施例提供的一种生成并存储共享文件数据块链状数据结构示意图;
图6是本公开第二实施例提供的一种获取共享文件的流程示意图;
图7是本公开一个实施例提供的一种共享文件的装置的结构示意图;
图8是本公开一个实施例提供的一种获取共享文件的装置的结构示意图;
图9是本公开一个实施例提供的一种获取共享文件的系统的结构示意图;
图10是本公开一个实施例提供的一种共享文件的流程示意图;
图11是本公开实施例可以应用于其中的示例性系统架构图;
图12是适于用来实现本公开实施例的终端设备或服务器的计算机系统的结构示意图。
具体实施方式
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。
如图1所示,本公开实施例提供了一种共享文件的方法,该方法可以包括以下步骤:
步骤S101:获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值。
具体地,待共享的文件为实时生成的文件,根据所述多个文件,形成至少两个文件包(即,多个文件包),并分别形成文件压缩包;其中,获取待共享的文件,形成至少两个文件压缩包,包括:获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
其中,所述待共享文件可以为在预定义时间范围内产生的,例如,一个小时之内某电子银行产生的交易文件、半小时之内某两个电子银行产生的对账单文件、一天之内电子商城产生的订单文件等,所述预定义时间范围可以根据业务的场景和产生文件的数量来设定,例如,一天、一小时、10分钟等;本公开对预定义时间范围不做限定。进一 步地,根据获取的待共享文件的总数量,根据网络带宽,确定各个文件包中文件的数量,可以理解的是,为了能够根据网络带宽实现并发上链,因此根据网络带宽确定文件包中的文件进而形成多个文件包,并分别对文件包进行压缩操作,分别形成文件压缩包;由于文件的尺寸不同,因此文件包中的数量是可变的;例如:不同电子银行之间的对账单文件、根据一个时间范围内的总量,通过获取网络的带宽确定每个文件包中包含文件的数量,进一步地,进行对文件包进行压缩形成多个文件压缩包。
再进一步地,获取待共享的文件,形成至少两个文件压缩包,还包括对文件包执行压缩操作以及加密操作,可以理解的是,通过加密提高了文件的安全性,尤其是提高了对安全性要求高的例如电子银行之间的对账单等文件的安全性;其中,压缩的方法可以使用压缩工具软件,例如gzip、WinRAR等;加密的方法可以使用压缩软件进行加密,也可使用操作系统或加密软件进行加密,本公开对压缩使用的具体方法、加密的具体方法不做限定。即,分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
更进一步地,对各个文件压缩包执行区块链并发上链操作,因为各个文件压缩包之间不具有依赖交易关系,从而可以执行文件压缩包的并发上链操作;可以理解的是,由于存在网络带宽等资源的限制,多个文件压缩包的上链操作还可以是分批进行的,每一批内文件压缩包执行并发上链,通过并发上链的操作,提高了文件上链的效率,即,对所述文件压缩包执行区块链并发上链操作。对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值,其中,可以将文件压缩包作为交易执行上链操作,并从区块链获取对应于该交易返回的哈希值,该哈希值即为所述文件压缩包对应的哈希值,即,并获取所述文件压缩包对应的哈希值。其中,所使用的区块链可以是联盟链、私有链等,本公开对区块链的类型不做限定。本公开对执行区块链上链所使用的具体工具或者方法不做限定。
步骤S102:针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述 第一数据块执行区块链上链操作;针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作。
具体地,根据步骤S101形成的文件压缩包所包含的文件压缩包的文件名、文件压缩包对应的哈希值,其中文件压缩包的文件名用于唯一标识文件压缩包,通过所述文件名,可以获取与所述文件名对应的文件压缩包,进而获取压缩文件包中的文件,本公开所述文件压缩包的文件名的命名规则不做限定。
进一步地,针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;具体地,获取至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块;所述第一数据块为初始数据块,包含指示为初始数据块的标识;即,所述第一数据块还包括初始数据块标识。
下面以图3中所示的例子说明上述步骤;
如图3所示,根据文件压缩包0(即,第一文件压缩包)、文件压缩包0的哈希值(即,第一文件压缩包对应的哈希值)形成第一数据块,所述第一数据块即为初始数据块,所述第一数据块包含初始数据块标识,本公开对初始数据块标识的具体命名规则和内容不做限定。
进一步地,生成第二数据块(节点数据块1);根据初始数据块哈希值、文件压缩包1(即,第二文件压缩包的文件名)、文件压缩包1哈希值(第二文件压缩包对应的哈希值)生成节点数据块1;其中,初始数据块哈希值为节点数据块1(第二数据块)的前一个数据块的哈希值;节点数据块1为所述至少两个文件压缩包中除所述第一文件压缩包(文件压缩包0)以外的第二文件压缩包;即,针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作。
针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的 文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作。其中,所述前一个数据块的哈希值为所述前一个数据块上链之后所获取的,例如,前一个数据块作为一个交易上链,得到了交易的返回值作为前一个数据块的哈希值;类似地,所述一个或者多个第二数据块的哈希值在第二数据块上链后从区块链获取。
可以理解的是,由于第一数据块(即初始数据块)不包含前一个数据块的哈希值,初始数据块作为初始数据块包含初始数据块标识;其中,除第一数据块以外,其他数据块均为第二数据块;可以理解的是,基于第一数据块、一个或者多个第二数据块形成了单向链表存储结构;进一步地,生成第二数据块可以采用两种方法:第一种方法的描述与图3中示例的步骤S301-步骤S304一致;第二种方法与图5中示例的步骤S501-步骤S504的描述一致,在此不再赘述。
步骤S103:将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
具体地,将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值;由步骤S102的描述可知,第一数据块和一个或者多个第二数据块形成单向链表结构,链表结构包含了第一数据块(初始数据块)和多个第二数据块;其中,多个第二数据块中的最后一个第二数据块的哈希值,作为根哈希值,发送所述根哈希值。
发送所述根哈希值有两种方法:1)通过区块链发送所述根哈希值给有获取共享文件权限的获取方;2)通过其他方式发送所述根哈希值给有获取共享文件权限的获取方,例如:官方电子邮件等;可以理解的是,将所述根哈希值发送给有获取共享文件权限的获取方,所述有权限的获取方可以是一方或者多方;例如:所述文件为银行A和银行B在一个小时内产生的对账单文件;在步骤S101-步骤S103之后产生了根哈希值,则将所述根哈希值发送给对这些对账单文件有获取权限的银行A和银行B;显而易见地,利用该操作进一步提高了文件的安全性。
如图2所示,本公开实施例提供了一种获取共享文件的方法,该方法可以包括以下步骤:
步骤S201:接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件。
具体地,根据所述根哈希值,从区块链上获取所述根哈希值对应的最后一个数据块,其中,进一步地,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;从区块链上获取文件的描述与步骤S401或者步骤S601所描述的示例一致,在此不再赘述。
步骤S202:循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
具体地,循环执行直至获取到所述根哈希值指示的区块链中的各个文件压缩包有两种方法:第一种方法与步骤S402-步骤S404所描述的示例一致,在此不再赘述;第二种方法与步骤S602-步骤S604所描述的示例一致,在此不再赘述。
如图3所示,本公开实施例提供了一种利用单向链状数据结构存储共享文件的方法,该方法可以包括以下步骤:
在步骤S301-步骤S304之前,假设各个文件压缩包已经生成并上链。
步骤S301:生成第一数据块。
具体地,根据文件压缩包0、文件压缩包0哈希值形成第一数据块,所述第一数据块即为初始数据块,所述第一数据块包含初始数据块标识,本公开对所述初始数据块标识的具体内容不做限定;即,所述第一数据块还包括初始数据块标识。
其中,文件压缩包0为所述文件压缩包的文件名;并且文件压缩 包0为所述第一文件压缩包;即,针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作。
步骤S302:生成第二数据块(节点数据块1)。
具体地,根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块;如图3的示例所示,根据初始数据块的哈希值、文件压缩包1、文件压缩包1对应的哈希值生成节点数据块1;其中,文件压缩包1为第二文件压缩包的文件名;初始数据块的哈希值为节点数据块1(第二数据块)前一个数据块的哈希值;文件压缩包1哈希值为所述第二文件压缩包对应的哈希值。
步骤S303:生成第二数据块(节点数据块2)。
具体地,如图3的示例所示,根据节点数据块1哈希值、文件压缩包2、文件压缩包2哈希值生成节点数据块2;其中,文件压缩包2为第二文件压缩包的文件名;节点数据块1的哈希值为节点数据块2(第二数据块)前一个数据块的哈希值;文件压缩包2哈希值为所述第二文件压缩包对应的哈希值。
步骤S304:生成第二数据块(节点数据块3)。
具体地,如图3的示例所示,根据节点数据块2哈希值、文件压缩包3、文件压缩包3哈希值生成节点数据块3;其中,文件压缩包3为第二文件压缩包的文件名;节点数据块2哈希值为节点数据块3(第二数据块)前一个数据块的哈希值;文件压缩包3哈希值为所述第二文件压缩包对应的哈希值。
步骤S302-步骤S304描述了多个第二数据块的生成过程,即,针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作。
进一步地,假设节点数据块3为最后一个第二数据块,则将节点数据块3的节点数据块3哈希值作为根哈希值;并发送所述根哈希值; 即,将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
通过步骤S301-步骤S304,举例说明了生成数据块并通过数据块的哈希值关联两个数据块的流程;进一步地,利用链表数据结构存储各个数据块,本公开对数据块的数量、数据块所包含的文件压缩包的具体内容不做限定。
如图4所示,本公开实施例提供了一种基于单向链状数据结构获取共享文件的方法,该方法可以包括以下步骤:
以下步骤S401-步骤S404对应步骤S301-步骤S304所描述的示例说明获取共享文件的方法。
步骤S401:根据接收的根哈希值,获取最后一个数据块(节点数据块3)包含的文件。
具体地,根据步骤S304的描述可知,如图4所示的节点数据块3为最后一个数据块,则节点数据块3的节点数据块3哈希值为根哈希值;接收所述根哈希值;根据所述根哈希值,从区块链上获取所述根哈希值对应的最后一个数据块(节点数据块3),并获取节点数据块3所包含的文件压缩包的文件名(文件压缩包3即为该文件压缩包的文件名),根据文件压缩包的文件名,获取文件压缩包,进而通过解压获取文件压缩包中的各个文件;即,接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件。
步骤S402:获取最后一个数据块的前一个数据块(节点数据块2)包含的文件。
具体地,如图4所示,通过步骤S401,获取节点数据块3(最后一个数据块)包含的节点数据块2的哈希值;并将节点数据块2(最后一个数据块的前一个数据块的哈希值)的哈希值(获取的所述前一个数据块的哈希值)作为当前哈希值;根据节点数据块2的哈希值,从区块链上获取节点数据块2所包含的文件压缩包的文件名(文件压缩包2),并获取所述文件压缩包(文件压缩包2)中的文件;其中,节 点数据块2的哈希值为最后一个数据块的前一个数据块的哈希值;文件压缩包2为文件压缩包的文件名。
步骤S403:获取前一个数据块(节点数据块1)包含的文件。
具体地,如图4所示,通过步骤S402,获取节点数据块2包含的节点数据块1的哈希值;根据节点数据块1的哈希值,从区块链上获取节点数据块1所包含的文件压缩包的文件名(文件压缩包1),并获取所述文件压缩包(文件压缩包1)中的文件;其中,节点数据块1的哈希值为节点数据块2的前一个数据块的哈希值;并将节点数据块1的哈希值作为当前哈希值;文件压缩包1为文件压缩包的文件名。
步骤S404:获取初始数据块对应的文件。
具体地,如图4所示,通过步骤S403,获取节点数据块1包含的初始数据块的哈希值;并将初始数据块的哈希值作为当前哈希值;根据初始数据块的哈希值,从区块链上获取初始数据块所包含的文件压缩包的文件名(文件压缩包0),并获取所述文件压缩包(文件压缩包0)中的文件;其中,初始数据块的哈希值为节点数据块1的前一个数据块的哈希值;文件压缩包0为文件压缩包的文件名。
可以理解的是,当获取指示为初始数据块的初始数据块标识时,初始数据块包含的压缩文件包中不存在前一个数据块的哈希值;则停止获取前一个数据块,指示为完成链表结构中的各个文件压缩包的获取过程;即,当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
步骤S401-步骤S404所描述的获取文件压缩包中的文件,即,循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
进一步地,对获取的文件压缩包执行解压和解密操作,获取文件压缩包中的文件。具体地,对所述文件压缩包执行解压和解密操作的 方法与对文件包压缩和加密的方法为一一对应,本公开对压缩、解压、加密、解密的具体方法不做限定。
如图5所示,本公开实施例提供了一种利用单向链状数据结构存储共享文件的方法,该方法可以包括以下步骤:
步骤S501:生成第一数据块(初始数据块)。
具体地,生成第一数据块的描述与步骤S301一致,在此不再赘述。
步骤S502:生成第二数据块(节点数据块1)。
具体地,根据文件压缩包1(第二文件压缩包的文件名)、文件压缩包1哈希值(所述第二文件压缩包对应的哈希值)、初始数据块的哈希值(前一个数据块的哈希值)生成节点数据块1(第二数据块)的第一种方法如步骤S302所描述;根据文件压缩包1(第二文件压缩包的文件名)、文件压缩包1哈希值(所述第二文件压缩包对应的哈希值)、初始数据块的哈希值(前一个数据块的哈希值)生成节点数据块1(第二数据块)的第一种方法的第二种方法如下:
根据第二文件压缩包的文件名(例如,文件压缩包1),获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块(初始数据块)的哈希值执行压缩和加密操作,形成更新文件压缩包(例如:更新文件压缩包1),对更新文件压缩包执行区块链上链操作并获取对应的哈希值(即更新文件压缩包1哈希值),进一步地,根据更新文件压缩包1、更新文件压缩包1哈希值形成第二数据块(例如,节点数据块1)。
步骤S503:生成第二数据块(节点数据块2)。
具体地,根据文件压缩包2(第二文件压缩包的文件名)、文件压缩包2的哈希值(所述第二文件压缩包对应的哈希值)、节点数据块1的哈希值(前一个数据块的哈希值)生成节点数据块2(第二数据块)的第一种方法如步骤S303所描述;根据文件压缩包2(第二文件压缩包的文件名)、文件压缩包2的哈希值(所述第二文件压缩包对应的哈希值)、节点数据块1的哈希值(前一个数据块的哈希值)生成节点数据块2(第二数据块)的第一种方法的第二种方法如下:
根据第二文件压缩包的文件名(文件压缩包2),获取所述第二文 件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块(节点数据块1)的哈希值执行压缩和加密操作,形成更新文件压缩包(例如:更新文件压缩包2),对更新文件压缩包执行区块链上链操作并获取对应的哈希值(即更新文件压缩包2哈希值),根据更新文件压缩包2、更新文件压缩包2哈希值形成第二数据块(例如,节点数据块2)。
步骤S504:生成第二数据块(节点数据块3)。
具体地,根据文件压缩包3(第二文件压缩包的文件名)、文件压缩包3的哈希值(所述第二文件压缩包对应的哈希值)、节点数据块2的哈希值(前一个数据块的哈希值)生成节点数据块3(第二数据块)的第一种方法如步骤S304所描述;根据文件压缩包2(第二文件压缩包的文件名)、文件压缩包2的哈希值(所述第二文件压缩包对应的哈希值)、初始数据块的哈希值(前一个数据块的哈希值)生成节点数据块2(第二数据块)的第一种方法的第二种方法与步骤S503类似,在此不再赘述。
步骤S502-步骤S504描述了生成第二数据块的流程,即,针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
进一步地,如图5所示,所述节点数据块3为将所述第二数据块中的最后一个第二数据块,将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。即,将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
通过步骤S501-步骤S504,举例说明了生成数据块的第二种方法,可以理解的是,本公开对数据块的数量、数据块所包含的文件压缩包 的具体内容不做限定。
如图6所示,本公开实施例提供了一种基于单向链状数据结构获取共享文件的方法,该方法可以包括以下步骤:
以下步骤S601-步骤S604对应步骤S501-步骤S504所描述的示例说明获取共享文件的方法;
步骤S601:根据接收的根哈希值,获取最后一个数据块(节点数据块3)包含的文件。
具体地,获取最后一个数据块(节点数据块3)所包含的文件压缩包的文件名(即,更新文件压缩包3),根据更新文件压缩包3,获取对应于文件名为“更新文件压缩包3”的文件压缩包,对所述文件压缩包进行解压解密,获取解压解密后的文件包所包含的前一个数据块(节点数据块2)的哈希值,并将节点数据块2哈希值作为当前哈希值,即,将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值。又即,接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件。
进一步地,当所述文件压缩包包含的前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,并获取所述前一个数据块的哈希值。
步骤S602:获取最后一个数据块的前一个数据块(节点数据块2)包含的文件。
具体地,如图6所示,通过步骤S601,获取节点数据块3(最后一个数据块)包含的节点数据块2的哈希值;其中,节点数据块2为最后一个数据块的前一个数据块,进一步地,根据节点数据块2哈希值,获取节点数据块2所对应的文件压缩包的文件名(更新文件压缩包2);并获取所述文件压缩包中的文件;对所述文件压缩包(更新文件压缩包2)进行解压解密,获取解压解密后的文件包所包含的前一个数据块(节点数据块1)的哈希值;即,当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
进一步地,将节点数据块2哈希值作为当前哈希值,并根据所述当前哈希值(节点数据块2哈希值)从区块链上获取前一个数据块的哈希值(节点数据块1哈希值,节点数据块1为节点数据块2的前一个数据块)、所述当前数据块(节点数据块2)对应的文件压缩包的文件名和所述文件压缩包中的文件(更新文件压缩包2中的文件)。
步骤S603:获取前一个数据块(节点数据块1)包含的文件。
具体地,与步骤S602类似,其中,节点数据块1为节点数据块2的前一个数据块,如图6所示,根据节点数据块1的哈希值,获取所述当前数据块(节点数据块1)对应的文件压缩包的文件名和所述文件压缩包中的文件(更新文件压缩包1中的文件)。
对所述文件压缩包(更新文件压缩包1)进行解压解密,获取解压解密后的文件包所包含的前一个数据块(初始数据块)的哈希值,并将节点数据块1哈希值作为当前哈希值;即,当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
步骤S604:获取前一个数据块(初始数据块)包含的文件。
具体地,与步骤S603类似,其中,初始数据块为节点数据块1的前一个数据块,如图6所示,根据初始数据块的哈希值,获取所述当前数据块(初始数据块)对应的文件压缩包的文件名和所述文件压缩包中的文件(文件压缩包0中的文件)。可以理解的是,初始数据块包含初始数据块标识;进一步地,当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
经过步骤S601-S604的循环操作,从最后一个数据块到初始数据块,根据各个数据块哈希值,直至获取到所述根哈希值指示的区块链中的各个文件压缩包。即,循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据 块的哈希值作为所述当前哈希值。
进一步地,获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。其中,对所述文件压缩包进行解压解密的方法与对所述文件压缩包压缩加密的方法为一一对应,本公开对压缩、解压、加密、解密的具体方法不做限定。
如图7所示,本公开实施例提供了一种共享文件的装置700,包括:文件压缩包上链模块701、文件数据块生成模块702和根哈希值生成模块703;其中,
所述文件压缩包上链模块701,用于获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值;
所述文件数据块生成模块702,用于针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作;
所述根哈希值生成模块703,用于将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
可选地,所述文件压缩包上链模块701,还用于获取待共享的文件,形成至少两个文件压缩包,包括:获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
可选地,所述文件压缩包上链模块701,还用于获取待共享的文件,形成至少两个文件压缩包,包括:分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
可选地,所述文件数据块生成模块702,还包括所述第一数据块还包括初始数据块标识。
可选地,所述文件压缩包上链模块701,还包括对所述文件压缩包 执行区块链并发上链操作。
可选地,所述文件数据块生成模块702,还用于针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
如图8所示,本公开实施例提供了一种共享文件的装置800,包括:获取根节点文件模块801和获取链上文件模块802;其中,
所述获取根节点文件模块801,用于接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;
所述获取链上文件模块802,用于所述获取链上文件模块,用于循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
可选地,所述获取链上文件模块802,还用于当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
可选地,所述获取链上文件模块802,还用于获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。
可选地,所述获取链上文件模块802,还用于当所述文件压缩包包 含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
如图10所示,本公开实施例提供了一种共享文件的流程,该流程可以包括以下步骤:
如图10所示的示意流程,利用步骤S1001-步骤S1003描述共享文件上链的过程;利用步骤S1004-步骤S1005描述共享文件获取方获取共享文件的过程;例如,执行共享文件上链的是银行总部,共享文件获取方可以是在业务上与共享文件直接相关的合作银行1、银行2,而所述共享文件为银行1、银行2之间的对账单;可以理解的是,银行1和银行2为有权限获得共享文件的获取方。
步骤S1001:获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值。
具体地,关于文件压缩包的形成以及上链的描述与步骤S101一致,在此不再赘述;进一步地,获取待共享的文件,形成至少两个文件压缩包,包括:获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量;分别对所述文件包执行压缩和加密操作,形成所述文件压缩包;对所述文件压缩包执行区块链并发上链操作。
步骤S1002:对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作。
针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作。具体地,关于生成数据块的描述与步骤S102一致,在此不再赘述。
进一步地,针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数 据块,还包括:根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
步骤S1003:分别对所述文件压缩包对应的哈希值、所述第一数据块以及对应的哈希值、第二数据块以及对应的哈希值执行区块链上链操作;将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
具体地,关于发送根哈希值的描述与步骤S103一致,在此不再赘述。
步骤S1004:接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件。
具体地,关于根据根哈希值,获取数据块所包含的文件的两种方法的描述与步骤S201一致,在此不再赘述。
步骤S1005:循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
具体地,关于循环获取根哈希值指示的区块链中的各个文件压缩包的两种方法的描述与步骤S202一致,在此不再赘述。
本公开实施例还提供了一种共享文件的电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现上述任一实施例提供的方法。
本公开实施例还提供了一种计算机可读介质,其上存储有计算机 程序,所述程序被处理器执行时实现上述任一实施例提供的方法。
图11示出了可以应用本公开实施例的共享文件的方法或共享文件的装置的示例性系统架构1100。
如图11所示,系统架构1100可以包括终端设备1101、1102、1103,网络1104和服务器1105。网络1104用以在终端设备1101、1102、1103和服务器1105之间提供通信链路的介质。网络1104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。
用户可以使用终端设备1101、1102、1103通过网络1104与服务器1105交互,以接收或发送消息等。终端设备1101、1102、1103上可以安装有各种客户端应用,例如企业应用客户端、网页浏览器应用、搜索类应用、即时通信工具和邮箱客户端等。
终端设备1101、1102、1103可以是具有显示屏并且支持运行各种客户端应用的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。
服务器1105可以是提供各种服务的服务器,例如对用户利用终端设备1101、1102、1103所提出的获取文件的请求提供支持的后台管理服务器。后台管理服务器可以将待共享文件执行上链和存储,针对提出的获取文件的请求进行处理,并将文件返回给终端设备。
需要说明的是,本公开实施例所提供的共享文件的方法一般由服务器1105执行,相应地,共享文件的装置一般设置于服务器1105中。
应该理解,图11中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。
下面参考图12,其示出了适于用来实现本公开实施例的终端设备的计算机系统1200的结构示意图。图12示出的终端设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图12所示,计算机系统1200包括中央处理单元(CPU)1201,其可以根据存储在只读存储器(ROM)1202中的程序或者从存储部分1208加载到随机访问存储器(RAM)1203中的程序而执行各种适当的动作和处理。在RAM 1203中,还存储有系统1200操作所需的各种程序和数据。CPU 1201、ROM 1202以及RAM 1203通过总线1204彼此 相连。输入/输出(I/O)接口1205也连接至总线1204。
以下部件连接至I/O接口1205:包括键盘、鼠标等的输入部分1206;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分1207;包括硬盘等的存储部分1208;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分1209。通信部分1209经由诸如因特网的网络执行通信处理。驱动器1210也根据需要连接至I/O接口1205。可拆卸介质1211,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1210上,以便于从其上读出的计算机程序根据需要被安装入存储部分1208。
特别地,根据本公开公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分1209从网络上被下载和安装,和/或从可拆卸介质1211被安装。在该计算机程序被中央处理单元(CPU)1201执行时,执行本公开的系统中限定的上述功能。
需要说明的是,本公开所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组 合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的模块和/或单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块和/或单元也可以设置在处理器中,例如,可以描述为:一种处理器包括件文件压缩包上链模块、文件数据块生成模块和根哈希值生成模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,文件数据块生成模块还可以被描述为“根据所述文件压缩包和前一个数据块的哈希值,形成数据块的模块”。还可以描述为:一种处理器包括件获取根节点文件模块和获取链上文件模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,获取根节点文件模块还可以被描述为“根据根哈希值,获取根哈希值对应的数据块所包含文件的模块”。
作为另一方面,本公开还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多 个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:获取待共享的文件,对共享文件压缩包执行区块链并发上链操作,根据压缩包文件名及其哈希值形成数据块,数据块还包含前一个数据块的哈希值;最后一个数据块的哈希值为根哈希值;根据根哈希值,获取最后一个数据块包含的文件,以及数据块包含的前一个数据块的哈希值,循环执行直至获取到根哈希值指示的区块链中的各个文件压缩包。
根据本公开实施例的技术方案,通过将多个文件压缩成文件包,部分克服了因为文件数量大造成的网络资源负担过高的技术问题,通过将各个文件压缩包并发上链,提高了文件上链和共享的效率;利用区块链上的单向链表数据结构保存和共享文件,提高文件的安全性。上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。

Claims (23)

  1. 一种共享文件的方法,其特征在于,包括:
    获取待共享的文件,形成至少两个文件压缩包;
    对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值;
    针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;
    针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作;
    将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
  2. 根据权利要求1所述的方法,其特征在于,
    获取待共享的文件,形成至少两个文件压缩包,包括:
    获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
  3. 根据权利要求2所述的方法,其特征在于,
    分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
  4. 根据权利要求1所述的方法,其特征在于,
    所述第一数据块还包括初始数据块标识。
  5. 根据权利要求1所述的方法,其特征在于,
    对所述文件压缩包执行区块链并发上链操作。
  6. 根据权利要求1所述的方法,其特征在于,
    针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:
    根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
  7. 一种共享文件的方法,其特征在于,包括:
    接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;
    循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述前一个数据块的哈希值作为所述当前哈希值。
  8. 根据权利要求7所述的方法,其特征在于,
    当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
  9. 根据权利要求7所述的方法,其特征在于,
    获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。
  10. 根据权利要求7所述的方法,其特征在于,
    当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
  11. 一种共享文件的装置,其特征在于,包括:文件压缩包上链模块、文件数据块生成模块和根哈希值生成模块;其中,
    所述文件压缩包上链模块,用于获取待共享的文件,形成至少两个文件压缩包;对所述文件压缩包执行区块链上链操作,并获取所述文件压缩包对应的哈希值;
    所述文件数据块生成模块,用于针对所述至少两个文件压缩包中的第一文件压缩包的文件名和所述第一文件压缩包的哈希值,生成第一数据块,并对所述第一数据块执行区块链上链操作;针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块并对所述第二数据块执行区块链上链操作;
    所述根哈希值生成模块,用于将所述第二数据块中的最后一个第二数据块的哈希值作为根哈希值,并发送所述根哈希值。
  12. 根据权利要求11所述的装置,其特征在于,
    所述文件压缩包上链模块,用于获取待共享的文件,形成至少两个文件压缩包,包括:获取预定义时间范围内待共享的文件,形成至少两个文件包,根据网络带宽,确定所述文件包中文件的数量。
  13. 根据权利要求12所述的装置,其特征在于,
    所述文件压缩包上链模块,用于分别对所述文件包执行压缩和加密操作,形成所述文件压缩包。
  14. 根据权利要求11所述的装置,其特征在于,
    所述文件数据块生成模块包括的所述第一数据块还包括初始数据块标识。
  15. 根据权利要求11所述的装置,其特征在于,
    所述文件压缩包上链模块,用于对所述文件压缩包执行区块链并发上链操作。
  16. 根据权利要求1所述的方法,其特征在于,
    针对所述至少两个文件压缩包中除所述第一文件压缩包以外的第二文件压缩包:根据前一个数据块的哈希值、所述第二文件压缩包的文件名和所述第二文件压缩包对应的哈希值,生成第二数据块,还包括:
    根据所述第二文件压缩包的文件名,获取所述第二文件压缩包所包含的共享文件,对所述共享文件和所述前一个数据块的哈希值执行压缩和加密操作,形成更新文件压缩包,对所述更新文件压缩包执行区块链上链操作,并获取所述更新文件压缩包对应的哈希值,根据所述更新文件压缩包的文件名、所述更新文件压缩包的哈希值生成第二数据块。
  17. 一种共享文件的装置,其特征在于,包括:获取根节点文件模块和获取链上文件模块;其中,
    所述获取根节点文件模块,用于接收根哈希值,根据所述根哈希值从区块链上获取所述根哈希值对应的最后一个数据块,获取所述最后一个数据块所包含的文件压缩包的文件名,并获取所述文件压缩包中的文件;
    所述获取链上文件模块,用于循环执行以下步骤,直至获取到所述根哈希值指示的区块链中的各个文件压缩包:将所述最后一个数据块中包含的前一个数据块的哈希值作为当前哈希值,并根据所述当前哈希值从区块链上获取前一个数据块的哈希值、所述当前数据块对应的文件压缩包的文件名和所述文件压缩包中的文件;并将获取的所述 前一个数据块的哈希值作为所述当前哈希值。
  18. 根据权利要求17所述的装置,其特征在于,
    所述获取链上文件模块,用于判断当所述当前数据块包含初始数据块标识时,指示为完成获取所述根哈希值指示的区块链中的各个文件压缩包。
  19. 根据权利要求17所述的装置,其特征在于,
    所述获取链上文件模块,用于获取文件压缩包中的文件,包括:对所述文件压缩包执行解压和解密操作,获取文件压缩包中的文件。
  20. 根据权利要求17所述的装置,其特征在于,
    所述获取链上文件模块,用于判断当所述文件压缩包包含所述前一个数据块的哈希值时,对所述文件压缩包执行解压和解密操作,获取所述前一个数据块的哈希值。
  21. 一种共享文件的系统,其特征在于,包括:权利要求10所述的共享文件的装置、以及权利要求11所述的共享文件的装置。
  22. 一种电子设备,其特征在于,包括:
    一个或多个处理器;
    存储装置,用于存储一个或多个程序,
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-10中任一所述的方法。
  23. 一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如权利要求1-10中任一所述的方法。
PCT/CN2021/110594 2020-08-04 2021-08-04 共享文件的方法、装置及系统 WO2022028484A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21854512.7A EP4180985A1 (en) 2020-08-04 2021-08-04 File sharing method, apparatus, and system
US18/040,619 US20230315692A1 (en) 2020-08-04 2021-08-04 File sharing method, apparatus, and system

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010772463.5A CN111984615B (zh) 2020-08-04 2020-08-04 一种共享文件的方法、装置及系统
CN202010772463.5 2020-08-04

Publications (1)

Publication Number Publication Date
WO2022028484A1 true WO2022028484A1 (zh) 2022-02-10

Family

ID=73444510

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/110594 WO2022028484A1 (zh) 2020-08-04 2021-08-04 共享文件的方法、装置及系统

Country Status (4)

Country Link
US (1) US20230315692A1 (zh)
EP (1) EP4180985A1 (zh)
CN (1) CN111984615B (zh)
WO (1) WO2022028484A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785592A (zh) * 2022-04-21 2022-07-22 中国科学技术大学 信息处理方法及装置

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984615B (zh) * 2020-08-04 2024-05-28 中国人民银行数字货币研究所 一种共享文件的方法、装置及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107728941A (zh) * 2017-09-28 2018-02-23 中国银行股份有限公司 一种区块链数据压缩方法及系统
CN110032545A (zh) * 2019-03-27 2019-07-19 远光软件股份有限公司 基于区块链的文件存储方法、系统及电子设备
US20190266178A1 (en) * 2016-04-08 2019-08-29 Chicago Mercantile Exchange Inc. Bilateral assertion model and ledger implementation thereof
CN110224814A (zh) * 2019-06-27 2019-09-10 深圳前海微众银行股份有限公司 一种区块链数据共享方法及装置
CN110349019A (zh) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 一种块链式账本中的验证方法、装置及设备
CN111984615A (zh) * 2020-08-04 2020-11-24 中国人民银行数字货币研究所 一种共享文件的方法、装置及系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9977918B2 (en) * 2015-09-30 2018-05-22 Robert Bosch Gmbh Method and system for verifiable searchable symmetric encryption
KR101637868B1 (ko) * 2016-02-22 2016-07-08 주식회사 코인플러그 블록체인을 기반으로 하는 금융기관 제증명서류 위변조 검증시스템 및 방법
DE102017205163A1 (de) * 2017-03-27 2018-09-27 Bundesdruckerei Gmbh Hashwerte für die bidirektionale verkettete Blockchain
CN107682016B (zh) * 2017-09-26 2021-09-17 深信服科技股份有限公司 一种数据压缩方法、数据解压方法及相关系统
CN108550037B (zh) * 2018-04-11 2022-05-17 北京知金链网络技术有限公司 基于区块链的文件处理方法和装置
CN110032581A (zh) * 2019-01-18 2019-07-19 阿里巴巴集团控股有限公司 一种基于区块链的业务文件存储方法及装置
US11249987B2 (en) * 2019-08-14 2022-02-15 Advanced New Technologies Co., Ltd. Data storage in blockchain-type ledger
US11507535B2 (en) * 2019-10-16 2022-11-22 International Business Machines Corporation Probabilistic verification of linked data
CN110912937B (zh) * 2019-12-23 2021-09-07 杭州中科先进技术研究院有限公司 一种基于区块链的数字存证平台和存证方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190266178A1 (en) * 2016-04-08 2019-08-29 Chicago Mercantile Exchange Inc. Bilateral assertion model and ledger implementation thereof
CN107728941A (zh) * 2017-09-28 2018-02-23 中国银行股份有限公司 一种区块链数据压缩方法及系统
CN110032545A (zh) * 2019-03-27 2019-07-19 远光软件股份有限公司 基于区块链的文件存储方法、系统及电子设备
CN110349019A (zh) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 一种块链式账本中的验证方法、装置及设备
CN110224814A (zh) * 2019-06-27 2019-09-10 深圳前海微众银行股份有限公司 一种区块链数据共享方法及装置
CN111984615A (zh) * 2020-08-04 2020-11-24 中国人民银行数字货币研究所 一种共享文件的方法、装置及系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785592A (zh) * 2022-04-21 2022-07-22 中国科学技术大学 信息处理方法及装置
CN114785592B (zh) * 2022-04-21 2023-10-20 中国科学技术大学 信息处理方法及装置

Also Published As

Publication number Publication date
EP4180985A1 (en) 2023-05-17
CN111984615B (zh) 2024-05-28
US20230315692A1 (en) 2023-10-05
CN111984615A (zh) 2020-11-24

Similar Documents

Publication Publication Date Title
KR102322729B1 (ko) 블록체인 월드 스테이트 머클 패트리샤 트라이 서브트리의 업데이트
US20210160245A1 (en) Parallel execution of transactions in a blockchain network based on smart contract whitelists
US10764261B2 (en) System and method for enabling a scalable public-key infrastructure on a smart grid network
WO2022028484A1 (zh) 共享文件的方法、装置及系统
CN109886692B (zh) 基于区块链的数据传输方法、装置、介质及电子设备
US9847981B1 (en) Encrypted augmentation storage
CN110753020A (zh) 网络请求处理方法和装置
CN114781351B (zh) 基于电力数据的投标文件解析方法、装置、设备和介质
CN111931474A (zh) 信息表生成方法、装置、电子设备和计算机可读介质
CN111181920A (zh) 一种加解密的方法和装置
US10540522B2 (en) Storing data securely in a database
WO2024060630A1 (zh) 数据传输管理的方法、数据处理的方法和装置
CN111984616B (zh) 一种更新共享文件的方法、装置和系统
CN112329044A (zh) 信息获取方法、装置、电子设备和计算机可读介质
CN111984613B (zh) 一种共享文件的方法、装置和系统
CN111798236A (zh) 交易数据加、解密方法、装置及设备
CN111984614B (zh) 一种共享文件的方法、装置和系统
CN111984612B (zh) 一种共享文件的方法、装置和系统
CN110705935B (zh) 一种物流单据的处理方法和装置
CN115277684A (zh) 文件传输方法、装置、设备以及存储介质
CN115129425A (zh) 一种复制镜像的方法和装置
CN115688165A (zh) 一种节点文件处理方法、装置、设备及存储介质
CN113761585A (zh) 一种数据处理方法、装置和系统
CN111835846B (zh) 信息更新方法、装置和电子设备
Ren et al. Consistency guarantee method of electronic record based on blockchain in cloud storage

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21854512

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021854512

Country of ref document: EP

Effective date: 20230209

NENP Non-entry into the national phase

Ref country code: DE