Group chat encryption method, system, device and medium based on quantum key

By using a key pool to generate random encryption public keys and decryption private keys in group chat encryption technology, and transmitting quantum keys through quantum channels, the problem of insufficient protection of public keys and private keys in the prior art is solved, and encryption is improved Information security and transmission efficiency.

CN118353627BActive Publication Date: 2024-11-05HAINAN JIKE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410603010.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-15
Publication Date
2024-11-05
Estimated Expiration
2044-05-15

AI Technical Summary

Technical Problem

The existing group chat encryption technology lacks the protection degree of public and private keys, which leads to the problem of leakage of encrypted information.

Method used

By randomly generating the encryption public key based on the key pool, the decrypted private key is obtained, and the quantum key is transmitted through the quantum channel to ensure the security of the transmission process. Then, the plain text is encrypted based on the encryption public key, and the receiver decrypts the private key by decrypting the private key. The key decrypts the encrypted ciphertext.

Benefits of technology

It improves the security of encrypted information and quantum keys, prevents quantum key leakage, and enhances the security and transmission efficiency of encrypted information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118353627B_ABST
    Figure CN118353627B_ABST
Patent Text Reader

Abstract

The invention discloses a group chat encryption method, system, device and medium based on quantum key, and relates to the technical field of group chat encryption, comprising the following steps: sending quantum keys respectively through a quantum channel, sending the quantum keys to a sending end and a receiving end respectively; encrypting the sent plaintext through the quantum key to obtain encrypted ciphertext; transmitting the encrypted ciphertext to a receiving end through a traditional channel, and the receiving end decrypting the encrypted ciphertext through the quantum key to obtain the sent plaintext; the invention is used to solve the problem that the existing group chat encryption technology still has insufficient protection for public keys and private keys, resulting in easy leakage of encrypted information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of group chat encryption, and in particular to a group chat encryption method, system, device and medium based on quantum key. Background Art

[0002] Group chat encryption technology refers to the use of encryption algorithms and protocols in group chat communications to protect the security and privacy of chat content. It ensures that only authorized participants can access and understand chat information, while preventing unauthorized persons from obtaining sensitive information.

[0003] Existing group chat encryption technology usually encrypts the chat content, but ignores the privacy and security of public keys and private keys. The protection of public keys and private keys is insufficient, and they are easily stolen during transmission, resulting in the leakage of encrypted information. For example, in the Chinese patent application publication number: "CN117335962A", a "one-to-many dynamic group encryption communication system and method" is disclosed. This solution does not encrypt the private key, and the key sent to each group is relatively fixed, which is not conducive to long-term encrypted transmission. The existing group chat encryption technology also has the problem of insufficient protection of public keys and private keys, resulting in the leakage of encrypted information. Summary of the invention

[0004] The present invention aims to solve one of the technical problems in the prior art to at least a certain extent, by randomly generating an encrypted public key based on a key pool, and then encrypting and calculating a decrypted private key based on the encrypted public key, and then transmitting the quantum key through a quantum channel to ensure the security of the transmission process, and then encrypting the sent plaintext based on the encrypted public key to obtain an encrypted ciphertext, and the receiving end decrypts the encrypted ciphertext by using the decryption private key, so as to solve the problem that the existing group chat encryption technology still has insufficient protection for public keys and private keys, resulting in easy leakage of encrypted information.

[0005] To achieve the above objectives, in a first aspect, the present application provides a group chat encryption method based on quantum key, comprising the following steps:

[0006] The quantum keys are sent separately through the quantum channel, and the quantum keys are sent to the sending end and the receiving end respectively;

[0007] Encrypt the sent plaintext through the quantum key to obtain the encrypted ciphertext;

[0008] The encrypted ciphertext is transmitted to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext using the quantum key to obtain the sent plaintext.

[0009] Furthermore, sending the quantum key to the transmitting end and the receiving end respectively through the quantum channel includes the following sub-steps:

[0010] Setting a key pool, wherein the key pool includes unit keys, and the unit keys include uppercase letters A to Z, lowercase letters a to Z, and numbers 0 to 9;

[0011] Randomly select a unit key of a first unit number from the key pool to form an initial key;

[0012] Convert the unit key in the initial key into a decimal number based on the ASCII code to obtain the initial public key;

[0013] Calculate the initial public key modulo 4 to get the public key remainder. If the public key remainder is 1, the output digits match the signal; if the public key remainder is not 1, the output digits do not match the signal.

[0014] If the output digits match the signal, the initial public key is marked as the encrypted public key; if the output digits do not match the signal, the last decimal digit of the initial public key is removed until the remainder of the public key is 1, and the encrypted public key is obtained;

[0015] Calculate the encryption public key to obtain the decryption private key.

[0016] Furthermore, calculating the encryption public key includes the following sub-steps:

[0017] Get the number of bits of the encrypted public key, named as the number of bits of the public key, represented by the symbol m; number the encrypted public key, named as the key number, represented by the symbol E n Indicates that n is a positive integer and 1≤n≤m, E n Represents the decimal number at the nth position in the encrypted public key;

[0018] E n Compare with 5, if E n Less than 5, the digital incremental signal is output; if E n If it is greater than or equal to 5, a digital decrement signal is output;

[0019] If the digital incremental signal is output, E n Increase by 5; if the digital decrement signal is output, E n Decrease by 5;

[0020] Calculate the remainder of the encrypted public key modulo 2 after enlargement or reduction, and name it as the private key algorithm parameter. If the private key algorithm parameter is 0, output the first private key algorithm signal; if the private key algorithm parameter is 1, output the second private key algorithm signal;

[0021] The first private key algorithm signal and the second private key algorithm signal are collectively referred to as private key algorithm signals, and different algorithm calculations are performed on the encrypted public key according to the private key algorithm signals.

