Block chain-based end-to-end encryption communication method and system

By sharding the master key MK and combining distributed storage of blockchain and IPFS, the problems of high key storage risks, complex recovery mechanisms and insufficient privacy protection in end-to-end encryption are solved, efficient key recovery and full-process secure encryption are achieved, and communication reliability and privacy protection are improved.

CN120389885APending Publication Date: 2025-07-29LINGSHU TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510514875.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

The existing end-to-end encryption technology has problems such as high key storage risks, complex recovery mechanisms, insufficient privacy protection and static key exposure, and lacks effective solutions.

Method used

The Shamir threshold algorithm is used to shard the master key MK. Some shards are stored in a trusted execution environment, and the other shards are encrypted by the public key and stored on the blockchain network. Combined with the event notification mechanism of the smart contract, dynamic key rotation and distributed shard storage, using the anti-tampering characteristics of the blockchain and the decentralized storage of IPFS, to achieve secure recovery and privacy protection of keys.

Benefits of technology

It improves the security and recovery efficiency of keys, reduces costs, realizes security encryption and privacy protection throughout the process, prevents the risk of long-term use of the same key and ensures the reliability and integrity of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120389885A_ABST
    Figure CN120389885A_ABST
Patent Text Reader

Abstract

The invention discloses an end-to-end encryption communication method and system based on a block chain. According to the method, a master key MK is fragmented through a Shamir threshold algorithm, a part of fragments are locally encrypted and stored in a trusted execution environment, the other part of fragments are encrypted through a public key and then stored in a block chain network, and even if a single point is leaked, the complete key cannot be recovered; dynamic key rotation and distributed fragmentation storage are adopted, and in combination with an event notification of an intelligent contract, a user can recover a master key by obtaining an enough number of fragments when the key is lost, and a third-party mechanism does not need to participate in; according to the method, the encryption result ESK of the session key SK is subjected to uplink evidence storage, the ciphertext is subjected to distributed storage through the IPFS, and the security encryption and privacy protection of the whole process are realized by using the tamper-proof characteristic of the block chain and the decentralization characteristic of the IPFS; through double triggering of the block height and the timing mechanism, a new master key can be generated regularly and re-fragmented, and the risk of being broken due to long-term use of the same key is effectively prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of information security and blockchain technology. Specifically, it relates to an end-to-end encrypted communication method and system based on blockchain. Background Art

[0002] Although the existing end-to-end encryption (E2EE) technology can ensure the confidentiality of communication data during transmission, it still has the following defects:

[0003] 1. High risk of key storage: Dependence on local devices to store private keys makes it easy for keys to be leaked when the device is lost or attacked;

[0004] 2. Complicated recovery mechanism: After the key is lost, it needs to be restored through a third-party institution or a complicated process, which is inefficient and costly;

[0005] 3. Insufficient privacy protection: Communication data may be tampered with or leaked during transmission or storage, and there is a lack of a dynamic update mechanism;

[0006] 4. Exposure of static keys: Long-term use of fixed keys increases the possibility of being brute-forced.

[0007] In view of the problems existing in the prior art, no effective solution has been proposed yet. Summary of the Invention

[0008] An end-to-end encrypted communication method and system based on blockchain are provided in an embodiment of the present invention to solve the problems of high risk of key storage, complicated recovery mechanism, insufficient privacy protection, and exposure of static keys in the prior art.

[0009] To achieve the above object, on the one hand, the present invention provides an end-to-end encrypted communication method based on blockchain, the method comprising: S1, the message sender obtains the public key and address of the message recipient through the encrypted communication hub; S2, the message sender calls the security module to generate the master key MK, and divides the master key MK into n pieces through the Shamir threshold algorithm, where at least k pieces can recover the master key; S3, the message sender locally encrypts and stores some of the shards in the trusted execution environment TEE, and encrypts the other part of the shards with the public key of the message recipient and stores them on the blockchain network; S4, the message sender calls the security module to generate a temporary session key SK, encrypts the current message with the temporary session key SK to obtain the ciphertext and stores it in the InterPlanetary File System IPFS; and encrypts the temporary session key SK based on the master key MK to obtain the encrypted session key ESK; S5, the message sender stores the packaged data on the blockchain network, and triggers an event notification through a smart contract to prompt the message recipient to obtain the current message; the packaged data includes: the address of the message recipient, the encrypted session key ESK; S6, the message recipient obtains the packaged data and the encrypted shards stored on the blockchain network according to the event notification, and decrypts the encrypted shards with the private key of the message recipient to obtain the key shards; the key shards are used to recover the master key MK through the Shamir threshold algorithm; S7, the message recipient decrypts the encrypted session key ESK according to the master key MK to obtain the temporary session key SK; the message recipient obtains the ciphertext stored in the InterPlanetary File System IPFS, and decrypts the ciphertext with the temporary session key SK to obtain the plaintext.

