Data transmission method, device, medium and equipment based on blockchain
The data is transmitted on the blockchain through the proxy re-encryption algorithm, which solves the problem of risk in the key transmission process and achieves high security and traceability of the data.
Patent Information
- Application Number
- CN202211012710.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-08-23
AI Technical Summary
When transmitting data on a blockchain, when encrypting data with a symmetric key, there is a risk of being stolen during key transmission, resulting in low data security.
The data to be transmitted is encrypted through the proxy re-encryption algorithm, encrypted data and encryption capsules are generated, and point-to-point transmission is used by blockchain, and decrypted by designated personnel to avoid key transmission and improve data security.
Reduces the risk of key theft, improves data security, and enables point-to-point transmission and data traceability in blockchain networks.
Smart Images

Figure CN115396179B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a blockchain-based data transmission method, a blockchain-based data transmission device, a computer-readable storage medium, and an electronic device. Background Art
[0002] With the application and development of blockchain technology, it is particularly important to encrypt the data written to the blockchain. Data encryption refers to the conversion of plain text into cipher text through encryption algorithms and encryption keys. It is a way to protect information, which can achieve the function of information concealment and play a role in protecting information security.
[0003] Taking data transmission encryption as an example, by encrypting the data stream in transmission, data leakage in the storage link can be prevented. Usually, data can be encrypted with a fixed symmetric key and the encrypted data can be uploaded to the blockchain. However, when using a symmetric key to encrypt data, the key needs to be transmitted. There is a risk of the key being stolen during transmission, resulting in low data security.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The purpose of the present disclosure is to provide a blockchain-based data transmission method, a blockchain-based data transmission device, a computer-readable storage medium, and an electronic device, thereby overcoming to a certain extent the problem of low data security when transmitting data on the blockchain due to the limitations and defects of related technologies.
[0006] According to a first aspect of the present disclosure, a blockchain-based data transmission method is provided, comprising:
[0007] Based on the private key of the first user and the public key of the second user, encrypt the data to be transmitted by using a proxy re-encryption algorithm to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user;
[0008] Uploading the encrypted data and the encrypted capsule to the blockchain;
[0009] When the first user triggers a sending event to the second user, the encrypted data and the encrypted capsule are sent to the second user through the blockchain;
[0010] Based on the private key of the second user and the encryption capsule, the encrypted data is decrypted by using the proxy re-encryption algorithm to obtain the data to be transmitted.
[0011] In an exemplary embodiment of the present disclosure, before encrypting the data to be transmitted by using a proxy re-encryption algorithm, the method further includes:
[0012] When the first user sends the data to be transmitted to the second user, the public key of the second user sent by the first user is received, where the public key of the second user is obtained by the first user from the blockchain according to the unique identifier of the second user.
[0013] In an exemplary embodiment of the present disclosure, the encryption capsule includes a first encryption capsule and a second encryption capsule; the data to be transmitted is encrypted by a proxy re-encryption algorithm based on a private key of the first user and a public key of the second user to obtain encrypted data and the encryption capsule, and the method further includes:
[0014] Based on the private key of the first user and the public key of the second user, a proxy key is generated by a proxy re-encryption algorithm, wherein the proxy key includes a proxy private key and a proxy public key;
[0015] Based on the public key of the first user and the proxy private key, the data to be transmitted is encrypted by the proxy re-encryption algorithm to obtain the encrypted data, the first encrypted capsule and the second encrypted capsule.
[0016] In an exemplary embodiment of the present disclosure, encrypting the data to be transmitted by using the proxy re-encryption algorithm based on the public key of the first user and the proxy private key to obtain the encrypted data, the first encryption capsule and the second encryption capsule includes:
[0017] Based on the public key of the first user, encrypt the data to be transmitted by using the proxy re-encryption algorithm to obtain the encrypted data and the first encryption capsule;
[0018] Based on the proxy private key, the first encrypted capsule is encrypted by the proxy re-encryption algorithm to generate the second encrypted capsule.
[0019] In an exemplary embodiment of the present disclosure, encrypting the data to be transmitted by using the proxy re-encryption algorithm based on the public key of the first user to obtain the encrypted data and the first encryption capsule includes:
[0020] Encrypting the first user's public key by using the proxy re-encryption algorithm to obtain an encryption key and the first encryption capsule;
[0021] The data to be transmitted is encrypted according to the encryption key and a preset encryption algorithm to obtain the encrypted data.
[0022] In an exemplary embodiment of the present disclosure, uploading the encrypted data and the encrypted capsule to the blockchain includes:
[0023] The encrypted data, the proxy public key and the second encrypted capsule are uploaded to the blockchain.
[0024] In an exemplary embodiment of the present disclosure, when the first user triggers a sending event to the second user, sending the encrypted data and the encrypted capsule to the second user through the blockchain includes:
[0025] When the first user triggers a sending event to the second user, the encrypted data, the proxy public key and the second encrypted capsule are sent to the second user through the blockchain.
[0026] In an exemplary embodiment of the present disclosure, the decrypting the encrypted data by the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted includes:
[0027] Based on the private key of the second user and the proxy public key, decrypting the second encrypted capsule by the proxy re-encryption algorithm to obtain a decryption key;
[0028] The encrypted data is decrypted according to the decryption key and the preset decryption algorithm to obtain the data to be transmitted, and the data to be transmitted is sent to the second user.
[0029] According to a second aspect of the present disclosure, there is provided a blockchain-based data transmission device, comprising:
[0030] a proxy encryption module, configured to encrypt the data to be transmitted by a proxy re-encryption algorithm based on a private key of a first user and a public key of a second user to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user;
[0031] A first data transmission module, used to upload the encrypted data and the encrypted capsule to the blockchain;
[0032] A second data transmission module, configured to send the encrypted data and the encrypted capsule to the second user through the blockchain when the first user triggers a sending event to the second user;
[0033] The proxy decryption module is used to decrypt the encrypted data through the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted.
[0034] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, any one of the methods described above is implemented.
[0035] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods by executing the executable instructions.
[0036] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0037] In the data transmission method based on blockchain provided in the exemplary embodiment of the present disclosure, based on the private key of the first user and the public key of the second user, the data to be transmitted is encrypted by a proxy re-encryption algorithm to obtain encrypted data and encrypted capsules; the encrypted data and encrypted capsules are uploaded to the blockchain; when the first user triggers a sending event to the second user, the encrypted data and encrypted capsules are sent to the second user through the blockchain; based on the private key and encrypted capsule of the second user, the encrypted data is decrypted by a proxy re-encryption algorithm to obtain the data to be transmitted. On the one hand, by using an asymmetric encryption key to encrypt the data to be transmitted, there is no need to transmit the key during the data transmission process, which reduces the risk of the key being stolen and improves the security of the data; on the other hand, by using a proxy re-encryption algorithm to encrypt the data to be transmitted, the data can be decrypted and viewed by a designated person, which further improves the security of the data, and realizes point-to-point data transmission in the blockchain network, and can ensure the traceability of the data.
[0038] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0040] Figure 1 A schematic diagram showing an exemplary system architecture of a blockchain-based data transmission method and device to which the embodiments of the present disclosure can be applied;
[0041] Figure 2 A flowchart of a blockchain-based data transmission method according to an embodiment of the present disclosure is schematically shown;
[0042] Figure 3 Schematically shows a flow chart of encrypting data by a proxy re-encryption algorithm according to an embodiment of the present disclosure;
[0043] Figure 4 Schematically shows a flow chart of decrypting data by a proxy re-encryption algorithm according to an embodiment of the present disclosure;
[0044] Figure 5 A flowchart of a blockchain-based data transmission method according to another embodiment of the present disclosure is schematically shown;
[0045] Figure 6 A block diagram of a blockchain-based data transmission device according to an embodiment of the present disclosure is schematically shown;
[0046] Figure 7 The structure diagram of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0047] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0048] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0049] Figure 1 A schematic diagram of an exemplary system architecture of a blockchain-based data transmission method and device to which an embodiment of the present disclosure can be applied is shown.
[0050] like Figure 1 As shown, when the first user transmits data to the second user, the data transmission system architecture 100 may include terminal devices 101 and 103, servers 102 and 104, a proxy server 105, and a blockchain network 106. Among them, the terminal device 101 may be a first user terminal device, and the terminal device 103 may be a second user terminal device. The terminal devices 101 and 103 may be various electronic devices with display screens, including but not limited to desktop computers, portable computers, smart phones, tablet computers, and the like. Correspondingly, the terminal device 101 may also be a second user terminal device, and the terminal device 103 may be a first user terminal device, which is not limited in the present disclosure. The server 102 communicates with the terminal device 101 through a network, and the server 104 communicates with the terminal device 103 through a network, and the network may include various connection types, such as wired, wireless communication links, or optical fiber cables, and the like. The proxy server 105 is used to encrypt and decrypt data of the terminal device 101 and the terminal device 103. The blockchain network 106 is used to store and forward encrypted data to achieve point-to-point data transmission. It should be understood that Figure 1 The number of terminal devices 101 and 103, servers 102, 104 and proxy servers 105 is only for illustration. Any number of terminal devices, networks and servers may be provided as required. For example, server 105 may be a server cluster composed of multiple servers, or a cloud computing platform or a virtualization center.
[0051] Specifically, the data transmission method based on blockchain provided in the embodiment of the present disclosure is generally executed by the proxy server 105. Accordingly, the data transmission device based on blockchain is generally set in the proxy server 105. The proxy server 105 can encrypt the plaintext data sent by the terminal device 101 through the proxy re-encryption algorithm, and upload the obtained encrypted data to the blockchain. When the terminal device 101 triggers a sending event to the terminal device 103, the proxy server 105 can obtain the encrypted data from the blockchain, decrypt the encrypted data through the proxy re-encryption algorithm, obtain the corresponding plaintext data, and send the plaintext data to the terminal device 103, and then the terminal device 103 displays it to the user. However, it is easy for those skilled in the art to understand that the data transmission method based on blockchain provided in the embodiment of the present disclosure can also be executed by the server 102 or 104, and this is not particularly limited in this exemplary embodiment.
[0052] The technical solution of the embodiment of the present disclosure is described in detail below:
[0053] At present, most of the data stored in the blockchain is in plain text. Due to the decentralized nature of the blockchain, any user can view the data in the blockchain at will, and the data security is low. Alternatively, data is encrypted using a fixed symmetric key and the encrypted data is uploaded to the blockchain. However, when using a symmetric key to encrypt data, the key needs to be transmitted. There is a risk of the key being stolen during transmission, and the data security is still low.
[0054] Based on one or more of the above problems, this example implementation provides a blockchain-based data transmission method, which can be applied to the above proxy server 105, or to the above server 102 or 104, and this example implementation does not make any special restrictions on this. Figure 2 As shown, the blockchain-based data transmission method may include the following steps S210 to S240:
[0055] Step S210. Based on the private key of the first user and the public key of the second user, encrypt the data to be transmitted by using a proxy re-encryption algorithm to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user;
[0056] Step S220. Upload the encrypted data and the encrypted capsule to the blockchain;
[0057] Step S230. When the first user triggers a sending event to the second user, the encrypted data and the encrypted capsule are sent to the second user via the blockchain;
[0058] Step S240: Based on the private key of the second user and the encryption capsule, the encrypted data is decrypted by the proxy re-encryption algorithm to obtain the data to be transmitted.
[0059] In the data transmission method based on blockchain provided in the exemplary embodiment of the present disclosure, based on the private key of the first user and the public key of the second user, the data to be transmitted is encrypted by a proxy re-encryption algorithm to obtain encrypted data and encrypted capsules; the encrypted data and encrypted capsules are uploaded to the blockchain; when the first user triggers a sending event to the second user, the encrypted data and encrypted capsules are sent to the second user through the blockchain; based on the private key and encrypted capsule of the second user, the encrypted data is decrypted by a proxy re-encryption algorithm to obtain the data to be transmitted. On the one hand, by using an asymmetric encryption key to encrypt the data to be transmitted, there is no need to transmit the key during the data transmission process, which reduces the risk of the key being stolen and improves the security of the data; on the other hand, by using a proxy re-encryption algorithm to encrypt the data to be transmitted, the data can be decrypted and viewed by a designated person, which further improves the security of the data, and realizes point-to-point data transmission in the blockchain network, and can ensure the traceability of the data.
[0060] Next, the above steps of this exemplary embodiment are described in more detail.
[0061] In step S210, the data to be transmitted is encrypted by a proxy re-encryption algorithm based on the private key of the first user and the public key of the second user to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user.
[0062] In the example implementation of the present disclosure, when the first user and the second user transmit data through the blockchain, the first user and the second user can monitor the sending event in the blockchain. For example, when the sending event belonging to the first user is triggered, the first user can obtain data from the blockchain in real time. Taking the first user sending data to the second user as an example, the corresponding data to be transmitted is the plaintext data sent by the first user to the second user.
[0063] Before the first user sends data to the second user, the first user and the second user can respectively apply to the proxy server for a corresponding key pair, which includes a private key and a public key. For example, if the first user is user A and the second user is user B, when user A and user B apply to the proxy server for their respective key pairs, the proxy server can generate user A's private key sk A and public key pk A , User B's private key sk B and public key pk BFor example, the proxy server may generate the key pair sk and pk by using the ECDSA (Elliptic Curve Digital Signature Algorithm) algorithm. The ECDSA algorithm refers to randomly selecting a point G on a curve as a reference point. For example, the curve may be y 2 =x 3 +ax+b, then select a random number k, such as 20 bytes, and use the random number k as the private key sk. Further, the second point P on the curve can be calculated using the random number k and the reference point G, for example, P = k × G, and the horizontal coordinate of point P is the public key pk.
[0064] After the proxy server generates the key pair of user A and user B, it can return the key pair of user A to user A and the key pair of user B to user B. Then, the proxy server can use the unique identifier uid of user A to identify the user B. A is the key, the public key pk A As value, the public key pk of user A is converted into A Stored on the blockchain. Exemplarily, a smart contract can be pre-written and deployed on the blockchain, and the public key of each user can be stored according to the smart contract. Among them, a smart contract refers to a computer program that drives the execution of instructions based on established conditions and transmitted information. Smart contracts can be written in programming languages such as Solidity (a programming language for writing smart contracts, running on the Ethereum virtual machine), LLL (a Python-like language), etc. Smart contracts can contain different functions, events, parameter states, etc. It is understandable that smart contracts can be deployed on different blockchains such as public chains and consortium chains, and the present disclosure does not make specific limitations on this. Similarly, user B’s unique identifier uid can be used B is the key, the public key pk B As value, the public key pk of user B is converted into B Stored on the blockchain. Therefore, the public key of the user can be obtained from the blockchain based on the user's unique identifier. It should be noted that the unique identifier of user A, uidA, and the unique identifier of user B, uidB, are public, that is, user A can obtain the unique identifier of user B, uidB, and user B can also obtain the unique identifier of user A, uidA.
[0065] When the first user sends data to be transmitted to the second user, point-to-point data transmission can be performed on the blockchain through a proxy re-encryption algorithm. Among them, the proxy re-encryption algorithm is an encryption method that can securely convert ciphertext, and can convert the ciphertext uploaded by the first user using the first user's public key into another form of ciphertext, and keep the corresponding plaintext unchanged, so that the second user can use his private key to decrypt the converted ciphertext. The ciphertext conversion process is performed by a semi-trusted agent, and the agent in the example implementation of the present disclosure can be a proxy server. Before executing the ciphertext conversion process, the agent needs to hold a conversion key from the first user to the second user. No plaintext information will be leaked during the entire ciphertext conversion process, which can ensure secure access and sharing of blockchain data.
[0066] In an example implementation, before encrypting the data to be transmitted by the proxy re-encryption algorithm, the proxy server may receive the public key of the second user sent by the first user, where the public key of the second user is read by the first user from the blockchain according to the unique identifier of the second user. For example, when user A sends the data to be transmitted M to user B, the unique identifier uid of user B may be obtained first. B , and based on the unique identifier uid of user B B Read user B’s public key pk from the blockchain B . Get user B's public key pk B After that, the proxy server can use user A's private key sk A and user B's public key pk B , the data to be transmitted M is encrypted by the proxy re-encryption algorithm to obtain the encrypted data and the encryption capsule. The encryption capsule contains the information for regenerating a new key during decryption, provided that a valid private key is provided.
[0067] The encryption capsule may include a first encryption capsule and a second encryption capsule. Figure 3 As shown, the data to be transmitted can be encrypted by a proxy re-encryption algorithm according to step S310 and step S320.
[0068] Step S310: Based on the private key of the first user and the public key of the second user, a proxy key is generated through a proxy re-encryption algorithm, where the proxy key includes a proxy private key and a proxy public key.
[0069] For example, the first user is user A, and the second user is user B. The private key sk of user A can be A and user B's public key pk B The proxy re-encryption algorithm generates a new encryption key, namely the proxy key, with the proxy re-encryption algorithm as the parameter. The proxy key includes the proxy private key and the proxy public key.
[0070] Specifically, user A can use the private key sk A and user B's public key pk B The proxy server can use the re-encryption formula (1) to encrypt the private key sk of user A. A and user B's public key pk B Calculate and obtain the proxy private key rk and proxy public key rp, where the proxy public key rp is a new public key obtained by the ECDSA algorithm, and the proxy public key rp and public key pk B , pk B different.
[0071] ReKeyGen(sk A , pk B ):
[0072]
[0073] in, represents a finite integer of order p, x A is a random number, g can be the generator of the ECDSA algorithm, correspondingly, X A To use the random number x A The calculated point on the curve, H is the hash function, and the calculated rk is a large integer, such as 818549944696221855..., pk B It is a structured data.
[0074] Step S320: Based on the public key of the first user and the proxy private key, the data to be transmitted is encrypted by the proxy re-encryption algorithm to obtain the encrypted data, the first encrypted capsule and the second encrypted capsule.
[0075] After the proxy private key is generated, the data to be transmitted can be encrypted using the proxy re-encryption algorithm based on the public key of the first user to obtain the encrypted data and the first encryption capsule. Aand the data to be transmitted M as parameters, and encrypted by a proxy re-encryption algorithm to obtain encrypted data DM and intermediate data, where the intermediate data is the first encryption capsule. For another example, the public key of the first user can be encrypted by a proxy re-encryption algorithm to obtain an encryption key and a first encryption capsule. Then, the data to be transmitted can be encrypted according to the encryption key and a preset encryption algorithm to obtain encrypted data. Among them, the preset encryption algorithm can be an AES (Advanced Encryption Standard) encryption algorithm, an RSA (Rivest-Shamir-Adleman, an encryption algorithm) encryption algorithm, an ECC (Elliptic Curves Cryptography, elliptic curve cryptography) encryption algorithm, etc., and the present disclosure does not make specific limitations on this.
[0076] For example, the public key pk of user A can be A The encryption key key and the first encryption capsule capsule 1 are calculated by the re-encryption algorithm. Then, the encryption key key can be used to encrypt the data M to be transmitted by the encryption algorithm, such as using the AES encryption algorithm to encrypt the data M to be transmitted to obtain the encrypted data DM, the encrypted data DM is a byte array, and the first encryption capsule capsule 1 is a structured data containing public key information.
[0077] After the first encrypted capsule is generated, the first encrypted capsule can be further encrypted by a proxy re-encryption algorithm based on the proxy private key to generate a second encrypted capsule. For example, the proxy private key rk and the first encrypted capsule capsule1 can be used as parameters to encrypt by a proxy re-encryption algorithm to generate new intermediate data, namely, the second encrypted capsule capsule2. It can be understood that the first encrypted capsule capsule1 and the second encrypted capsule capsule2 are structured data with the same structure but different values.
[0078] Specifically, the proxy server may calculate the proxy private key rk and the first encryption capsule capsule1 according to the re-encryption formula (2) to obtain the second encryption capsule capsule2.
[0079] ReEncrption(rk, capsule1):
[0080] capsule1=(E,V,s)
[0081] E′=E rk , V′=V rk (2)
[0082] capsule2=(E′,V′,s)
[0083] Among them, E, V, and s are the three parameters in the first encryption capsule capsule1, and E and V are the public key pk obtained by user A. A The two keys obtained by encapsulation, s is the shared key. The proxy private key rk is used to calculate E and V respectively to obtain E' and V', and E', V' and s are recombined to obtain the second encryption capsule capsule2. It can be seen that the first encryption capsule capsule1 and the second encryption capsule capsule2 have the same structure, but contain different data.
[0084] In this example, an asymmetric encryption key is used to encrypt the data to be transmitted, so that the key does not need to be transmitted during the data transmission process, which reduces the risk of the key being stolen and improves the security of the data.
[0085] In step S220, the encrypted data and the encrypted capsule are uploaded to the blockchain.
[0086] After the data to be transmitted is encrypted, the encrypted data DM, the proxy public key rp, and the second encryption capsule capsule2 can be uploaded to the blockchain through the smart contract.
[0087] In step S230, when the first user triggers a sending event to the second user, the encrypted data and the encrypted capsule are sent to the second user through the blockchain.
[0088] When the first user triggers a sending event to the second user, the encrypted data, the proxy public key, and the second encrypted capsule can be sent to the second user through the blockchain. For example, when user A triggers a sending event to user B, the structured data can be packaged and sent to user B through the event. For example, a response message can be created through a smart contract, and the encrypted data DM, the proxy public key rp, and the second encrypted capsule capsule2 can be replied to user B through the response message, so that after user B receives the response message from user A, he can use his private key sk B Decrypt.
[0089] In step S240, the encrypted data is decrypted by the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted.
[0090] In an example implementation, the second encryption capsule, the proxy public key, and the encrypted data can be obtained at the same time. Then, the encrypted data can be decrypted by the proxy re-encryption algorithm based on the second user's private key, the second encryption capsule, and the proxy public key. For example, after user B reads the structure data from the sending event, he can use the private key sk B, encrypted data DM, public key rp and the second encryption capsule capsule2 are used as parameters, and the encrypted data DM is decrypted through the proxy re-encryption algorithm to obtain the data M to be transmitted.
[0091] Exemplary, reference Figure 4 As shown, the data to be transmitted can be decrypted by a proxy re-encryption algorithm according to step S410 and step S420.
[0092] Step S410: Based on the private key of the second user and the proxy public key, the second encrypted capsule is decrypted by the proxy re-encryption algorithm to obtain a decryption key.
[0093] For example, user B's private key sk can be used B , public key rp and the second encrypted capsule capsule2, decrypted by the proxy re-encryption algorithm to obtain the decryption key key. Specifically, the proxy server can use user B's private key sk B , public key rp, calculate the second encrypted capsule capsule2 according to the re-encryption formula (3) to obtain the decryption key key. The decryption key key can be the same as the encryption key key in step S320.
[0094]
[0095] Wherein, E′ and V′ are two parameters in the second encryption capsule capsule2, d is the decryption parameter obtained by hash operation, and G is the key generation algorithm, such as AES symmetric encryption function, including symmetric encryption algorithm encryption function ε AES And the symmetric encryption algorithm decryption function D AES .
[0096] Step S420: Decrypt the encrypted data according to the decryption key and the preset decryption algorithm to obtain the data to be transmitted, and send the data to be transmitted to the second user.
[0097] After obtaining the decryption key, the decryption key key can be used to decrypt the encrypted data DM through a preset decryption algorithm to obtain the data to be transmitted M. The preset decryption algorithm can be an AES encryption algorithm, an RSA encryption algorithm, an ECC encryption algorithm, etc., which is not specifically limited in the present disclosure.
[0098] Specifically, the proxy server can calculate the encrypted data DM according to the decryption formula (4) to obtain the data to be transmitted M, which is:
[0099] M=D AES (DM, key) (4)
[0100] In this example, blockchain data is encrypted using an asymmetric encryption key, and relevant personnel can be designated to decrypt it, which not only ensures the privacy of blockchain data, but also ensures that relevant personnel can view the data. At the same time, during the data transmission process, there is no need to transmit the private key, which further ensures the security of the data.
[0101] In one example implementation, reference is made to Figure 5 As shown, point-to-point data transmission can be performed on the blockchain according to steps S501 to S514.
[0102] Step S501. The proxy server generates a key pair sk for user A A and pk A , and sk A and pk A Send to end A;
[0103] Step S502. End A uses a smart contract to A Upload to blockchain;
[0104] Step S503. The proxy server generates a key pair sk for user B B and pk B , and sk B and pk B Send to end B;
[0105] Step S504.B uses smart contract to convert pk B Upload to blockchain;
[0106] Step S505. When the blockchain monitors that end A sends data M to end B, obtain pk B ;
[0107] Step S506. Set pk B ,sk A Sending a proxy server so that the proxy server encrypts and transmits the data M;
[0108] Step S507. The proxy server will pk B ,sk A Encrypt through the proxy re-encryption algorithm to obtain rk and rp;
[0109] Step S508. The proxy server will pk A , data M is encrypted by the proxy re-encryption algorithm to obtain DM and capsule1;
[0110] Step S509. The proxy server encrypts rk and capsule1 using a proxy re-encryption algorithm to generate capsule2;
[0111] Step S510. Upload the obtained DM, rp, and capsule2 to the blockchain;
[0112] Step S511. When the A terminal triggers a sending event to the B terminal, DM, rp, and capsule2 are sent to the B terminal;
[0113] Step S512. Terminal B sends DM, rp, and capsule2 to the proxy server;
[0114] Step S513. The proxy server decrypts DM, rp, and capsule2 using a proxy re-encryption algorithm to obtain data M;
[0115] Step S514. The proxy server sends the data M to the B end, completing the data transmission from the A end to the B end based on the blockchain.
[0116] In this example, the proxy server converts user A's ciphertext into ciphertext that can be decrypted by user B without leaking user A's private key and plaintext information, thus achieving end-to-end data transmission. Without transmitting the private key, the proxy re-encryption algorithm is used to transmit data point-to-point in the blockchain network, which can ensure both the traceability and security of the data.
[0117] In the data transmission method based on blockchain provided in the exemplary embodiment of the present disclosure, based on the private key of the first user and the public key of the second user, the data to be transmitted is encrypted by a proxy re-encryption algorithm to obtain encrypted data and encrypted capsules; the encrypted data and encrypted capsules are uploaded to the blockchain; when the first user triggers a sending event to the second user, the encrypted data and encrypted capsules are sent to the second user through the blockchain; based on the private key and encrypted capsule of the second user, the encrypted data is decrypted by a proxy re-encryption algorithm to obtain the data to be transmitted. On the one hand, by using an asymmetric encryption key to encrypt the data to be transmitted, there is no need to transmit the key during the data transmission process, which reduces the risk of the key being stolen and improves the security of the data; on the other hand, by using a proxy re-encryption algorithm to encrypt the data to be transmitted, the data can be decrypted and viewed by a designated person, which further improves the security of the data, and realizes point-to-point data transmission in the blockchain network, and can ensure the traceability of the data.
[0118] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0119] Furthermore, in this exemplary embodiment, a data transmission device based on blockchain is also provided, which can be applied to a server or a terminal device. Figure 6 As shown, the blockchain-based data transmission device 600 may include a proxy encryption module 610, a first data transmission module 620, a second data transmission module 630 and a proxy decryption module 640, wherein:
[0120] A proxy encryption module 610 is used to encrypt the data to be transmitted by a proxy re-encryption algorithm based on the private key of the first user and the public key of the second user to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user;
[0121] A first data transmission module 620, configured to upload the encrypted data and the encrypted capsule to the blockchain;
[0122] A second data transmission module 630, configured to send the encrypted data and the encrypted capsule to the second user through the blockchain when the first user triggers a sending event to the second user;
[0123] The proxy decryption module 640 is configured to decrypt the encrypted data by using the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted.
[0124] In an optional implementation, the blockchain-based data transmission device 600 further includes:
[0125] A public key acquisition module is used to receive the public key of the second user sent by the first user when the first user sends the data to be transmitted to the second user, where the public key of the second user is obtained by the first user from the blockchain according to the unique identifier of the second user.
[0126] In an optional implementation, the encryption capsule includes a first encryption capsule and a second encryption capsule; the proxy encryption module 610 includes:
[0127] A first proxy encryption module, configured to generate a proxy key based on a private key of the first user and a public key of the second user through a proxy re-encryption algorithm, wherein the proxy key includes a proxy private key and a proxy public key;
[0128] The second proxy encryption module is used to encrypt the data to be transmitted by the proxy re-encryption algorithm based on the public key of the first user and the proxy private key to obtain the encrypted data, the first encryption capsule and the second encryption capsule.
[0129] In an optional implementation, the second proxy encryption module includes:
[0130] a first proxy encryption unit, configured to encrypt the data to be transmitted by using the proxy re-encryption algorithm based on the public key of the first user to obtain the encrypted data and the first encryption capsule;
[0131] The second proxy encryption unit is configured to encrypt the first encryption capsule by using the proxy re-encryption algorithm based on the proxy private key to generate the second encryption capsule.
[0132] In an optional implementation, the first proxy encryption unit includes:
[0133] A first proxy encryption subunit, configured to encrypt the first user's public key by using the proxy re-encryption algorithm to obtain an encryption key and the first encryption capsule;
[0134] The second proxy encryption subunit is used to encrypt the data to be transmitted according to the encryption key and a preset encryption algorithm to obtain the encrypted data.
[0135] In an optional implementation, the first data transmission module 620 is configured to upload the encrypted data, the proxy public key and the second encrypted capsule to the blockchain.
[0136] In an optional implementation, the second data transmission module 630 is configured to send the encrypted data, the proxy public key and the second encrypted capsule to the second user through the blockchain when the first user triggers a sending event to the second user.
[0137] In an optional implementation, the proxy decryption module 640 includes:
[0138] A first proxy decryption module, configured to decrypt the second encrypted capsule using the proxy re-encryption algorithm based on the second user's private key and the proxy public key to obtain a decryption key;
[0139] The second proxy decryption module is used to decrypt the encrypted data according to the decryption key and the preset decryption algorithm to obtain the data to be transmitted, and send the data to be transmitted to the second user.
[0140] The specific details of each module in the above-mentioned blockchain-based data transmission device have been described in detail in the corresponding blockchain-based data transmission method, so they will not be repeated here.
[0141] Each module in the above device can be a general-purpose processor, including: a central processing unit, a network processor, etc.; it can also be a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each module can also be implemented in the form of software, firmware, etc. Each processor in the above device can be an independent processor or integrated together.
[0142] The exemplary embodiments of the present disclosure also provide a computer-readable storage medium on which a program product capable of implementing the above-mentioned method of this specification is stored. In some possible embodiments, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on an electronic device, the program code is used to cause the electronic device to perform the steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "exemplary method" section of this specification. The program product may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on an electronic device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, an apparatus or a device or used in combination with it.
[0143] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0144] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0145] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0146] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0147] The exemplary embodiment of the present disclosure also provides an electronic device capable of implementing the above method. Figure 7 hereinafter, an electronic device 700 according to this exemplary embodiment of the present disclosure is described. Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0148] like Figure 7 As shown, the electronic device 700 may be in the form of a general-purpose computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710), and a display unit 740.
[0149] The storage unit 720 stores program codes, which can be executed by the processing unit 710, so that the processing unit 710 executes the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 710 can execute Figures 2 to 5 Any one or more method steps.
[0150] The storage unit 720 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 721 and / or a cache memory unit 722 , and may further include a read-only memory unit (ROM) 723 .
[0151] The storage unit 720 may also include a program / utility 724 having a set (at least one) of program modules 725, such program modules 725 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0152] Bus 730 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0153] The electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 760. As shown, the network adapter 760 communicates with other modules of the electronic device 700 via a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0154] In some embodiments, the blockchain-based data transmission method described in the present disclosure may be executed by the processing unit 710 of the electronic device. In some embodiments, the data to be transmitted of the first user may be input through the input interface 750. In some embodiments, the decrypted data to be transmitted may be output to the external device 900 through the output interface 750 for viewing by the second user.
[0155] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the exemplary implementation of the present disclosure.
[0156] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiment of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0157] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0158] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data transmission method based on blockchain, characterized in that: include: Based on the private key of the first user and the public key of the second user, encrypt the data to be transmitted by using a proxy re-encryption algorithm to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user, and the encryption capsule includes a first encryption capsule and a second encryption capsule; Uploading the encrypted data and the encrypted capsule to the blockchain; When the first user triggers a sending event to the second user, the encrypted data and the encrypted capsule are sent to the second user through the blockchain; Based on the private key of the second user and the encryption capsule, decrypting the encrypted data by using the proxy re-encryption algorithm to obtain the data to be transmitted; The method encrypts the data to be transmitted by using a proxy re-encryption algorithm based on the private key of the first user and the public key of the second user to obtain encrypted data and an encrypted capsule, including: Based on the private key of the first user and the public key of the second user, generating a proxy key through the proxy re-encryption algorithm, the proxy key including a proxy private key and a proxy public key; Based on the public key of the first user and the proxy private key, encrypt the data to be transmitted by using the proxy re-encryption algorithm to obtain the encrypted data, the first encryption capsule and the second encryption capsule; The decrypting the encrypted data by using the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted includes: Based on the private key of the second user and the proxy public key, decrypting the second encrypted capsule by the proxy re-encryption algorithm to obtain a decryption key; The encrypted data is decrypted according to the decryption key and a preset decryption algorithm to obtain the data to be transmitted, and the data to be transmitted is sent to the second user.
2. The data transmission method based on blockchain according to claim 1 is characterized in that: Before encrypting the data to be transmitted by using the proxy re-encryption algorithm, the method further includes: When the first user sends the data to be transmitted to the second user, the public key of the second user sent by the first user is received, where the public key of the second user is obtained by the first user from the blockchain according to the unique identifier of the second user.
3. The data transmission method based on blockchain according to claim 1 is characterized in that: The method of encrypting the data to be transmitted by using the proxy re-encryption algorithm based on the public key of the first user and the proxy private key to obtain the encrypted data, the first encryption capsule and the second encryption capsule includes: Based on the public key of the first user, encrypt the data to be transmitted by using the proxy re-encryption algorithm to obtain the encrypted data and the first encryption capsule; Based on the proxy private key, the first encrypted capsule is encrypted by the proxy re-encryption algorithm to generate the second encrypted capsule.
4. The data transmission method based on blockchain according to claim 3 is characterized in that: The step of encrypting the data to be transmitted by using the proxy re-encryption algorithm based on the public key of the first user to obtain the encrypted data and the first encryption capsule includes: Encrypting the first user's public key by using the proxy re-encryption algorithm to obtain an encryption key and the first encryption capsule; The data to be transmitted is encrypted according to the encryption key and a preset encryption algorithm to obtain the encrypted data.
5. The data transmission method based on blockchain according to claim 1 is characterized in that: The uploading of the encrypted data and the encrypted capsule to the blockchain includes: The encrypted data, the proxy public key and the second encrypted capsule are uploaded to the blockchain.
6. The data transmission method based on blockchain according to claim 5 is characterized in that: When the first user triggers a sending event to the second user, sending the encrypted data and the encrypted capsule to the second user through the blockchain includes: When the first user triggers a sending event to the second user, the encrypted data, the proxy public key and the second encrypted capsule are sent to the second user through the blockchain.
7. A data transmission device based on blockchain, characterized in that: include: a proxy encryption module, configured to encrypt the data to be transmitted by a proxy re-encryption algorithm based on the private key of the first user and the public key of the second user to obtain encrypted data and an encryption capsule, wherein the data to be transmitted is plaintext data sent by the first user to the second user, and the encryption capsule includes a first encryption capsule and a second encryption capsule; A first data transmission module, used to upload the encrypted data and the encrypted capsule to the blockchain; A second data transmission module, configured to send the encrypted data and the encrypted capsule to the second user through the blockchain when the first user triggers a sending event to the second user; a proxy decryption module, configured to decrypt the encrypted data by using the proxy re-encryption algorithm based on the private key of the second user and the encryption capsule to obtain the data to be transmitted; The proxy encryption module is further used to generate a proxy key based on the private key of the first user and the public key of the second user through the proxy re-encryption algorithm, wherein the proxy key includes a proxy private key and a proxy public key; Based on the public key of the first user and the proxy private key, encrypt the data to be transmitted by using the proxy re-encryption algorithm to obtain the encrypted data, the first encryption capsule and the second encryption capsule; The proxy decryption module is further used to decrypt the second encrypted capsule through the proxy re-encryption algorithm based on the private key of the second user and the proxy public key to obtain a decryption key; The encrypted data is decrypted according to the decryption key and a preset decryption algorithm to obtain the data to be transmitted, and the data to be transmitted is sent to the second user.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 6 by executing the executable instructions.
Citation Information
Patent Citations
Distributed data security sharing method and system based on block chain, and computer readable medium
CN113595971A
Data authorization method and device and data access method and device
CN113609522A