Blockchain-based file sharing method, blockchain node, and computing node
By deploying smart contracts in the blockchain to manage shared groups and authorization information, the problem of targeted sharing of target files on the blockchain is solved, and efficient and reliable file sharing off-chain is achieved.
Patent Information
- Application Number
- CN202310600278.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-25
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2043-05-25
AI Technical Summary
Existing technologies struggle to efficiently achieve targeted sharing of target files on the blockchain, especially when the files are large. They also lack the reliability and traceability of file access.
By deploying smart contracts in the blockchain, the grouping information of shared groups and the authorization information of target files are managed. The functions of smart contracts are used to query and verify the identity of computing nodes, ensuring that only computing nodes with access permissions can obtain the target files.
It enables efficient off-chain sharing of target files to authorized computing nodes, while improving the reliability and traceability of file access by recording access behavior through blockchain.
Smart Images

Figure CN116633626B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the specification belong to the field of blockchains, and particularly relate to a file sharing method based on a blockchain, a blockchain node and a computing node. BACKGROUND
[0002] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism and encryption algorithm. In a blockchain system, data blocks are combined into a chain-type data structure in a time sequence, and are guaranteed to be non-tamperable and non-forgable by cryptography. Due to the characteristics of decentralization, information non-tamperability and autonomy, blockchain has attracted more and more attention and application. SUMMARY
[0003] The purpose of the present application is to provide a file sharing method based on a blockchain, a blockchain node and a computing node.
[0004] In a first aspect, a file sharing method based on a blockchain is provided. The blockchain has a smart contract deployed therein. The contract state of the smart contract includes authorization information of a target file and grouping information of a first sharing group. The authorization information includes a file identifier of the target file and a group identifier of the first sharing group. The grouping information includes the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group. The method includes: receiving, by a second computing node, a query request from a third computing node, wherein the query request includes the file identifier of the target file and an identity identifier of the third computing node, and the second computing node belongs to the plurality of first computing nodes; sending, by the second computing node, a first transaction to the blockchain, wherein the first transaction includes the file identifier of the target file and the identity identifier of the third computing node; executing, by the blockchain, a first function in the smart contract according to the first transaction, to achieve: obtaining the group identifier from the authorization information according to the file identifier of the target file, querying whether the identity identifier of the third computing node is included in the grouping information according to the group identifier, and returning a first query result to the second computing node, to indicate whether the identity identifier of the third computing node is included in the grouping information; and sending, by the second computing node, the target file to the third computing node, in a case where the identity identifier of the third computing node is included in the grouping information.
[0005] In a second aspect, a file sharing method based on a blockchain is provided. The blockchain has a smart contract deployed thereon. The contract state of the smart contract includes authorization information of a target file and group information of a first sharing group. The authorization information includes a file identifier of the target file and a group identifier of the first sharing group. The group information includes the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group. The method is performed by a blockchain node in the blockchain. The method includes: receiving a first transaction from a second computing node, the second computing node belonging to the plurality of first computing nodes, the first transaction being initiated by the second computing node based on a query request from a third computing node, the query request and the first transaction including the file identifier of the target file and an identity identifier of the third computing node; and executing a first function in the smart contract according to the first transaction, so as to: obtain the group identifier from the authorization information according to the file identifier of the target file, query whether the identity identifier of the third computing node is included in the group information according to the group identifier, and return a first query result to the second computing node, the first query result indicating whether the identity identifier of the third computing node is included in the group information, so that the second computing node sends the target file to the third computing node when the identity identifier of the third computing node is included in the group information.
[0006] In a third aspect, a file sharing method based on a blockchain is provided. The blockchain has a smart contract deployed thereon. The contract state of the smart contract includes authorization information of a target file and group information of a first sharing group. The authorization information includes a file identifier of the target file and a group identifier of the first sharing group. The group information includes the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group. The method is performed by a second computing node belonging to the plurality of first computing nodes. The method includes: receiving a query request from a third computing node, the query request including the file identifier of the target file and an identity identifier of the third computing node, the second computing node belonging to the plurality of first computing nodes; sending a first transaction to the blockchain, the first transaction including the file identifier of the target file and the identity identifier of the third computing node, so that the blockchain executes a first function in the smart contract according to the first transaction, so as to: obtain the group identifier from the authorization information according to the file identifier of the target file, query whether the identity identifier of the third computing node is included in the group information according to the group identifier, and return a first query result to the second computing node, the first query result indicating whether the identity identifier of the third computing node is included in the group information; and sending the target file to the third computing node when the identity identifier of the third computing node is included in the group information.
[0007] Fourthly, a blockchain node is provided, wherein a smart contract is deployed in the blockchain to which the blockchain node belongs. The contract state of the smart contract includes authorization information of a target file and grouping information of a first shared group. The authorization information includes the file identifier of the target file and the group identifier of the first shared group. The grouping information includes the group identifier and the identity identifiers of several first computing nodes belonging to the first shared group. The blockchain node includes: a transaction receiving unit configured to receive a first transaction from a second computing node belonging to several first computing nodes. The first transaction is initiated by the second computing node based on a query request from a third computing node. The query request and the first transaction include the file identifier of the target file and the identity identifier of the third computing node. A transaction execution unit configured to execute a first function in the smart contract according to the first transaction, which implements: obtaining the group identifier from the authorization information based on the file identifier of the target file; querying whether the grouping information includes the identity identifier of the third computing node based on the group identifier; and returning a first query result to the second computing node to indicate whether the grouping information includes the identity identifier of the third computing node, so that if the grouping information includes the identity identifier of the third computing node, the second computing node sends the target file to the third computing node.
[0008] Fifthly, a second computing node is provided, which belongs to a plurality of first computing nodes connected to a blockchain. The blockchain deploys a smart contract, the contract state of which includes authorization information of a target file and grouping information of a first shared group. The authorization information includes a file identifier of the target file and a group identifier of the first shared group. The grouping information includes the group identifier and the identity identifiers of the plurality of first computing nodes belonging to the first shared group. The second computing node includes a request receiving unit configured to receive a query request from a third computing node, including the file identifier of the target file and the identity identifier of the third computing node. The second computing node belongs to the plurality of first computing nodes. The system includes a transaction sending unit configured to send a first transaction to the blockchain, including the file identifier of the target file and the identity identifier of the third computing node, causing the blockchain to execute a first function in the smart contract based on the first transaction, thereby: obtaining the group identifier from the authorization information based on the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node based on the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node; and a request response unit configured to send the target file to the third computing node if the group information includes the identity identifier of the third computing node.
[0009] In a sixth aspect, a computer-readable storage medium is provided, storing a computer program / instructions that, when executed in a computer, cause the computer to perform the method described in the second or third aspect.
[0010] In a seventh aspect, a computing device is provided, including a memory and a processor, wherein the memory stores a computer program / instruction, and the processor, when executing the computer program / instruction, implements the method described in the second or third aspect.
[0011] In the embodiments of this specification, smart contracts deployed in the blockchain manage the grouping information of shared groups and the authorization information of target files. When a third computing node wants to query a target file from a second computing node holding the target file, the second computing node can send a first transaction to the blockchain, containing the file identifier of the target file and the identity identifier of the third computing node, to invoke the smart contract based on the query request from the third computing node. The blockchain can then execute a first function in the smart contract based on the first transaction, which retrieves the group identifier from the authorization information of the target file based on the file identifier of the target file, queries whether the corresponding grouping information includes the identity identifier of the third computing node based on the group identifier, and returns a first query result to the second computing node, indicating whether the grouping information includes the identity identifier of the third computing node. If the queried grouping information includes the identity identifier of the third computing node, it indicates that the third computing node has permission to access the target file. Correspondingly, the second computing node can only send the target file it holds to the third computing node if it confirms that the relevant grouping information includes the identity identifier of the third computing node based on the indication information. In this way, it can be ensured that the second computing node will only share the target file efficiently off-chain with computing nodes that have the right to access the target file. At the same time, the computing node's access to the target file will be recorded in the blockchain through the first transaction initiated by the second computing node holding the target file, ensuring that the computing node's access to the target file is traceable, which is convenient for analyzing illegal access to the target file and has higher reliability. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.
[0013] Figure 1 This is a system architecture diagram of the technical solutions provided in the embodiments of this specification;
[0014] Figure 2 This is a flowchart illustrating a method for establishing a shared group based on blockchain, as provided in the embodiments of this specification.
[0015] Figure 3 This is a flowchart illustrating a method for determining whether grouping information is effective, as provided in the embodiments of this specification.
[0016] Figure 4 This is a flowchart of a file access authorization method provided in the embodiments of this specification;
[0017] Figure 5 This is a flowchart illustrating a method for changing grouping information provided in the embodiments of this specification;
[0018] Figure 6 This is a flowchart illustrating a blockchain-based file-sharing method provided in the embodiments of this specification;
[0019] Figure 7 This is a schematic diagram of the structure of a blockchain node provided in the embodiments of this specification;
[0020] Figure 8 This is a schematic diagram of the structure of a computing node provided in the embodiments of this specification. Detailed Implementation
[0021] 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.
[0022] A blockchain (blockchain system) can include multiple blockchain nodes, and P2P (Peer-to-Peer) connections can be established between blockchain nodes. The aforementioned P2P connection can be a transmission control protocol (TCP) connection or a communication connection based on other communication protocols. The aforementioned P2P connection is used to support the transmission of data between different blockchain nodes.
[0023] In a blockchain, system data that needs to be persistently stored can be divided into two parts: block data and state data.
[0024] Block data includes one or more blocks in ascending order of block height (or block number). A single block may include a block header and a block body. The block header may include the previous block's block hash (or parent hash), timestamp, block number (BlockNum), state root hash (State_Root), transaction root hash (Transaction_Root), and receipt root hash (Receipt_Root), etc. The block body may include a set of transactions and a set of receipts.
[0025] For any k-th block, based on the state data with block height (or version) k-1, execute multiple transactions in the transaction set belonging to the k-th block, arranged in sequence, and obtain the execution results of these transactions. Then, update the state data with block height k-1 based on the execution results of these transactions to obtain the state data with block height k.
[0026] A transaction in a blockchain refers to a unit of task executed and recorded within the blockchain. A single transaction typically includes a From field, a To field, and a Data field. The From field includes the account initiating the transaction, and the To field may include another account involved in the transaction. 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. In the case of a transaction calling a smart contract in the blockchain, the From field represents the account address initiating the transaction, the To field represents the account address of the contract called by the transaction, and the Data field includes the function name in the called contract and the parameters passed to that function, which is used to retrieve and execute the function's code from the blockchain during transaction execution.
[0027] In blockchain, smart contracts are contracts that can be triggered and executed by transactions. Smart contracts can be defined in the form of code. For example, in a consortium blockchain, calling a smart contract involves initiating a transaction pointing to the smart contract's address, causing each node in the consortium blockchain network to run the smart contract code in a distributed manner. It's important to note that besides users creating smart contracts, the system can also set smart contracts in the genesis block. These contracts are generally called genesis contracts. Typically, genesis contracts can set some blockchain data structures, parameters, attributes, and methods. Furthermore, accounts with system administrator privileges can create or modify system-level contracts (referred to as system contracts).
[0028] In smart contract deployment scenarios, a transaction containing smart contract creation information (i.e., a transaction used to create a smart contract) can be sent to the blockchain. The `from` field of this transaction is the account address of the transaction initiator, the `data` field includes the code of the smart contract to be created (such as bytecode or machine code), and the `to` field is empty to indicate that the transaction is used to deploy the contract. After nodes reach a consensus through the consensus mechanism, the contract address is determined, a contract account corresponding to the smart contract's contract address is added to the state database, state storage corresponding to the contract account is allocated, and the contract code is stored in the smart contract's state storage.
[0029] In scenarios involving contract invocation, a transaction for invoking a smart contract can be sent to the blockchain. The `from` field of this transaction is the account address of the transaction initiator, the `to` field is the contract address of the smart contract being invoked, and the `data` field includes the method and parameters for invoking the smart contract. After consensus is reached on this transaction within the blockchain, each node can execute the transaction, thereby executing the smart contract and updating the corresponding state database based on the execution of the smart contract.
[0030] It's important to note that contract accounts typically also possess some state. This state is defined by state variables within the smart contract and generates new values during the smart contract's creation and execution. Contract accounts can be used to store the contract state related to the smart contract. Once an event triggers a clause in the smart contract (meeting the execution conditions), the code can be executed automatically. In the blockchain, the contract state of a smart contract is stored in a storage trie. The hash value of the root node of this storage trie is stored in `storage_root`, thus locking all contract states of that contract under that contract account through hashing. The storage trie is an MPT tree structure that stores a key-value mapping from state addresses to state values. From the root node to the leaf node, each node stores the address of a state variable, and each leaf node stores the value of a state variable.
[0031] A blockchain can involve multiple participants. For example, different blockchain nodes may interface with different computing nodes. Interconnected blockchain nodes and computing nodes belong to the same participant, while different blockchain nodes / computing nodes may belong to different participants. These participants can be institutions, organizations, or individuals. See also... Figure 1 As shown, the blockchain can be, for example, a consortium blockchain corresponding to multiple participants / members. This blockchain includes, for example, multiple blockchain nodes such as node 1 to node 4. Node 1 and compute node 10 belong to participant A, node 2 and compute node 20 belong to participant B, node 3 and compute node 30 belong to participant C, and node 4 and compute node 40 belong to participant D. It should be noted that the technical solutions provided in the embodiments of this specification are not limited to... Figure 1 The system framework shown allows different computing nodes to connect to the same blockchain node.
[0032] Participants or different computing nodes may wish to share files. If the files are relatively large, efficient file sharing needs to be implemented off-chain. For example, after obtaining a target file, participant A may, for compliance or business purposes, allow sharing the target file with participants B and C, but prohibit sharing it with participant D. However, the target file may be a relatively large video evidence file, legal document, etc., making it difficult to efficiently share the target file with participants B and C on the blockchain. In this case, participant A needs to complete the efficient and reliable off-chain sharing of the target file with participants B and C.
[0033] This specification provides at least one blockchain-based file sharing method, a blockchain node, and a computing node. A smart contract deployed in the blockchain manages the grouping information of shared groups and the authorization information of target files. When a third computing node requests to query a target file from a second computing node holding the target file, the second computing node can send a first transaction to the blockchain, containing the file identifier of the target file and the identity identifier of the third computing node, to invoke the smart contract based on the query request from the third computing node. The blockchain can then execute a first function in the smart contract based on the first transaction. This function retrieves the group identifier from the authorization information of the target file based on the file identifier, queries whether the corresponding grouping information includes the identity identifier of the third computing node, and returns a first query result to the second computing node, indicating whether the grouping information includes the identity identifier of the third computing node. If the queried grouping information includes the identity identifier of the third computing node, it indicates that the third computing node has permission to access the target file. Correspondingly, the second computing node can only send the target file it holds to the third computing node if it confirms that the relevant grouping information includes the identity identifier of the third computing node based on the indication information. In this way, it can be ensured that the second computing node will only share the target file efficiently off-chain with computing nodes that have the right to access the target file. At the same time, the computing node's access to the target file will be recorded in the blockchain through the first transaction initiated by the second computing node holding the target file, ensuring that the computing node's access to the target file is traceable, which is convenient for analyzing illegal access to the target file and has higher reliability.
[0034] Figure 2This is a flowchart illustrating a method for establishing a shared group based on a blockchain, as provided in the embodiments of this specification. The method exemplarily describes the process of establishing a shared group X1 (first shared group) containing several first computing nodes based on a smart contract C1 deployed in the blockchain. These first computing nodes can belong to at least one of the multiple participants corresponding to the blockchain, and any two first computing nodes can belong to the same or different participants. The first computing nodes can correspond to IPFS nodes in the InterPlanetary File System (IPFS), or can be implemented as virtual or physical nodes specifically designed to interface with the blockchain and support off-chain file sharing.
[0035] IPFS is a peer-to-peer distributed file system that attempts to make all compute nodes connect 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. 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 a distributed hash table, encourages block exchange, and 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 Hypertext Transfer Protocol (HTTP) schemes might encounter. IPFS can be accessed in several ways, including FUSE and HTTP. Compute nodes can make local files available worldwide by adding them to IPFS. File identifiers are derived from their hashes, which is beneficial for caching. IPFS nodes can efficiently share files using BitTorrent-based protocols.
[0036] See Figure 2 As shown, the method may include some or all of the following steps S201 and S203.
[0037] In step S201, the fourth computing node, which belongs to a plurality of first computing nodes, sends a second transaction to the blockchain to invoke smart contract C1. The second transaction includes the group identifier of shared group X1 and the identity identifiers of a plurality of first computing nodes belonging to shared group X1.
[0038] The identity of a first computing node can be the identifier of its respective participant in the blockchain. For example, several first computing nodes include computing node 10 belonging to participant A, computing node 20 belonging to participant B, and computing node 30 belonging to participant C; then, the identity of computing node 10 can be the identifier of participant A in the blockchain, the identity of computing node 20 can be the identifier of participant B in the blockchain, and the identity of computing node 30 can be the identifier of participant C in the blockchain.
[0039] When the first compute node corresponds to an IPFS node in IPFS, the identity of the first compute node can also be the identifier of its corresponding IPFS node in IPFS. For example, several first compute nodes include compute node 10 belonging to participant A, compute node 20 belonging to participant B, and compute node 30 belonging to participant C; compute node 10, compute node 20, and compute node 30 correspond to IPFS node A, IPFS node B, and IPFS node C in the same IPFS in sequence; then, the identity of compute node 10 can be the identifier of IPFS node A in IPFS, the identity of compute node 20 can be the identifier of IPFS node B in IPFS, and the identity of compute node 30 can be the identifier of IPFS node C in IPFS.
[0040] The group identifier of shared group X1 can be determined by the fourth computing node. For example, the fourth computing node can calculate the hash value of the identity identifiers of the aforementioned first computing nodes, and determine the group identifier of shared group X1 based on the calculated hash value.
[0041] In step S203, the blockchain executes the second function in smart contract C1 according to the second transaction, thereby creating group information Y1 of shared group X1 in the contract state of smart contract C1. Group information Y1 includes the group identifier of shared group X1 and the identity identifiers of several first computing nodes.
[0042] Once the group information Y1 of shared group X1 is created in the contract state of the smart contract, the establishment of shared group X1 can be considered complete. Alternatively, to minimize the possibility of malicious creation of shared groups, when the blockchain executes the second function in smart contract C1 according to the second transaction, it can also create the effective information Z1 of group information Y1 in the contract state of smart contract C1. Then, the first computing nodes belonging to shared group X1 can vote on group information Y1 based on the effective information Z1, realizing the decision of several first computing nodes on whether to make group information Y1 effective.
[0043] Figure 3 This is a flowchart illustrating a method for determining whether grouping information is effective, as provided in the embodiments of this specification.
[0044] See Figure 3 As shown, the method may include, but is not limited to, some or all of the following steps S301 and S303.
[0045] In step S301, the first computing node sends a fourth transaction to the blockchain, which includes the group identifier of shared group X1 and the first voting information. The first voting information is used to indicate whether the first computing node agrees to establish shared group X1.
[0046] It is understandable that several first computing nodes belonging to shared group X1 can obtain the group identifier of shared group X1 included in the group information Y1 of shared group X1 created by the blockchain based on the second transaction through subscription or other means.
[0047] In step S303, the blockchain executes the fourth function in smart contract C1 according to the fourth transaction, which realizes: recording the first voting information in the effective information Z1 of group information Y1 according to the group identifier of shared group X1, and recording the voting result Q1 in the effective information Z1 based on the first voting information from several first computing nodes. The voting result Q1 is used to indicate whether group information Y1 is effective.
[0048] For example, when the blockchain executes the fourth function in smart contract C1 based on the fourth transaction, it can first count the cumulative number of votes representing the first votes in favor of establishing shared group X1 in each of the fourth transactions received from several first computing nodes; then it can determine whether the ratio between the cumulative number of votes and the total number of nodes of several first computing nodes reaches a predetermined value, or whether the cumulative number of votes reaches the total number of nodes of several first computing nodes; if not, the voting result Q1 is set to a first value indicating that the group information Y1 of shared group X1 has not taken effect; if so, the voting result Q1 is set to a second value indicating that the group information Y1 of shared group X1 has taken effect.
[0049] When voting result Q1 indicates that group information Y2 is effective, the corresponding indication has been completed to establish shared group X1.
[0050] The preceding text exemplifies the process of establishing a shared group X1 based on actual needs. It can be understood that by executing a similar process multiple times, multiple shared groups can be established according to actual needs; thus, the contract state of smart contract C1 includes the grouping information of these multiple shared groups, for example, it also includes the grouping information Y2 of shared group X2. A single computing node can participate in multiple shared groups; for example, shared group X1 and shared group X2 can include the same computing node, meaning that the grouping information Y1 of shared group X1 and the grouping information Y2 of shared group X2 can include the identity identifier of the same computing node.
[0051] After a shared group is established based on blockchain, a computing node holding a target file can grant access to that target file to other computing nodes in a specific shared group to which the computing node belongs.
[0052] Figure 4 This is a flowchart illustrating a file access authorization method provided in an embodiment of this specification. The method exemplarily describes the process by which a second computing node belonging to shared group X1 grants access permissions to a target file to the remaining first computing nodes belonging to shared group X1. See also... Figure 4 As shown, the method may include, but is not limited to, the following steps S401 and S403.
[0053] In step S401, the second computing node sends a third transaction to the blockchain, which includes the file identifier of the target file and the group identifier of the shared group X1. Additionally, the third transaction may also include the identity identifier of the second computing node.
[0054] The file identifier of the target file is used to uniquely identify the target file among several first computing nodes. For example, when the second computing node corresponds to the IPFS node in IPFS, the second computing node can obtain the content identifier (CID) of the target file in IPFS after adding the target file to IPFS, and then use the CID of the target file in IPFS as the file identifier of the target file.
[0055] After the IPFS node corresponding to the second computing node obtains the CID of the target file, it can broadcast the metadata of the target file in its own IPFS, so that the other IPFS nodes in the IPFS can know the CID of the target file and the identity of the second computing node holding the target file, so that the other first computing nodes in the shared group X1 can know the CID of the target file and the identity of the second computing node holding the target file.
[0056] In step S403, the blockchain executes the third function in smart contract C1 according to the third transaction, at least to: create authorization information P1 of the target file in the contract state of smart contract C1, including the file identifier of the target file and the group identifier of the shared group X1.
[0057] When the contract state of smart contract C1 includes the effective information Z1 corresponding to the group information Y1 of shared group X1, when the blockchain executes the third function in smart contract C1 according to the third transaction, it can also query the voting result Q1 from the effective information Z1 corresponding to the group information Y1 of shared group X1 based on the group identifier of shared group X1, and determine whether the group information Y1 of shared group X1 has taken effect based on the voting result Q1. If the group information Y1 has not taken effect, the authorization information P1 for creating the target file in the contract state of smart contract C1 can no longer be executed.
[0058] When the third transaction includes the identity identifier of the second computing node, when the blockchain executes the third function in smart contract C1 based on the third transaction, it can also query whether the identity identifier of the second computing node is included in the group information Y1 based on the group identifier of the shared group X1. If not, it means that the second computing node does not belong to the shared group X1, and the authorization information P1 for creating the target file in the contract state of smart contract C1 can no longer be executed.
[0059] Correspondingly, when the contract state of smart contract C1 includes the effective information Z1 and the third transaction includes the identity identifier of the second computing node, the blockchain needs to ensure that the voting result Q1 in the effective information Z1 indicates that the group information Y1 has taken effect, and that the group information Y1 includes the identity identifier of the second computing node before it can create the authorization information P1 of the target file in the contract state of smart contract C1.
[0060] After the blockchain successfully creates the authorization information P1 of the target file in the contract state of smart contract C1, the second computing node grants access to the target file to the remaining first computing nodes in its shared group X1.
[0061] The preceding text exemplarily described the process of granting access permissions for a target file to the remaining first computing nodes in the shared group X1 by creating authorization information P1 in the contract state of smart contract C1. It can be understood that through multiple rounds of execution, the process is similar to the aforementioned... Figure 4 A similar process to the illustrated embodiment can be used to create one or more authorization information for one or more files in the contract state of smart contract C1, thereby completing the corresponding file authorization operation.
[0062] After creating grouping and authorization information in the contract state of smart contract C1 deployed on the blockchain, the grouping information can be modified to expand or shrink the scope of computing nodes that can access specific files.
[0063] Figure 5This is a flowchart illustrating a method for changing grouping information provided in an embodiment of this specification. The method exemplarily describes the process by which a fifth node, belonging to a plurality of first computing nodes, changes the grouping information Y1 of its shared group X1. See also... Figure 5 As shown, the method may include some or all of the following steps S501 to S507.
[0064] In step S501, a fifth computing node belonging to a plurality of first computing nodes sends a fifth transaction to the blockchain node for invoking smart contract C1, which includes the group identifier and change information of shared group X1. It may also include the identity identifier of the fifth computing node.
[0065] The change information is used to delete shared group X1, add one or more identity identifiers of computing nodes to the group information of shared group X1, or delete one or more identity identifiers of first computing nodes from the group information of shared group X1.
[0066] In step S503, the blockchain executes the fifth function in smart contract C1 based on the fifth transaction, which achieves: determining the change identifier of the change information, and storing the change identifier, change information, group identifier of shared group X1, and effective information Z2 in the contract state of smart contract C1 according to the group identifier of shared group X1.
[0067] When the fifth transaction includes the identity representation of the fifth computing node, when the blockchain executes the fifth function in smart contract C1 based on the fifth transaction, it can also query whether the group information Y1 of shared group X1 includes the identity representation of the fifth computing node based on the group identifier of shared group X1. If it does, it continues to execute the change identifier to determine the change information.
[0068] It is understandable that several first computing nodes belonging to the shared group X1 can obtain the change identifier corresponding to the change information in the fifth transaction determined by the blockchain through subscription or other means.
[0069] In step S505, the first computing node sends a sixth transaction to the blockchain to invoke smart contract C1, which includes the group identifier of shared group X1, the change identifier of the change information, and second voting information. The second voting information is used to indicate whether the first computing node agrees to update shared group X1 based on the relevant change information.
[0070] In step S507, the blockchain executes the sixth function in smart contract C1 according to the sixth transaction, and implements the following: recording the second voting information in the effective information Z2 according to the group identifier of shared group X1 and the change identifier of the change information; recording the voting result Q2 in the effective information Z2 based on the second voting information from several first computing nodes; and updating the group information Y1 according to the group identifier and change information of shared group X1 if the second voting result Q2 indicates that the change information is allowed to take effect.
[0071] The voting result Q2 can be determined based on the cumulative number of approvals from the sixth transactions received by the blockchain from several first computing nodes, representing the number of approvals for updating the shared group X1 based on the relevant change information. For example, when the ratio between the cumulative number of approvals and the total number of nodes of the several first computing nodes reaches a predetermined value, or when the cumulative number of approvals reaches the total number of nodes, the determined voting result Q2 can indicate that the relevant change information is allowed to take effect, and the group information Y1 is updated according to the relevant change information.
[0072] After creating grouping and authorization information in the contract state of smart contract C1 deployed on the blockchain, access control can be implemented for the process of sharing files between different computing nodes based on the blockchain.
[0073] Figure 6 This is a flowchart illustrating a blockchain-based file-sharing method provided in the embodiments of this specification. The method exemplarily describes the process by which a third computing node queries a target file from a second computing node.
[0074] See Figure 6 As shown, the method may include, but is not limited to, some or all of the following steps S601 to S607.
[0075] In step S601, the third computing node sends a query request to the second computing node, which includes the file identifier of the target file and the identity identifier of the third computing node.
[0076] The third computing node can also send a seventh transaction to the blockchain, which includes the file identifier of the target file that the third computing node expects to query. The blockchain can then execute the seventh function in smart contract C1 based on the seventh transaction, which performs the following: obtaining the group identifier of shared group X1 from the authorization information P1 of the target file based on the file identifier of the target file; obtaining the identity identifiers of several first computing nodes from the group information Y1 based on the group identifier of shared group X1; and returning a second query result to the third computing node, which includes the identity identifiers of several first computing nodes. Furthermore, the third computing node can select one of the identity identifiers of the several first computing nodes as the identity identifier of the second computing node, and send a query request to the second computing node based on the selected identity identifier.
[0077] When the third computing node and the second computing node correspond to different IPFS nodes within the same IPFS, the IPFS node corresponding to the third computing node can obtain the CID of the target file and the identity of the second computing node holding the target file based on the metadata of the target file received from the IPFS node corresponding to the second computing node. Furthermore, the third computing node can send a query request to the second computing node based on the identity of the second computing node.
[0078] In step S603, the second computing node sends a first transaction to the blockchain to invoke smart contract C1, which includes the file identifier of the target file and the identity identifier of the third computing node. The identity identifier of the second computing node may also be included.
[0079] In step S605, the blockchain executes the first function in smart contract C1 according to the first transaction, which implements: obtaining the group identifier of shared group X1 from the authorization information P1 of the target file according to the file identifier of the target file; querying whether the group information Y1 of shared group X1 includes the identity identifier of the third computing node according to the group identifier of shared group X1; and returning the first query result to the second computing node to indicate whether the group information Y1 includes the identity identifier of the third computing node.
[0080] When the first transaction includes the identity identifier of the second computing node, when the blockchain executes the first function in smart contract C1 based on the first transaction, it can also obtain the group identifier of shared group X1 from the authorization information P1 of the target file based on the file identifier of the target file, and then query whether the group information Y1 of shared group X1 includes the identity identifier of the third computing node based on the group identifier of shared group X1. If so, it continues to query whether the group information Y1 of shared group X1 includes the identity identifier of the third computing node based on the group identifier of shared group X1.
[0081] When the group information Y1 includes the identity identifier of the third computing node, it indicates that the third computing node belongs to several first computing nodes that make up the shared group X1, and the third computing node has the permission to access the target file.
[0082] In step S607, if the indication information indicates that the group information Y1 includes the identity of the third computing node, the second computing node sends the target file to the third computing node.
[0083] When the second and third computing nodes correspond to different IPFS nodes in the same IPFS, the second computing node can efficiently provide the target file to the third computing node through the bitswap protocol, according to the file exchange method allowed by IPFS.
[0084] It is important to note that when the second and third compute nodes correspond to different IPFS nodes within the same IPFS, the second compute node may not be the first original node to add the target file to IPFS. For example, shared packet X1 includes compute node 10 corresponding to IPFS node A, compute node 20 corresponding to IPFS node B, and compute node 30 corresponding to IPFS node C. Compute node 10 corresponding to IPFS node A may be the first to submit the target file to the IPFS compute node, thus making it the second compute node holding the target file. Compute node 20 corresponding to IPFS node B can then act as the third compute node querying the target file from compute node 10, enabling compute node 20 to obtain the target file. Subsequently, both compute node 10 corresponding to IPFS node A and compute node 20 corresponding to IPFS node B may act as the second compute node holding the target file, and compute node 30 corresponding to IPFS node C may act as the third compute node querying the target file from either compute node 10 or compute node 20, thus enabling compute node 30 to obtain the target file.
[0085] It should be noted that any method step executed by the blockchain in the aforementioned method embodiments can be specifically executed by a blockchain node within the blockchain.
[0086] Based on the same concept as the aforementioned method embodiments, this specification also provides a blockchain node 700. The blockchain node 700 belongs to a blockchain in which a smart contract is deployed. The contract state of the smart contract includes authorization information of a target file and grouping information of a first shared group. The authorization information includes the file identifier of the target file and the group identifier of the first shared group. The grouping information includes the group identifier and the identity identifiers of several first computing nodes belonging to the first shared group. See also... Figure 7As shown, the blockchain node 700 includes: a transaction receiving unit 701, configured to receive a first transaction from a second computing node belonging to a plurality of first computing nodes, the first transaction being initiated by the second computing node based on a query request from a third computing node, the query request and the first transaction including the file identifier of the target file and the identity identifier of the third computing node; and a transaction execution unit 703, configured to execute a first function in the smart contract according to the first transaction, implementing: obtaining the group identifier from the authorization information based on the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node based on the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node, so that if the group information includes the identity identifier of the third computing node, the second computing node sends the target file to the third computing node.
[0087] Based on the same concept as the aforementioned method embodiments, this specification also provides a second computing node 800. The second computing node 800 belongs to a plurality of first computing nodes connected to a blockchain. The blockchain deploys smart contracts, and the contract state of the smart contracts includes authorization information of a target file and grouping information of a first shared group. The authorization information includes the file identifier of the target file and the group identifier of the first shared group. The grouping information includes the group identifier and the identity identifiers of the plurality of first computing nodes belonging to the first shared group. See also... Figure 8 As shown, the second computing node 800 includes: a request receiving unit 801, configured to receive a query request from a third computing node, including the file identifier of the target file and the identity identifier of the third computing node, wherein the second computing node belongs to the plurality of first computing nodes; a transaction sending unit 803, configured to send a first transaction to the blockchain, including the file identifier of the target file and the identity identifier of the third computing node, such that the blockchain executes a first function in the smart contract according to the first transaction, thereby: obtaining the group identifier from the authorization information according to the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node according to the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node; and a request response unit 805, configured to send the target file to the third computing node if the group information includes the identity identifier of the third computing node.
[0088] This specification also provides a computer-readable storage medium storing a computer program / instruction that, when executed in a computer, causes the computer to perform various method steps executed by the first computing node, second computing node, third computing node, fourth computing node, fifth computing node, or blockchain in any of the aforementioned method embodiments.
[0089] This specification also provides a computing device in its embodiments, including a memory and a processor. The memory stores computer programs / instructions. When the processor executes the computer programs / instructions, it implements the various method steps executed by the first computing node, the second computing node, the third computing node, the fourth computing node, the fifth computing node, or the blockchain in any of the foregoing method embodiments.
[0090] 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.
[0091] 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.
[0092] 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.
[0093] 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.
[0094] 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.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0099] 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.
[0100] 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.
[0101] 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.
[0102] 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.
[0103] 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.
[0104] 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 blockchain, wherein a smart contract is deployed in the blockchain, the contract state of the smart contract includes authorization information of a target file and grouping information of a first sharing group, the authorization information including a file identifier of the target file and a group identifier of the first sharing group, the grouping information including the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group, the method comprising: The second computing node receives a query request from the third computing node, which includes the file identifier of the target file and the identity identifier of the third computing node. The second computing node belongs to the plurality of first computing nodes. The second computing node sends a first transaction to the blockchain, which includes the file identifier of the target file and the identity identifier of the third computing node; The blockchain executes a first function in the smart contract based on the first transaction to achieve: obtaining the group identifier from the authorization information based on the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node based on the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node; If the second computing node includes the identity identifier of the third computing node in the packet information, the second computing node sends the target file to the third computing node.
2. The method according to claim 1, further comprising: The fourth computing node sends a second transaction to the blockchain, which includes the group identifier and the identity identifiers of the plurality of first computing nodes, wherein the fourth computing node belongs to the plurality of first computing nodes; The blockchain executes the second function in the smart contract based on the second transaction, thereby creating the grouping information in the contract state of the smart contract.
3. The method according to claim 2, further comprising: The second computing node sends a third transaction to the blockchain, which includes the file identifier of the target file and the group identifier; The blockchain executes the third function in the smart contract based on the third transaction, thereby creating the authorization information in the contract state of the smart contract.
4. The method according to claim 3, wherein the third transaction further includes the identity identifier of the second computing node; in, When the blockchain executes the third function in the smart contract according to the third transaction, it also implements: querying whether the identity identifier of the second computing node is included in the group information according to the group identifier; if so, it executes the creation of the authorization information in the contract state of the smart contract.
5. The method according to claim 3, wherein when the blockchain executes the second function in the smart contract according to the second transaction, it further implements: creating first effective information of the grouping information in the contract state of the smart contract; in, The method further includes: The first computing node sends a fourth transaction to the blockchain, which includes the group identifier and the first voting information; The blockchain executes the fourth function in the smart contract according to the fourth transaction to achieve: recording the first voting information in the first effective information, and recording the first voting result in the first effective information based on the first voting information from the plurality of first computing nodes, wherein the first voting result is used to indicate whether the grouping information is effective; When the blockchain executes the third function in the smart contract according to the third transaction, it also implements: querying the first voting result from the first effective information according to the group identifier, and determining whether the group information has taken effect according to the first voting result; if so, it executes the creation of the authorization information in the contract state of the smart contract.
6. The method according to claim 1, further comprising: The fifth computing node sends a fifth transaction to the blockchain node, which includes the group identifier and change information. The fifth computing node belongs to the plurality of first computing nodes. The blockchain executes the fifth function in the smart contract according to the fifth transaction to: determine the change identifier of the change information, and store the group identifier, the change identifier, the change information, and the second effective information in the contract state of the smart contract according to the group identifier; The first computing node sends a sixth transaction to the blockchain, which includes the group identifier, the change identifier, and the second voting information; The blockchain executes the sixth function in the smart contract according to the sixth transaction, and implements: recording the second voting information in the second effective information according to the group identifier and the change identifier; recording the second voting result in the second effective information based on the second voting information from the plurality of first computing nodes; and updating the group information according to the group identifier and the change information when the second voting result indicates that the change information is allowed to take effect.
7. The method according to claim 1, further comprising: The third computing node sends a seventh transaction to the blockchain, which includes the file identifier of the target file; The blockchain executes the seventh function in the smart contract according to the seventh transaction to achieve: obtaining the group identifier from the authorization information based on the file identifier of the target file, obtaining the identity identifiers of the plurality of first computing nodes from the group information based on the group identifier, and returning a second query result to the third computing node, which includes the identity identifiers of the plurality of first computing nodes; The third computing node selects the identity identifier of the second computing node from the identity identifiers of the plurality of first computing nodes, and sends the query request to the second computing node according to the identity identifier of the second computing node.
8. The method according to any one of claims 1-7, wherein the plurality of first computing nodes correspond one-to-one with a plurality of first IPFS nodes in the InterPlanetary File System (IPFS), the third computing node corresponds to a third IPFS node in the IPFS, the third IPFS node does not belong to the plurality of first IPFS nodes, and the file identifier of the target file includes the content identifier (CID) corresponding to the target file in the IPFS.
9. The method according to claim 8, wherein the identity identifier includes the identifier of the corresponding IPFS node in the IPFS; or, the identity identifier includes the identifier of the participant to which the corresponding computing node belongs in the blockchain.
10. A file-sharing method based on blockchain, wherein a smart contract is deployed in the blockchain, the contract state of the smart contract includes authorization information of a target file and grouping information of a first sharing group, the authorization information includes a file identifier of the target file and a group identifier of the first sharing group, the grouping information includes the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group, the method being executed by blockchain nodes in the blockchain, comprising: The first transaction is received from the second computing node, which belongs to the plurality of first computing nodes. The first transaction is initiated by the second computing node based on a query request from the third computing node. The query request and the first transaction include the file identifier of the target file and the identity identifier of the third computing node. According to the first transaction, the first function in the smart contract is executed to achieve the following: obtaining the group identifier from the authorization information based on the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node based on the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node, so that if the group information includes the identity identifier of the third computing node, the second computing node sends the target file to the third computing node.
11. The method according to claim 10, further comprising: The second transaction is received from the fourth computing node, which belongs to the plurality of first computing nodes, and the second transaction includes the group identifier and the identity identifier of the plurality of first computing nodes; According to the second transaction, the second function in the smart contract is executed to achieve the following: creating the grouping information in the contract state of the smart contract.
12. The method according to claim 11, further comprising: Receive a third transaction from the second computing node, which includes the file identifier of the target file and the group identifier; According to the third transaction, the third function in the smart contract is executed to achieve the following: creating the authorization information in the contract state of the smart contract.
13. The method according to claim 12, wherein the third transaction further includes the identity identifier of the second computing node; in, When the blockchain node executes the third function in the smart contract according to the third transaction, it also performs the following: queries whether the identity identifier of the second computing node is included in the group information according to the group identifier; if so, it executes the creation of the authorization information in the contract state of the smart contract.
14. The method according to claim 12, wherein when the blockchain node executes the second function in the smart contract according to the second transaction, it further implements: creating first effective information of the grouping information in the contract state of the smart contract; in, The method further includes: Receive the fourth transaction from the first computing node, which includes the group identifier and the first voting information; According to the fourth transaction, the fourth function in the smart contract is executed to achieve the following: the first voting information is recorded in the first effective information, and the first voting result is recorded in the first effective information based on the first voting information from the plurality of first computing nodes, wherein the first voting result is used to indicate whether the grouping information is effective; When the blockchain node executes the third function in the smart contract according to the third transaction, it also performs the following: queries the first voting result from the first effective information according to the group identifier, and determines whether the group information has taken effect according to the first voting result. If so, it executes the creation of the authorization information in the contract state of the smart contract.
15. The method according to claim 10, further comprising: A fifth transaction is received from a fifth computing node, which belongs to the plurality of first computing nodes, and the fifth transaction includes the group identifier and change information; According to the fifth transaction, the fifth function in the smart contract is executed to: determine the change identifier of the change information, and store the group identifier, the change identifier, the change information and the second effective information in the contract state of the smart contract according to the group identifier; The sixth transaction is received from the first computing node, including the group identifier, the change identifier, and the second voting information; According to the sixth transaction, the sixth function in the smart contract is executed to achieve the following: recording the second voting information in the second effective information according to the group identifier and the change identifier; recording the second voting result in the second effective information based on the second voting information from the plurality of first computing nodes; and updating the group information according to the group identifier and the change information when the second voting result indicates that the change information is allowed to take effect.
16. A file-sharing method based on blockchain, wherein a smart contract is deployed in the blockchain, the contract state of the smart contract includes authorization information of a target file and grouping information of a first sharing group, the authorization information includes a file identifier of the target file and a group identifier of the first sharing group, the grouping information includes the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first sharing group, the method is executed by a second computing node belonging to the plurality of first computing nodes, the method comprising: The query request is received from the third computing node, which includes the file identifier of the target file and the identity identifier of the third computing node, wherein the second computing node belongs to the plurality of first computing nodes; A first transaction is sent to the blockchain, including the file identifier of the target file and the identity identifier of the third computing node, so that the blockchain executes a first function in the smart contract according to the first transaction, which realizes: obtaining the group identifier from the authorization information according to the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node according to the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node; If the grouping information includes the identity identifier of the third computing node, the target file is sent to the third computing node.
17. The method according to claim 16, wherein the grouping information is created by the blockchain executing a second function in the smart contract based on a second transaction, the second transaction being sent to the blockchain by a fourth computing node belonging to the plurality of first computing nodes, and the second transaction including the grouping identifier and the identity identifier of the plurality of first computing nodes; in, The method further includes: sending a third transaction to the blockchain, including the file identifier of the target file and the group identifier, so that the blockchain executes a third function in the smart contract according to the third transaction, thereby creating the authorization information in the contract state of the smart contract.
18. The method according to claim 17, wherein the third transaction further includes the identity identifier of the second computing node, such that when the blockchain executes the third function in the smart contract according to the third transaction, it also implements: querying whether the group information includes the identity identifier of the second computing node according to the group identifier, and if so, executing the creation of the authorization information in the contract state of the smart contract.
19. The method according to claim 17, wherein the contract state of the smart contract further includes first effective information of the grouping information, the first effective information being created by the blockchain executing the second function in the smart contract based on the second transaction; wherein, The method further includes: A fourth transaction is sent to the blockchain, including the group identifier and the first voting information, so that the blockchain executes the fourth function in the smart contract according to the fourth transaction, thereby realizing: recording the first voting information in the first effective information, and recording the first voting result in the first effective information based on the first voting information from the plurality of first computing nodes, wherein the first voting result is used to indicate whether the group information is effective; When the blockchain executes the third function in the smart contract according to the third transaction, it also implements: querying the first voting result from the first effective information according to the group identifier, and determining whether the group information has taken effect according to the first voting result; if so, it executes the creation of the authorization information in the contract state of the smart contract.
20. The method according to claim 16, wherein the contract state of the smart contract further includes the associated storage of the group identifier, change information, change identifier of the change information, and second effective information, which is created by the blockchain executing the fifth function in the smart contract according to the fifth transaction, the fifth transaction being sent by the fifth computing node belonging to the plurality of first computing nodes, and the fifth transaction including the group identifier and the change information; in, The method further includes: sending a sixth transaction to the blockchain, including the group identifier, the change identifier, and the second voting information, causing the blockchain to execute a sixth function in the smart contract according to the sixth transaction, thereby achieving: recording the second voting information in the second effective information according to the group identifier and the change identifier; recording the second voting result in the second effective information based on the second voting information from the plurality of first computing nodes; and updating the group information according to the group identifier and the change information when the second voting result indicates that the change information is allowed to take effect.
21. A blockchain node, wherein a smart contract is deployed in the blockchain to which the blockchain node belongs, the contract state of the smart contract including authorization information of a target file and grouping information of a first shared group, the authorization information including a file identifier of the target file and a group identifier of the first shared group, the grouping information including the group identifier and identity identifiers of a plurality of first computing nodes belonging to the first shared group, the blockchain node comprising: The transaction receiving unit is configured to receive a first transaction from a second computing node belonging to a plurality of first computing nodes. The first transaction is initiated by the second computing node based on a query request from a third computing node. The query request and the first transaction include the file identifier of the target file and the identity identifier of the third computing node. The transaction execution unit is configured to execute a first function in the smart contract according to the first transaction, and implement: obtaining the group identifier from the authorization information according to the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node according to the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node, so that if the group information includes the identity identifier of the third computing node, the second computing node sends the target file to the third computing node.
22. A second computing node, belonging to a plurality of first computing nodes connected to a blockchain, wherein a smart contract is deployed in the blockchain, the contract state of the smart contract including authorization information of a target file and grouping information of a first shared group, the authorization information including a file identifier of the target file and a group identifier of the first shared group, the grouping information including the group identifier and an identity identifier of the plurality of first computing nodes belonging to the first shared group, the second computing node comprising: The request receiving unit is configured to receive a query request from a third computing node, which includes the file identifier of the target file and the identity identifier of the third computing node, wherein the second computing node belongs to the plurality of first computing nodes; A transaction sending unit is configured to send a first transaction to the blockchain, including the file identifier of the target file and the identity identifier of the third computing node, so that the blockchain executes a first function in the smart contract according to the first transaction, which realizes: obtaining the group identifier from the authorization information according to the file identifier of the target file, querying whether the group information includes the identity identifier of the third computing node according to the group identifier, and returning a first query result to the second computing node to indicate whether the group information includes the identity identifier of the third computing node; The request-response unit is configured to send the target file to the third computing node if the identity identifier of the third computing node is included in the group information.
Citation Information
Patent Citations
Authorized file share method and device
CN109144961A
Data processing method, device and system based on block chain
CN111416704A