[0010] Optionally, when the rotation trigger condition is met, the message sender calls the security module to generate a new master key MK and re-shards and stores it to update the encrypted shards stored on the blockchain network; the rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a timed task is triggered.

[0011] Optionally, before the S2, it further includes: dynamically calculating the sharding parameters n and k according to the number of consensus nodes on the blockchain network; if the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes; k = floor(n / 2)+1.

[0012] Optionally, storing the sharded another part on the blockchain network after encrypting it with the public key of the message recipient further includes: storing the current key version on the blockchain network; the current key version is the sharding information version of the master key MK; after encrypting the current message with the temporary session key SK to obtain the ciphertext and storing it in the InterPlanetary File System (IPFS), the IPFS returns the ciphertext identifier to the message sender; the message recipient obtains the ciphertext stored in the IPFS including: the message recipient obtains the ciphertext stored in the IPFS according to the ciphertext identifier; the packed data further includes: the current key version, the ciphertext identifier, and the current message hash; the current message hash is the hash value generated by the message sender by calculating the current message through the hash algorithm.

[0013] Optionally, after the S7, it further includes: the message recipient calculates the hash value of the decrypted plaintext through the hash algorithm, compares the decrypted hash value with the current message hash in the obtained packed data, and if they are the same, it is confirmed that the current message has not been tampered with.

[0014] Optionally, before the S1, it includes: the message sender submits registration information to the encryption communication hub and generates the public-private key pair of the message sender; the message recipient submits registration information to the encryption communication hub and generates the public-private key pair of the message recipient; the encryption communication hub records the addresses of the message sender and the message recipient and retains the public keys of the message sender and the message recipient; the message sender and the message recipient establish a connection through the encryption communication hub.

[0015] On the other hand, the present invention provides an end-to-end encrypted communication system based on blockchain, which includes: an acquisition unit for the message sender to obtain the public key and address of the message receiver through an encrypted communication hub; a sharding unit for the message sender to call a security module to generate a master key MK and divide the master key MK into n pieces through the Shamir threshold algorithm, where at least k pieces can recover the master key; a sharding encryption storage unit for the message sender to locally encrypt and store some of the shards in a trusted execution environment TEE, and encrypt and store the other part of the shards on the blockchain network using the public key of the message receiver; a session key encryption unit for the message sender to call a security module to generate a temporary session key SK, encrypt the current message with the temporary session key SK to obtain a ciphertext and store it in the InterPlanetary File System IPFS; and encrypt the temporary session key SK with the master key MK to obtain an encrypted session key ESK; an event notification unit for the message sender to store the packaged data on the blockchain network and trigger an event notification through a smart contract to prompt the message receiver to obtain the current message; the packaged data includes: the address of the message receiver, the encrypted session key ESK; a master key recovery unit for the message receiver to obtain the packaged data and the encrypted shards stored on the blockchain network according to the event notification, and decrypt the encrypted shards with the private key of the message receiver to obtain key shards; recover the master key MK using the Shamir threshold algorithm for the key shards; a decryption unit for the message receiver to decrypt the encrypted session key ESK with the master key MK to obtain the temporary session key SK; the message receiver obtains the ciphertext stored in the InterPlanetary File System IPFS and decrypts the ciphertext with the temporary session key SK to obtain the plaintext.

[0016] Optionally, when the rotation trigger condition is met, the message sender calls a security module to generate a new master key MK and re-shard and store it to update the encrypted shards stored on the blockchain network; the rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a timed task is triggered.

[0017] Optionally, it further includes: a sharding parameter calculation unit for dynamically calculating the sharding parameters n and k according to the number of consensus nodes on the blockchain network; if the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes; k = floor(n / 2)+1.

