File sharing method, device and node based on blockchain system
Patent Information
- Application Number
- CN202310672454.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-06-07
AI Technical Summary
[0016]在本说明书实施例提供的方案中,文件提供方的设备可以基于主密钥和目标文件的标识生成派生密钥,使用派生密钥将目标文件加密为密文文件,以及将密文文件上传到链下存储系统。之后,该设备可以使用目标文件的第一使用方的第一公钥将该派生密钥加密为第一密文密钥,并向区块链系统发送第一交易,第一交易包括目标文件的文件哈希值、密文文件在链下存储系统中的文件存储信息、及第一密文密钥,以用于在区块链系统中存储第一交易的交易哈希值和第一交易。接着,该设备可以接收区块链系统返回的交易哈希值,以供文件提供方将该交易哈希值分享给第一使用方,从而使得第一使用方能基于该交易哈希值从区块链系统获取第一交易,并从第一交易中获取该文件哈希值、该文件存储信息、及第一密文密钥,进而基于获取到的信息进行一系列操作后获得目标文件。由此,能使得文件提供方将待分享的文件使用派生密钥加密后上传到链下存储系统,将派生密钥使用文件使用方的公钥加密后连同该文件的信息(如文件哈希值和文件存储信息)上传到区块链系统,通过区块链系统向文件使用方有效安全的传递派生密钥和文件信息,这样不仅能减轻区块链系统的存储压力,还能灵活的在区块链系统的参与方子集之间分享文件,使得文件提供方不论分享多少文件,都能够做到一文件一密钥,提高安全性的同时,文件提供方只需管理主密钥,降低了密钥管理的难度。
Smart Images

