A blockchain-based on-chain off-chain consistency verification method, device and system
By generating random numbers on the blockchain to prove the parameter set, using verifiable random functions to ensure the authenticity of off-chain data, and performing batch verification on the blockchain, the problems of low off-chain storage efficiency and difficulty in proving authenticity are solved, and on-chain scalability and throughput are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-07-10
- Publication Date
- 2026-07-03
Smart Images

Figure CN116743737B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of blockchain technology, specifically, it relates to a blockchain-based on-chain and off-chain consistency verification method, device and system. Background Technology
[0002] As a powerful blockchain architecture model, on-chain and off-chain collaboration technology is increasingly being applied to real-world blockchain storage systems, especially suitable for on-chain large file storage environments. This new blockchain architecture paradigm, through off-chain storage and computation and on-chain consensus verification, shifts a large amount of computing demand from the blockchain mainnet off-chain, thereby reducing the burden on the main chain.
[0003] However, off-chain scaling technology also faces problems such as low data storage efficiency and difficulty in proving authenticity. Specifically: although large files can be stored on off-chain disk space, the hash value is usually uploaded to the blockchain for verification, thereby anchoring the off-chain and on-chain data. However, this leads to reduced storage efficiency and longer verification time. If off-chain data is tampered with, the authenticity of the data needs to be proven on the blockchain. However, there is often a time lag, which leads to false reporting and concealment of data, making it difficult to prove its authenticity. Adding or removing on-chain nodes requires corresponding additions and deletions of off-chain data, which is costly and has poor scalability. Summary of the Invention
[0004] To address the problems in existing technologies, this application provides a blockchain-based on-chain and off-chain consistency verification method, apparatus, and system that can ensure that when large files are stored off-chain, the on-chain can simultaneously perceive the authenticity of the off-chain data, thus avoiding data anchoring on-chain and reducing file storage efficiency.
[0005] According to the first aspect of this application, a blockchain-based on-chain and off-chain consistency verification method is provided, comprising:
[0006] In response to receiving a file upload request submitted by a user on the client, a file content identifier is generated on the blockchain, and a random number and a proof corresponding to the random number are generated based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; the random number and the proof are stored on the blockchain to generate a random number proof parameter set.
[0007] In response to receiving a file query request submitted by a user on the client, the system determines the random number proof parameter set corresponding to the user on the blockchain and verifies the random number proof parameter set.
[0008] In response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid, it is determined that there is consistency between on-chain and off-chain.
[0009] In some optional embodiments of this example, the method further includes: an initialization of security parameters step:
[0010] In response to receiving a user's request to initialize security parameters submitted on the client, the system generates the user's public key and private key based on a random function generator, and stores the user's private key locally.
[0011] The user's public key is sent to the service gateway, so that the service gateway calls the blockchain smart contract interface to generate a digital identity and a symmetric key, and stores the digital identity and user's public key and encrypts the symmetric key to generate initialized security parameters.
[0012] Receive and store the initialized security parameters returned by the service gateway.
[0013] In some optional embodiments of this example, the step of generating a file content identifier under the blockchain in response to receiving a file upload request submitted by a user on the client includes:
[0014] The uploaded file data is encrypted using the symmetric key in the initialization security parameters to generate a encrypted file, and the file data is signed using the pre-stored user private key.
[0015] The signature, encrypted file, and digital identity are sent to the service gateway, which then decrypts the encrypted file and generates a file content identifier.
[0016] In some optional embodiments of this example, the step of determining the random number proof parameter set corresponding to the user on the blockchain in response to receiving a file query request submitted by the user on the client includes:
[0017] Read the user's digital identity and determine the set of random number proof parameters corresponding to the user on the blockchain based on the digital identity.
[0018] In some optional embodiments of this example, the method further includes:
[0019] Read the user's digital identity and send a file query request to the service gateway, so that the service gateway calls the blockchain smart contract interface to obtain and return a list of file directories related to the digital identity;
[0020] A file access request is submitted to the service gateway based on the file selected from the file directory list, so that the service gateway can call the blockchain storage smart contract API to obtain the encrypted file;
[0021] In response to determining that there is consistency between on-chain and off-chain, the receiving service gateway performs integrity verification and signature verification on the encrypted file based on the user's public key corresponding to the digital identity, and decrypts the encrypted file using the user's private key corresponding to the digital identity when the verification is successful, and returns the decrypted file information to the client;
[0022] In response to the determination that there is no consistency between on-chain and off-chain, the system receives the consistency verification failure message.
[0023] According to a second aspect of this application, a corresponding blockchain-based on-chain and off-chain consistency verification device is also provided, comprising:
[0024] The blockchain operation module is configured to, in response to receiving a file upload request submitted by a user on the client, generate a file content identifier on the blockchain, and generate a random number and a proof corresponding to the random number based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; and store the random number and the proof on the blockchain to generate a random number proof parameter set.
[0025] The blockchain operation module is configured to, in response to receiving a file query request submitted by a user on the client, determine the random number proof parameter group corresponding to the user on the blockchain and verify the random number proof parameter group;
[0026] The consistency result generation module is configured to determine on-chain and off-chain consistency in response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid.
[0027] According to a third aspect of this application, an on-chain and off-chain consistency verification system based on blockchain is also provided, including: a client, a service gateway, storage nodes, and blockchain nodes; the client is connected to the service gateway, the service gateway is connected to the storage node cluster, and the storage node cluster is connected to the blockchain node cluster.
[0028] The client includes the blockchain-based on-chain and off-chain consistency verification device of the aforementioned embodiments, or the client is configured to execute the blockchain-based on-chain and off-chain consistency verification method of the aforementioned embodiments.
[0029] According to a fourth aspect of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement the steps of the blockchain-based on-chain and off-chain consistency verification method.
[0030] According to a fifth aspect of this application, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the blockchain-based on-chain and off-chain consistency verification method.
[0031] According to a sixth aspect of this application, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the blockchain-based on-chain and off-chain consistency verification method.
[0032] This application proposes a blockchain-based on-chain and off-chain consistency verification method, device, and system. It addresses issues such as low efficiency, difficulty in proving authenticity, and poor scalability when storing large files on-chain and off-chain. Specifically, it offloads on-chain transactions to off-chain execution and, while ensuring the correctness and security of off-chain transactions, uses cryptographic algorithms to construct proofs for batch transactions. On-chain verification is performed only on a batch basis, and the latest state of transactions is maintained. This ensures that when large files are stored off-chain, the on-chain can simultaneously perceive the authenticity of the off-chain data, avoiding data anchoring on-chain and reducing file storage efficiency, and improving the throughput of on-chain transaction processing. It has significant potential for widespread adoption. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A scenario structure diagram for an on-chain and off-chain consistency verification method based on blockchain provided in this application.
[0035] Figure 2 This application provides a hierarchical structure diagram of an on-chain and off-chain consistency verification system based on blockchain.
[0036] Figure 3 This application provides a structural diagram of a service gateway for an on-chain / off-chain consistency verification system based on blockchain.
[0037] Figure 4 This application provides a structural diagram of a blockchain node in an on-chain / off-chain consistency verification system based on blockchain.
[0038] Figure 5 This application provides a structural diagram of the storage node in an on-chain / off-chain consistency verification system based on blockchain.
[0039] Figure 6 A flowchart illustrating an on-chain / off-chain consistency verification method based on blockchain, provided for an embodiment of this application.
[0040] Figure 7 A flowchart illustrating the steps for initializing security parameters according to an embodiment of this application.
[0041] Figure 8 A flowchart illustrating the steps for generating file content identifiers according to an embodiment of this application.
[0042] Figure 9 This is a flowchart illustrating an on-chain / off-chain consistency verification method based on blockchain, provided as an embodiment of this application.
[0043] Figure 10 This is a schematic diagram of an on-chain / off-chain consistency verification device based on blockchain, provided in an embodiment of this application.
[0044] Figure 11 This is a block diagram of an electronic device used to implement the blockchain-based on-chain and off-chain consistency verification method in the embodiments of this application. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] To address the problems existing in the background technology, this application provides an on-chain and off-chain consistency verification system based on blockchain, comprising: a client, a service gateway, a storage node, and a blockchain node, wherein:
[0047] The client communicates with the service gateway, the service gateway communicates with the storage node cluster, and the storage node cluster communicates with the blockchain node cluster.
[0048] The client initiates smart contract deployment requests, decentralized storage transaction requests, and decentralized storage query requests. The client is configured to execute a blockchain-based on-chain and off-chain consistency verification method according to an embodiment of this application.
[0049] The service gateway provides a smart contract API to implement rate limiting and circuit breaking, security detection, file storage and access, authentication, and security parameter settings.
[0050] The storage node receives file read / write requests from the service gateway, performs decentralized file read / write, and stores transaction information on the blockchain node.
[0051] Blockchain nodes complete transaction broadcasting, transaction execution, transaction verification, consensus, and storage.
[0052] In one specific embodiment, such as Figure 1 The diagram shown is a structural diagram of an on-chain and off-chain consistency verification system based on blockchain, including users, clients, service gateways, blockchain nodes, and storage nodes, where:
[0053] User A (User B): Initiates user data upload or receives data information from the blockchain network. The user wishes that the uploaded file information be treated as sensitive data and cannot be disclosed without permission.
[0054] Client A (Client B): Primarily responsible for receiving user transaction requests, initiating smart contract deployment requests, distributed storage transaction requests, distributed storage query requests, etc.
[0055] Service Gateway A (Service Gateway B): Primarily responsible for providing smart contract APIs for client calls, implementing rate limiting and circuit breaking, security detection, file storage and access, authentication, and security parameter settings.
[0056] Blockchain node: A node that performs functions such as transaction broadcasting, transaction execution, transaction verification, consensus, and storage. It possesses the general characteristics of a blockchain. It receives file or digital asset read commands from clients, executes file read / write storage smart contracts, and stores the executed transaction results on the blockchain.
[0057] Storage Node: Also known as the decentralized DS node, it serves as an off-chain expansion storage node to offload on-chain pressure. It is responsible for receiving file read and write requests from blockchain node 4, performing decentralized file read and write, and storing transaction information on the blockchain node. Furthermore, client A and client B connect to the blockchain node through service gateway A and service gateway B respectively to publish smart contracts, read files, and store files.
[0058] Based on the above system, in a specific embodiment, the hierarchical structure diagram of the blockchain-based on-chain and off-chain consistency verification system is as follows: Figure 2 As shown, it includes a client access layer 20, a service gateway layer 21, a blockchain network 22, and a decentralized file storage network 23, wherein:
[0059] Client Access Layer 20: This layer provides client software for operator access, facilitating the initiation of distributed storage requests and the receipt of distributed storage results. Clients can publish chaincode on the blockchain platform. After generating upload or download behavior data, clients can invoke the chaincode to initiate transaction requests, uploading the behavior data to the blockchain. Depending on the client's usage scenario, the data is submitted to the corresponding channel for each scenario (clients can directly upload customer behavior data without processing; the specific data processing logic can be handled by the scenario provider). Suppliers can also publish chaincode, query data belonging to their own channels, and process and analyze the data within their channels.
[0060] Service Gateway Layer 21: Responsible for providing blockchain smart contract service APIs to clients, enabling transaction rate limiting and circuit breaking, file upload and download of DS nodes, Cid generation, and smart contract function calls such as Did registration, verification, directory query and update.
[0061] Blockchain Network 22: Responsible for receiving and decrypting distributed file storage messages, triggering pre-defined smart contract logic, and generating distributed storage log results. The blockchain network can provide hosted nodes, and local node deployment is also available for capable providers. Each scenario provider has its own channel on the blockchain, and scenario providers cannot access data information from other channels, i.e., other providers.
[0062] Decentralized file storage network 23: Responsible for configuring parameters, data, and business logic through distributed storage logic based on client-submitted upload (download), query, and other requests. Simultaneously, it encrypts and forms file block data, whose hash values are broadcast to blockchain network 22. Scenario providers can also publish joint operation chaincode, which calls DS node services. Each blockchain node has a corresponding DS node service, and the chaincode can specify which DS services are needed for joint computation. Scenario providers initiate joint computation requests through chaincode. Previously, data from other channel providers was inaccessible to each other; through DS, distributed data storage can be achieved without leaking individual data.
[0063] Specifically, such as Figure 3 As shown, the service gateway in the verification system includes a first communication module 31, a rate limiting and circuit breaking module 32, a security authentication module 33, and an API service interface 34, wherein:
[0064] First communication module 31: Responsible for establishing a secure channel for the service gateway, enabling the sending and receiving of messages such as decentralized file storage requests and initialization of security parameters.
[0065] Module 32 for rate limiting and circuit breaking: Responsible for rate limiting and circuit breaking control of transactions based on the transaction throughput configuration.
[0066] Security Authentication Module 33: Responsible for storing users' private keys and symmetric keys, managing users' digital identities (Did); responsible for calling the smart contract service API provided by the blockchain network to implement user data storage, user data encryption, identity registration, authentication, and decryption of encrypted files. Executes the random function generator G, inputting initialization security parameter 1. k This generates the user's public key PK and private key SK, formally represented as: G(1 K = (PK, SK), where the private key SK is stored on the client side.
[0067] API Service Interface 34: Responsible for providing blockchain smart contract API calls, such as data storage, information query, security settings and other smart contract API interface services.
[0068] Specifically, such as Figure 4 As shown, the blockchain node in the verification system includes a second communication module 41, a smart contract module 42, a consensus verification module 43, and a block generation module 44, wherein:
[0069] The second communication module 41 is responsible for communication and interaction between nodes, and completes general blockchain node communication information, including transaction information broadcasting, consensus-related information, block synchronization information, network status information, etc.
[0070] Smart contract module 42: Responsible for receiving transaction requests from the second communication module 41, generating a unique transaction identifier, assembling the unique transaction identifier, contract identifier, and call parameters into a transaction, and broadcasting it to other nodes in the blockchain; simultaneously, it compiles the smart contract using a built-in compiler to execute the transaction request. This invention's smart contract module provides data storage services, storing the smart contract execution results as files on the storage node. It executes a verifiable proof function, proving the legality of the input (PK, x, v, proof), formally represented as:
[0071] (v,proof)=F(SK,x)
[0072] At the same time, this judgment cannot be guessed by others, meaning the probability of prediction is less than 1 / 2.
[0073] PROB[(V(PK,x,v,proof)=YES]>1-2 -Ω(k)
[0074] Consensus verification module 43: responsible for consensus processing of received transaction requests. If a consensus is reached, it calls smart contract module 42 to execute the smart contract and ultimately forms a record that can be audited or verified in the future.
[0075] Block generation module 44: Used to generate blocks for storing user data and verification results.
[0076] Specifically, such as Figure 5 As shown, the storage node in the verification system includes a third communication module 51, a content generation module 52, a DAG module 53, a Chunk module 54, and a verifiable proof generation module 55, wherein:
[0077] The third communication module 51 is responsible for establishing a secure channel for storage nodes, enabling decentralized storage message sending and receiving, and transmitting (PK, x, v, proof) to blockchain nodes in the form of broadcast.
[0078] Content Generation Module 52: Responsible for generating file content identifiers (Cids) for decentralized file content. Let digital asset file M represent the user's file content, and Cid be the content identifier of M.
[0079] DAG module 53: Responsible for performing Merkle verification on the file content identifier Cid, ensuring that the Cid of the root node is equal to the calculated digest hash. To integrate off-chain and on-chain data, the Cid is incorporated as part of the ref into x. Let FileLink... M The data format representing the link to file M is as follows:
[0080] FileLink M =(Cid,Size,FileObj{Links,data M},chksum)
[0081] Where Size represents the size of file M, FileObj represents the file object structure, Links represents the linked array of file segments, and data... M M represents the data content, and Cid represents the content address information. In terms of format:
[0082] Cid = h(M, Did1, ..., Did) n )
[0083] Where h is a hash function, and Did1, Did2, ..., Did n This indicates the group of digital identities that owns file M.
[0084] Chunk module 54: Divides the data content of a file object into fragments, while ensuring that the fragmented data are connected to each other to form a file object tree.
[0085] Verifiable proof generation module 55: Used to generate verifiable proofs based on x, assuming: T = (T E ,T J ), where T includes 2 components T E and TJ T E For querying f and generating test questions; T J Given a question and a value v, a decision component is used to determine whether v is a random value generated by f. Calculate T. E (1 k The parameters (PK, x, v, proof) are generated by setting (PK, Cid) = (x, state), v = F1(SK, x), and proof = F2(SK, x), thus generating a verifiable random number proof parameter tuple: (PK, x, v, proof).
[0086] Based on such Figures 1 to 5 The application also provides a blockchain-based on-chain and off-chain consistency verification method, with the client as the execution entity, as shown in the blockchain-based on-chain and off-chain consistency verification system. Figure 6 As shown, it includes:
[0087] Step 601: In response to receiving a file upload request submitted by a user on the client, generate a file content identifier on the blockchain, and generate a random number and a proof corresponding to the random number based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; store the random number and the proof on the blockchain to generate a random number proof parameter set.
[0088] It should be noted that in some optional methods of this embodiment, such as Figure 7 As shown, the on-chain and off-chain consistency verification method based on blockchain in this embodiment also includes the step of initializing security parameters:
[0089] Step 701: In response to receiving the user's request to initialize security parameters submitted on the client, generate the user's public key and private key based on the random function generator, and store the user's private key locally;
[0090] Step 702: Send the user public key to the service gateway so that the service gateway calls the blockchain smart contract interface to generate a digital identity and a symmetric key, and to store the digital identity and user public key and encrypt the symmetric key to generate initialized security parameters.
[0091] Step 703: Receive and store the initialized security parameters returned by the service gateway.
[0092] In a specific example, the initialization security parameters of steps 701-703 are further explained based on the following S101-S107:
[0093] S101. The user submits an initialization security parameter request through the client;
[0094] S102. After receiving the request, the client calls the key SDK, executes the random function generator G, and inputs the initialization security parameter 1. k This generates the user's public key PK and private key SK, formally represented as: G(1 K ) = (PK, SK), where the private key SK is stored locally on the client, and the public key PK is uploaded to the service gateway and processed on the blockchain through the service gateway;
[0095] S103. Call the blockchain smart contract algorithm to initialize security parameters and upload the public key PK for evidence storage;
[0096] S104. The transaction processing module receives and checks the initialization security parameter request;
[0097] S105. Execute the key processing smart contract to generate the user's digital identity Did and symmetric key sk. b In terms of form: sk b =GenSymKey(Did,P(1 k ), where GenSymKey is the symmetric key generation function, Did represents the user's distributed digital identity, P(1 k () indicates a safety parameter;
[0098] S106, Pk the user's digital identity (Did) and public key (PK) u Perform evidence storage and execute encryption function C simultaneously. skb =Encry(sk b ,PK) Encrypts the symmetric key, generating the symmetric key pk b The ciphertext C skb And send it back to the user;
[0099] S107. Return the security parameters to the client, and send the symmetric private key C. skb Store the data locally on the client and return a message indicating successful initialization of security parameters.
[0100] Based on the initialized security parameters, in some optional methods of this implementation, such as Figure 8 As shown, in response to receiving a file upload request submitted by a user on the client, a file content identifier is generated under the blockchain, further including:
[0101] Step 801: Encrypt the uploaded file data based on the symmetric key in the initialization security parameters to generate a encrypted file, and sign the file data with the pre-stored user private key;
[0102] Step 802: Send the signature, encrypted file, and digital identity to the service gateway so that the service gateway can decrypt the encrypted file and generate a file content identifier.
[0103] In a specific example, the generated file content identification in steps 801-802 is further explained based on the following S201-S206:
[0104] S201. The user initiates a file upload request through the client.
[0105] S202. Encrypt the file using a symmetric key, have the user sign the file M with their private key, and upload the signature, encrypted file, and Did together to the service gateway. The specific processing flow is as follows:
[0106] (1) C skb Decrypt and restore to the symmetric key sk b :sk b =Decry(C skb ,SK);
[0107] (2) Encrypt file M with a symmetric key to generate ciphertext C. M :C M =SymEncry(M,sk b );
[0108] (3) Using the user's private key sk u For C M Perform the signing process to generate signature S. CM :S CM =Sign(C M ,SK);
[0109] (4) Forming a message for the upload service gateway: P M =(Did,C M ,S CM ).
[0110] S203. Call the decentralized file storage smart contract service API and upload message P. M .
[0111] S204, Parsing message P M , the encrypted file C M Upload and store the data to the DS storage node, and simultaneously generate a file content identifier (Cid). Cid represents the content address information of file M, in the form: Cid = h(M, Did1, ..., Did1). n ), where h is a hash function, and Did1, Did2, ..., Did n This indicates the group of digital identities that owns file M.
[0112] S205. The service gateway checks whether the file upload and CID generation were successful.
[0113] S206. If it fails, send a failure message to the client; if it succeeds, generate a file content identifier (Cid).
[0114] Furthermore, when the service gateway successfully checks the uploaded file and generates the CID, it generates a random number and a corresponding proof based on the file content identifier, the pre-set user public key, the pre-set user private key, and a verifiable random function; the random number and the proof are then stored on the blockchain to generate a random number proof parameter set.
[0115] For example, to generate a verifiable proof based on x, let: T = (T E ,T J ), where T includes 2 components T E and T J T E For querying f and generating test questions; T J Given a question and a value v, a decision component is used to determine whether v is a random value generated by f. Calculate T. E (1 k The parameters (PK, x, v, proof) are set up as follows: (PK, Cid) = (x, state), v = F1(SK, x), and proof = F2(SK, x). The verifiable random number proof proof and the verifiable random number v are stored on the blockchain to generate the verifiable random number proof parameter set: (PK, x, v, proof).
[0116] Step 602: In response to receiving a file query request submitted by a user on the client, determine the random number proof parameter group corresponding to the user on the blockchain, and verify the random number proof parameter group.
[0117] It should be understood that in this embodiment, the random number proof parameter set corresponds one-to-one with the user's digital identity. Therefore, in an optional manner of this embodiment, the user's digital identity can be read, and the random number proof parameter set corresponding to the user can be determined on the blockchain based on the digital identity.
[0118] In other words, the blockchain smart contract is invoked to query and obtain the corresponding verifiable random number proof parameter set (PK,x,v,proof) of the user's digital identity Did on the chain, and then verifiable random number proof is performed.
[0119] For example, executing a verifiable proof function, given the input (PK,x,v,proof), proves its validity. Its formal representation is: (v,proof) = F(SK,x). Simultaneously, this judgment should be unpredictable to others, meaning the probability of prediction is less than 1 / 2. Its formal representation is: PROB[(V(PK,x,v,proof) = YES] > 1-2 -Ω(k) .
[0120] Step 603: In response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid, determine that there is consistency between on-chain and off-chain.
[0121] In this embodiment, when it is determined that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and the random number proof parameter set is valid, it is determined that there is consistency between on-chain and off-chain.
[0122] In some optional embodiments of this example, such as Figure 9 As shown, after receiving a file query request submitted by a user through the client, the method further includes the following steps:
[0123] Step 901: Read the user's digital identity and send a file query request to the service gateway, so that the service gateway calls the blockchain smart contract interface to obtain and return a list of file directories related to the digital identity;
[0124] Step 902: Submit a file access request to the service gateway based on the file to be accessed selected from the file directory list, so that the service gateway calls the blockchain storage smart contract API to obtain the encrypted file;
[0125] Step 903: In response to determining that there is consistency between the on-chain and off-chain, the receiving service gateway performs integrity verification and signature verification on the encrypted file based on the user public key corresponding to the digital identity, and decrypts the encrypted file using the user private key corresponding to the digital identity when the verification is successful, and returns the decrypted file information to the client.
[0126] Step 904: In response to the determination that there is no consistency between the on-chain and off-chain, receive the consistency verification failure information returned.
[0127] In a specific example, the method of steps 901-904 described above is further explained based on the following S301-S311:
[0128] S301. After receiving a user request, the client reads the user's digital identity (Did) and sends a file directory list query request to the service gateway.
[0129] S302. The service gateway calls the blockchain smart contract API interface and enters Did to query the file directory list.
[0130] S303. Execute the smart contract. Based on the input user digital identity (Did), query the on-chain record corresponding to the user digital identity (Did). If the record exists, the check is successful.
[0131] S304. Query the list of file directories related to the user's digital identity (Did) and return it to the client.
[0132] S305. Display the file directory list on the client.
[0133] S306. The user selects the file to be accessed based on the file directory displayed on the client and submits a file access request to the service gateway.
[0134] S307. After extracting the file content identifier Cid, the client submits a file access request to the service gateway.
[0135] S308. Input the file content identifier Cid and the user's digital identity Did to call the blockchain storage smart contract API in order to obtain the encrypted file.
[0136] S309. Execute the smart contract to collect fragmented data of file M from storage node DS and aggregate it to form encrypted file C. M Check the integrity of the file.
[0137] S310. In response to determining that there is consistency between the on-chain and off-chain systems, the receiving service gateway performs integrity verification and signature verification on the encrypted file based on the user's public key corresponding to the digital identity. Upon successful verification, the gateway decrypts the encrypted file using the user's private key corresponding to the digital identity and returns the decrypted file information to the client. For example, to perform integrity verification and signature verification on the encrypted file, the user's public key pk is input. u Execute the following signature function: S′ CM =chkSign(C M ,PK), if S′ CM =S CM If true, it indicates successful verification, and further verification is performed based on the symmetric key sk. b For the dense file C M Decryption is performed to generate plaintext M, formalized as follows: M = Decry(C M ,sk b ), and return file M to the client.
[0138] S311. In response to determining that there is no consistency between on-chain and off-chain, receive the consistency verification failure information returned, that is, the probability of the random number proof parameter group being predicted by other users besides the user is not less than one-half and / or the random number proof parameter group is invalid, indicating that there is no consistency between on-chain and off-chain, and return the verification failure information to the client to issue a warning.
[0139] This application proposes an on-chain and off-chain consistency verification method based on a verifiable random algorithm to address the consistency and authenticity verification issues of large file storage on and off-chain. This method, based on a verifiable random algorithm, constructs a consensus synchronization structure where on-chain and off-chain processes collaborate. On-chain transactions are off-chain for execution, and while ensuring the correctness and security of off-chain transactions, proofs for batch transactions are constructed using cryptographic algorithms. On-chain processes only perform batch verification of transactions and maintain the latest transaction state, thereby improving the throughput of on-chain transaction processing. This method is suitable for executing large file storage in decentralized environments, effectively solving the shortcomings of low efficiency, difficulty in proving authenticity, and poor scalability in large file storage, and has good promotional value. Specifically:
[0140] First, we propose an on-chain and off-chain consistency verification system framework based on a verifiable random algorithm. This framework implements a consistency synchronization mechanism for on-chain and off-chain storage based on a verifiable random algorithm, which not only improves the scalability of on-chain storage, but also effectively reduces the capacity of real on-chain storage.
[0141] Second, a verifiable random number algorithm for on-chain and off-chain consistency synchronization is proposed. This algorithm is based on a verifiable random number oracle, realizes the file content identifier Cid, the unique generation proof of pseudo-random numbers, and applies it to the blockchain for proof, thereby improving the authenticity of on-chain and off-chain collaborative storage.
[0142] Third, a supporting algorithm for phased (i.e., off-chain verifiable proof generation phase and on-chain verifiable proof verification phase) file storage proof is proposed. By combining the user's digital identity (Did), the security of the encrypted storage of user files is improved, the user's ownership and usage rights are separated, the efficiency and credibility of block signature are effectively improved, and a good technical support is provided for the trusted storage of large files.
[0143] Based on the same inventive concept, this application also provides a corresponding blockchain-based on-chain and off-chain consistency verification device, which can be used to implement the methods described in the above embodiments, as described in the following embodiments. Since the principle of this blockchain-based on-chain and off-chain consistency verification device in solving the problem is similar to that of the blockchain-based on-chain and off-chain consistency verification method, embodiments of the blockchain-based on-chain and off-chain consistency verification device can refer to the implementation of the blockchain-based on-chain and off-chain consistency verification method, and repeated details will not be elaborated further. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the system described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0144] like Figure 10 As shown, this application also provides a corresponding blockchain-based on-chain and off-chain consistency verification device, comprising:
[0145] The blockchain operation module 1001 is configured to, in response to receiving a file upload request submitted by a user on the client, generate a file content identifier on the blockchain, and generate a random number and a proof corresponding to the random number based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; and store the random number and the proof on the blockchain to generate a random number proof parameter set.
[0146] The blockchain operation module 1002 is configured to, in response to receiving a file query request submitted by a user on the client, determine the random number proof parameter group corresponding to the user on the blockchain and verify the random number proof parameter group.
[0147] The consistency result generation module 1003 is configured to determine on-chain and off-chain consistency in response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid.
[0148] In some alternative embodiments of this embodiment, the device further includes an initialization security parameter module, configured to:
[0149] In response to receiving a user's request to initialize security parameters submitted on the client, the system generates the user's public key and private key based on a random function generator, and stores the user's private key locally.
[0150] The user's public key is sent to the service gateway, so that the service gateway calls the blockchain smart contract interface to generate a digital identity and a symmetric key, and stores the digital identity and user's public key and encrypts the symmetric key to generate initialized security parameters.
[0151] Receive and store the initialized security parameters returned by the service gateway.
[0152] In some optional embodiments of this example, the blockchain-based operation module is further configured as follows:
[0153] The uploaded file data is encrypted using the symmetric key in the initialization security parameters to generate a encrypted file, and the file data is signed using the pre-stored user private key.
[0154] The signature, encrypted file, and digital identity are sent to the service gateway, which then decrypts the encrypted file and generates a file content identifier.
[0155] In some alternative embodiments of this embodiment, the blockchain operation module is further configured to include:
[0156] Read the user's digital identity and determine the set of random number proof parameters corresponding to the user on the blockchain based on the digital identity.
[0157] In some alternative embodiments of this embodiment, the device is further configured as follows:
[0158] Read the user's digital identity and send a file query request to the service gateway, so that the service gateway calls the blockchain smart contract interface to obtain and return a list of file directories related to the digital identity;
[0159] A file access request is submitted to the service gateway based on the file selected from the file directory list, so that the service gateway can call the blockchain storage smart contract API to obtain the encrypted file;
[0160] In response to determining that there is consistency between on-chain and off-chain, the receiving service gateway performs integrity verification and signature verification on the encrypted file based on the user's public key corresponding to the digital identity, and decrypts the encrypted file using the user's private key corresponding to the digital identity when the verification is successful, and returns the decrypted file information to the client;
[0161] In response to the determination that there is no consistency between on-chain and off-chain, the system receives the consistency verification failure message.
[0162] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0163] An electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the blockchain-based on-chain and off-chain consistency verification method of the foregoing embodiments.
[0164] A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the blockchain-based on-chain and off-chain consistency verification method of the foregoing embodiments.
[0165] A computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the blockchain-based on-chain and off-chain consistency verification method of the foregoing embodiments.
[0166] Figure 11A schematic block diagram of an example electronic device 1100 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0167] like Figure 11 As shown, device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1102 or a computer program loaded from storage unit 1108 into random access memory (RAM) 1103. The RAM 1103 may also store various programs and data required for the operation of device 1100. The computing unit 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. Input / output (I / O) interface 1105 is also connected to bus 1104.
[0168] Multiple components in device 1100 are connected to I / O interface 1105, including: input unit 1106, such as keyboard, mouse, etc.; output unit 1107, such as various types of monitors, speakers, etc.; storage unit 1108, such as disk, optical disk, etc.; and communication unit 1109, such as network card, modem, wireless transceiver, etc. Communication unit 1109 allows device 1100 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0169] Computing unit 1101 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of computing unit 1101 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Computing unit 1101 performs the various methods and processes described above, such as blockchain-based on-chain and off-chain consistency verification methods.
[0170] For example, in some embodiments, the blockchain-based on-chain and off-chain consistency verification method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1108. In some embodiments, part or all of the computer program can be loaded and / or installed on device 1100 via ROM 1102 and / or communication unit 1109. When the computer program is loaded into RAM 1103 and executed by computing unit 1101, one or more steps of the blockchain-based on-chain and off-chain consistency verification method described above can be performed. Alternatively, in other embodiments, computing unit 1101 can be configured to perform the blockchain-based on-chain and off-chain consistency verification method by any other suitable means (e.g., by means of firmware).
[0171] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0172] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0173] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0174] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0175] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0176] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0177] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0178] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
[0179] 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 its differences from other embodiments. In particular, for hardware + program embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. Although the embodiments in this specification provide the method operation steps as shown in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent the only execution order. In actual device or terminal product execution, the methods can be executed in the order shown in the embodiments or drawings 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 includes 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 said elements is not excluded. For ease of description, the above devices are described in terms of function, divided into various modules. Of course, in implementing the embodiments of this specification, the functions of each module can be implemented in one or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. 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; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms. 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 should 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 device to produce a machine, such that the instructions, which are executable by the processor of the computer or other programmable data processing device, produce instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0180] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, the embodiments of this specification can take the form of computer program products 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. The various embodiments in this specification are described in a progressive manner, and similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the description of the method embodiments. In the description of this specification, the reference to the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., means that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the embodiments of this specification.
[0181] In this specification, the illustrative expressions of the terms used do not necessarily refer to the same embodiments or examples. Furthermore, those skilled in the art can combine and integrate different embodiments or examples described in this specification, as well as features of different embodiments or examples, without contradiction. The above descriptions are merely embodiments of this specification and are not intended to limit the embodiments of this specification. Various modifications and variations can be made to the embodiments of this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of this specification should be included within the scope of the claims of the embodiments of this specification.
Claims
1. A blockchain-based on-chain and off-chain consistency verification method, characterized in that, include: In response to receiving a file upload request submitted by a user on the client, a file content identifier is generated on the blockchain, and a random number and a proof corresponding to the random number are generated based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; the random number and the proof are stored on the blockchain to generate a random number proof parameter set. In response to receiving a file query request submitted by a user on the client, the system determines the random number proof parameter set corresponding to the user on the blockchain and verifies the random number proof parameter set. In response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid, it is determined that there is consistency between on-chain and off-chain; The method further includes: an initialization of security parameters: In response to receiving a user's request to initialize security parameters submitted on the client, the system generates the user's public key and private key based on a random function generator, and stores the user's private key locally. The user's public key is sent to the service gateway, so that the service gateway calls the blockchain smart contract interface to generate a digital identity and a symmetric key, and stores the digital identity and user's public key and encrypts the symmetric key to generate initialized security parameters. The service gateway is connected to the storage node cluster, and the storage nodes are used as off-chain expansion storage nodes to relieve on-chain pressure and are responsible for distributed file reading and writing. Receive and store the initialized security parameters returned by the service gateway; The step of generating a file content identifier under the blockchain in response to receiving a file upload request submitted by a user on the client includes: The uploaded file data is encrypted using the symmetric key in the initialization security parameters to generate a encrypted file, and the file data is signed using the pre-stored user private key. The signature, encrypted file, and digital identity are sent to the service gateway, which then decrypts the encrypted file and generates a file content identifier.
2. The method according to claim 1, characterized in that, The step of responding to receiving a file query request submitted by a user on the client and determining the random number proof parameter set corresponding to the user on the blockchain includes: Read the user's digital identity and determine the set of random number proof parameters corresponding to the user on the blockchain based on the digital identity.
3. The method according to claim 1, characterized in that, Also includes: Read the user's digital identity and send a file query request to the service gateway, so that the service gateway calls the blockchain smart contract interface to obtain and return a list of file directories related to the digital identity; A file access request is submitted to the service gateway based on the file selected from the file directory list, so that the service gateway can call the blockchain storage smart contract API to obtain the encrypted file; In response to determining that there is consistency between on-chain and off-chain, the receiving service gateway performs integrity verification and signature verification on the encrypted file based on the user's public key corresponding to the digital identity, and decrypts the encrypted file using the user's private key corresponding to the digital identity when the verification is successful, and returns the decrypted file information to the client; In response to the determination that there is no consistency between on-chain and off-chain, the system receives the consistency verification failure message.
4. A blockchain-based on-chain and off-chain consistency verification device, characterized in that, include: The blockchain operation module is configured to, in response to receiving a file upload request submitted by a user on the client, generate a file content identifier on the blockchain, and generate a random number and a proof corresponding to the random number based on the file content identifier, a pre-set user public key, a pre-set user private key, and a verifiable random function; and store the random number and the proof on the blockchain to generate a random number proof parameter set. The blockchain operation module is configured to, in response to receiving a file query request submitted by a user on the client, determine the random number proof parameter group corresponding to the user on the blockchain and verify the random number proof parameter group; The consistency result generation module is configured to determine on-chain and off-chain consistency in response to determining that the probability of the random number proof parameter set being predicted by other users besides the user is less than one-half and that the random number proof parameter set is valid. The on-chain and off-chain consistency verification device is also configured to initialize security parameters: In response to receiving a user's request to initialize security parameters submitted on the client, the system generates the user's public key and private key based on a random function generator, and stores the user's private key locally. The user's public key is sent to the service gateway, so that the service gateway calls the blockchain smart contract interface to generate a digital identity and a symmetric key, and stores the digital identity and user's public key and encrypts the symmetric key to generate initialized security parameters. The service gateway is connected to the storage node cluster, and the storage nodes are used as off-chain expansion storage nodes to relieve on-chain pressure and are responsible for distributed file reading and writing. Receive and store the initialized security parameters returned by the service gateway; The step of generating a file content identifier under the blockchain in response to receiving a file upload request submitted by a user on the client includes: The uploaded file data is encrypted using the symmetric key in the initialization security parameters to generate a encrypted file, and the file data is signed using the pre-stored user private key. The signature, encrypted file, and digital identity are sent to the service gateway, which then decrypts the encrypted file and generates a file content identifier.
5. A blockchain-based on-chain and off-chain consistency verification system, characterized in that, It includes a client, a service gateway, storage nodes, and a blockchain node. The client is communicatively connected to the service gateway, the service gateway is communicatively connected to the storage node cluster, and the storage node cluster is communicatively connected to the blockchain node cluster. Wherein, the client includes the blockchain-based on-chain and off-chain consistency verification device as described in claim 4, or the client is configured to execute the blockchain-based on-chain and off-chain consistency verification method as described in any one of claims 1-3.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the blockchain-based on-chain and off-chain consistency verification method according to any one of claims 1 to 3.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the blockchain-based on-chain and off-chain consistency verification method as described in any one of claims 1 to 3.
8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the blockchain-based on-chain and off-chain consistency verification method as described in any one of claims 1 to 3.