[0018] Optionally, the storing of the encrypted shards of the other part on the blockchain network using the public key of the message recipient further includes: storing the current key version on the blockchain network; the current key version is the shard information version of the master key MK; after encrypting the current message with the temporary session key SK and storing it in the InterPlanetary File System (IPFS), the IPFS returns a ciphertext identifier to the message sender; the message recipient obtains the ciphertext stored in the IPFS by: the message recipient obtaining the ciphertext stored in the IPFS according to the ciphertext identifier; the packaged data further includes: the current key version, the ciphertext identifier, and the current message hash; the current message hash is the hash value generated by the message sender calculating the current message through a hashing algorithm.

[0019] Advantages of the present invention:

[0020] The present invention provides an end-to-end encrypted communication method and system based on blockchain. Among them, the method shards the master key MK through the Shamir threshold algorithm. Some shards are locally encrypted and stored in a trusted execution environment, and the other shards are encrypted with a public key and stored in the blockchain network. Even if a single point is leaked, it is not enough to recover the complete key; dynamic key rotation and distributed shard storage are adopted, combined with event notifications of smart contracts. When a user loses a key, the user can recover the master key by obtaining a sufficient number of shards without the participation of a third-party institution, significantly improving efficiency and reducing costs; the present invention stores the encrypted result ESK of the session key SK on the blockchain for evidence, and distributes and stores the ciphertext through the IPFS. Utilizing the anti-tampering feature of the blockchain and the decentralized feature of the IPFS, it realizes end-to-end secure encryption and privacy protection; through the dual triggering of the block height and the timing mechanism, a new master key can be periodically generated and re-sharded, effectively preventing the risk of being compromised due to the long-term use of the same key. Description of the Drawings

[0021] Figure 1 is a flowchart of an end-to-end encrypted communication method based on blockchain provided by an embodiment of the present invention;

[0022] Figure 2 is a schematic structural diagram of an end-to-end encrypted communication system based on blockchain provided by an embodiment of the present invention. Detailed Embodiments

[0023] To make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0024] Figure 1 is a flowchart of an end-to-end encrypted communication method based on blockchain provided by an embodiment of the present invention. As Figure 1 shown, the method includes:

[0025] S1. The message sender obtains the public key and address of the message recipient through the encrypted communication hub;

[0026] Before sending an encrypted message, the message sender (such as user A) needs to obtain the identity information of the message recipient (such as user B), including B's public key and address on the blockchain. This process is usually executed by the encrypted communication hub (CryptoGuardHub, abbreviated as CG). After the message sender sends a request, CG returns the public key information and address pre-saved when user B registered in the system to A.

[0027] In an alternative embodiment, before the S1, it includes:

[0028] The message sender submits registration information to the encrypted communication hub and generates a public-private key pair for the message sender; the message recipient submits registration information to the encrypted communication hub and generates a public-private key pair for the message recipient;

[0029] The encrypted communication hub records the addresses of the message sender and the message recipient and retains the public keys of the message sender and the message recipient;

[0030] The message sender and the message recipient establish a connection through the encrypted communication hub.

[0031] Specifically, when the message sender (such as user A) first accesses the system, it needs to submit registration information to the encrypted communication hub (CryptoGuard Hub, abbreviated as CG). This information may include user identity identifiers (such as username, mobile phone number or email), password, biometric identification and necessary identity verification information (such as verification code or two-factor authentication data). The registration request of user A is sent through a secure HTTPS or similar encrypted transmission protocol to ensure that the information in the registration process is not stolen.

[0032] During the registration process, the CG activates a key generation module to generate a pair of public and private keys locally on the device or on the server using a Hardware Security Module (HSM). The generated public key will be used for subsequent communication encryption, while the private key is stored in the user device or a protected hardware security module (such as a TEE, hardware security token, etc.) in a highly secure manner. After generation, only the private key of User A remains in the user device, while the public key is sent to the CG together with the user's registration information. After receiving the registration information and public key of User A, the Encryption Communication Hub records in the secure database: (1) the unique identity identifier of User A and the assigned address (for locating the user in the blockchain or internal system); (2) the public key of User A, which serves as the basis for subsequent encryption, authentication, and distributed key sharding operations.