[0022] Furthermore, performing different algorithm calculations on the encrypted public key according to the private key algorithm signal includes the following sub-steps:

[0023] If the first private key algorithm signal is output, then starting from n=1, E n With E n+1 The corresponding decimal numbers are swapped, n is increased by 2, and E n With E n+1 Replace the corresponding decimal numbers and increase n by 2 until n=m-2. n With E n+1 After the exchange, the increase stopped;

[0024] If the second private key algorithm signal is output, then starting from n=1, E n With E n+2 The corresponding decimal numbers are swapped, and E n+1 With E n+3 The corresponding decimal numbers are swapped; n is increased by 4, and the swapping process is repeated, increasing n by 4 in sequence until n=m-4, and then the increase is stopped;

[0025] The continuous numbers obtained after the exchange are marked as the decryption private key, and the encrypted public key is sent to the sender through the quantum channel, and the decrypted private key is sent to the receiver.

[0026] Furthermore, sending plaintext encryption by quantum key pair includes the following sub-steps:

[0027] Get the sent plaintext, convert the language of the sent plaintext into English format, and get the plaintext to be encrypted;

[0028] Convert the letters in the plaintext to be encrypted into binary numbers according to ASCII codes to obtain the ciphertext to be encrypted;

[0029] Convert each decimal digit in the encrypted public key into an 8-bit binary digit to obtain the key to be encrypted;

[0030] Get the number of digits of the ciphertext to be encrypted, named as the number of ciphertext digits; get the number of digits of the key to be encrypted, named as the number of key digits;

[0031] Compare the number of ciphertext digits with the number of key digits. If the number of ciphertext digits is less than the number of key digits, output the key removal signal; if the number of ciphertext digits is equal to the number of key digits, output the same number of digits signal; if the number of ciphertext digits is greater than the number of key digits, output the key increase signal;

[0032] If the key removal signal is output, the number of key bits minus the number of ciphertext bits is calculated, the calculation result is marked as the encryption bit difference, and the number of encryption bit difference after the key to be encrypted is removed to obtain the true encryption key; if the key addition signal is output, another key to be encrypted is spliced ​​after the key to be encrypted, and the number of ciphertext bits and key bits are compared again; if the output number of bits is the same, the key to be encrypted is changed to the true encryption key;

[0033] Number each digit in the encrypted ciphertext, using the symbol S i Indicates that i is the serial number of S and i is a positive integer; each digit in the true encryption key is numbered, and the symbol P i Indicates that i and S i The i in is the same;

[0034] S is sorted in the order from i = 1 to i equal to the number of ciphertext bits. i With P i Perform XOR and obtain the encrypted ciphertext after XOR is completed.

[0035] Furthermore, the encrypted ciphertext is transmitted to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key, including the following sub-steps:

[0036] Get the number of digits of the decryption private key, named as the private key digits, represented by the symbol h; number the decryption private key, named as the private key number, represented by the symbol K f Indicates that f is a positive integer and 1≤f≤h, K f Represents the decimal number at the fth position in the decrypted private key;

[0037] K f Compare with 5, if K f Less than 5, a digital incremental signal is output; if K f If it is greater than or equal to 5, a digital decrement signal is output;

[0038] If the digital incremental signal is output, K f Increase by 5; if the digital decrement signal is output, K f Decrease by 5;

[0039] Calculate the remainder of the decryption private key modulo 2 after increase or decrease, and name it as the private key inverse algorithm parameter. If the private key inverse algorithm parameter is 1, output the first private key inverse algorithm signal; if the private key inverse algorithm parameter is 0, output the second private key inverse algorithm signal;

[0040] If the first private key reverse algorithm signal is output, then starting from f=1, K f With K f+1 The corresponding decimal numbers are swapped, f is increased by 2, and K f With K f+1Replace the corresponding decimal numbers and increase f by 2 until f = h-2. f With K f+1 After the exchange, the increase stopped;

[0041] If the second private key reverse algorithm signal is output, then starting from f=1, K f With K f+2 The corresponding decimal numbers are swapped and K f+1 With K f+3 The corresponding decimal numbers are swapped; f is increased by 4, and the swapping process is repeated, increasing f by 4 in sequence until f = h-4, and then the increase is stopped;

[0042] After the exchange is completed, the first decryption key is obtained, and the encrypted ciphertext is decrypted by the first decryption key to obtain the sent plaintext.

[0043] Furthermore, decrypting the encrypted ciphertext using the first decryption key includes the following sub-steps:

[0044] Convert each decimal digit in the first decryption key into an 8-bit binary digit to obtain a second decryption key;

[0045] The number of bits of the encrypted ciphertext is obtained, which is named as the number of bits for decryption; the number of bits of the second decryption key is obtained, which is named as the number of bits for decryption key;

[0046] Compare the number of decrypted bits with the number of decrypted key bits. If the number of decrypted bits is less than the number of decrypted key bits, a key removal signal is output; if the number of decrypted bits is equal to the number of decrypted key bits, a signal of the same number of bits is output; if the number of decrypted bits is greater than the number of decrypted key bits, a key increase signal is output;

[0047] If the key removal signal is output, the number of decryption bits is calculated and subtracted from the number of decryption bits, and the calculation result is marked as the decryption bit difference. The number of decryption bit difference after the second decryption key is removed to obtain the true decryption key; if the key increase signal is output, a second decryption key is spliced ​​after the second decryption key, and the number of decryption bits is compared with the number of decryption bits again; if the signal of the same number of bits is output, the second decryption key is changed to the true decryption key;

[0048] Number each digit in the encrypted ciphertext, using the symbol C j Indicates that j is the serial number of C and j is a positive integer; each digit in the true encryption key is numbered, and the symbol V j Indicates that j and C j The j in is the same;

[0049] C is sorted in the order from j = 1 to j equal to the number of decrypted bits. j With V j Perform XOR, and after XOR is completed, the ciphertext to be decrypted is obtained;

