Implementation Method for Data Encryption and Sharing Based on Blockchain and Chameleon Hash Algorithm
The symmetric key generation is solved through blockchain and chameleon hashing algorithms, and the leakage risk and parameter forgetting problems during the symmetric key transmission process are solved, achieving secure and efficient data encryption and sharing.
Patent Information
- Application Number
- CN202210123855.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-10
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-02-10
AI Technical Summary
The delivery process of symmetric keys in existing data encryption schemes increases the risk of key leakage, and the forgetting of parameter information leads to the loss of keys.
The data encryption sharing method based on blockchain and chameleon hash algorithm is adopted to generate symmetric keys through the blockchain network, and the trapped characteristics of the elliptic curve encryption algorithm and the chameleon hash algorithm are used to generate the same key, avoiding the risk of key transmission and forgetting.
It realizes that without exposing symmetric key information, both users generate the same key, avoiding the risk of leakage of the key during the transmission process, and ensuring the security and uniqueness of key generation.
Smart Images

Figure CN114462065B_ABST
Abstract
Description
Technical Field
[0001] The present invention discloses an implementation method for data encryption and sharing based on blockchain and chameleon hash algorithm, which relates to the technical field of data encryption. Background Art
[0002] Data encryption technology is one of the main technical means adopted to improve the security and confidentiality of information systems and data and prevent secret data from being deciphered externally. Commonly used data encryption algorithms are divided into two categories: symmetric encryption algorithms and asymmetric encryption algorithms. The encryption and decryption of symmetric encryption algorithms rely on the same symmetric key, that is: using the symmetric key to encrypt the plaintext to obtain the ciphertext, and using the same symmetric key to decrypt the ciphertext to obtain the plaintext. Asymmetric encryption algorithms rely on a pair of keys: public key and private key. The public key is publicly announced, and the private key needs to be kept confidential. Data encrypted with the public key needs to be decrypted with the private key, and data encrypted with the private key needs to be decrypted with the public key.
[0003] Symmetric encryption algorithms are suitable for encrypting data with a large amount of data, and asymmetric data is suitable for encrypting data with a small amount of data. Currently, mainstream data encryption and sharing solutions usually use symmetric encryption algorithms to encrypt private data and asymmetric encryption algorithms to encrypt symmetric keys. The two parties sharing data transfer encrypted data and encrypted symmetric keys. This solution includes the transfer process of the symmetric key, increasing the risk of key leakage.
[0004] Elliptic Curve Cryptography, abbreviated as ECC, is an asymmetric encryption algorithm based on the mathematical theory of elliptic curves. The public and private keys of ECC are generated based on elliptic curves and the operation rules on elliptic curves. Chameleon Hash is a special hash function. It is difficult to find collisions for traditional hash functions, but the chameleon hash function can artificially set a "back door", which we call the trapdoor information. After mastering the trapdoor information, collisions can be easily found. Summary of the Invention
[0005] In view of the problems of the prior art, the present invention provides an implementation method for data encryption and sharing based on blockchain and chameleon hash algorithm. The technical solution adopted is: an implementation method for data encryption and sharing based on blockchain and chameleon hash algorithm. The specific steps of the method are as follows:
[0006] S1 Build a Fabric blockchain network as the basis for data encryption storage and exchange and sharing, and register blockchain identities for users;
[0007] S2 Generate a symmetric key according to the encrypted data exchanged between users;
[0008] S3 encrypts the data through an encryption party and writes it to the chain;
[0009] S4 The decryption party reads the data from the data and the written chain and generates a symmetric secret key;
[0010] S5 Uses the generated symmetric secret key to decrypt the encrypted data to obtain the original private data.
[0011] The specific steps for S2 to generate a symmetric secret key according to the encrypted data exchanged between users are as follows:
[0012] S201 Generates trapdoor information using the private key of the encryption party and the public key of the decryption party;
[0013] S202 Generates 4 random numbers denoted as g, m1, m2, r1, and uses g and the trapdoor information to generate a chameleon hash function Hab(m,r);
[0014] S203 Substitutes m1, r1, m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1,r1) = Hab(m2,r2);
[0015] S204 Uses the hash value obtained by substituting m1, r2 into Hab as the symmetric secret key.
[0016] The written chain data in S3 is in json format.
[0017] The specific steps for S4, the decryption party, to read the data from the data and the written chain and generate a symmetric secret key are as follows:
[0018] S401 Generates trapdoor information using the private key of the decryption party and the public key of the encryption party;
[0019] S402 Reads the symmetric secret key additional information g, m1, m2, r1 from the chain, and uses g and the trapdoor information to generate a chameleon hash function Hab(m,r);
[0020] S403 Substitutes m1, r1, m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1,r1) = Hab(m2,r2);
[0021] S404 Uses the hash value obtained by substituting m1, r2 into Hab as the symmetric secret key.
[0022] An implementation system for data encryption and sharing based on blockchain and chameleon hash algorithm, the system specifically includes an identity establishment module, a secret key generation module A, an encryption processing module, a secret key generation module B, and an encryption parsing module:
[0023] Identity establishment module: Builds a Fabric blockchain network as the basis for data encryption storage and exchange and sharing, and registers blockchain identities for users;
[0024] Secret key generation module A: Generates a symmetric secret key based on the encrypted data exchanged between users;
[0025] Encryption processing module: Encrypts data by the encrypting party and writes it to the chain;
[0026] Secret key generation module B: The decrypting party reads data from the data and the chain and generates a symmetric secret key;
[0027] Encryption parsing module: Decrypts the encrypted data using the generated symmetric secret key to obtain the original private data.
[0028] The secret key generation module A specifically includes an information generation module A, an information processing module A, a hash processing module A, and a substitution generation module A:
[0029] Information generation module A: Generates trapdoor information using the private key of the encrypting party and the public key of the decrypting party;
[0030] Information processing module A: Generates 4 random numbers denoted as g, m1, m2, r1, and uses g and the trapdoor information to generate a chameleon hash function Hab(m,r);
[0031] Hash processing module A: Substitutes m1, r1, m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1,r1) = Hab(m2,r2);
[0032] Substitution generation module A: Uses the hash value obtained by substituting m1, r2 into Hab as the symmetric secret key.
[0033] The data written to the chain in the encryption processing module is in json format.
[0034] The secret key generation module B specifically includes an information generation module B, an information processing module B, a hash processing module B, and a substitution generation module B:
[0035] Information generation module B: Generates trapdoor information using the private key of the decrypting party and the public key of the encrypting party;
[0036] Information processing module B: Reads the symmetric secret key additional information g, m1, m2, r1 from the chain, and uses g and the trapdoor information to generate a chameleon hash function Hab(m,r);
[0037] Hash processing module B: Substitutes m1, r1, m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1,r1) = Hab(m2,r2);
[0038] Substitution generation module B: The hash value obtained by substituting m1, r2 into Hab is the symmetric secret key.
[0039] The beneficial effects of the present invention are as follows: The generation of the symmetric key and the process of using it for data encryption and decryption are completed unilaterally by the user, without the transfer and exchange of keys, avoiding the risk of the key being stolen and exposed during the transfer process; the additional parameters required for key generation are written into the blockchain, eliminating the worry of key loss due to the forgetting of parameter information; the key used for each encryption is newly generated based on random parameters. Even if the key used for a certain encryption is leaked due to unpredictable reasons, it will not pose a threat to other encrypted data;
[0040] The method of the present invention utilizes the public and private key generation characteristics of the elliptic curve encryption algorithm and combines the trapdoor characteristics of the chameleon hash algorithm to achieve the effect of generating the same key for both users without exposing the symmetric key information; the privacy data holder encrypts the privacy data using the generated symmetric key and writes it into the blockchain, attaching the additional information for generating the key; any user can view this information on the chain but cannot decrypt it; only the authorized user can use this information to generate the symmetric key and then decrypt the original privacy data. Brief Description of the Drawings
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0042] Figure 1 It is a schematic flowchart of the implementation process of the method of the present invention. Detailed Embodiments
[0043] The following further illustrates the present invention in conjunction with the drawings and specific embodiments, so that those skilled in the art can better understand the present invention and be able to implement it, but the embodiments cited do not limit the present invention.
[0044] Embodiment 1:
[0045] An implementation method for data encryption and sharing based on blockchain and chameleon hash algorithm, the specific steps of the method are as follows:
[0046] S1 Build a Fabric blockchain network as the basis for data encryption storage and exchange and sharing, and register blockchain identities for users;
[0047] S2 Generate a symmetric key according to the encrypted data exchanged between users;
[0048] S3 Encrypt the data by the encrypting party and write it to the chain;
[0049] The S4 decryption party reads data from the data and write chain and generates a symmetric secret key;
[0050] S5 uses the generated symmetric secret key to decrypt the encrypted data to obtain the original private data;
[0051] Build a Fabric blockchain network as the basis for data encryption storage and exchange and sharing, register blockchain identities for users, that is, public and private keys; the signature algorithm used in Fabric is ECDSA. The private key of a user is essentially a relatively large positive integer (denoted as s), and the public key of a user is essentially a point on the elliptic curve (denoted as P), and there is such a relationship between them: P = s × G, where G is the base point of the elliptic curve;
[0052] Suppose there are user a, user b, and user c. User a wants to encrypt a piece of private data and store it in the blockchain network, and share this data with user b and user c; the public key of user a is denoted as Pa, and the private key is denoted as sa. Similarly, the public and private keys of user b and user c are denoted as: Pb, sb, Pc, sc; the private data to be encrypted and shared by user a is denoted as D;
[0053] As Figure 1 shown, first, user a generates key additional information, that is, the 4 random numbers in the second step of the technical solution, and then uses the key additional information, the public key of user b, and its own private key to generate a symmetric secret key;
[0054] Next, user a encrypts the private data using the generated symmetric secret key, and writes the obtained encrypted data and key additional information into the blockchain;
[0055] User b reads the key additional information and encrypted data from the blockchain, and uses the key additional information, the public key of user a, and its own private key to generate a symmetric secret key, which is the same as the symmetric secret key generated by user a;
[0056] Finally, user b decrypts the encrypted data using the generated symmetric secret key, thereby obtaining the original private data;
[0057] Furthermore, the specific steps for the S2 to generate a symmetric secret key according to the encrypted data exchanged between users are as follows:
[0058] S201 uses the private key of the encrypting party and the public key of the decrypting party to generate trapdoor information;
[0059] S202 generates 4 random numbers denoted as g, m1, m2, r1, and uses g and the trapdoor information to generate a chameleon hash function Hab(m,r);
[0060] S203 substitutes m1, r1, and m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1, r1) = Hab(m2, r2);
[0061] S204 takes the hash value obtained by substituting m1 and r2 into Hab as the symmetric key;
[0062] User a generates intermediate parameters Kab and Kac, and the generation formulas are: K ab = s a × P b and K ac = s a × P c
[0063] Kab and Kac are essentially two points on the elliptic curve. Encode Kab and Kac as two numbers (encoding method such as: adding the x coordinate and the y coordinate) and denote them as: xab and xac;
[0064] User a generates 4 random numbers denoted as g, m1, m2, and r1;
[0065] Generate hab using g and xab,
[0066] Generate hac using g and xac,
[0067] Construct two chameleon hash functions Hab and Hac using g, hab, and hac
[0068] H ab (m, r) = g m h ab r
[0069] H ac (m, r) = g m h ac r
[0070] xab and xac are the trapdoor information of the Hab and Hac hash functions respectively;
[0071] Taking Hab as an example, substituting m1 and r1 into the Hab function to get the hash value Hab(m1, r1). After knowing the trapdoor information xab, a specific random number r2ab can be obtained to satisfy Hab(m1, r1) = Hab(m2, r2ab), and the calculation formula is:
[0072] r2 ab = (m / 1 - m2)x ab -1 + r1
[0073] Similarly, it can be obtained that r2ac satisfies Hac(m1, r1) = Hac(m2, r2ac).
[0074] Substitute m1 and r2ab into Hab to obtain the hash value Hab(m1, r2ab), denoted as Sab. Sab is the symmetric key for exchanging encrypted data between user a and user b.
[0075] Similarly, substitute m1 and r2ac into Hac to obtain the hash value Hac(m1, r2ac), denoted as Sac. Sac is the symmetric key for exchanging encrypted data between user a and user c.
[0076] Furthermore, the write-chain data in S3 is in json format.
[0077] User a encrypts the private data D using the symmetric key Sab, and the obtained value is denoted as EDab.
[0078] Encrypt the private data D using the symmetric key Sac, and the obtained value is denoted as EDac.
[0079] Organize a json string with the following structure:
[0080]
[0081]
[0082] User a generates a uuid denoted as data_id, uses data_id as the key, and the above json string as the value, performs data write-chain and sends data_id to user b and user c.
[0083] Furthermore, the specific steps for the decryption party in S4 to read data from the data write-chain and generate a symmetric key are as follows:
[0084] S401 uses the private key of the decryption party and the public key of the encryption party to generate trapdoor information.
[0085] S402 reads the symmetric key additional information g, m1, m2, r1 from the chain, and uses g and the trapdoor information to generate the chameleon hash function Hab(m, r).
[0086] S403 substitutes m1, r1, m2 into Hab, and uses the trapdoor information to obtain r2 such that Hab(m1, r1) = Hab(m2, r2) is satisfied.
[0087] The hash value obtained by substituting m1, r2 into Hab is the symmetric key.
[0088] Taking user b as an example, read the json data from the blockchain according to the data_id, and obtain g, m1, m2, r1, and EDab from the json;
[0089] Calculate the intermediate parameter Kab, K ab = s b × P a , and obtain the trapdoor information xab according to Kab;
[0090] Generate hab using g and xab,
[0091] Obtain the chameleon hash function Hab, H ab (m, r) = g m h ab r ;
[0092] Substitute m1 and r1 into the Hab function to get the hash value Hab(m1, r1). After knowing the trapdoor information xab, a specific random number r2ab can be obtained to satisfy Hab(m1, r1) = Hab(m2, r2ab). The calculation formula is:
[0093] r2 ab = (m1 - m2)x ab -1 + r1
[0094] Substitute m1 and r2ab into Hab to get the hash value Hab(m1, r2ab), which is Sab, that is, the symmetric key for exchanging encrypted data between user a and user b;
[0095] Use Sab to decrypt EDab, that is, obtain the original privacy data D.
[0096] Example 2:
[0097] An implementation system for data encryption and sharing based on blockchain and chameleon hash algorithm. The system specifically includes an identity establishment module, a secret key generation module A, an encryption processing module, a secret key generation module B, and an encryption parsing module:
[0098] Identity establishment module: Build a Fabric blockchain network as the basis for data encryption storage and exchange and sharing, and register blockchain identities for users;
[0099] Secret key generation module A: Generate a symmetric key according to the encrypted data exchanged between users;
[0100] Encryption processing module: Encrypt data by the encrypting party and write it to the chain;
[0101] Secret key generation module B: The decrypting party reads data from the data and the write chain and generates a symmetric key;
[0102] Encryption and parsing module: Use the generated symmetric key to decrypt the encrypted data to obtain the original private data;
[0103] Furthermore, the key generation module A specifically includes an information generation module A, an information processing module A, a hash processing module A, and a substitution generation module A:
[0104] Information generation module A: Use the private key of the encrypting party and the public key of the decrypting party to generate trapdoor information;
[0105] Information processing module A: Generate 4 random numbers denoted as g, m1, m2, r1, and use g and the trapdoor information to generate a chameleon hash function Hab(m, r);
[0106] Hash processing module A: Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1) = Hab(m2, r2);
[0107] Substitution generation module A: Use the hash value obtained by substituting m1, r2 into Hab as the symmetric key;
[0108] Furthermore, the write-chain data in the encryption processing module is in json format;
[0109] Still further, the key generation module B specifically includes an information generation module B, an information processing module B, a hash processing module B, and a substitution generation module B:
[0110] Information generation module B: Use the private key of the decrypting party and the public key of the encrypting party to generate trapdoor information;
[0111] Information processing module B: Read the symmetric key additional information g, m1, m2, r1 from the chain, and use g and the trapdoor information to generate a chameleon hash function Hab(m, r);
[0112] Hash processing module B: Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1) = Hab(m2, r2);
[0113] Substitution generation module B: The hash value obtained by substituting m1, r2 into Hab is the symmetric key.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; 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 recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and 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. Implementation method for data encryption and sharing based on blockchain and chameleon hash algorithm, characterized by The specific steps of the described method are as follows: S1 Build a Fabric blockchain network as the basis for encrypted data storage and exchange sharing, and register blockchain identities for users; S2 Generate a symmetric key based on the encrypted data exchanged between users; S3 The encrypting party encrypts the data and writes it to the chain; S4 The decrypting party reads the data from the data and the chain and generates a symmetric key; S5 Use the generated symmetric key to decrypt the encrypted data to obtain the original private data; The specific steps of generating a symmetric key by S2 based on the encrypted data exchanged between users are as follows: S201 Use the private key of the encrypting party and the public key of the decrypting party to generate trapdoor information; S202 Generate 4 random numbers denoted as g, m1, m2, r1, and use g and the trapdoor information to generate a chameleon hash function Hab(m, r); Generate hab using g and xab, ; Obtain the chameleon hash function Hab, ; where xab is the trapdoor information; S203 Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1)=Hab(m2, r2); S204 Use the hash value obtained by substituting m1, r2 into Hab as the symmetric key.
2. The method according to claim 1, wherein The data written to the chain in S3 is in json format.
3. The method according to claim 2, wherein The specific steps of the decrypting party in S4 reading the data from the data and the chain and generating a symmetric key are as follows: S401 Use the private key of the decrypting party and the public key of the encrypting party to generate trapdoor information; S402 Read the symmetric key additional information g, m1, m2, r1 from the chain, and use g and the trapdoor information to generate a chameleon hash function Hab(m, r); S403 Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1)=Hab(m2, r2); S404 Use the hash value obtained by substituting m1, r2 into Hab as the symmetric key.
4. An implementation system for data encryption and sharing based on blockchain and chameleon hash algorithm, characterized in that The described system specifically includes an identity establishment module, a key generation module A, an encryption processing module, a key generation module B, and an encryption parsing module: Identity establishment module: Build a Fabric blockchain network as the basis for encrypted data storage and exchange sharing, and register blockchain identities for users; Key generation module A: Generate a symmetric key based on the encrypted data exchanged between users; Encryption processing module: The encrypting party encrypts the data and writes it to the chain; Key generation module B: The decrypting party reads the data from the data and the chain and generates a symmetric key; Encryption parsing module: Use the generated symmetric key to decrypt the encrypted data to obtain the original private data; The key generation module A specifically includes an information generation module A, an information processing module A, a hash processing module A, and a substitution generation module A: Information generation module A: Use the private key of the encrypting party and the public key of the decrypting party to generate trapdoor information; Information processing module A: Generate 4 random numbers denoted as g, m1, m2, r1, and use g and the trapdoor information to generate a chameleon hash function Hab(m, r); Generate hab using g and xab, ; Obtain the chameleon hash function Hab, ; where xab is the trapdoor information; Hash processing module A: Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1)=Hab(m2, r2); Input Generation Module A: The hash value obtained by substituting m1 and r2 into Hab is used as the symmetric key.
5. The system according to claim 4, characterized in that The write-chain data in the encryption processing module is in JSON format.
6. The system according to claim 5, characterized in that The key generation module B specifically includes an information generation module B, an information processing module B, a hash processing module B, and an input generation module B: Information Generation Module B: Generate trapdoor information using the private key of the decrypting party and the public key of the encrypting party; Information Processing Module B: Read the symmetric key additional information g, m1, m2, r1 from the chain, and generate the chameleon hash function Hab(m, r) using g and the trapdoor information; Hash Processing Module B: Substitute m1, r1, m2 into Hab, and use the trapdoor information to obtain r2 such that Hab(m1, r1) = Hab(m2, r2); Input Generation Module B: The hash value obtained by substituting m1 and r2 into Hab is the symmetric key.
Citation Information
Patent Citations
Data encryption and decryption method and device based on block chain, and medium
CN111934874A