Data cross-chain distribution method and device based on IPFS, equipment and medium
By transmitting symmetric keys and data indexes separately through cross-chain technology and introducing tracking numbers and confirmation messages, the problems of untraceable data transmission status and insufficient security in a single blockchain network are solved, thus achieving secure and reliable cross-chain data distribution.
Patent Information
- Application Number
- CN202511276951.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-09-09
AI Technical Summary
Existing technical solutions cannot track the data transmission status during data transmission in a single blockchain network, and data security is insufficient if the recipient's private key is accidentally leaked, allowing malicious parties to easily obtain data.
By using cross-chain technology to transmit the symmetric key and data index separately, employing a two-way handshake process, and introducing a tracking number and acknowledgment message, the security and reliability of data distribution are ensured.
It enhances the security and controllability of data distribution, reduces the risk of data theft after private key leakage, and achieves end-to-end reliability and controllability.
Smart Images

Figure CN120811604B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, specifically to a method, apparatus, device, and medium for cross-chain data distribution based on IPFS. Background Technology
[0002] Cross-chain technology is a key technology for enabling interoperability and asset transfer between different blockchain networks. It breaks down barriers between blockchains through various methods such as notary mechanisms, sidechains / relay chains, and hash locking, promoting the free flow of value across different chains and enhancing blockchain interoperability and scalability.
[0003] IPFS (InterPlanetary File System) is a decentralized distributed file system that enables permanent storage and sharing of files through content addressing and peer-to-peer (P2P) technology. It combines the advantages of distributed hash tables, BitTorrent, and Git (a distributed version control system) to provide a storage solution with high throughput, security, and data integrity.
[0004] Symmetric encryption, also known as private key encryption or shared key encryption, is an encryption method that uses the same key or mutually deducible keys for encryption and decryption. Its advantages include publicly available algorithms, low computational cost, fast encryption speed, and high efficiency, but its disadvantage is insufficient security. Common symmetric encryption algorithms include AES and SM4. Symmetric keys are frequently used for file encryption.
[0005] Asymmetric encryption, also known as public-key encryption, is an encryption method that uses a pair of keys (a public key and a private key) for encryption and decryption. The public key can be made public, while the private key is known only to the holder. Data encrypted with the public key can only be decrypted with the corresponding private key, and vice versa. This encryption method is widely used in scenarios such as data encryption, data signing, and identity verification to ensure the security and trustworthiness of information.
[0006] Existing technical solutions utilize a single blockchain and IPFS for secure data transmission. The sender encrypts the data using a symmetric key to obtain ciphertext, stores the ciphertext in IPFS to obtain an index value, and then encrypts the index value and symmetric key using the receiver's public key before uploading them to the blockchain. The receiver decrypts the data using their private key to obtain the index value and symmetric key, retrieves the data from IPFS based on the index value, and decrypts it using the symmetric key to obtain the original plaintext data.
[0007] However, existing technical solutions are limited to a single blockchain network. There are no confirmation messages during data transmission, and the sender cannot track the data transmission status. In addition, the index value and symmetric key are transmitted simultaneously. If the receiver's private key is accidentally leaked, a malicious party can easily obtain the index value and then acquire the data. Summary of the Invention
[0008] To address the aforementioned issues, this application provides a method, apparatus, device, and medium for cross-chain data distribution based on IPFS. It solves the data distribution problem between different blockchain networks through cross-chain technology; enhances data distribution security by separating the symmetric key from the data index through a two-way handshake; and resolves the issues of non-closed-loop on-chain and off-chain processes and untraceable processes by adding tracking numbers and confirmation messages; thus improving the reliability and controllability of data distribution.
[0009] The embodiments of this application adopt the following technical solutions:
[0010] Firstly, a cross-chain data distribution method based on IPFS is provided. This method applies to both the sender and receiver, who belong to different blockchains, including:
[0011] First handshake:
[0012] The sender encrypts and shares the tracking number and symmetric key with the receiver.
[0013] The receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and then encrypts and shares the first ACK confirmation message with the sender.
[0014] The sender confirms the first handshake was successful based on the decryption of the first ACK acknowledgment message;
[0015] Second handshake:
[0016] The sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver.
[0017] The receiver decrypts the data index based on the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ACK confirmation message based on the decrypted data, and encrypts and shares the second ACK confirmation message with the sender.
[0018] The sender confirms the success of the second handshake based on the decrypted second ACK confirmation message.
[0019] Secondly, an IPFS-based cross-chain data distribution device is provided, characterized in that the device is applied to a sender and a receiver, the sender and the receiver belonging to different blockchains, and the device includes:
[0020] The first shared unit is used to enable the sender to encrypt and share the tracking number and symmetric key with the receiver;
[0021] The second sharing unit is used to enable the receiver to construct a first ACK confirmation message based on the decrypted tracking number and symmetric key, and to encrypt and share the first ACK confirmation message with the sender.
[0022] The confirmation unit is used to enable the sender to determine that the first handshake was successful based on the decryption of the first ACK confirmation message;
[0023] The first sharing unit is also used to enable the sender to encrypt and store the data in IPFS, and to encrypt and share the tracking number and data index with the receiver.
[0024] The second sharing unit is also used to enable the receiver to decrypt the data index according to the tracking number and symmetric key, download the encrypted data from IPFS according to the data index and decrypt it, construct a second ack confirmation message based on the decrypted data, and encrypt and share the second ack confirmation message with the sender.
[0025] The confirmation unit is also used to enable the sender to determine that the second handshake was successful based on the decryption of the second ACK confirmation message.
[0026] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described IPFS-based cross-chain data distribution method.
[0027] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when instructed by a processor, implements the steps of the above-described IPFS-based cross-chain data distribution method.
[0028] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:
[0029] The IPFS-based cross-chain data distribution method provided in this application includes a two-handshake process. The first handshake involves the sender and receiver sharing a symmetric key, and the second handshake involves the sender and receiver sharing a data index. Separating the symmetric key and data index through these two handshakes enhances the security of data distribution. The introduction of tracking numbers and confirmation messages allows for the association of on-chain processes with internal application flows through tracking numbers, resolving issues of non-closed-loop on-chain and off-chain processes and untraceable processes. Confirmation messages ensure the reliability and controllability of end-to-end distribution. Attached Figure Description
[0030] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0031] Figure 1 A flowchart illustrating an IPFS-based cross-chain data distribution method according to an embodiment of this application is shown.
[0032] Figure 2A schematic diagram illustrating the first handshake of an IPFS-based cross-chain data distribution method according to an embodiment of this application is shown.
[0033] Figure 3 A schematic diagram illustrating the second handshake of an IPFS-based cross-chain data distribution method according to an embodiment of this application is shown.
[0034] Figure 4 This diagram illustrates the structure of an IPFS-based cross-chain data distribution method apparatus according to an embodiment of this application.
[0035] Figure 5 A schematic diagram of the structure of a computer device according to an embodiment of this application is shown. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0037] To enable those skilled in the art to more clearly understand the technical solutions provided in the various embodiments of this application, the technical concept of this application will first be described.
[0038] This application utilizes blockchain to enhance the security, controllability, and cross-chain capabilities of data distribution.
[0039] (1) Cross-chain distribution: Cross-chain parameters are embedded in the message to enable reliable data transmission between different blockchain networks. The introduction of cross-chain technology expands the application scenarios with cross-chain requirements and can cover fields such as finance and government affairs that require multi-chain collaboration.
[0040] (2) Enhanced Key Security: By transmitting the symmetric key and data index separately through a two-way handshake, the risk of data theft after private key leakage is greatly reduced. This improves data security, reduces the risk of sensitive information leakage, and meets the compliance requirements of industries such as healthcare and intellectual property management.
[0041] (3) Full-process traceability closed loop: The introduction of tracking numbers and confirmation messages provides fine-grained traceability capabilities, solves the problem of fragmentation between on-chain and off-chain processes, and significantly improves the reliability and control capabilities of the data distribution process.
[0042] Figure 1 This diagram illustrates a flowchart of an IPFS-based cross-chain data distribution method according to an embodiment of this application. (Reference) Figure 1As shown, the cross-chain data distribution method based on IPFS proposed in this embodiment includes a first handshake S11 and a second handshake S12.
[0043] The first handshake S11 includes steps S111 to S113.
[0044] Step S111: The sender encrypts the shared tracking number and symmetric key to the receiver.
[0045] In step S112, the receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and encrypts and shares the first ACK confirmation message with the sender.
[0046] In step S113, the sender confirms the success of the first handshake based on the decrypted first ACK confirmation message.
[0047] The key to the first handshake is that the sender and receiver share a symmetric key. A tracking number and an acknowledgment message are introduced. The tracking number links on-chain steps to the internal application process, solving the problems of non-closed loops and untraceable processes between on-chain and off-chain operations; the acknowledgment message ensures the reliability and controllability of end-to-end distribution.
[0048] The second handshake S12 includes steps S121 to S123.
[0049] In step S121, the sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver.
[0050] In step S122, the receiver decrypts the data index based on the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ack confirmation message based on the decrypted data, and encrypts and shares the second ack confirmation message with the sender.
[0051] In step S123, the sender confirms the success of the second handshake based on the decrypted second ACK confirmation message.
[0052] The key to the second handshake is that the sender shares the data index with the receiver. Since the first handshake was successful, it means the receiver has received the tracking number and symmetric key, preparing for data reception. By transmitting the symmetric key and data index separately through two handshakes, the risk of data theft after private key leakage is greatly reduced.
[0053] Figure 2 This diagram illustrates the first handshake process of an IPFS-based cross-chain data distribution method according to an embodiment of this application. (Reference) Figure 2 As shown, the first handshake of the IPFS-based cross-chain data distribution method proposed in this embodiment is described in detail.
[0054] The first handshake includes the following steps S201 to S206.
[0055] In step S201, the sender generates a symmetric key K and a tracking number TN locally, and uses the symmetric key K, tracking number TN, and sender's public key PKA to form a first transaction message M1; the sender signs the first transaction message M1 using the sender's private key PA to obtain a first signature SG1; the sender queries the receiver's public key PKB through a smart contract, and uses the receiver's public key PKB to encrypt the first transaction message M1 to obtain a first ciphertext message EM1; the sender packages the first ciphertext message EM1, the first signature SG1, and the receiver's receiver identifier BC_B into a first message and submits it to blockchain A.
[0056] Specifically, the sender generates a symmetric key K locally, uses UUID and other technologies to generate a unique tracking number TN for the business, and uses the symmetric key K, tracking number TN and sender's public key PKA to form the first transaction message M1.
[0057] The sender uses the sender's public key PKA and the sender's private key PA to sign the first transaction message M1, thus obtaining the first signature SG1.
[0058] The sender queries the receiver's public key PKB through a smart contract, and uses the receiver's public key PKB to encrypt the first transaction message M1, thus obtaining the first ciphertext message EM1.
[0059] The sender initiates a cross-chain transaction, packaging the first encrypted message EM1, the first signature SG1, and the receiver identifier BC_B of the target blockchain where the receiver is located into a first message and submitting it to blockchain A.
[0060] In step S202, the cross-chain gateway A of blockchain A monitors the first message and submits the first message to blockchain B through the cross-chain gateway B of blockchain B according to the recipient identifier BC_B.
[0061] Specifically, cross-chain gateway A monitors cross-chain transactions on blockchain A and submits the transaction to blockchain B through cross-chain gateway B based on the recipient identifier BC_B of the target blockchain in the first message.
[0062] In step S203, the receiver uses its private key PB to decrypt the first ciphertext message EM1 to obtain the first transaction message M1; the receiver uses the first signature SG1 to verify the signature of the first transaction message M1; after the signature verification is successful, the receiver parses the symmetric key K, the tracking number TN, and the sender's public key PKA from the first transaction message M1; the receiver saves the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA.
[0063] Specifically, the receiver monitors successful transactions on blockchain B, and uses the receiver's public key PKB to decrypt the first ciphertext message EM1, obtaining the first transaction message M1.
[0064] The receiver uses the first signature SG1 to verify the signature of the first transaction message M1.
[0065] After the signature verification is successful, the receiver parses the symmetric key K, tracking number TN, and sender's public key PKA from the first transaction message M1.
[0066] The receiver stores the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA.
[0067] In step S204, the receiver constructs a first ACK confirmation message M2 using the tracking number TN and the status value PREPARED; the receiver signs the first ACK confirmation message M2 using the receiver's private key PB to obtain a second signature SG2; the receiver encrypts the first ACK confirmation message M2 using the sender's public key PKA to obtain a second ciphertext message EM2; the receiver packages the second ciphertext message EM2, the second signature SG2, and the sender's sender identifier BC_A into a second message and submits it to blockchain B.
[0068] Specifically, the receiver uses the tracking number TN and the status value PREPARED to construct the first ACK acknowledgment message M2.
[0069] The receiver uses the receiver's public key PKB, corresponding to the receiver's private key PB, to sign the first ACK confirmation message M2, thus obtaining the second signature SG2.
[0070] The receiver uses the sender's public key PKA to encrypt the first ACK confirmation message M2 and generate the second ciphertext message EM2.
[0071] The recipient initiates a cross-chain transaction by packaging the second encrypted message EM2, the second signature SG2, and the sender identifier BC_A of the target blockchain where the sender is located into a second message and submitting it to blockchain B.
[0072] In step S205, the cross-chain gateway B of blockchain B monitors the second message and submits the second message to blockchain A through the cross-chain gateway A of blockchain A according to the sender identifier BC_A.
[0073] Specifically, cross-chain gateway B monitors cross-chain transactions on blockchain B and submits the transaction to blockchain A through cross-chain gateway B based on the sender identifier BC_A of the target blockchain in the second message.
[0074] In step S206, the sender uses its private key PA to decrypt the second ciphertext message EM2 to obtain the first ack confirmation message M2; the sender uses the second signature SG2 to verify the first ack confirmation message M2; after the signature verification is successful, the sender parses the tracking number TN and the status value PREPARED from the first ack confirmation message M2; the sender determines that the first handshake was successful based on the tracking number TN and the status value PREPARED.
[0075] Specifically, the sender monitors successful transactions on blockchain A, uses the sender's public key PKA corresponding to the sender's private key PA to decrypt the second ciphertext message EM2, and obtains the first ACK confirmation message M2.
[0076] The sender uses the second signature SG2 to verify the signature of the first ack confirmation message M2.
[0077] After the signature verification is successful, the sender parses the tracking number TN and the status value PREPARED from the first ACK confirmation message M2.
[0078] The sender determines that the first handshake was successful based on the tracking number TN and the status value PREPARED.
[0079] Figure 3 This diagram illustrates the second handshake process of an IPFS-based cross-chain data distribution method according to an embodiment of this application. (Reference) Figure 3 As shown, the second handshake of the IPFS-based cross-chain data distribution method proposed in this embodiment is described in detail.
[0080] The second handshake includes the following steps S301 to S310.
[0081] In step S301, the sender encrypts the data F using the symmetric key K to obtain the ciphertext file EF; the sender then stores the ciphertext file EF in IPFS.
[0082] Specifically, the sender uses a symmetric key K to encrypt the data F to be distributed, obtaining a ciphertext file EF. The sender then uploads the ciphertext file EF to the IPFS node.
[0083] In step S302, the sender receives the data index I returned by IPFS.
[0084] Specifically, the IPFS node sends data index I back to the sender.
[0085] In step S303, the sender encrypts the data index I using the symmetric key K to obtain the ciphertext index value EI; the sender uses the ciphertext index value EI and the tracking number TN to form the third transaction message M3; the sender signs the third transaction message M3 using the sender's private key PA to obtain the third signature SG3; the sender encrypts the third transaction message M3 using the receiver's public key PKB to obtain the third ciphertext message EM3; the sender packages the third ciphertext message EM3, the third signature SG3, and the receiver's receiver identifier BC_B into a third message and submits it to blockchain A.
[0086] Specifically, the sender uses the symmetric key K to encrypt the data index I, obtaining the ciphertext index value EI.
[0087] The sender uses the index value ciphertext EI and the tracking number TN to compose the third transaction message M3.
[0088] The sender uses the sender's public key PKA, corresponding to the sender's private key PA, to sign the third transaction message M3, thus obtaining the third signature SG3.
[0089] The sender uses the receiver's public key PKB to encrypt the third transaction message M3, thus obtaining the third ciphertext message EM3.
[0090] The sender initiates a cross-chain transaction, packaging the third encrypted message EM3, the third signature SG3, and the receiver identifier BC_B of the target blockchain where the receiver is located into a third message and submitting it to blockchain A.
[0091] In step S304, the cross-chain gateway A of blockchain A detects the third message and submits the third message to blockchain B through the cross-chain gateway B of blockchain B according to the recipient identifier BC_B.
[0092] Specifically, cross-chain gateway A monitors cross-chain transactions on blockchain A and submits the transaction to blockchain B through cross-chain gateway B based on the recipient identifier BC_B of the target blockchain in the third message.
[0093] In step S305, the receiver decrypts the third ciphertext message EM3 using its private key PB to obtain the third transaction message M3; the receiver verifies the signature of the third transaction message M3 using the third signature SG3; after successful verification, the receiver parses the index value ciphertext EI and the tracking number TN from the third transaction message M3; the receiver determines the symmetric key K corresponding to the tracking number TN using the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA; the receiver decrypts the index value ciphertext EI using the symmetric key K to obtain the data index I.
[0094] Specifically, the receiver monitors successful transactions on blockchain B, and uses the receiver's public key PKB corresponding to the receiver's private key PB to decrypt the third ciphertext message EM3, thus obtaining the third transaction message M3.
[0095] The recipient uses the third signature SG3 to verify the signature of the third transaction message M3.
[0096] After the signature is verified, the receiver parses the index value ciphertext EI and the tracking number TN from the third transaction message M3.
[0097] The receiver uses the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA recorded during the first handshake to find the symmetric key K corresponding to the tracking number TN.
[0098] The receiver uses the found symmetric key K to decrypt the ciphertext index value EI, obtaining the data index I.
[0099] Step S306: The receiver downloads the encrypted file EF from IPFS according to data index I.
[0100] Specifically, the receiver downloads the encrypted file EF from the IPFS node based on data index I.
[0101] In step S307, the receiver uses the symmetric key K to decrypt the ciphertext file EF and obtain the data F.
[0102] Specifically, the receiver uses the found symmetric key K to decrypt the ciphertext file EF and obtain the data F.
[0103] In step S308, the receiver constructs a second ack confirmation message M4 using the tracking number TN and the status value DONE; the receiver signs the second ack confirmation message M4 using the receiver's private key PB to obtain a fourth signature SG4; the receiver encrypts the second ack confirmation message M4 using the sender's public key PKA to obtain a fourth ciphertext message EM4; the receiver packages the fourth ciphertext message EM4, the fourth signature SG4, and the sender's sender identifier BC_A into a fourth message and submits it to blockchain B.
[0104] Specifically, the receiver uses the tracking number TN and the status value DONE to construct the second ack confirmation message M4.
[0105] The receiver uses the receiver's public key PKB, corresponding to the receiver's private key PB, to sign the second ack confirmation message M4, thus obtaining the fourth signature SG4.
[0106] The receiver uses the sender's public key PKA to encrypt the second ACK confirmation message M4, generating the fourth ciphertext message EM4.
[0107] The recipient initiates a cross-chain transaction, packaging the fourth encrypted message EM4, the fourth signature SG4, and the sender identifier BC_A of the target blockchain where the sender is located into a fourth message and submitting it to blockchain B.
[0108] In step S309, the cross-chain gateway B of blockchain B detects the fourth message and submits the fourth message to blockchain A through the cross-chain gateway A of blockchain A according to the sender identifier BC_A.
[0109] Specifically, cross-chain gateway B monitors cross-chain transactions on blockchain B and submits the transaction to blockchain A through cross-chain gateway B based on the sender identifier BC_A of the target blockchain in the fourth message.
[0110] In step S310, the sender uses its private key PA to decrypt the fourth ciphertext message EM4 to obtain the second ack confirmation message M4; the sender uses the fourth signature SG4 to verify the signature of the second ack confirmation message M4; after the signature verification is successful, the sender parses the tracking number TN and the status value DONE from the second ack confirmation message M4; the sender determines that the second handshake was successful based on the tracking number TN and the status value DONE.
[0111] Specifically, the sender monitors successful transactions on blockchain A, decrypts the fourth ciphertext message EM4 using the sender's private key PA corresponding to the sender's public key PKA, and obtains the second ACK confirmation message M4.
[0112] The sender uses the fourth signature SG4 to verify the signature of the second ack confirmation message M4.
[0113] After the signature verification is successful, the sender parses the tracking number TN and the status value DONE from the second ACK confirmation message M4.
[0114] The sender determines that the second handshake was successful based on the tracking number TN and the status value DONE.
[0115] Existing mainstream blockchain cross-chain technology solutions, based on their specific implementation methods, mainly include notary mechanisms, hash locking, sidechains & relay chains, etc. This application focuses on describing the distribution and sharing of data in cross-chain scenarios, and does not impose limitations or constraints on specific cross-chain technologies.
[0116] If the symmetric key K and data index I are encrypted with the recipient's public key PKB and uploaded to the blockchain during a handshake, a malicious party can easily obtain data F if the recipient's private key PB is accidentally leaked. However, encrypting the symmetric key K and data index I separately and uploading them to the blockchain separately increases the difficulty for a malicious party to obtain data F, especially when the malicious party is unaware of the business logic, making it difficult to identify the relationship between the two on-chain transactions.
[0117] The key operations during the two handshake processes are automatically recorded on the blockchain via smart contracts. Based on the tracking number TN and timestamp, a complete traceability chain can be constructed. The tracking number TN can also be associated with internal application processes, forming a unified and trustworthy traceability system that aggregates internal and on-chain processes. Both the sender and receiver can promptly understand the progress of data distribution through traceability. The ACK confirmation mechanism during the two handshake processes also ensures the reliability and controllability of end-to-end data distribution messages.
[0118] Figure 4 A schematic diagram of the structure of an IPFS-based cross-chain data distribution device according to an embodiment of this application is shown. Figure 4 As shown, the device 400 is used for a sender and a receiver who belong to different blockchains. The device 400 includes:
[0119] The first sharing unit 401 is used to enable the sender to encrypt and share the tracking number and symmetric key with the receiver;
[0120] The second sharing unit 402 is used to enable the receiver to construct a first ack confirmation message based on the decrypted tracking number and symmetric key, and to encrypt and share the first ack confirmation message with the sender.
[0121] Confirmation unit 403 is used to enable the sender to determine that the first handshake was successful based on the decryption of the first ACK confirmation message;
[0122] The first sharing unit 401 is also used to enable the sender to encrypt and store the data in IPFS, and to encrypt and share the tracking number and data index with the receiver.
[0123] The second sharing unit 402 is also used to enable the receiver to decrypt the data index based on the symmetric key corresponding to the decrypted tracking number, download the encrypted data from IPFS according to the data index and decrypt it, construct a second ack confirmation message based on the decrypted data, and encrypt and share the second ack confirmation message with the sender.
[0124] The confirmation unit 403 is also used to enable the sender to determine that the second handshake was successful based on the decryption of the second ack confirmation message.
[0125] In some optional embodiments, in the above-described apparatus 400, the first sharing unit 401 includes: a transaction message construction module, used to generate a symmetric key K and a tracking number TN locally on the sender's side, and to compose a first transaction message M1 using the symmetric key K, the tracking number TN, and the sender's public key PKA; a first signature module, used to sign the first transaction message M1 using the sender's private key PA to obtain a first signature SG1; a first ciphertext message construction module, used to query the receiver's public key PKB through a smart contract, and to encrypt the first transaction message M1 using the receiver's public key PKB to obtain a first ciphertext message EM1; a first submission module, used to package the first ciphertext message EM1, the first signature SG1, and the receiver's receiver identifier BC_B into a first message and submit it to blockchain A; and a cross-chain gateway A, used to monitor the first message and submit the first message to blockchain B through the cross-chain gateway B of blockchain B according to the receiver identifier BC_B.
[0126] In some optional embodiments, in the above-described apparatus 400, the second sharing unit 402 includes: a second encrypted message decryption module, used to decrypt the first encrypted message EM1 using the receiver's private key PB to obtain the first transaction message M1; a second signature verification module, used to verify the signature of the first transaction message M1 using the first signature SG1; a transaction message parsing module, used to parse the symmetric key K, tracking number TN, and sender's public key PKA from the first transaction message M1 after successful signature verification; a relationship establishment module, used to store the correspondence between the symmetric key K, tracking number TN, and sender's public key PKA; and an acknowledgment message construction module, used to construct the acknowledgment message using the tracking number TN and the status value P. RDPARED constructs the first ACK confirmation message M2; the second signature module is used to sign the first ACK confirmation message M2 using the recipient's private key PB to obtain the second signature SG2; the second ciphertext message construction module is used to encrypt the first ACK confirmation message M2 using the sender's public key PKA to obtain the second ciphertext message EM2; the second submission module is used to package the second ciphertext message EM2, the second signature SG2, and the sender's sender identifier BC_A into a second message and submit it to blockchain B; the cross-chain gateway B is used to monitor the second message and submit the second message to blockchain A through the cross-chain gateway A that leads to cross-chain A according to the sender identifier BC_A.
[0127] In some optional embodiments, in the above-described apparatus 400, the confirmation unit 403 includes: a first encrypted message decryption module, used to decrypt the second encrypted message EM2 using the sender's private key PA to obtain a first ack confirmation message M2; a first signature verification module, used to verify the first ack confirmation message M2 using a second signature SG2; a confirmation message parsing module, used to parse the tracking number TN and the status value PREPARED from the first ack confirmation message M2 after the signature verification is successful; and a confirmation module, used to determine that the first handshake was successful based on the tracking number TN and the status value PREPARED.
[0128] In some optional embodiments, in the above-described apparatus 400, the first sharing unit 401 includes: a data encryption module for encrypting data F using a symmetric key K to obtain a ciphertext file EF; a data upload module for storing the ciphertext file EF to IPFS to obtain a data index I returned by IPFS; an index encryption module for encrypting data index I using a symmetric key K to obtain an index value ciphertext EI; a transaction message construction module for assembling a third transaction message M3 using the index value ciphertext EI and a tracking number TN; a first signature module for signing the third transaction message M3 using the sender's private key PA to obtain a third signature SG3; a first ciphertext message construction module for encrypting the third transaction message M3 using the receiver's public key PKB to obtain a third ciphertext message EM3; a first submission module for packaging the third ciphertext message EM3, the third signature SG3, and the receiver's receiver identifier BC_B into a third message and submitting it to blockchain A; and a cross-chain gateway A for monitoring the third message and submitting it to blockchain B through the cross-chain gateway B of blockchain B according to the receiver identifier BC_B.
[0129] In some optional embodiments, in the above-described apparatus 400, the second sharing unit 402 includes: a second encrypted message decryption module, used to decrypt the third encrypted message EM3 using the receiver's private key PB to obtain the third transaction message M3; a second signature verification module, used to verify the signature of the third transaction message M3 using the third signature SG3; a transaction message parsing module, used to parse the index value encrypted message EI and the tracking number TN from the third transaction message M3 after the signature verification is successful; a symmetric key query module, used to determine the symmetric key K corresponding to the tracking number TN using the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA; an index decryption module, used to decrypt the index value encrypted message EI using the symmetric key K to obtain the data index I; and a data download module, used to download the encrypted file EF from IPFS according to the data index I; The decryption module is used to decrypt the ciphertext file EF using the symmetric key K to obtain data F; the confirmation message construction module is used to construct the second ack confirmation message M4 using the tracking number TN and the status value DONE; the second signature module is used to sign the second ack confirmation message M4 using the receiver's private key PB to obtain the fourth signature SG4; the second ciphertext message construction module is used to encrypt the second ack confirmation message M4 using the sender's public key PKA to obtain the fourth ciphertext message EM4; the second submission module is used to package the fourth ciphertext message EM4, the fourth signature SG4, and the sender's sender identifier BC_A into a fourth message and submit it to blockchain B; the cross-chain gateway B is used to monitor the fourth message and submit the fourth message to blockchain A through the cross-chain gateway A of blockchain A according to the sender identifier BC_A.
[0130] In some optional embodiments, in the above-described apparatus 400, the confirmation unit 403 includes: a first encrypted message decryption module, used to decrypt the fourth encrypted message EM4 using the sender's private key PA to obtain a second ack confirmation message M4; a first signature verification module, used to verify the second ack confirmation message M4 using a fourth signature SG4; a confirmation message parsing module, used to parse the tracking number TN and the status value DONE from the second ack confirmation message M4 after the signature verification is successful; and a confirmation module, used to determine that the second handshake was successful based on the tracking number TN and the status value DONE.
[0131] It should be noted that the aforementioned IPFS-based cross-chain data distribution device 400 can implement the aforementioned IPFS-based cross-chain data distribution methods one by one, which will not be elaborated further.
[0132] Figure 5 This application shows a schematic diagram of the structure of a computer device according to one embodiment of the present application. Figure 5As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external devices via a network connection. When the computer program is executed by the processor, it implements the functions or steps of the IPFS-based cross-chain data distribution method.
[0133] In one embodiment, the computer device provided in this application includes a memory and a processor. The memory stores a database and a computer program that can run on the processor. When the processor executes the computer program, it performs the following steps:
[0134] First handshake:
[0135] The sender encrypts and shares the tracking number and symmetric key with the receiver.
[0136] The receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and then encrypts and shares the first ACK confirmation message with the sender.
[0137] The sender confirms the first handshake was successful based on the decryption of the first ACK acknowledgment message;
[0138] Second handshake:
[0139] The sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver.
[0140] The receiver decrypts the data index based on the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ACK confirmation message based on the decrypted data, and encrypts and shares the second ACK confirmation message with the sender.
[0141] The sender confirms the success of the second handshake based on the decrypted second ACK confirmation message.
[0142] The above is as stated in this application. Figure 4The method for cross-chain data distribution based on IPFS disclosed in the illustrated embodiments can be applied to a processor or implemented by a processor. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The steps of the method disclosed in the embodiments of this application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0143] In one embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, the computer program performing the following steps when executed by a processor:
[0144] First handshake:
[0145] The sender encrypts and shares the tracking number and symmetric key with the receiver.
[0146] The receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and then encrypts and shares the first ACK confirmation message with the sender.
[0147] The sender confirms the first handshake was successful based on the decryption of the first ACK acknowledgment message;
[0148] Second handshake:
[0149] The sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver.
[0150] The receiver decrypts the data index based on the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ACK confirmation message based on the decrypted data, and encrypts and shares the second ACK confirmation message with the sender.
[0151] The sender confirms the success of the second handshake based on the decrypted second ACK confirmation message.
[0152] It should be noted that the functions or steps that can be implemented by the computer device or computer-readable storage medium described above can be referred to the relevant descriptions in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0153] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0154] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0155] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A cross-chain data distribution method based on IPFS, characterized in that, The method is applied to a sender and a receiver, who belong to different blockchains, including: First handshake: The sending direction encrypts the shared tracking number and symmetric key with the receiving party; The receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and encrypts and shares the first ACK confirmation message with the sender. The sender determines that the first handshake was successful based on the decryption of the first ACK confirmation message; Second handshake: The sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver. The receiver decrypts the data index based on the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ACK confirmation message based on the decrypted data, and encrypts and shares the second ACK confirmation message with the sender. The sender determines that the second handshake was successful based on the decryption of the second ACK confirmation message.
2. The IPFS-based cross-chain data distribution method according to claim 1, characterized in that, The sending party encrypts and shares the tracking number and symmetric key with the receiver, including: The sender generates a symmetric key K locally, generates a tracking number TN, and uses the symmetric key K, the tracking number TN and the sender's public key PKA to form the first transaction message M1; The sender uses its private key PA to sign the first transaction message M1 to obtain the first signature SG1; The sender queries the receiver's public key PKB through a smart contract, and uses the receiver's public key PKB to encrypt the first transaction message M1 to obtain the first ciphertext message EM1. The sender packages the first encrypted message EM1, the first signature SG1, and the receiver's receiver identifier BC_B into a first message and submits it to blockchain A; Blockchain A's cross-chain gateway A detects the first message and submits it to blockchain B through blockchain B's cross-chain gateway B based on the recipient identifier BC_B.
3. The IPFS-based cross-chain data distribution method according to claim 2, characterized in that, The receiver constructs a first ACK confirmation message based on the decrypted tracking number and symmetric key, and encrypts and shares the first ACK confirmation message with the sender, including: The receiver uses its private key PB to decrypt the first ciphertext message EM1 to obtain the first transaction message M1. The recipient uses the first signature SG1 to verify the signature of the first transaction message M1; After the signature verification is successful, the receiver parses the symmetric key K, tracking number TN, and sender's public key PKA from the first transaction message M1; The receiver stores the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA; The receiver uses the tracking number TN and the status value PREPARED to construct the first ACK confirmation message M2; The receiver uses its private key PB to sign the first ack confirmation message M2 to obtain the second signature SG2; The receiver uses the sender's public key PKA to encrypt the first ACK confirmation message M2 to obtain the second ciphertext message EM2; The receiver packages the second encrypted message EM2, the second signature SG2, and the sender's sender identifier BC_A into a second message and submits it to blockchain B; Blockchain B's cross-chain gateway B detects the second message and submits it to blockchain A through blockchain A's cross-chain gateway A based on the sender identifier BC_A.
4. The IPFS-based cross-chain data distribution method according to claim 3, characterized in that, The sender determines that the first handshake was successful based on the decryption of the first ACK confirmation message, including: The sender uses its private key PA to decrypt the second ciphertext message EM2 and obtains the first ACK confirmation message M2. The sender uses the second signature SG2 to verify the signature of the first ack confirmation message M2; After the signature verification is successful, the sender parses the tracking number TN and the status value PREPARED from the first ACK confirmation message M2; The sender determines that the first handshake was successful based on the tracking number TN and the status value PREPARED.
5. The IPFS-based cross-chain data distribution method according to claim 4, characterized in that, The sender encrypts and stores the data in IPFS, and encrypts and shares the tracking number and data index with the receiver, including: The sender uses a symmetric key K to encrypt data F, resulting in a ciphertext file EF; The sender stores the encrypted file EF in IPFS and obtains the data index I returned by IPFS; The sender uses the symmetric key K to encrypt the data index I, obtaining the ciphertext index value EI; The sender uses the index value ciphertext EI and the tracking number TN to compose the third transaction message M3; The sender uses its private key PA to sign the third transaction message M3, resulting in a third signature SG3. The sender uses the receiver's public key PKB to encrypt the third transaction message M3, obtaining the third ciphertext message EM3; The sender packages the third encrypted message EM3, the third signature SG3, and the receiver's receiver identifier BC_B into a third message and submits it to blockchain A; Blockchain A's cross-chain gateway A detects a third message and submits the third message to blockchain B through blockchain B's cross-chain gateway B based on the recipient identifier BC_B.
6. The IPFS-based cross-chain data distribution method according to claim 5, characterized in that, The receiver decrypts the data index using the symmetric key corresponding to the decrypted tracking number, downloads and decrypts the encrypted data from IPFS according to the data index, constructs a second ACK confirmation message based on the decrypted data, and encrypts and shares the second ACK confirmation message with the sender, including: The receiver uses its private key PB to decrypt the third ciphertext message EM3 to obtain the third transaction message M3. The recipient uses the third signature SG3 to verify the signature of the third transaction message M3. After the signature verification is successful, the receiver parses the index value ciphertext EI and the tracking number TN from the third transaction message M3; The receiver uses the correspondence between the symmetric key K, the tracking number TN, and the sender's public key PKA to determine the symmetric key K corresponding to the tracking number TN; The receiver uses the symmetric key K to decrypt the ciphertext of the index value EI to obtain the data index I; The receiver downloads the encrypted file EF from IPFS according to data index I; The receiver uses the symmetric key K to decrypt the ciphertext file EF to obtain the data F; The receiver uses the tracking number TN and the status value DONE to construct a second ACK confirmation message M4; The receiver uses its private key PB to sign the second ack confirmation message M4 to obtain the fourth signature SG4; The receiver uses the sender's public key PKA to encrypt the second ACK confirmation message M4, and obtains the fourth ciphertext message EM4. The receiver packages the fourth ciphertext message EM4, the fourth signature SG4, and the sender's sender identifier BC_A into a fourth message and submits it to blockchain B; Blockchain B's cross-chain gateway B detects the fourth message and submits it to blockchain A through blockchain A's cross-chain gateway A based on the sender identifier BC_A.
7. The IPFS-based cross-chain data distribution method according to claim 6, characterized in that, The sender determines the second handshake was successful based on the decrypted second ACK confirmation message, including: The sender uses its private key PA to decrypt the fourth ciphertext message EM4 and obtains the second ACK confirmation message M4. The sender uses the fourth signature SG4 to verify the signature of the second ack confirmation message M4. After the signature verification is successful, the sender parses the tracking number TN and the status value DONE from the second ACK confirmation message M4; The sender determines that the second handshake was successful based on the tracking number TN and the status value DONE.
8. A cross-chain data distribution device based on IPFS, characterized in that, The device is used by a sender and a receiver, the sender and the receiver belonging to different blockchains, and the device includes: The first sharing unit is used to enable the sender to encrypt and share the tracking number and symmetric key with the receiver; The second sharing unit is used to enable the receiver to construct a first ACK confirmation message based on the decrypted tracking number and symmetric key, and to encrypt and share the first ACK confirmation message with the sender. The confirmation unit is used to enable the sender to determine that the first handshake was successful based on the decryption of the first ACK confirmation message; The first sharing unit is also used to enable the sender to encrypt and store the data in IPFS, and to encrypt and share the tracking number and data index with the receiver; The second sharing unit is also used to enable the receiver to decrypt the data index according to the tracking number and symmetric key, download the encrypted data from IPFS according to the data index and decrypt it, construct a second ack confirmation message based on the decrypted data, and encrypt and share the second ack confirmation message with the sender. The confirmation unit is also used to enable the sender to determine that the second handshake was successful based on the decryption of the second ack confirmation message.
9. A computer 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 computer program, it implements the steps of the IPFS-based cross-chain data distribution method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is instructed by the processor, it implements the steps of the IPFS-based cross-chain data distribution method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data transmission method and device and network node
CN110166411A
Electronic medical record sharing method based on national cryptographic algorithm and IPFS
CN114553582A