[0050] The ciphertext to be decrypted is restored to English letters according to the ASCII code table to obtain the decrypted plaintext, and the decrypted plaintext is translated into the sending plaintext according to the language selected by the user.

[0051] In a second aspect, the present application provides a group chat encryption system based on quantum keys, including a quantum key distribution module, an information encryption module and an information decryption module; the quantum key distribution module and the information decryption module are respectively connected to the information encryption module in communication;

[0052] The quantum key distribution module is used to send quantum keys to the transmitting end and the receiving end respectively through the quantum channel;

[0053] The information encryption module is used to encrypt the sent plain text through the quantum key to obtain the encrypted ciphertext;

[0054] The information decryption module is used to transmit the encrypted ciphertext to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key to obtain the sent plaintext.

[0055] In a third aspect, the present application provides an electronic device, including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method described above are executed.

[0056] In a fourth aspect, the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method described above are executed.

[0057] Beneficial effects of the present invention: The present invention sets a key pool, and randomly extracts a unit key from the key pool each time information is encrypted and converts it into an encrypted public key. The advantage is that the encrypted public key and the decrypted private key will be changed once each time a group chat is opened. The encrypted public key can be changed at any time to greatly prevent the leakage of the quantum key, thereby improving the security of the encrypted information and the security of the quantum key.

[0058] The present invention obtains a decryption private key based on the encryption public key conversion, and then transmits the encrypted quantum key through a quantum channel. The advantage is that the decryption private key can be changed with the encryption public key. At the same time, the transmission of the quantum key through a quantum channel can effectively prevent the quantum key from being intercepted by others during the transmission process, further improving the security of encrypted information and the security of the quantum key.

[0059] The present invention converts the sent information into English format for encryption, and automatically translates it based on the language selected by the user after decryption. The advantage is that group chats involve many people, and the two communicating parties may not speak the same language. Converting to English format for encryption can increase the encryption operation rate, improve the efficiency of information encryption and the convenience of the two communicating parties.

[0060] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 is a flow chart of the steps of the method of the present invention;

[0062] Figure 2 A flowchart of the steps of processing a digital increment signal and a digital decrement signal of the present invention;

[0063] Figure 3 A flowchart of the steps of a private key algorithm corresponding to the private key algorithm signal of the present invention;

[0064] Figure 4 It is a functional block diagram of the system of the present invention. DETAILED DESCRIPTION

[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0066] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides a group chat encryption method based on quantum key, comprising the following steps:

[0067] Step S1, sending quantum keys respectively through a quantum channel, sending quantum keys to a transmitting end and a receiving end respectively; Step S1 includes the following sub-steps:

[0068] Step S101, setting a key pool, the key pool includes unit keys, the unit keys include uppercase letters A to Z, lowercase letters a to Z and numbers 0 to 9;

[0069] Step S102, randomly selecting a first unit number of unit keys from a key pool to form an initial key;

[0070] Step S103, converting the unit key in the initial key into a decimal number based on the ASCII code to obtain an initial public key;

[0071] Step S104, calculating the initial public key modulo 4 to obtain the public key remainder, if the public key remainder is 1, then outputting a digit compliance signal; if the public key remainder is not 1, then outputting a digit non-compliance signal;

[0072] Step S105, if the output digits match the signal, the initial public key is marked as the encrypted public key; if the output digits do not match the signal, the last decimal digit of the initial public key is removed until the remainder of the public key is 1, and the encrypted public key is obtained;

[0073] In the specific implementation, the first unit number is only to provide a standard for the selection of the unit key. The first unit number can be changed. The larger the first unit number is, the higher the encryption security is, and the slower the encryption rate is. In this embodiment, the first unit number is set to 6, and the initial key randomly selected is "F237a8"; the initial public key obtained by conversion based on ASCII code is "70237978". When converting, if the unit key is a number, no conversion is required; the public key remainder is calculated to be 0, and the public key remainder is not 1 through comparison, and a digit mismatch signal is output, and the last digit of the initial public key "70237978" is removed to obtain the encrypted public key "70237";

[0074] Step S106, calculating the encryption public key to obtain the decryption private key;

[0075] Step S106 includes the following sub-steps:

[0076] See also Figure 2 As shown, in step S106.1, the number of bits of the encrypted public key is obtained, which is named as the number of bits of the public key and represented by the symbol m; the encrypted public key is numbered, which is named as the key number and represented by the symbol E n Indicates that n is a positive integer and 1≤n≤m, E n Represents the decimal number at the nth position in the encrypted public key;

[0077] Step S106.2, E n Compare with 5, if E n Less than 5, the digital incremental signal is output; if E n If it is greater than or equal to 5, a digital decrement signal is output;

[0078] Step S106.3: If a digital incremental signal is output, then E n Increase by 5; if the digital decrement signal is output, E n Decrease by 5;

[0079] Step S106.4, calculating the remainder of the encrypted public key modulo 2 after enlargement or reduction, and naming it as the private key algorithm parameter. If the private key algorithm parameter is 0, outputting the first private key algorithm signal; if the private key algorithm parameter is 1, outputting the second private key algorithm signal;

[0080] In the specific implementation, the number of bits of the public key obtained is 5, that is, m=5, E1 is "7", E2 is "0", E3 is "2", E4 is "3", and E5 is "7". By comparison and processing, E1 is "2", E2 is "5", E3 is "7", E4 is "8", and E5 is "2", that is, the encrypted public key is changed to "25782", 25782%2 is calculated, and the private key algorithm parameter is 0, and the first private key algorithm signal is output; the encrypted public key changed here is only the encrypted public key in the process of decrypting the private key, and the encrypted public key actually sent to the sender is still "70237";