[0033] The message receiver is similar to the message sender.

[0034] After registration, to facilitate subsequent message exchange, the CG establishes a point-to-point communication channel for User A and User B through a real-time network connection based on a secure channel (such as TLS / SSL).

[0035] User A adds User B by scanning a code or using an identifier. The CG prompts User B with a friend request from User A, and User B approves the friend request from User A to complete the connection.

[0036] S2. The message sender invokes the security module to generate the master key MK and divides the master key MK into n pieces through the Shamir threshold algorithm, where at least k pieces can recover the master key;

[0037] The message sender invokes the Hardware Security Module (HSM) to generate a 256-bit AES master key MK. After generation, the system uses the Shamir threshold algorithm to shard the master key MK. The master key MK is split into n parts (n key shards) through the algorithm, and it is set that at least k parts (k ≤ n) are required to recover the original MK. This sharding mechanism ensures that even if some shards are lost or maliciously stolen, an attacker cannot restore the MK with insufficient shards, thus greatly enhancing the key security.

[0038] In an optional implementation, before the S2, it further includes:

[0039] Dynamically calculate the sharding parameters n and k according to the number of consensus nodes on the blockchain network;

[0040] That is, before generating and sharding the master key MK, in order to better balance security and system performance, it is necessary to dynamically determine the sharding parameters n and k according to the number of consensus nodes on the current blockchain network. n represents the total number of pieces into which the master key is divided. k represents the minimum number of shards required to recover the master key.

[0041] If the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes.

[0042] k = floor(n / 2) + 1.

[0043] floor(n / 2) represents the operation of rounding down the result of n divided by 2. Generally, n is an odd number. When n = 5, k = 3; when n = 3, k = 2. This setting ensures that k is always greater than n / 2, and only by obtaining the "majority" of the shards can the master key MK be restored, thus effectively preventing attacks with insufficient malicious nodes (i.e., majority attacks) and improving the anti - attack ability of the entire system against key leakage and tampering.

[0044] Furthermore, the number of local shards is 1 less than the number of on - chain shards, and the sum of the number of local shards and the number of on - chain shards is n. When n = 5, the number of on - chain shards is 3, and the number of local shards is 2; when n = 3, the number of on - chain shards is 2, and the number of local shards is 1.

[0045] S3. The message sender locally encrypts some of the shards and stores them in the trusted execution environment TEE, and encrypts the other part of the shards with the public key of the message receiver and stores them on the blockchain network;

[0046] Local storage: The message sender encrypts a part of the key shards. Generally, the PBKDF2 - HMAC - SHA256 algorithm is used for the encryption process. After multiple iterations and salting, the security of the shard data is enhanced. The encrypted shards are stored in the trusted execution environment (TEE). TEE provides a secure isolation area to prevent data from being illegally accessed externally, and access to these encrypted shards requires verification through password checks and other means.

[0047] On - chain storage: The remaining part of the shards is encrypted with the public key of the message receiver B to ensure that only user B can decrypt the encrypted shards with its corresponding private key. The encrypted shards are then uploaded to the blockchain network.

[0048] Through the two - place storage of local and on - chain, even if one storage environment fails or is attacked, the other can still provide the necessary data to support the reconstruction of the master key. Local storage relies on the enhanced protection of TEE, while on - chain storage relies on asymmetric encryption, and only user B can decrypt it, ensuring that the key shards will not be illegally copied or misused.

[0049] Furthermore, the operation of encrypting the other part of the shards with the public key of the message receiver and storing them on the blockchain network also includes: storing the current key version on the blockchain network; the current key version is the version of the shard information of the master key MK.

[0050] Each time a new master key MK is generated and the sharding operation is performed, a unique "version number" needs to be assigned to the sharded data for that time.

[0051] S4. The message sender calls the security module to generate a temporary session key SK, encrypts the current message with the temporary session key SK to obtain the ciphertext, and stores it in the InterPlanetary File System IPFS; and encrypts the temporary session key SK with the master key MK to obtain the encrypted session key ESK.

[0052] Specifically, the message sender calls the security module to generate a temporary session key SK, which is usually also a 256-bit AES key. Using the generated SK, the current message body is encrypted to obtain the ciphertext; then, the ciphertext is uploaded to IPFS (InterPlanetary File System), and IPFS provides decentralized storage; further, after encrypting the current message with the temporary session key SK to obtain the ciphertext and storing it in IPFS, IPFS returns the ciphertext identifier to the message sender.