Figure CN116633559B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification belong to the field of blockchain technology, and in particular relate to file sharing methods, devices and nodes based on blockchain systems. Background Technology
[0002] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. In a blockchain, data blocks are sequentially linked together in a chain-like data structure, and cryptographic methods are used to ensure the immutability and forgery resistance of these data blocks. Due to its decentralized, immutable, and autonomous characteristics, blockchain is receiving increasing attention and application.
[0003] Consortium blockchain technology has matured over the years, with more and more projects transitioning from exploration to production systems. The network's reach has expanded from single-enterprise operations to multiple enterprises distributed across different regions. Due to the inherently incremental nature of blockchain, the amount of data stored within it is constantly increasing as networks grow in scale and new applications emerge. Summary of the Invention
[0004] The purpose of this invention is to provide a file sharing solution based on a blockchain system, which can not only reduce the storage pressure of the blockchain system, but also flexibly share files among a subset of participants in the blockchain system. This allows file providers to use a unique key for each file, regardless of how many files are shared, thus improving security. At the same time, file providers only need to manage the master key, reducing the difficulty of key management.
[0005] This specification provides a file sharing method based on a blockchain system, the method being executed by a file provider's device, comprising: generating a derived key based on a master key and an identifier of a target file; encrypting the target file into a ciphertext file using the derived key; uploading the ciphertext file to an off-chain storage system; encrypting the derived key into a first ciphertext key using a first public key of a first user of the target file; sending a first transaction to the blockchain system, the first transaction including a file hash value of the target file, file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key, for storing the transaction hash value of the first transaction and the first transaction in the blockchain system; and receiving the transaction hash value returned by the blockchain system.
[0006] A second aspect of this specification provides a file-sharing method based on a blockchain system, the method being executed by a device of a first user of a target file, comprising: sending a query request to the blockchain system, the query request including a transaction hash value shared by a file provider of the target file to the first user; receiving a first transaction corresponding to the transaction hash value returned by the blockchain system; and obtaining from the first transaction the file hash value of the target file, file storage information of the encrypted file in an off-chain storage system, and a first encrypted key; wherein the encrypted file is obtained by the file provider's device encrypting the target file using a derived key, and the first encrypted key is obtained by the device encrypting the derived key using the first user's first public key.
[0007] A third aspect of this specification provides a file-sharing method based on a blockchain system, wherein a smart contract is deployed in the blockchain system, and the method is executed by a device of a second user of a target file, comprising: sending a query request to the blockchain system, the query request including a transaction hash value shared by a file provider of the target file to the second user; receiving a first transaction returned by the blockchain system corresponding to the transaction hash value; obtaining from the first transaction the file hash value of the target file and file storage information of the encrypted file in an off-chain storage system; wherein the encrypted file is obtained by encrypting the target file using a derived key by the file provider's device; sending a third transaction to the blockchain system, the third transaction invoking the smart contract and including the transaction hash value and a second public key of the second user, for obtaining a second encrypted key associated with the transaction hash value and the storage of the second public key from the contract state of the smart contract; wherein the second encrypted key is obtained by encrypting the derived key using the second public key by the file provider's device; and receiving the second encrypted key returned by the blockchain system.
[0008] This specification provides a fourth aspect of a file-sharing method based on a blockchain system, wherein smart contracts are deployed in the blockchain system, and the method is executed by nodes in the blockchain system, comprising: receiving a query request sent by a device of a second user of a target file, the query request including a transaction hash value shared by the file provider of the target file to a first user; retrieving a first transaction corresponding to the transaction hash value from the blockchain system, and returning the first transaction to the device of the second user, so that the device can retrieve the file hash value of the target file and the file storage information of the encrypted file in an off-chain storage system from the first transaction; wherein, the... The encrypted file is obtained by encrypting the target file using a derived key by the file provider's device; a third transaction is received from the second user's device, the third transaction invoking the smart contract and including the transaction hash value and the second user's second public key; wherein, the transaction hash value, the second public key, and the second encrypted key are stored in the contract state of the smart contract, and the second encrypted key is obtained by encrypting the derived key using the second public key by the file provider's device; the second encrypted key is obtained from the contract state by executing the third transaction; and the second encrypted key is returned to the second user's device.
[0009] This specification provides a file sharing device based on a blockchain system, applied to a file provider's device, comprising: a generation unit configured to generate a derived key based on a master key and an identifier of a target file; an encryption unit configured to encrypt the target file into a ciphertext file using the derived key; a file upload unit configured to upload the ciphertext file to an off-chain storage system; the encryption unit further configured to encrypt the derived key into a first ciphertext key using a first public key of a first user of the target file; a sending unit configured to send a first transaction to the blockchain system, the first transaction including a file hash value of the target file, file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key, for storing the transaction hash value and the first transaction in the blockchain system; and a receiving unit configured to receive the transaction hash value returned by the blockchain system.
[0010] This specification provides a file sharing device based on a blockchain system, applied to a device of a first user of a target file, comprising: a sending unit configured to send a query request to the blockchain system, the query request including a transaction hash value shared by a file provider of the target file to the first user; a receiving unit configured to receive a first transaction corresponding to the transaction hash value returned by the blockchain system; and an acquisition unit configured to acquire from the first transaction the file hash value of the target file, file storage information of the encrypted file in an off-chain storage system, and a first encrypted key; wherein the encrypted file is obtained by the file provider's device encrypting the target file using a derived key, and the first encrypted key is obtained by the device encrypting the derived key using the first user's first public key.
[0011] This specification provides a file-sharing device based on a blockchain system, wherein a smart contract is deployed in the blockchain system. The device is applied to a device of a second user of a target file and includes: a sending unit configured to send a query request to the blockchain system, the query request including a transaction hash value shared by the file provider of the target file to the second user; a receiving unit configured to receive a first transaction corresponding to the transaction hash value returned by the blockchain system; and an acquisition unit configured to acquire, from the first transaction, the file hash value of the target file and file storage information of the encrypted file in an off-chain storage system; wherein the encrypted... The file is obtained by encrypting the target file using a derived key by the file provider's device; the sending unit is further configured to send a third transaction to the blockchain system, the third transaction invoking the smart contract and including the transaction hash value and the second public key of the second user, for obtaining a second ciphertext key associated with the transaction hash value and the second public key from the contract state of the smart contract; wherein the second ciphertext key is obtained by encrypting the derived key using the second public key by the file provider's device; the receiving unit is further configured to receive the second ciphertext key returned by the blockchain system.
[0012] This specification provides a node in a blockchain system, wherein smart contracts are deployed in the blockchain system. The node includes: a receiving unit configured to receive a query request sent by a device of a second user of a target file, the query request including a transaction hash value shared by the file provider of the target file with the first user; and an obtaining unit configured to obtain a first transaction corresponding to the transaction hash value from the blockchain system and return the first transaction to the device of the second user, so that the device obtains the file hash value of the target file and file storage information of the encrypted file in an off-chain storage system from the first transaction; wherein the encrypted file is used by the device of the file provider. The target file is obtained by encrypting it with a derived key; the receiving unit is further configured to receive a third transaction sent by the device of the second user, the third transaction invoking the smart contract and including the transaction hash value and the second public key of the second user; wherein, the transaction hash value, the second public key and the second ciphertext key are stored in the contract state of the smart contract, and the second ciphertext key is obtained by the device of the file provider encrypting the derived key with the second public key; the execution unit is configured to obtain the second ciphertext key from the contract state by executing the third transaction; the sending unit is configured to return the second ciphertext key to the device of the second user.
[0013] The ninth aspect of this specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method described in any of the implementations of the first to fourth aspects.
[0014] This specification provides a computing device in a tenth aspect, including a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method described in any of the implementations of the first to fourth aspects.
[0015] The eleventh aspect of this specification provides a computer program product that, when executed in a computer, causes the computer to perform the method described in any of the implementations of the first to fourth aspects.
[0016] In the scheme provided in the embodiments of this specification, the device of the file provider can generate a derived key based on the master key and the identifier of the target file, use the derived key to encrypt the target file into a ciphertext file, and upload the ciphertext file to the off-chain storage system. Then, the device can use the first public key of the first user of the target file to encrypt the derived key into a first ciphertext key and send a first transaction to the blockchain system. The first transaction includes the file hash value of the target file, the file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key, for use in storing the transaction hash value and the first transaction in the blockchain system. Next, the device can receive the transaction hash value returned by the blockchain system, allowing the file provider to share the transaction hash value with the first user. This enables the first user to obtain the first transaction from the blockchain system based on the transaction hash value, and from the first transaction, obtain the file hash value, the file storage information, and the first ciphertext key. Based on the obtained information, the user can then perform a series of operations to obtain the target file. This allows file providers to encrypt files to be shared using a derived key and upload them to an off-chain storage system. They then encrypt the derived key using the file user's public key, along with the file's information (such as its hash value and storage information), and upload it to the blockchain system. The blockchain system then effectively and securely transmits the derived key and file information to the file user. This not only reduces the storage pressure on the blockchain system but also allows for flexible file sharing among subsets of participants. Regardless of the number of files shared, the file provider can maintain a unique key for each file, improving security. Furthermore, the file provider only needs to manage the master key, reducing the complexity of key management. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments in this specification, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a diagram of a blockchain architecture in one embodiment;
[0019] Figure 2 This is a schematic diagram illustrating one application scenario in which the embodiments of this specification can be applied;
[0020] Figure 3 This is a sequence diagram of the file sharing method based on a blockchain system in the embodiments of this specification;
[0021] Figure 4 This is a schematic diagram of the encrypted file storage process in the embodiments of this specification;
[0022] Figure 5 This is a sequence diagram of the file sharing method based on a blockchain system in the embodiments of this specification;
[0023] Figure 6 This is a sequence diagram of the file sharing method based on a blockchain system in the embodiments of this specification;
[0024] Figure 7 This is a sequence diagram of the file sharing method based on a blockchain system in the embodiments of this specification;
[0025] Figure 8 This is a schematic diagram of the structure of the file sharing device based on the blockchain system in the embodiments of this specification;
[0026] Figure 9 This is a schematic diagram of the structure of the file sharing device based on the blockchain system in the embodiments of this specification;
[0027] Figure 10 This is a schematic diagram of the structure of the file sharing device based on the blockchain system in the embodiments of this specification;
[0028] Figure 11 This is a schematic diagram of the structure of a node in the blockchain system in the embodiments of this specification. Detailed Implementation
[0029] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0030] Figure 1 A blockchain architecture diagram from one embodiment is shown. Figure 1 In the blockchain architecture diagram shown, blockchain 100 includes N nodes. Figure 1 The diagram illustrates nodes 1 through 8. The lines connecting the nodes schematically represent P2P (Peer-to-Peer) connections, such as TCP connections, used for data transfer between nodes. These nodes can store the entire ledger, i.e., the state of all blocks and all accounts. Each node in the blockchain can produce the same state by executing the same transactions, and each node can store the same state database.
[0031] In the blockchain field, a transaction refers to a unit of task executed and recorded within the blockchain. A transaction typically includes a From field, a To field, and a Data field. Specifically, in the case of a transfer transaction, the From field represents the account address initiating the transaction (i.e., initiating a transfer task to another account), the To field represents the account address receiving the transaction (i.e., receiving the transfer), and the Data field includes the transfer amount.
[0032] Blockchain provides the functionality of smart contracts. A smart contract on the blockchain is a contract that can be triggered and executed through transactions within the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract on the blockchain involves initiating a transaction pointing to the smart contract's address, causing each node in the blockchain to run the smart contract code in a distributed manner.
[0033] In a contract deployment scenario, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to a server such as... Figure 1 In the blockchain shown, the `data` field of the transaction includes the code (such as bytecode or machine code) of the contract to be created, and the `to` field of the transaction is empty, indicating that the transaction is used to deploy the contract. After the nodes reach an agreement through the consensus mechanism, they determine the contract address "0x6f8ae93…". Each node adds a contract account corresponding to the contract address of the smart contract to the state database, allocates state storage corresponding to the contract account, stores the contract code, and saves the hash value of the contract code in the contract's state storage, thus the contract is successfully created.
[0034] In scenarios where contracts are invoked, for example, Bob sends a transaction to invoke a smart contract, such as... Figure 1 In the blockchain shown, the `from` field of this transaction is the address of the account of the transaction initiator (i.e., Bob), the `to` field is the aforementioned "0x6f8ae93…", which is the address of the smart contract being invoked, and the `data` field of the transaction includes the method and parameters for invoking the smart contract. After consensus is reached on this transaction in the blockchain, each node in the blockchain can execute the transaction, thereby executing the contract separately, and updating the state database based on the execution of the contract.
[0035] As mentioned earlier, due to the inherent characteristic of blockchain that only increases and never decreases, as the network expands and the scale grows, and as new applications of blockchain continue to emerge, the amount of data stored in the blockchain is increasing.
[0036] This specification provides a file sharing scheme based on a blockchain system, which not only reduces the storage pressure on the blockchain system, but also allows for flexible file sharing among subsets of participants in the blockchain system. This enables file providers to maintain a one-file-one-key system regardless of the number of files shared, improving security. At the same time, file providers only need to manage the master key, reducing the difficulty of key management.
[0037] It should be noted that due to the inherent characteristic of blockchain—that it only adds data and never depletes it—it is not conducive to storing large files. However, for applications such as video evidence storage, judicial documents, and file sharing, the original large files are indispensable. Therefore, how blockchain can effectively handle large files presents a challenge. To enable blockchain systems to effectively handle large files, the off-chain storage system provided in the embodiments of this specification can store large files.
[0038] See Figure 2 This is a schematic diagram illustrating one application scenario to which the embodiments of this specification can be applied. Figure 2 The application scenario shown may include device 201 (provider of the target file A), blockchain system 202, off-chain storage system 203, device 204 (user of the target file B1), and device 205 (user of the target file B2). Provider A, user B1, and user B2 are all participants in blockchain system 202. Devices 201, 204, and 205 may each have a blockchain application installed corresponding to blockchain system 202. These devices can access blockchain system 202 and off-chain storage system 203 through their installed blockchain applications. Blockchain system 202 may include, but is not limited to, a consortium blockchain system. Off-chain storage system 203 may include, for example, a traditional storage server or cloud storage server, or it may include a distributed storage system.
[0039] It should be noted that user B1 can be a pre-selected sharer of the target file, and user B2 can be either a pre-selected sharer or a newly added sharer. A pre-selected sharer is one that was pre-selected before the encrypted target file was uploaded to the off-chain storage system 203. A newly added sharer is one that was added after the encrypted target file was uploaded to the off-chain storage system 203, specifically after the key used to encrypt the target file was shared with user B1.
[0040] Below, in conjunction with Figure 3 This describes the process by which provider A shares target files with user B1. Figure 3 This is a timing diagram of the file sharing method based on a blockchain system in the embodiments of this specification.
[0041] like Figure 3As shown, firstly, in step S301, provider A's device 201 generates a derived key based on the master key and the identifier of the target file.
[0042] Specifically, a Key Derivation Function (KDF) can be used to generate derived keys based on the master key and the identifier of the target file. In cryptography, a key derivation function is a cryptographic hash function that uses a pseudo-random function to derive one or more secret keys from a secret value.
[0043] The master key can be the user master key of provider A. Provider A can create its own master key using existing master key creation methods. The identifier of the target file can include, but is not limited to, the file hash value of the target file. As an example, provider A can create its own master key using device 201 using existing master key creation methods, perform hash calculation on the target file to obtain the file hash value, and then use a key derivation function to generate a derived key based on the master key and the file hash value.
[0044] In step S303, device 201 uses a derived key to encrypt the target file into a ciphertext file.
[0045] Specifically, device 201 can use a derived key to encrypt the target file based on a symmetric encryption algorithm to obtain a ciphertext file. Here, a symmetric encryption algorithm refers to an encryption algorithm that uses the same key for both encryption and decryption.
[0046] In step S305, device 201 uploads the encrypted file to off-chain storage system 203.
[0047] In step S307, device 201 uses the public key PK1 of the user B1 of the target file to encrypt the derived key into the ciphertext key CK1.
[0048] Specifically, device 201 can use user B1's public key PK1 to encrypt the derived key based on an asymmetric encryption algorithm to obtain the ciphertext key CK1. Here, an asymmetric encryption algorithm refers to an encryption algorithm that uses different keys for encryption and decryption.
[0049] In step S309, device 201 sends transaction Tx1 to blockchain system 202. Transaction Tx1 includes the file hash value of the target file, the file storage information of the encrypted file in the off-chain storage system 203, and the encrypted key CK1.
[0050] In step S311, the blockchain system 202 performs a hash calculation on transaction Tx1 to obtain the transaction hash value, and stores the transaction hash value and transaction Tx1 in the blockchain system 202.
[0051] In step S313, the blockchain system 202 returns the transaction hash value to the device 201.
[0052] After receiving the transaction hash value returned by the blockchain system 202, device 201 can share the transaction hash value with user B1. Since the transaction hash value does not contain any meaningful plaintext information, provider A can share the transaction hash value with user B1 using any conventional method (such as making a phone call, sending a text message, or sending an email). After obtaining the transaction hash value, user B1 can retrieve transaction Tx1 from the blockchain system 202 based on the transaction hash value, and obtain the file hash value of the target file, the file storage information of the encrypted file in the off-chain storage system 203, and the encrypted key CK1 from transaction Tx1. Then, based on the obtained information, user B1 can perform a series of operations to obtain the target file.
[0053] Figure 3 The corresponding implementation provides a solution that allows the file provider to encrypt the file to be shared using a derived key and upload it to an off-chain storage system. The derived key, encrypted using the file user's public key, along with the file's information (such as the file hash value and file storage information), is then uploaded to the blockchain system. The blockchain system effectively and securely transmits the derived key and file information to the file user. This not only reduces the storage pressure on the blockchain system but also allows for flexible file sharing among subsets of participants in the blockchain system. Regardless of the number of files shared, the file provider can maintain a one-file-one-key system, improving security. Furthermore, the file provider only needs to manage the master key, reducing the difficulty of key management.
[0054] In practice, traditional storage servers or cloud storage servers may have the following problems: First, there is a single point of failure; when the file storage service fails, the original files may be lost or corrupted. Second, since the storage manager has complete control over the files, it is difficult for the file manager to prove their innocence if a dispute arises and the original files are lost or corrupted. Third, when the original files are unfavorable to the file manager, it is difficult to prevent the file manager from restricting access to or performing other operations on the original files. Fourth, when a large number of files need to be shared among different users, an additional system is required to manage authorization, which will bring additional costs.
[0055] To minimize the occurrence of these problems, in one implementation, the off-chain storage system 203 may include a distributed storage system, which may include, but is not limited to, an IPFS (InterPlanetary File System) cluster.
[0056] IPFS is a peer-to-peer distributed file system that attempts to connect all computing devices to the same file system. In some ways, IPFS is similar to the World Wide Web and can also be viewed as a group of BitTorrent nodes exchanging objects in the same Git repository. In other words, IPFS provides a high-throughput, content-addressable block storage model and content-related hyperlinks. This forms a generalized Merkle Directed Acyclic Graph (DAG). IPFS combines distributed hash tables, encourages block exchange, and has a self-certifying namespace. IPFS has no single point of failure, and nodes do not need to trust each other. Distributed content delivery saves bandwidth and protects against DDoS attacks that HTTP schemes may encounter. The file system can be accessed in several ways, including FUSE and HTTP. Adding local files to the IPFS file system makes them available worldwide. File representations are based on their hashes, thus facilitating caching. File distribution uses a BitTorrent-based protocol. Other users viewing the content also help make it available to others on the network. IPFS has a name service called IPNS (InterPlanetary Naming Service), which is a PKI-based global namespace used to build trust chains. It is compatible with other namespaces and can map DNS, .onion, .bit, etc. to IPNS.
[0057] It should be noted that the IPFS cluster in the embodiments of this specification can be a private network formed through an admission mechanism, and is not connected to the public, open IPFS network. Only IPFS nodes that have received an invitation can join the IPFS cluster. As an example, the IPFS cluster may include the IPFS nodes of several participants in the blockchain system 202. These participants may be all or some of the participants in the blockchain system 202.
[0058] Since the existing IPFS does not actively provide the ability to manage the number of replicas, in order to ensure the reliability of file storage, when the off-chain storage system 203 includes an IPFS cluster, a management device for file replica management corresponding to the IPFS cluster can be set up, so that the off-chain storage system 203 includes both the IPFS cluster and the management device.
[0059] When the off-chain storage system 203 includes an IPFS cluster and management devices, the implementation process of step S305 above can be as follows: Figure 4 As shown. Among them, Figure 4 This is a schematic diagram of the encrypted file storage process in the embodiments of this specification.
[0060] like Figure 4As shown, firstly, in step S401, provider A's device 201 sends a storage request including the encrypted file to the management device.
[0061] In step S403, the management device selects multiple IPFS nodes from the IPFS cluster based on preset file storage reliability requirements.
[0062] The file storage reliability requirements may include, for example, a maximum number of storage replicas N and a minimum number of storage replicas M. As an example, the management device can determine the target number of storage replicas within the range [M, N] based on these requirements and select IPFS nodes from the IPFS cluster that represent that target number of storage replicas. When selecting these IPFS nodes, the load on each IPFS node in the cluster can be considered; for example, nodes with lower loads can be selected.
[0063] In step S405, the management device sends storage requests to the aforementioned multiple IPFS nodes.
[0064] In step S407, the aforementioned multiple IPFS nodes store the ciphertext file and generate the ciphertext file's CID (ContentIdentifier).
[0065] In step S409, the aforementioned multiple IPFS nodes return the CID of the encrypted file to the management device.
[0066] In step S411, in response to the fact that the CIDs returned by the multiple IPFS nodes are the same, the management device returns file storage information to device 201. The file storage information includes the CID and the node information of the multiple IPFS nodes.
[0067] The node information may include the node identifier and / or IP (Internet Protocol) address of its corresponding IPFS node.
[0068] Figure 4 The corresponding embodiment provides a solution in which the management device selects multiple IPFS nodes from the IPFS cluster based on preset file storage reliability requirements, and then sends storage requests to these multiple IPFS nodes, thereby enabling these multiple IPFS nodes to store encrypted files. This solves the problem that IPFS itself does not guarantee file storage reliability, and allows for flexible formulation of file storage copy requirements, thus meeting the file reliability requirements among the participants in the blockchain system.
[0069] The previous section described the process of provider A sharing the target file with user B1. Below, we will combine... Figure 5This describes the process by which user B1 obtains the target file based on the transaction hash value shared by provider A. Figure 5 This is a timing diagram of the file sharing method based on a blockchain system in the embodiments of this specification.
[0070] like Figure 5 As shown, firstly, in step S501, device 204 of user B1 sends a query request to blockchain system 202. The query request includes the transaction hash value shared by provider A of the target file to user B1.
[0071] In step S503, the blockchain system 202 obtains the stored transaction Tx1 corresponding to the transaction hash value.
[0072] In step S505, the blockchain system 202 returns transaction Tx1 to the device 204.
[0073] In step S507, device 204 obtains the file hash value of the target file, the file storage information of the ciphertext file in the off-chain storage system 203, and the ciphertext key CK1 from transaction Tx1.
[0074] In step S509, device 204 uses user B1's private key SK1 to decrypt the ciphertext key CK1 into a derived key.
[0075] Specifically, device 204 can use private key SK1 to decrypt ciphertext key CK1 based on the decryption algorithm corresponding to the asymmetric encryption algorithm described above, to obtain derived key.
[0076] In step S511, device 204 retrieves the encrypted file from off-chain storage system 203 based on file storage information.
[0077] Specifically, device 204 can, for example, send a file retrieval request including the file's storage information to off-chain storage system 203, thereby causing off-chain storage system 203 to return the encrypted file. Alternatively, when off-chain storage system 203 includes an IPFS cluster, device 204 can select one IPFS node from the multiple IPFS nodes included in the file's storage information, for example, selecting the IPFS node of user B1, and then send a file retrieval request including the CID of the encrypted file to the selected IPFS node, thereby causing the IPFS node to return the encrypted file.
[0078] In step S513, device 204 uses the derived key to decrypt the ciphertext file into the target file.
[0079] Specifically, device 204 can use a derived key to decrypt the ciphertext file based on the decryption algorithm corresponding to the symmetric encryption algorithm described above, and obtain the target file.
[0080] In step S515, device 204 performs integrity verification on the decrypted target file based on the file hash value.
[0081] Specifically, device 204 can perform a hash calculation on the decrypted target file to obtain the calculation result, and then compare the calculation result with the hash value of the file. If the comparison result is the same as the hash value of the file, it is determined that the decrypted target file is complete. If the comparison result is different from the hash value of the file, it is determined that the decrypted target file is incomplete.
[0082] Figure 5 The corresponding implementation provides a solution that allows the file provider to encrypt the file to be shared using a derived key and upload it to an off-chain storage system. The derived key, encrypted using the file user's public key, along with the file's information (such as the file hash value and file storage information), is then uploaded to the blockchain system. The blockchain system effectively and securely transmits the derived key and file information to the file user. This not only reduces the storage pressure on the blockchain system but also allows for flexible file sharing among subsets of participants in the blockchain system. Regardless of the number of files shared, the file provider can maintain a one-file-one-key system, improving security. Furthermore, the file provider only needs to manage the master key, reducing the difficulty of key management.
[0083] In one implementation, for users other than user B1, such as other pre-planned sharers or newly added sharers, the target file can be shared with other users based on the transaction hash value generated during the process of sharing the target file with user B1.
[0084] It should be noted that blockchain systems 202 can be deployed with, for example, […]. Figure 2 The smart contract C shown can manage the encryption results of the derived key using the public key of the other users mentioned above, thereby effectively and securely transmitting the derived key to the other users through the smart contract C.
[0085] Below, taking user B2 as an example as described above, combined with... Figure 6 and Figure 7 This paper describes the process of sharing a target file with user B2 when a smart contract C is deployed in a blockchain system 202, and the process of user B2 obtaining the target file.
[0086] See Figure 6 This is a timing diagram of a file-sharing method based on a blockchain system in the embodiments of this specification.
[0087] like Figure 6As shown, firstly, in step S601, provider A's device 201 generates a derived key based on the master key and the identifier of the target file.
[0088] In one example, device 201 may locally store a master key and an identifier for a target file, and device 201 may generate a derived key based on the stored master key and the identifier for the target file.
[0089] In another example, the identifier of the target file can be a file hash value. Device 201 can locally store the master key and transaction hash values, but not the file hash value. Device 201 can send a query request including the transaction hash value to the blockchain system 202, receive the transaction Tx1 corresponding to the transaction hash value returned by the blockchain system 202, and obtain the file hash value of the target file from transaction Tx1.
[0090] In step S603, device 201 uses the public key PK2 of the user B2 of the target file to encrypt the derived key into the ciphertext key CK2.
[0091] In step S605, device 201 sends transaction Tx2 to blockchain system 202. Transaction Tx2 calls smart contract C and includes transaction hash value, public key PK2, and encrypted key CK2.
[0092] In step S607, the blockchain system 202 executes transaction Tx2 to store the transaction hash value, public key PK2, and ciphertext key CK2 into the contract state of smart contract C.
[0093] Specifically, the combination of the transaction hash value and the public key PK2 is used as the key, and the ciphertext key CK2 is used as the value for corresponding storage.
[0094] It should be noted that by sending a transaction Tx2, which calls smart contract C and includes a transaction hash value, public key PK2, and ciphertext key CK2, from device 201 to blockchain system 202, blockchain system 202 stores the transaction hash value, public key PK2, and ciphertext key CK2 in the contract state of smart contract C. Compared with the above steps S309 and S311 performed on user B1, this avoids blockchain system 202 calculating a new transaction hash value for user B2 and redundantly storing the file hash value of the target file and the file storage information of the ciphertext file, thereby reducing the computational and storage pressure on blockchain system 202.
[0095] After step S607 is completed, provider A can share the transaction hash value with user B2 and inform user B2 to obtain transaction Tx1 from blockchain system 202 based on the transaction hash value, and obtain the file hash value of the target file and the file storage information of the ciphertext file in off-chain storage system 203 from transaction Tx1, as well as call smart contract C to obtain the ciphertext key CK2 from the contract state of smart contract C based on the transaction hash value and public key PK2.
[0096] Specifically, see Figure 7 This is a timing diagram of a file-sharing method based on a blockchain system in the embodiments of this specification.
[0097] like Figure 7 As shown, firstly, in step S701, device 205 of user B2 sends a query request to blockchain system 202. The query request includes the transaction hash value shared by provider A with user B2.
[0098] In step S703, the blockchain system 202 obtains the stored transaction Tx1 corresponding to the transaction hash value.
[0099] In step S705, the blockchain system 202 returns transaction Tx1 to the device 205.
[0100] In step S707, device 205 obtains the file hash value of the target file and the file storage information of the encrypted file in the off-chain storage system 203 from transaction Tx1.
[0101] In step S709, device 205 sends transaction Tx3 to blockchain system 202. Transaction Tx3 calls smart contract C and includes transaction hash value and public key PK2 of user B2.
[0102] In step S711, the blockchain system 202 obtains the ciphertext key CK2 from the contract state of smart contract C by executing transaction Tx3.
[0103] In step S713, the blockchain system 202 returns the ciphertext key CK2 to the device 205.
[0104] In step S715, device 205 uses user B2's private key SK2 to decrypt the ciphertext key CK2 into a derived key.
[0105] In step S717, device 205 retrieves the encrypted file from off-chain storage system 203 based on file storage information.
[0106] In step S719, device 205 uses the derived key to decrypt the ciphertext file into the target file.
[0107] In step S721, device 205 performs integrity verification on the decrypted target file based on the file hash value.
[0108] Figure 6 and Figure 7 The corresponding implementation provides a solution that can encrypt the derived key using the user's public key and then propagate it through a smart contract. The user obtains the derived key through the smart contract, which avoids an additional key sharing mechanism. Moreover, both sharing and use leave evidence on the blockchain, making the whole process verifiable and improving the credibility of file sharing.
[0109] As described above, the off-chain storage system in the embodiments of this specification can store large files, and the blockchain system may include a consortium blockchain system. The solution provided in this specification combines the functions of consortium blockchains and IPFS private storage clusters with fine-grained on-chain data access control technology to address the need for flexible sharing of large files among subsets of members on a blockchain. It offers the following advantages: 1. A file storage mechanism with an access control system, meeting the requirement of consortium blockchains that only consortium members can access and store files; 2. File copy management functionality corresponding to the management devices of the IPFS cluster, solving the problem that IPFS itself does not guarantee file storage reliability, allowing for flexible formulation of file storage copy requirements, satisfying the file reliability requirements among consortium blockchain enterprises; 3. Fine-grained on-chain sharing control technology, ensuring that regardless of the number of files shared, each file has a unique key, improving security while reducing the difficulty of key management by requiring only the management of the master key; 4. Derived keys are encrypted using the user's public key and propagated through smart contracts, with the user obtaining the derived keys through smart contracts. This avoids additional key sharing mechanisms, and both sharing and usage leave evidence on the blockchain, making the entire process traceable and improving the credibility of file sharing.
[0110] Figure 8 This is a schematic diagram of the structure of a file-sharing device based on a blockchain system, as described in the embodiments of this specification. The file-sharing device 800 based on a blockchain system can be applied to the device of the file provider, and this device 800 can perform actions such as... Figure 3 , Figure 4 , Figure 6The steps performed by the device of provider A as shown in any of the above. The device 800 may include: a generation unit 801 configured to generate a derived key based on a master key and an identifier of a target file; an encryption unit 802 configured to encrypt the target file into a ciphertext file using the derived key; a file upload unit 803 configured to upload the ciphertext file to an off-chain storage system; the encryption unit 802 is further configured to encrypt the derived key into a first ciphertext key using a first public key of a first user of the target file; a sending unit 804 configured to send a first transaction to the blockchain system, the first transaction including a file hash value of the target file, file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key, for storing the transaction hash value and the first transaction in the blockchain system; and a receiving unit 805 configured to receive the transaction hash value returned by the blockchain system.
[0111] Figure 9 This is a schematic diagram of the structure of a file-sharing device based on a blockchain system, as described in the embodiments of this specification. The file-sharing device 900 based on a blockchain system can be applied to the device of the first user of the target file, and the device 900 can perform actions such as... Figure 5 The steps shown are performed by the device of user B1. The device 900 may include: a sending unit 901 configured to send a query request to the blockchain system, the query request including a transaction hash value shared by the file provider of the target file to the first user; a receiving unit 902 configured to receive a first transaction corresponding to the transaction hash value returned by the blockchain system; and an obtaining unit 903 configured to obtain from the first transaction the file hash value of the target file, file storage information of the encrypted file in an off-chain storage system, and a first encrypted key; wherein the encrypted file is obtained by encrypting the target file using a derived key by the file provider's device, and the first encrypted key is obtained by encrypting the derived key using the first user's first public key by the device.
[0112] Figure 10 This is a schematic diagram of the structure of a file-sharing device based on a blockchain system, as described in the embodiments of this specification. The blockchain system deploys smart contracts, and the file-sharing device 1000 based on the blockchain system can be applied to the device of a second user of the target file. This device 1000 can execute actions such as... Figure 7The steps shown are performed by the device of user B2. The device 1000 may include: a sending unit 1001 configured to send a query request to the blockchain system, the query request including a transaction hash value shared by the file provider of the target file to the second user; a receiving unit 1002 configured to receive a first transaction corresponding to the transaction hash value returned by the blockchain system; an acquisition unit 1003 configured to acquire, from the first transaction, the file hash value of the target file and file storage information of the encrypted file in an off-chain storage system; wherein the encrypted file is obtained by encrypting the target file using a derived key by the file provider's device; the sending unit 1001 is further configured to send a third transaction to the blockchain system, the third transaction invoking a smart contract and including the transaction hash value and the second public key of the second user, for obtaining a second encrypted key associated with the transaction hash value and the storage of the second public key from the contract state of the smart contract; wherein the second encrypted key is obtained by encrypting the derived key using the second public key by the file provider's device; and the receiving unit 1002 is further configured to receive the second encrypted key returned by the blockchain system.
[0113] Figure 11 This is a schematic diagram of the node structure in the blockchain system described in the embodiments of this specification. Smart contracts are deployed in the blockchain system. This node can execute actions such as... Figure 3 , Figures 5 to 7 The steps performed by the blockchain system 202 are shown below. The node may include: a receiving unit 1101, configured to receive a query request sent by a device of a second user of the target file, the query request including a transaction hash value shared by the file provider of the target file with the first user; and an obtaining unit 1102, configured to obtain a first transaction corresponding to the transaction hash value from the blockchain system and return the first transaction to the device of the second user, so that the device can obtain the file hash value of the target file and the file storage information of the encrypted file in the off-chain storage system from the first transaction; wherein the encrypted file is encrypted by the file provider's device using a derived key to encrypt the target file. The receiving unit 1101 is further configured to receive a third transaction sent by the device of the second user, the third transaction calling the smart contract and including a transaction hash value and the second public key of the second user; wherein, the transaction hash value, the second public key and the second ciphertext key are stored in the contract state of the smart contract, and the second ciphertext key is obtained by the device of the file provider encrypting the derived key using the second public key; the execution unit 1103 is configured to obtain the second ciphertext key from the contract state by executing the third transaction; the sending unit 1104 is configured to return the second ciphertext key to the device of the first user.
[0114] This specification also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed in a computer, it causes the computer to perform actions such as... Figures 3 to 7 The method shown in any of the above.
[0115] This specification also provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements, as shown in the embodiment. Figures 3 to 7 The method shown in any of the above.
[0116] This specification also provides a computer program product, wherein when the computer program product is executed in a computer, it causes the computer to perform the following: Figures 3 to 7 The method shown in any of the above.
[0117] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0118] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0119] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0120] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes the elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.
[0121] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.
[0122] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0123] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0124] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0126] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0127] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0128] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0129] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0130] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0131] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.
Claims
1. A file-sharing method based on a blockchain system, the method being executed by a device of a file provider, comprising: A derived key is generated based on the master key and the identifier of the target file; The target file is encrypted into a ciphertext file using the derived key; Upload the encrypted file to the off-chain storage system; The derived key is encrypted into a first ciphertext key using the first public key of the first user of the target file; Send a first transaction to the blockchain system. The first transaction includes the file hash value of the target file, the file storage information of the encrypted file in the off-chain storage system, and the first encrypted key, so as to store the transaction hash value of the first transaction and the first transaction in the blockchain system. Receive the transaction hash value returned by the blockchain system; The transaction hash value is used to share the encrypted file with any user.
2. The method according to claim 1, wherein, The off-chain storage system includes an InterPlanetary File System (IPFS) cluster and management devices for file copy management; as well as Uploading the encrypted file to the off-chain storage system includes: The management device sends a storage request including the encrypted file to the management device, so that after the management device selects multiple IPFS nodes from the IPFS cluster based on preset file storage reliability requirements, it sends the storage request to the multiple IPFS nodes, thereby enabling the multiple IPFS nodes to store the encrypted file and generate the content identifier of the encrypted file. The system receives file storage information returned by the management device, which includes the content identifier and node information of the multiple IPFS nodes.
3. The method according to claim 1, wherein, The blockchain system is equipped with smart contracts. as well as After receiving the transaction hash value returned by the blockchain system, the process also includes: The derived key is generated based on the master key and the identifier of the target file; The derived key is encrypted into a second ciphertext key using the second public key of the second user of the target file; A second transaction is sent to the blockchain system. The second transaction invokes the smart contract and includes the transaction hash value, the second public key, and the second ciphertext key, for storing the transaction hash value, the second public key, and the second ciphertext key in the contract state of the smart contract.
4. The method according to claim 3, wherein, The identifier of the target file is the file hash value; as well as Before generating the derived key based on the master key and the identifier of the target file, the method further includes: Send a query request, including the transaction hash value, to the blockchain system; Receive the first transaction returned by the blockchain system; Obtain the file hash value from the first transaction.
5. A file-sharing method based on a blockchain system, the method being executed by a device of a first user of a target file, comprising: Send a query request to the blockchain system, the query request including the transaction hash value shared by the file provider of the target file to the first user; The transaction hash value is used to share the encrypted file with any user. The encrypted file is obtained by encrypting the target file using a derived key by the device of the file provider. Receive the first transaction corresponding to the transaction hash value returned by the blockchain system; The first ciphertext key is obtained from the first transaction. The file hash value of the target file, the file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key are obtained by the device encrypting the derived key using the first public key of the first user.
6. The method according to claim 5, further comprising: The first encrypted key is decrypted into the derived key using the first private key of the first user; The encrypted file is retrieved from the off-chain storage system based on the file storage information. The ciphertext file is decrypted into the target file using the derived key; The integrity of the decrypted target file is verified based on the file hash value.
7. A file-sharing method based on a blockchain system, wherein a smart contract is deployed in the blockchain system, and the method is executed by a device of a second user of the target file, comprising: Send a query request to the blockchain system, the query request including the transaction hash value shared by the file provider of the target file to the second user; The transaction hash value is used to share the encrypted file with any user. The encrypted file is obtained by encrypting the target file using a derived key by the device of the file provider. Receive the first transaction corresponding to the transaction hash value returned by the blockchain system; Obtain the file hash value of the target file and the file storage information of the encrypted file in the off-chain storage system from the first transaction; A third transaction is sent to the blockchain system. The third transaction invokes the smart contract and includes the transaction hash value and the second public key of the second user to obtain a second ciphertext key associated with the transaction hash value and the second public key from the contract state of the smart contract. The second ciphertext key is obtained by the file provider's device encrypting the derived key using the second public key. Receive the second ciphertext key returned by the blockchain system.
8. The method according to claim 7, further comprising: The second encrypted key is decrypted into the derived key using the second private key of the second user; The encrypted file is retrieved from the off-chain storage system based on the file storage information. The ciphertext file is decrypted into the target file using the derived key; The integrity of the decrypted target file is verified based on the file hash value.
9. A file-sharing method based on a blockchain system, wherein a smart contract is deployed in the blockchain system, and the method is executed by nodes in the blockchain system, comprising: The device receives a query request from a second user of a target file, the query request including a transaction hash value shared by the file provider of the target file to the second user; the transaction hash value is used to share a ciphertext file with any user, the ciphertext file being obtained by encrypting the target file using a derived key by the file provider's device; The first transaction corresponding to the transaction hash value is obtained from the blockchain system, and the first transaction is returned to the device of the second user so that the device can obtain the file hash value of the target file and the file storage information of the encrypted file in the off-chain storage system from the first transaction; The system receives a third transaction sent by the device of the second user, the third transaction invoking the smart contract and including the transaction hash value and the second public key of the second user; wherein the transaction hash value, the second public key and the second ciphertext key are stored in the contract state of the smart contract, and the second ciphertext key is obtained by the device of the file provider encrypting the derived key using the second public key; By executing the third transaction, the second ciphertext key is obtained from the contract state; The second ciphertext key is returned to the device of the second user.
10. The method according to claim 9, wherein, Before receiving the query request sent by the device of the second user of the target file, the following is also included: The device receives the first transaction sent by the file provider's device. The first transaction includes the file hash value, the file storage information, and a first ciphertext key. The first ciphertext key is obtained by the file provider's device encrypting the derived key using the first public key of the first user of the target file. The first transaction is hashed to obtain the transaction hash value, and the transaction hash value and the first transaction are stored in the blockchain system; The transaction hash value is returned to the device of the file provider.
11. The method according to claim 9, wherein, Before receiving the third transaction sent by the second user's device, the process also includes: The system receives a second transaction sent by the device of the file provider. The second transaction invokes the smart contract and includes the transaction hash value, the second public key, and the second ciphertext key. By executing the second transaction, the transaction hash value, the second public key, and the second ciphertext key are stored in the contract state.
12. A file-sharing device based on a blockchain system, the device being applied to a file provider's device, comprising: The generation unit is configured to generate a derived key based on the master key and the identifier of the target file; An encryption unit is configured to encrypt the target file into a ciphertext file using the derived key; The file upload unit is configured to upload the encrypted file to the off-chain storage system; The encryption unit is further configured to encrypt the derived key into a first ciphertext key using the first public key of the first user of the target file; The sending unit is configured to send a first transaction to the blockchain system. The first transaction includes the file hash value of the target file, the file storage information of the encrypted file in the off-chain storage system, and the first encrypted key, for storing the transaction hash value of the first transaction and the first transaction in the blockchain system. The receiving unit is configured to receive the transaction hash value returned by the blockchain system; The transaction hash value is used to share the encrypted file with any user.
13. A file-sharing device based on a blockchain system, the device being applied to the device of a first user of a target file, comprising: The sending unit is configured to send a query request to the blockchain system, the query request including a transaction hash value shared by the file provider of the target file to the first user; the transaction hash value is used to share a ciphertext file with any user, the ciphertext file being obtained by encrypting the target file with a derived key using the file provider's device; The receiving unit is configured to receive a first transaction returned by the blockchain system corresponding to the transaction hash value; The acquisition unit is configured to acquire from the first transaction the file hash value of the target file, the file storage information of the ciphertext file in the off-chain storage system, and the first ciphertext key; wherein the first ciphertext key is obtained by the device encrypting the derived key using the first public key of the first user.
14. A file-sharing device based on a blockchain system, wherein a smart contract is deployed in the blockchain system, and the device is applied to a device of a second user of a target file, comprising: The sending unit is configured to send a query request to the blockchain system, the query request including a transaction hash value shared by the file provider of the target file to the second user; the transaction hash value is used to share a ciphertext file with any user, the ciphertext file being obtained by encrypting the target file using a derived key by the file provider's device; The receiving unit is configured to receive a first transaction returned by the blockchain system corresponding to the transaction hash value; The acquisition unit is configured to acquire the file hash value of the target file and the file storage information of the ciphertext file in the off-chain storage system from the first transaction; The sending unit is further configured to send a third transaction to the blockchain system, the third transaction invoking the smart contract and including the transaction hash value and the second public key of the second user, for obtaining a second ciphertext key associated with the transaction hash value and the second public key from the contract state of the smart contract; wherein the second ciphertext key is obtained by the file provider's device encrypting the derived key using the second public key; The receiving unit is also configured to receive the second ciphertext key returned by the blockchain system.
15. A node in a blockchain system, wherein smart contracts are deployed in the blockchain system, the node comprising: The receiving unit is configured to receive a query request sent by a device of a second user of a target file. The query request includes a transaction hash value shared by the file provider of the target file to the second user. The transaction hash value is used to share a ciphertext file with any user. The ciphertext file is obtained by encrypting the target file using a derived key by the file provider's device. The acquisition unit is configured to acquire a first transaction corresponding to the transaction hash value from the blockchain system and return the first transaction to the device of the second user, so that the device can acquire the file hash value of the target file and the file storage information of the encrypted file in the off-chain storage system from the first transaction; The receiving unit is further configured to receive a third transaction sent by the device of the second user, the third transaction invoking the smart contract and including the transaction hash value and the second public key of the second user; wherein the transaction hash value, the second public key and the second ciphertext key are stored in the contract state of the smart contract, and the second ciphertext key is obtained by the device of the file provider encrypting the derived key using the second public key; An execution unit is configured to obtain the second ciphertext key from the contract state by executing the third transaction; The sending unit is configured to return the second ciphertext key to the device of the second user.
16. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-11.
17. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-11.
Citation Information
Patent Citations
Data file security privacy storage and sharing method based on a block chain
CN109768987A
Data management method, device and equipment
CN111932263A
Attribute-based encryption and block chain combined trusted data access control scheme
CN112836229A
File storage and reading method and file storage and reading system in block chain network
CN114499894A