[0081] See also Figure 3 As shown, in step S106.5, the first private key algorithm signal and the second private key algorithm signal are collectively referred to as private key algorithm signals, and different algorithm calculations are performed on the encrypted public key according to the private key algorithm signals;

[0082] Step S106.5 includes the following sub-steps:

[0083] Step S106.5.a: If the first private key algorithm signal is output, then starting from n=1, E n With E n+1 The corresponding decimal numbers are swapped, n is increased by 2, and E n With E n+1 Replace the corresponding decimal numbers and increase n by 2 until n=m-2. n With E n+1 After the exchange, the increase stopped;

[0084] Step S106.5.b: If the second private key algorithm signal is output, then starting from n=1, E n With E n+2 The corresponding decimal numbers are swapped, and E n+1 With E n+3 The corresponding decimal numbers are swapped; n is increased by 4, and the swapping process is repeated, increasing n by 4 in sequence until n=m-4, and then the increase is stopped;

[0085] Step S106.5.c, marking the continuous numbers obtained after the exchange as the decryption private key, sending the encryption public key to the sending end through the quantum channel, and sending the decryption private key to the receiving end;

[0086] In the specific implementation, the first private key algorithm signal is output, n=1, E1 and E2 are swapped, that is, E1 is changed to "5", E2 is changed to "2", n is increased by 2, at this time n=3, E3 and E4 are swapped, that is, E3 is changed to "8", E4 is changed to "7", n is 3, which is equal to m-2, then the increase is stopped, and the decryption private key is "52872"; the encryption public key "70237" is sent to the sending end through the quantum channel, and the decryption private key "52872" is sent to the receiving end.

[0087] Step S2, encrypting the sent plain text by using the quantum key to obtain the encrypted ciphertext; Step S2 includes the following sub-steps:

[0088] Step S201, obtaining the sent plaintext, converting the language of the sent plaintext into English format, and obtaining the plaintext to be encrypted;

[0089] Step S202, converting letters in the plain text to be encrypted into binary numbers according to ASCII codes to obtain cipher text to be encrypted;

[0090] Step S203, converting each decimal digit in the encryption public key into an 8-bit binary digit to obtain a key to be encrypted;

[0091] In the specific implementation, the purpose of converting the sent plain text into English format is to facilitate the conversion between different languages ​​in group chats; the sent plain text is obtained as "ideal", which is converted into English format as "ideals", and the ciphertext to be encrypted is obtained by ASCII code conversion as "011010010110010001100101011000010110110001110011"; the encryption public key is "70237", 7, 0, 2, 3 and 7 are converted into 8-digit binary numbers respectively, and the encryption key to be obtained is "00000111000000000000001000000011000000111;

[0092] Step S204, obtaining the number of digits of the ciphertext to be encrypted, named as the number of ciphertext digits; obtaining the number of digits of the key to be encrypted, named as the number of key digits;

[0093] Step S205, compare the number of ciphertext bits with the number of key bits, if the number of ciphertext bits is less than the number of key bits, output a key removal signal; if the number of ciphertext bits is equal to the number of key bits, output a signal of the same number of bits; if the number of ciphertext bits is greater than the number of key bits, output a signal of the key addition;

[0094] Step S206, if the key removal signal is output, the number of key bits minus the number of ciphertext bits is calculated, the calculation result is marked as the encryption bit difference, and the number of encryption bit difference after the key to be encrypted is removed to obtain the true encryption key; if the key addition signal is output, another key to be encrypted is spliced ​​after the key to be encrypted, and the number of ciphertext bits and the number of key bits are compared again; if the number of bits is the same signal, the key to be encrypted is changed to the true encryption key;

[0095] In the specific implementation, the number of ciphertext bits is 48, and the number of key bits is 40. By comparison, it is found that the number of ciphertext bits is greater than the number of key bits, and a key increase signal is output. A key to be encrypted is concatenated after the key to be encrypted, that is, "0000011100000000000000100000001100000111000001110000000000000100000001100000111", at which time the number of key bits is 80, and the number of ciphertext bits is less than the number of key bits. A key removal signal is output to remove the end of the key to be encrypted until 48 digits remain, and the true encryption key is "00000111000000000000010000000110000011100000111".

[0096] Step S207: number each digit in the encrypted ciphertext, using the symbol S i Indicates that i is the serial number of S and i is a positive integer; each digit in the true encryption key is numbered, and the symbol P i Indicates that i and S i The i in is the same;

[0097] Step S208: sort S in the order of i=1 to i=the number of ciphertext bits. i With P i Perform XOR and obtain the encrypted ciphertext after XOR is completed;

[0098] In the specific implementation, S1 is 0, P1 is 0, S1 = P1, then the XOR result is 0, and the remaining S i With P i After XOR, the encrypted ciphertext is "011011100110010001100111011000100110101101110100".

[0099] Step S3, transmitting the encrypted ciphertext to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key to obtain the sent plaintext; Step S3 includes the following sub-steps:

[0100] Step S301, obtain the number of bits of the decryption private key, named as the private key number, represented by the symbol h; number the decryption private key, named as the private key number, represented by the symbol Kf Indicates that f is a positive integer and 1≤f≤h, K f Represents the decimal number at the fth position in the decrypted private key;

[0101] Step S302: K f Compare with 5, if K f Less than 5, a digital incremental signal is output; if K f If it is greater than or equal to 5, a digital decrement signal is output;

[0102] Step S303: If a digital incremental signal is output, K f Increase by 5; if the digital decrement signal is output, K f Decrease by 5;

[0103] Step S304, calculating the remainder of the decryption private key modulo 2 after increase or decrease, and naming it as the private key inverse algorithm parameter. If the private key inverse algorithm parameter is 1, then outputting the first private key inverse algorithm signal; if the private key inverse algorithm parameter is 0, then outputting the second private key inverse algorithm signal;