[0053] The message sender uses the pre-generated master key MK to encrypt the temporary session key SK to obtain the encrypted session key ESK.

[0054] Encrypting the message body with SK prevents the actual communication data from being directly exposed; while encrypting SK with MK forms an additional security layer, and only the legitimate message recipient who can recover MK can decrypt SK and thus decrypt the message. Using IPFS to store the ciphertext solves the problem that the blockchain is not suitable for storing large file data.

[0055] S5. The message sender stores the packaged data on the blockchain network and triggers an event notification through a smart contract to prompt the message recipient to obtain the current message; the packaged data includes: the address of the message recipient, the encrypted session key ESK.

[0056] Specifically, the message sender transmits the current message to the message recipient. After the transmission is completed, the message sender packs a set of key information as the packaged data, and the packaged data includes: the address of the message recipient, the encrypted session key ESK, the current key version, the ciphertext identifier, the current message hash.

[0057] The current message hash is the hash value generated by the message sender calculating the current message through the hash algorithm (SHA-3-256).

[0058] The packaged data is stored on the blockchain network by calling a smart contract. The notarization function of the blockchain ensures the non-forgery and traceability of the data.

[0059] At this time, there is a concept of on-chain events in the smart contract. The encrypted communication hub will listen for on-chain events. That is, when the encrypted communication hub detects that a message sender has initiated data packaging, it will automatically read the address of the message recipient of this record, and check whether there is such an address among the users registered in the encrypted communication hub. If there is, it will initiate an in-site message or email notification to the corresponding message recipient that a new message has arrived, reminding them to start the decryption process. If not, it will be ignored.

[0060] Storing evidence on the chain makes all key information public, transparent, and immutable, facilitating subsequent auditing and verification. The automatic event notification mechanism of the smart contract ensures that the message recipient can be informed of new messages in a timely manner, which is beneficial to the user experience and the system response efficiency.

[0061] S6. The message recipient obtains the packaged data and the encrypted shards stored on the blockchain network according to the event notification, and decrypts the encrypted shards with the private key of the message recipient to obtain key shards; the key shards are used to recover the master key MK by using the Shamir threshold algorithm;

[0062] Specifically, the message recipient B obtains the packaged data through the blockchain according to the smart contract notification. B also downloads the encrypted shards stored on the blockchain. Since these shards are encrypted with B's public key, B decrypts them with its own private key to obtain the original key shards.

[0063] After B collects a sufficient number of key shards (reaching the threshold k), the Shamir threshold algorithm is used to combine these shards to recover the original master key MK.

[0064] Through distributed storage and the threshold algorithm, it is ensured that only when a set number of key shards are reached can MK be recovered, protecting the key from being leaked by a single node.

[0065] S7. The message recipient decrypts the encrypted session key ESK with the master key MK to obtain the temporary session key SK; the message recipient obtains the ciphertext stored in the InterPlanetary File System (IPFS) and decrypts the ciphertext with the temporary session key SK to obtain the plaintext.

[0066] Specifically, after obtaining the master key MK, the message recipient decrypts the encrypted session key ESK stored in the blockchain-packaged data with MK to obtain the real temporary session key SK. This temporary session key is the direct key factor for encrypting the message body.

[0067] The message recipient obtains the ciphertext from the IPFS network according to the ciphertext identifier provided in the packaged data, and performs a symmetric decryption operation on the ciphertext with the obtained temporary session key SK, thereby restoring the original plaintext message.

[0068] Only by first restoring the MK and then decrypting the ESK with the MK to obtain the SK can the next step of ciphertext decryption be carried out. This process ensures that even if there are vulnerabilities in any layer of key management, attackers cannot directly steal the plaintext. The final message is only decrypted with the correct key at the legitimate message recipient, ensuring end-to-end communication privacy, while verifying the integrity and authenticity of the message through means of evidence preservation.

[0069] In an alternative embodiment, when the rotation trigger condition is met, the message sender calls the security module to generate a new master key MK and store it in a re-sharded manner to update the encrypted shards stored on the blockchain network;

[0070] The rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a timed task is triggered.

[0071] The system sets a fixed block height threshold (for example, every 100 blocks or a custom height interval). Once the height of the latest block on the blockchain reaches or exceeds this threshold, the system triggers the key rotation operation; this mechanism uses the continuously accumulating block height of the blockchain itself as a time reference to ensure that the key does not increase the exposure risk due to long-term use.

[0072] The system pre-sets a timed task (for example, every 10 minutes or at fixed time intervals) to detect whether the current time and the last rotation time meet the interval requirements. When the timed task is triggered, the system considers it an appropriate time to update the master key and related shards. Even if the block height may not have reached the preset threshold, a key update will be forced to achieve dynamic protection.

[0073] These two conditions can exist simultaneously or trigger the rotation operation when either of them is met, thus providing a flexible and reliable key update strategy for different situations.

[0074] When the rotation trigger condition is met, the message sender calls the security module to generate a new master key MK and store it in a re-sharded manner to update the encrypted shards stored on the blockchain network; at the same time, update the "current key version", and this version number identifies the new master key and its shard information generated by this rotation.

[0075] This dynamic key rotation mechanism based on trigger conditions not only enhances the overall security of message transmission but also ensures the consistency and correctness of shard information during the update process through key version management, effectively preventing security risks brought by long-term use of the same key.

[0076] In an alternative embodiment, after the S7, it further includes:

[0077] The message recipient calculates the hash value after decryption of the plaintext through a hash algorithm, and compares the decrypted hash value with the current message hash in the obtained packaged data. If they are consistent, it is confirmed that the current message has not been tampered with.

[0078] In an optional embodiment, S6 further includes:

[0079] The message recipient obtains the current key version in the packaged data, and compares the current key version in the packaged data with the version corresponding to the obtained encrypted shard. If they are consistent, it is confirmed that the current message has not been tampered with.

[0080] Figure 2 It is an end-to-end encrypted communication system based on blockchain provided by an embodiment of the present invention. As Figure 2 shown, the system includes:

[0081] An acquisition unit 201, configured to enable a message sender to obtain the public key and address of a message recipient through an encrypted communication hub;

[0082] A sharding unit 202, configured to enable a message sender to call a security module to generate a master key MK, and divide the master key MK into n shards through the Shamir threshold algorithm, where at least k shards can recover the master key;

[0083] A sharding encryption storage unit 203, configured to enable a message sender to locally encrypt and store some shards in a trusted execution environment TEE, and encrypt and store another part of the shards on a blockchain network using the public key of the message recipient;

[0084] A session key encryption unit 204, configured to enable a message sender to call a security module to generate a temporary session key SK, encrypt the current message through the temporary session key SK to obtain a ciphertext and store it in the InterPlanetary File System IPFS; and encrypt the temporary session key SK based on the master key MK to obtain an encrypted session key ESK;

[0085] An event notification unit 205, configured to enable a message sender to store packaged data on a blockchain network, and trigger an event notification through a smart contract to prompt the message recipient to obtain the current message; the packaged data includes: the address of the message recipient, the encrypted session key ESK;

[0086] A master key recovery unit 206, configured to enable a message recipient to obtain the packaged data and the encrypted shards stored on the blockchain network according to the event notification, and decrypt the encrypted shards according to the private key of the message recipient to obtain key shards; and recover the master key MK from the key shards using the Shamir threshold algorithm;

[0087] A decryption unit, for the message recipient to decrypt the encrypted session key ESK according to the master key MK to obtain a temporary session key SK; the message recipient obtains the ciphertext stored in the InterPlanetary File System (IPFS), and decrypts the ciphertext according to the temporary session key SK to obtain the plaintext.

[0088] In an optional embodiment,

[0089] When the rotation trigger condition is satisfied, the message sender calls the security module to generate a new master key MK and re-shard and store it to update the encrypted shards stored on the blockchain network;

[0090] The rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a timing task is triggered.

[0091] In an optional embodiment, the system further includes:

[0092] A sharding parameter calculation unit, for dynamically calculating sharding parameters n and k according to the number of consensus nodes on the blockchain network;

[0093] If the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes;

[0094] k = floor(n / 2)+1.

[0095] In an optional embodiment,