[0104] Step S305: If the first private key reverse algorithm signal is output, then starting from f=1, K f With K f+1 The corresponding decimal numbers are swapped, f is increased by 2, and K f With K f+1 Replace the corresponding decimal numbers and increase f by 2 until f = h-2. f With K f+1 After the exchange, the increase stopped;

[0105] Step S306: If the second private key reverse algorithm signal is output, then starting from f=1, K f With K f+2 The corresponding decimal numbers are swapped and K f+1 With K f+3 The corresponding decimal numbers are swapped; f is increased by 4, and the swapping process is repeated, increasing f by 4 in sequence until f = h-4, and then the increase is stopped;

[0106] In the specific implementation, the decryption private key is "52872", and the number of bits of the private key is 5, that is, h = 5. f After increment or decrement, the decryption private key is "07327"; the private key inverse algorithm parameter is calculated to be 1, and the first private key inverse algorithm signal is output; f=1, K1 and K2 are swapped, that is, K1 is changed to "7", K2 is changed to "0", f is increased by 2, at this time f=3=h-2, and it will not be increased in the future, K3 and K4 are swapped, that is, K3 is changed to "2", K4 is changed to "3", and the first decryption key is "70237" obtained by processing;

[0107] Step S307, after the exchange is completed, the first decryption key is obtained, and the encrypted ciphertext is decrypted by the first decryption key to obtain the sent plaintext;

[0108] Step S307 includes the following sub-steps:

[0109] Step S307.1, convert each decimal digit in the first decryption key into an 8-bit binary digit to obtain a second decryption key;

[0110] Step S307.2, obtaining the number of bits of the encrypted ciphertext, named as the number of bits for decryption; obtaining the number of bits of the second decryption key, named as the number of bits for decryption key;

[0111] Step S307.3, compare the number of decrypted bits with the number of decrypted key bits. If the number of decrypted bits is less than the number of decrypted key bits, output a key removal signal; if the number of decrypted bits is equal to the number of decrypted key bits, output a number of bits that are the same; if the number of decrypted bits is greater than the number of decrypted key bits, output a key increase signal;

[0112] Step S307.4, if the key removal signal is output, the number of decryption bits minus the number of decryption bits is calculated, the calculation result is marked as the decryption bit difference, and the number of decryption bit difference after the second decryption key is removed to obtain the true decryption key; if the key increase signal is output, a second decryption key is spliced ​​after the second decryption key, and the number of decryption bits is compared with the number of decryption bits again; if the signal of the same number of bits is output, the second decryption key is changed to the true decryption key;

[0113] In a specific implementation, the encrypted ciphertext is "011011100110010001100111011000100110101101110100", and the decimal number is converted into a binary number to obtain the second decryption key "0000011100000000000000100000001100000111", and the number of decryption bits is 48, and the number of decryption bits is 40. By comparison, it is found that the number of decryption bits is greater than the number of decryption bits, and a key increase signal is output, and a second decryption key is spliced ​​after the second decryption key, that is, "0000011100000000000001000000011000001110 000011100000000000000100000001100000111", compare again to get the decryption bit number is less than the decryption key bit number, output the key removal signal, calculate the decryption bit difference is 80-48=32, remove the last 32 bits of “000001110000000000000100000001100000111000001110000000000000100000001100000111”, get the true decryption key “00000111000000000000010000000110000011100000111”;

[0114] Step S307.5: number each digit in the encrypted ciphertext, using the symbol C j Indicates that j is the serial number of C and j is a positive integer; each digit in the true encryption key is numbered, and the symbol V j Indicates that j and C j The j in is the same;

[0115] Step S307.6, in the order of j=1 to j=the number of decrypted bits, C j With V j Perform XOR, and after XOR is completed, the ciphertext to be decrypted is obtained;

[0116] Step S307.7, restore the ciphertext to be decrypted to English letters according to the ASCII code table to obtain the decrypted plaintext, and translate the decrypted plaintext according to the language selected by the user to obtain the sending plaintext;

[0117] In the specific implementation, C1 is 0, V1 is 0, C1 = V1, then the XOR result is 0. j With V jAfter all the XOR operations are performed, the ciphertext to be decrypted is "01101001011001000110010101100001011011000110011". In order from front to back, the 8-digit binary number is restored to English letters based on the ASCII code table, and the decrypted plaintext is "ideals". If the language selected by the user is Chinese, the plaintext sent is translated as "ideal".

[0118] Example 2, please refer to Figure 4 As shown, in the second aspect, the present application provides a group chat encryption system based on quantum key, including a quantum key distribution module, an information encryption module and an information decryption module; the quantum key distribution module and the information decryption module are respectively connected to the information encryption module in communication;

[0119] The quantum key distribution module is used to send quantum keys to the sending end and the receiving end respectively through the quantum channel; the quantum key distribution module includes a public key generation unit and a private key generation unit;

[0120] The public key generation unit is configured with a public key generation strategy, which includes:

[0121] Set a key pool, which includes unit keys, and the unit keys include uppercase letters A to Z, lowercase letters a to Z, and numbers 0 to 9;

[0122] Randomly select a unit key of a first unit number from the key pool to form an initial key;

[0123] Convert the unit key in the initial key into a decimal number based on the ASCII code to obtain the initial public key;

[0124] Calculate the initial public key modulo 4 to get the public key remainder. If the public key remainder is 1, the output digits match the signal; if the public key remainder is not 1, the output digits do not match the signal.

[0125] If the output digits match the signal, the initial public key is marked as the encrypted public key; if the output digits do not match the signal, the last decimal digit of the initial public key is removed until the remainder of the public key is 1, and the encrypted public key is obtained;

[0126] Calculate the encryption public key to obtain the decryption private key;

[0127] The private key generation unit is configured with a private key generation strategy, which includes:

[0128] Get the number of bits of the encrypted public key, named as the number of bits of the public key, represented by the symbol m; number the encrypted public key, named as the key number, represented by the symbol E n Indicates that n is a positive integer and 1≤n≤m, E nRepresents the decimal number at the nth position in the encrypted public key;

[0129] E n Compare with 5, if E n Less than 5, the digital incremental signal is output; if E n If it is greater than or equal to 5, a digital decrement signal is output;

[0130] If the digital incremental signal is output, E n Increase by 5; if the digital decrement signal is output, E n Decrease by 5;

[0131] Calculate the remainder of the encrypted public key modulo 2 after enlargement or reduction, and name it as the private key algorithm parameter. If the private key algorithm parameter is 0, output the first private key algorithm signal; if the private key algorithm parameter is 1, output the second private key algorithm signal;

[0132] The first private key algorithm signal and the second private key algorithm signal are collectively referred to as private key algorithm signals, and different algorithm calculations are performed on the encrypted public key according to the private key algorithm signals;

[0133] If the first private key algorithm signal is output, then starting from n=1, E n With E n+1 The corresponding decimal numbers are swapped, n is increased by 2, and E n With E n+1 Replace the corresponding decimal numbers and increase n by 2 until n=m-2. n With E n+1 After the exchange, the increase stopped;

[0134] If the second private key algorithm signal is output, then starting from n=1, E n With E n+2 The corresponding decimal numbers are swapped, and E n+1 With E n+3 The corresponding decimal numbers are swapped; n is increased by 4, and the swapping process is repeated, increasing n by 4 in sequence until n=m-4, and then the increase is stopped;

[0135] The serial numbers obtained after the swap are marked as the decryption private key, and the encryption public key is sent to the sender through the quantum channel, and the decryption private key is sent to the receiver;

[0136] The information encryption module is used to encrypt the sent plain text through the quantum key pair to obtain the encrypted ciphertext;

[0137] The information encryption module is configured with information encryption strategies, which include:

[0138] Get the sent plaintext, convert the language of the sent plaintext into English format, and get the plaintext to be encrypted;

[0139] Convert the letters in the plaintext to be encrypted into binary numbers according to ASCII codes to obtain the ciphertext to be encrypted;

[0140] Convert each decimal digit in the encrypted public key into an 8-bit binary digit to obtain the key to be encrypted;

[0141] Get the number of digits of the ciphertext to be encrypted, named as the number of ciphertext digits; get the number of digits of the key to be encrypted, named as the number of key digits;

[0142] Compare the number of ciphertext digits with the number of key digits. If the number of ciphertext digits is less than the number of key digits, output the key removal signal; if the number of ciphertext digits is equal to the number of key digits, output the same number of digits signal; if the number of ciphertext digits is greater than the number of key digits, output the key increase signal;

[0143] If the key removal signal is output, the number of key bits minus the number of ciphertext bits is calculated, the calculation result is marked as the encryption bit difference, and the number of encryption bit difference after the key to be encrypted is removed to obtain the true encryption key; if the key addition signal is output, another key to be encrypted is spliced ​​after the key to be encrypted, and the number of ciphertext bits and key bits are compared again; if the output number of bits is the same, the key to be encrypted is changed to the true encryption key;

[0144] Number each digit in the encrypted ciphertext, using the symbol S i Indicates that i is the serial number of S and i is a positive integer; each digit in the true encryption key is numbered, and the symbol P i Indicates that i and S i The i in is the same;

[0145] S is sorted in the order from i = 1 to i equal to the number of ciphertext bits. i With P i Perform XOR and obtain the encrypted ciphertext after XOR is completed;

[0146] The information decryption module is used to transmit the encrypted ciphertext to the receiving end through the traditional channel. The receiving end decrypts the encrypted ciphertext through the quantum key to obtain the sent plaintext. The information decryption module includes a private key conversion unit and a ciphertext decryption unit.

[0147] The private key conversion unit is configured with a private key conversion strategy, which includes:

[0148] Get the number of digits of the decryption private key, named as the private key digits, represented by the symbol h; number the decryption private key, named as the private key number, represented by the symbol K f Indicates that f is a positive integer and 1≤f≤h, K f Represents the decimal number at the fth position in the decrypted private key;

[0149] K fCompare with 5, if K f Less than 5, a digital incremental signal is output; if K f If it is greater than or equal to 5, a digital decrement signal is output;

[0150] If the digital incremental signal is output, K f Increase by 5; if the digital decrement signal is output, K f Decrease by 5;

[0151] Calculate the remainder of the decryption private key modulo 2 after increase or decrease, and name it as the private key inverse algorithm parameter. If the private key inverse algorithm parameter is 1, output the first private key inverse algorithm signal; if the private key inverse algorithm parameter is 0, output the second private key inverse algorithm signal;

[0152] If the first private key reverse algorithm signal is output, then starting from f=1, K f With K f+1 The corresponding decimal numbers are swapped, f is increased by 2, and K f With K f+1 Replace the corresponding decimal numbers and increase f by 2 until f = h-2. f With K f+1 After the exchange, the increase stopped;

[0153] If the second private key reverse algorithm signal is output, then starting from f=1, K f With K f+2 The corresponding decimal numbers are swapped and K f+1 With K f+3 The corresponding decimal numbers are swapped; f is increased by 4, and the swapping process is repeated, increasing f by 4 in sequence until f = h-4, and then the increase is stopped;

[0154] After the exchange is completed, the first decryption key is obtained, and the encrypted ciphertext is decrypted by the first decryption key to obtain the sent plaintext;

[0155] The ciphertext decryption unit is configured with a ciphertext decryption strategy, which includes:

[0156] Convert each decimal digit in the first decryption key into an 8-bit binary digit to obtain a second decryption key;

[0157] The number of bits of the encrypted ciphertext is obtained, which is named as the number of bits for decryption; the number of bits of the second decryption key is obtained, which is named as the number of bits for decryption key;