[0096] The storing the other part of the shards encrypted with the public key of the message recipient on the blockchain network further includes: storing the current key version on the blockchain network; the current key version is the version of the sharding information of the master key MK;

[0097] After encrypting the current message with the temporary session key SK to obtain the ciphertext and storing it in IPFS, IPFS returns the ciphertext identifier to the message sender;

[0098] The message recipient obtaining the ciphertext stored in the InterPlanetary File System (IPFS) includes: the message recipient obtaining the ciphertext stored in the InterPlanetary File System (IPFS) according to the ciphertext identifier;

[0099] The packaged data further includes: the current key version, the ciphertext identifier, the current message hash; the current message hash is the hash value generated by the message sender calculating the current message through the hash algorithm.

[0100] The system of the present invention corresponds to the above method, and the specific implementation manners of the system will not be repeated here.

[0101] Advantages of the present invention:

[0102] The present invention provides an end-to-end encrypted communication method and system based on blockchain. In this method, the master key MK is sharded through the Shamir threshold algorithm. Some shards are locally encrypted and stored in a trusted execution environment, while the other shards are encrypted with a public key and stored in the blockchain network. Even if a single point is leaked, it is not sufficient to recover the complete key. By adopting dynamic key rotation and distributed shard storage, combined with the event notification of smart contracts, when a user loses the key, they can recover the master key by obtaining a sufficient number of shards without the participation of a third-party institution, significantly improving efficiency and reducing costs. The present invention stores the encrypted result ESK of the session key SK on the blockchain for evidence, and stores the ciphertext through IPFS distributed storage. Utilizing the anti-tampering feature of blockchain and the decentralized feature of IPFS, it realizes secure encryption and privacy protection for the entire process. Through the dual trigger of block height and timing mechanism, new master keys can be generated regularly and re-sharded to effectively prevent the risk of being compromised due to the long-term use of the same key. The message sender uploads the hash value of the original message to the blockchain through a smart contract, and the receiver decrypts and calculates the hash and compares it with the record on the chain to immediately verify whether the message has been tampered with or intercepted, comprehensively improving the reliability of communication.