[0158] Compare the number of decrypted bits with the number of decrypted key bits. If the number of decrypted bits is less than the number of decrypted key bits, a key removal signal is output; if the number of decrypted bits is equal to the number of decrypted key bits, a signal of the same number of bits is output; if the number of decrypted bits is greater than the number of decrypted key bits, a key increase signal is output;

[0159] If the key removal signal is output, the number of decryption bits is calculated and subtracted from the number of decryption bits, and the calculation result is marked as the decryption bit difference. The number of decryption bit difference after the second decryption key is removed to obtain the true decryption key; if the key increase signal is output, a second decryption key is spliced ​​after the second decryption key, and the number of decryption bits is compared with the number of decryption bits again; if the signal of the same number of bits is output, the second decryption key is changed to the true decryption key;

[0160] Number each digit in the encrypted ciphertext, using the symbol C j Indicates that j is the serial number of C and j is a positive integer; each digit in the true encryption key is numbered, and the symbol V j Indicates that j and C j The j in is the same;

[0161] C is sorted in the order from j = 1 to j equal to the number of decrypted bits. j With V j Perform XOR, and after XOR is completed, the ciphertext to be decrypted is obtained;

[0162] The ciphertext to be decrypted is restored to English letters according to the ASCII code table to obtain the decrypted plaintext, and the decrypted plaintext is translated into the sending plaintext according to the language selected by the user.

[0163] Embodiment 3, in the third aspect, the present application provides an electronic device, including a processor and a memory, the memory storing computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the above method are executed. Through the above technical solution, the processor and the memory are interconnected and communicate with each other through a communication bus and / or other forms of connection mechanisms, and the memory stores a computer program executable by the processor. When the electronic device is running, the processor executes the computer program to execute the method in any optional implementation of the above embodiment to achieve the following functions: send quantum keys separately through quantum channels, and send quantum keys to the sending end and the receiving end respectively; encrypt the sent plaintext through the quantum key to obtain the encrypted ciphertext; transmit the encrypted ciphertext to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key to obtain the sent plaintext.

[0164] Embodiment 4, in a fourth aspect, the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above method are executed. Through the above technical solution, when the computer program is executed by the processor, the method in any optional implementation of the above embodiment is executed to achieve the following functions: quantum keys are sent separately through a quantum channel, and quantum keys are sent to the sending end and the receiving end respectively; the sent plaintext is encrypted by the quantum key to obtain the encrypted ciphertext; the encrypted ciphertext is transmitted to the receiving end through a traditional channel, and the receiving end decrypts the encrypted ciphertext by the quantum key to obtain the sent plaintext.

[0165] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0166] It should be understood by those skilled in the art that the embodiments of the present invention can be provided as methods, systems or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0167] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

Claims

1. Group chat encryption method based on quantum key, It is characterized in that The steps include: The quantum keys are sent separately through the quantum channel, and the quantum keys are sent to the sending end and the receiving end respectively; Encrypt the sent plaintext through the quantum key to obtain the encrypted ciphertext; The encrypted ciphertext is transmitted to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext with the quantum key to obtain the sent plaintext; The quantum keys are sent separately through the quantum channel to the sending end and the receiving end respectively, including the following sub-steps: Setting a key pool, wherein the key pool includes unit keys, and the unit keys include uppercase letters A to Z, lowercase letters a to Z, and numbers 0 to 9; Randomly select a unit key of a first unit number from the key pool to form an initial key; Convert the unit key in the initial key into a decimal number based on the ASCII code to obtain the initial public key; Calculate the initial public key modulo 4 to get the public key remainder. If the public key remainder is 1, the output digits match the signal; if the public key remainder is not 1, the output digits do not match the signal. If the output digits match the signal, the initial public key is marked as the encrypted public key; if the output digits do not match the signal, the last decimal digit of the initial public key is removed until the remainder of the public key is 1, and the encrypted public key is obtained; Calculate the encryption public key to obtain the decryption private key; The calculation of the encryption public key includes the following sub-steps: Get the number of bits of the encrypted public key, named as the number of bits of the public key, represented by the symbol m; number the encrypted public key, named as the key number, represented by the symbol E n Indicates that n is a positive integer and 1≤n≤m, E n Represents the decimal number at the nth position in the encrypted public key; E n Compare with 5, if E n Less than 5, the digital incremental signal is output; if E n If it is greater than or equal to 5, a digital decrement signal is output; If the digital incremental signal is output, E n Increase by 5; if the digital decrement signal is output, E n Decrease by 5; Calculate the remainder of the encrypted public key modulo 2 after enlargement or reduction, and name it as the private key algorithm parameter. If the private key algorithm parameter is 0, output the first private key algorithm signal; if the private key algorithm parameter is 1, output the second private key algorithm signal; The first private key algorithm signal and the second private key algorithm signal are collectively referred to as private key algorithm signals, and different algorithm calculations are performed on the encrypted public key according to the private key algorithm signals; The different algorithm calculations of the encrypted public key according to the private key algorithm signal include the following sub-steps: If the first private key algorithm signal is output, then starting from n=1, E n With E n+1 The corresponding decimal numbers are swapped, n is increased by 2, and E n With E n+1 Replace the corresponding decimal numbers and increase n by 2 until n=m-2. n With E n+1 After the exchange, the increase stopped; If the second private key algorithm signal is output, then starting from n=1, E n With E n+2 The corresponding decimal numbers are swapped, and E n+1 With E n+3 The corresponding decimal numbers are swapped; n is increased by 4, and the swapping process is repeated, increasing n by 4 in sequence until n=m-4, and then the increase is stopped; The continuous numbers obtained after the exchange are marked as the decryption private key, and the encrypted public key is sent to the sender through the quantum channel, and the decrypted private key is sent to the receiver.