[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features. However, these modifications or replacements 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.

Claims

1. An end-to-end encrypted communication method based on blockchain, characterized in that Including: S1. The message sender obtains the public key and address of the message receiver through the encrypted communication hub; S2. The message sender calls the security module to generate the master key MK, and divides the master key MK into n pieces through the Shamir threshold algorithm, where at least k pieces can recover the master key; S3. The message sender locally encrypts and stores some of the shards in the trusted execution environment TEE, and encrypts the other part of the shards with the public key of the message receiver and stores them on the blockchain network; S4. The message sender calls the security module to generate a temporary session key SK, encrypts the current message with the temporary session key SK to obtain the ciphertext and stores it in the InterPlanetary File System IPFS; and encrypts the temporary session key SK based on the master key MK to obtain the encrypted session key ESK; S5. The message sender stores the packaged data on the blockchain network and triggers an event notification through a smart contract to prompt the message receiver to obtain the current message; the packaged data includes: the address of the message receiver, the encrypted session key ESK; S6. The message receiver obtains the packaged data and the encrypted shards stored on the blockchain network according to the event notification, and decrypts the encrypted shards with the private key of the message receiver to obtain the key shards; the key shards are used to recover the master key MK through the Shamir threshold algorithm; S7. The message receiver decrypts the encrypted session key ESK according to the master key MK to obtain the temporary session key SK; the message receiver obtains the ciphertext stored in the InterPlanetary File System IPFS and decrypts the ciphertext with the temporary session key SK to obtain the plaintext.

2. The method according to claim 1, wherein: When the rotation trigger condition is satisfied, the message sender calls the security module to generate a new master key MK and re-shards and stores it to update the encrypted shards stored on the blockchain network; The rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a scheduled task is triggered.

3. The method according to claim 1, characterized in that, Before the S2, it further includes: Dynamically calculating the sharding parameters n and k according to the number of consensus nodes on the blockchain network; If the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes; k = floor(n / 2)+1.

4. The method according to claim 1, wherein: The step of encrypting the other part of the shards with the public key of the message receiver and storing them on the blockchain network further includes: storing the current key version on the blockchain network; the current key version is the sharding information version of the master key MK; After encrypting the current message with the temporary session key SK and storing it in the InterPlanetary File System IPFS, the InterPlanetary File System IPFS returns a ciphertext identifier to the message sender; The step that the message receiver obtains the ciphertext stored in the InterPlanetary File System IPFS includes: the message receiver obtains the ciphertext stored in the InterPlanetary File System IPFS according to the ciphertext identifier; The packed data further includes: the current key version, the ciphertext identifier, and the current message hash; the current message hash is the hash value generated by the message sender by calculating the current message through a hash algorithm.

5. The method according to claim 4, characterized in that, After the S7, it further includes: The message receiver calculates the hash value of the decrypted plaintext through a hash algorithm, and compares the decrypted hash value with the current message hash in the obtained packed data. If they are the same, it is confirmed that the current message has not been tampered with.

6. The method according to claim 1, characterized in that Before the S1, it includes: The message sender submits registration information to the encryption communication hub and generates a public-private key pair for the message sender; the message receiver submits registration information to the encryption communication hub and generates a public-private key pair for the message receiver; The encryption communication hub records the addresses of the message sender and the message receiver, and retains the public keys of the message sender and the message receiver; The message sender and the message receiver establish a connection through the encryption communication hub.

7. An end-to-end encrypted communication system based on blockchain, characterized in that, It includes: An acquisition unit, used for the message sender to obtain the public key and address of the message receiver through the encryption communication hub; A sharding unit, used for the message sender to call the security module to generate the master key MK, and divide the master key MK into n pieces through the Shamir threshold algorithm, where at least k pieces can recover the master key; A sharding encryption storage unit, used for the message sender to locally encrypt and store some shards in the trusted execution environment TEE, and encrypt and store the other part of the shards on the blockchain network using the public key of the message receiver; A session key encryption unit, used for the message sender to call the security module to generate a temporary session key SK, encrypt the current message through the temporary session key SK to obtain the ciphertext and store it in the InterPlanetary File System IPFS; And encrypt the temporary session key SK based on the master key MK to obtain the encrypted session key ESK; An event notification unit, used for the message sender to store the packed data on the blockchain network and trigger an event notification through a smart contract to prompt the message receiver to obtain the current message; the packed data includes: the address of the message receiver, the encrypted session key ESK; A master key recovery unit, used for the message receiver to obtain the packed data and the encrypted shards stored on the blockchain network according to the event notification, and decrypt the encrypted shards according to the private key of the message receiver to obtain the key shards; recover the master key MK from the key shards using the Shamir threshold algorithm; A decryption unit, used for the message receiver to decrypt the encrypted session key ESK according to the master key MK to obtain the temporary session key SK; the message receiver obtains the ciphertext stored in the InterPlanetary File System IPFS, and decrypts the ciphertext according to the temporary session key SK to obtain the plaintext.

8. The system according to claim 7, wherein: When the rotation trigger condition is met, the message sender calls the security module to generate a new master key MK and re-shards and stores it to update the encrypted shards stored on the blockchain network; The rotation trigger condition includes: the blockchain height reaches a preset threshold and / or a timed task is triggered.

9. The system according to claim 7, wherein It further includes: A sharding parameter calculation unit, configured to dynamically calculate sharding parameters n and k according to the number of consensus nodes on the blockchain network; If the number of consensus nodes is greater than 5, then n = 5; if the number of consensus nodes is less than or equal to 5, then n is the number of consensus nodes; k = floor(n / 2)+1.

10. The system according to claim 7, wherein: The storing of the other part of the shards encrypted with the public key of the message recipient on the blockchain network further includes: storing the current key version on the blockchain network; the current key version is the shard information version of the master key MK; After encrypting the current message with the temporary session key SK and storing it in the InterPlanetary File System IPFS, the InterPlanetary File System IPFS returns a ciphertext identifier to the message sender; The message recipient obtaining the ciphertext stored in the InterPlanetary File System IPFS includes: the message recipient obtaining the ciphertext stored in the InterPlanetary File System IPFS according to the ciphertext identifier; The packaged data further includes: the current key version, the ciphertext identifier, the current message hash; the current message hash is the hash value generated by the message sender calculating the current message through a hash algorithm.

Citation Information

Cited By

  • Intelligent Internet of Things equipment storage data transmission system and method based on block chain

    CN121036946A