2. The group chat encryption method based on quantum key according to claim 1, It is characterized in that Sending plaintext encryption via quantum key pair includes the following sub-steps: Get the sent plaintext, convert the language of the sent plaintext into English format, and get the plaintext to be encrypted; Convert the letters in the plaintext to be encrypted into binary numbers according to ASCII codes to obtain the ciphertext to be encrypted; Convert each decimal digit in the encrypted public key into an 8-bit binary digit to obtain the key to be encrypted; Get the number of digits of the ciphertext to be encrypted, named as the number of ciphertext digits; get the number of digits of the key to be encrypted, named as the number of key digits; Compare the number of ciphertext bits with the number of key bits. If the number of ciphertext bits is less than the number of key bits, output the key removal signal. If the number of ciphertext bits is equal to the number of key bits, the output signal will have the same number of bits; If the number of ciphertext bits is greater than the number of key bits, a key increase signal is output; If the key removal signal is output, the number of key bits minus the number of ciphertext bits is calculated, the calculation result is marked as the encryption bit difference, and the number of encryption bit difference after the encryption key is removed to obtain the true encryption key; If the output key increases the signal, then another key to be encrypted is spliced ​​after the key to be encrypted, and the number of ciphertext bits is compared with the number of key bits again; if the output bit number is the same signal, the key to be encrypted is changed to the real encryption key; Number each digit in the encrypted ciphertext, using the symbol S i Indicates that i is the serial number of S and i is a positive integer; each digit in the true encryption key is numbered, and the symbol P i Indicates that i and S i The i in is the same; S is sorted in the order from i = 1 to i equal to the number of ciphertext bits. i With P i Perform XOR and obtain the encrypted ciphertext after XOR is completed.

3. The group chat encryption method based on quantum key according to claim 2, It is characterized in that The encrypted ciphertext is transmitted to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key, including the following sub-steps: Get the number of digits of the decryption private key, named as the private key digits, represented by the symbol h; number the decryption private key, named as the private key number, represented by the symbol K f Indicates that f is a positive integer and 1≤f≤h, K f Represents the decimal number at the fth position in the decrypted private key; K f Compare with 5, if K f Less than 5, a digital incremental signal is output; if K f If it is greater than or equal to 5, a digital decrement signal is output; If the digital incremental signal is output, K f Increase by 5; if the digital decrement signal is output, K f Decrease by 5; Calculate the remainder of the decryption private key modulo 2 after increase or decrease, and name it as the private key inverse algorithm parameter. If the private key inverse algorithm parameter is 1, output the first private key inverse algorithm signal; if the private key inverse algorithm parameter is 0, output the second private key inverse algorithm signal; If the first private key reverse algorithm signal is output, then starting from f=1, K f With K f+1 The corresponding decimal numbers are swapped, f is increased by 2, and K f With K f+1 Replace the corresponding decimal numbers and increase f by 2 until f = h-2. f With K f+1 After the exchange, the increase stopped; If the second private key reverse algorithm signal is output, then starting from f=1, K f With K f+2 The corresponding decimal numbers are swapped and K f+1 With K f+3 The corresponding decimal numbers are swapped; f is increased by 4, and the swapping process is repeated, increasing f by 4 in sequence until f = h-4, and then the increase is stopped; After the exchange is completed, the first decryption key is obtained, and the encrypted ciphertext is decrypted by the first decryption key to obtain the sent plaintext.

4. The group chat encryption method based on quantum key according to claim 3, It is characterized in that Decrypting the encrypted ciphertext using the first decryption key includes the following sub-steps: Convert each decimal digit in the first decryption key into an 8-bit binary digit to obtain a second decryption key; The number of bits of the encrypted ciphertext is obtained, which is named as the number of bits for decryption; the number of bits of the second decryption key is obtained, which is named as the number of bits for decryption key; The decryption bit number is compared with the decryption key bit number. If the decryption bit number is less than the decryption key bit number, a key removal signal is output; If the number of decrypted bits is equal to the number of decryption key bits, the output is the same number of bits signal; if the number of decrypted bits is greater than the number of decryption key bits, the output is the key increase signal; If the key removal signal is output, the number of decryption bits is calculated and subtracted from the number of decryption bits, and the calculation result is marked as the decryption bit difference. The number of decryption bit difference after the second decryption key is removed to obtain the true decryption key; if the key increase signal is output, a second decryption key is spliced ​​after the second decryption key, and the number of decryption bits is compared with the number of decryption bits again; if the signal of the same number of bits is output, the second decryption key is changed to the true decryption key; Number each digit in the encrypted ciphertext, using the symbol C j Indicates that j is the serial number of C and j is a positive integer; each digit in the true encryption key is numbered, and the symbol V j Indicates that j and C j The j in is the same; C is sorted in the order from j = 1 to j equal to the number of decrypted bits. j With V j Perform XOR, and after XOR is completed, the ciphertext to be decrypted is obtained; The ciphertext to be decrypted is restored to English letters according to the ASCII code table to obtain the decrypted plaintext, and the decrypted plaintext is translated into the sending plaintext according to the language selected by the user.

5. A group chat encryption system based on quantum key, applicable to the group chat encryption method based on quantum key according to any one of claims 1 to 4, It is characterized in that It includes a quantum key distribution module, an information encryption module and an information decryption module; the quantum key distribution module and the information decryption module are respectively connected to the information encryption module in communication; The quantum key distribution module is used to send quantum keys to the transmitting end and the receiving end respectively through the quantum channel; The information encryption module is used to encrypt the sent plain text through the quantum key to obtain the encrypted ciphertext; The information decryption module is used to transmit the encrypted ciphertext to the receiving end through the traditional channel, and the receiving end decrypts the encrypted ciphertext through the quantum key to obtain the sent plaintext.

6. An electronic device, It is characterized in that The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 4 are executed.

7. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are executed.