Text encryption and decryption method, system and device based on elliptic curve cryptography
Through the text encryption and decryption method based on elliptic curve cryptography, the existing text encryption algorithm is solved, and the problem of being vulnerable to attack and long encryption and decryption time is achieved, and an efficient and secure text encryption and decryption process is achieved.
Patent Information
- Application Number
- CN202211606811.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-12-14
AI Technical Summary
Existing text encryption algorithms are vulnerable to various attacks, and have a long encryption and decryption time and small key space, which poses a risk of being cracked.
The text encryption and decryption method based on elliptic curve cryptography is adopted. By converting plaintext messages into ASCII code arrays, adding position indexes, modulo operation groupings, generating session keys and encryption matrices, and matrix multiplication is used to generate ciphertexts.
Shorten the encryption and decryption time, reduce mapping overhead, improve the security of data transmission and access processes, and avoid expensive mapping and sharing of public lookup tables.
Smart Images

Figure CN116094716B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to a text encryption and decryption method, system and device based on elliptic curve cryptography. Background Art
[0002] With the rapid development of cloud storage, Internet and multimedia technology, multimedia files have shown explosive growth. People's frequent operations on multimedia files such as images stored in the cloud have led to increasing copyright issues. Therefore, in order to achieve copyright protection for cave mural images, copyright owners have also encrypted the copyright information of digital images to solve the security problems faced in network transmission and access. However, the existing text encryption algorithms are vulnerable to attacks such as Ciphtext Only Attack (COA), Known Plaintext Attack (KPA), Chosen Plaintext Attack (CPA) and Chosen Ciphertext Attack (CCA), and there is a risk of being cracked. Elliptic Curve Cryptography (ECC) has the characteristics of high security, small key size, high flexibility and small storage space occupation, which can well solve the network transmission security and access security problems of text information such as digital image copyright.
[0003] ECC technology achieves data security by protecting the communication content of both the sender and the receiver. It provides more secure encryption for data when the key size is small, and is widely used in cryptography. Although traditional text encryption technologies such as symmetric encryption, hash algorithm and asymmetric encryption are relatively complete, they still have problems such as easy cracking, slow encryption speed and small key space. Existing ECC text encryption technologies mostly solve the problem of low data confidentiality caused by static mapping by improving message mapping schemes, and use mapping security to achieve double security, but the overhead of complex mapping schemes is large and vulnerable to CPA attacks. Therefore, in order to enhance the security of the encryption process, scholars encrypt the mapped data in reverse order, but this method still has the possibility of being cracked by brute force based on frequency analysis. At present, although the existing method of selecting ECC private keys in combination with deep learning technology improves the accuracy of ECC, the private key selection process still makes the time overhead of encryption and decryption large. Most of the existing improvements to the ECC scheme are to shorten the encryption time by improving the mapping scheme of plaintext messages, but when the message is large, the encryption efficiency is not high, it is vulnerable to CPA attacks, and the mapping overhead and data security cannot be balanced. Summary of the invention
[0004] The purpose of the present invention is to provide a text encryption and decryption method, system and device based on elliptic curve cryptography to shorten the encryption and decryption time and ensure the security of data transmission and access while reducing mapping overhead.
[0005] To achieve the above object, the present invention provides the following solutions:
[0006] A text encryption method based on elliptic curve cryptography, the text encryption method comprising:
[0007] Get the plaintext message to be encrypted;
[0008] Convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same;
[0009] Adding position indexes to the ASCII code values in the ASCII code array to be encrypted in sequence to obtain a string array to be encrypted; the number of bits of each position index is the same;
[0010] Performing a modular operation of a set modulus on the ASCII code value of each string in the array of strings to be encrypted, and grouping each string in the array of strings to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus;
[0011] The character strings in each of the character string groups are concatenated to obtain a plurality of concatenated character strings to be encrypted, and each of the concatenated character strings to be encrypted is converted into an integer to obtain a plurality of integer values to be encrypted;
[0012] Determine the generator of elliptic curve encryption, and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number;
[0013] Generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key;
[0014] Performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption;
[0015] According to the encryption matrix and the encryption mode, each of the integer values to be encrypted is encrypted to obtain a plurality of ciphertexts; the number of the ciphertexts is half the number of the integer values to be encrypted.
[0016] Optionally, encrypting each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain a plurality of ciphertexts specifically includes:
[0017] According to the encryption mode, the integer values to be encrypted are arranged and grouped in pairs to obtain a plurality of integer pairs to be encrypted;
[0018] According to the encryption matrix, matrix multiplication operations are performed on each pair of integers to be encrypted to obtain multiple ciphertexts.
[0019] A text decryption method based on elliptic curve cryptography, the text decryption method comprising:
[0020] Obtaining a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption;
[0021] Generate a session key according to the receiver's private key and the sender's public key, and determine a corresponding decryption matrix according to the session key;
[0022] Decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts;
[0023] According to the set number of digits information, each of the integer values to be decrypted is converted into a concatenated string to be decrypted; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender;
[0024] Concatenate the concatenated character strings to be decrypted to obtain a secondary concatenated character string;
[0025] According to the set number of bits information, the secondary concatenated string is segmented to obtain an array of strings to be decrypted;
[0026] Arrange the ASCII code values of each string in the array of strings to be decrypted according to the position index in each string in the array of strings to be decrypted, to obtain an array of ASCII codes to be decrypted;
[0027] The decrypted plaintext message is determined according to the array of ASCII codes to be decrypted.
[0028] Optionally, decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted specifically includes:
[0029] According to the decryption matrix, matrix multiplication operations are performed on each of the ciphertexts to obtain a plurality of integer pairs to be decrypted;
[0030] According to the encryption mode, each of the to-be-decrypted integer pairs is split and arranged respectively to obtain a plurality of to-be-decrypted integer values.
[0031] A text encryption and decryption method based on elliptic curve cryptography, the text encryption and decryption method comprising: an encryption process and a decryption process;
[0032] The encryption process includes:
[0033] Get the plaintext message to be encrypted;
[0034] Convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same;
[0035] Adding position indexes to the ASCII code values in the ASCII code array to be encrypted in sequence to obtain a string array to be encrypted; the number of bits of each position index is the same;
[0036] Performing a modular operation of a set modulus on the ASCII code value of each string in the array of strings to be encrypted, and grouping each string in the array of strings to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus;
[0037] The character strings in each of the character string groups are concatenated to obtain a plurality of concatenated character strings to be encrypted, and each of the concatenated character strings to be encrypted is converted into an integer to obtain a plurality of integer values to be encrypted;
[0038] Determine the generator of elliptic curve encryption, and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number;
[0039] Generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key;
[0040] Performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption;
[0041] Encrypting each of the to-be-encrypted integer values according to the encryption matrix and the encryption mode to obtain a plurality of ciphertexts; the number of the ciphertexts is half the number of the to-be-encrypted integer values;
[0042] The decryption process includes:
[0043] Obtaining a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption;
[0044] Generate a session key according to the receiver's private key and the sender's public key, and determine a corresponding decryption matrix according to the session key;
[0045] Decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts;
[0046] According to the set number of digits information, each of the integer values to be decrypted is converted into a concatenated string to be decrypted; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender;
[0047] Concatenate the concatenated character strings to be decrypted to obtain a secondary concatenated character string;
[0048] According to the set number of bits information, the secondary concatenated string is segmented to obtain an array of strings to be decrypted;
[0049] Arrange the ASCII code values of each string in the array of strings to be decrypted according to the position index in each string in the array of strings to be decrypted, to obtain an array of ASCII codes to be decrypted;
[0050] The decrypted plaintext message is determined according to the array of ASCII codes to be decrypted.
[0051] Optionally, the converting of each of the to-be-decrypted integer values into a to-be-decrypted concatenated character string according to the set bit number information specifically includes:
[0052] Convert each of the integer values to be decrypted into a corresponding character string to obtain a plurality of converted character strings;
[0053] If the number of digits of the converted character string is not an integer multiple of the third set number of digits, 0 is added before the converted character string until the number of digits of the converted character string is an integer multiple of the third set number of digits; the third set number of digits is the sum of the first set number of digits and the second set number of digits;
[0054] If the number of digits of the converted character string is an integer multiple of the third set number of digits, the converted character string is determined as the concatenated character string to be decrypted.
[0055] A text encryption system based on elliptic curve cryptography, the text encryption system comprising:
[0056] A plaintext message acquisition module, used to obtain the plaintext message to be encrypted;
[0057] An ASCII code conversion module is used to convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same;
[0058] An index adding module is used to sequentially add position indexes to each of the ASCII code values in the ASCII code array to be encrypted, so as to obtain an array of character strings to be encrypted; the number of bits of each position index is the same;
[0059] A modular operation grouping module, used for performing a modular operation of a set modulus on the ASCII code value in each string in the string array to be encrypted, and grouping each string in the string array to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus;
[0060] A module for determining the integer value to be encrypted, used for concatenating the strings in each of the string groups to obtain a plurality of concatenated strings to be encrypted, and converting each of the concatenated strings to be encrypted into an integer to obtain a plurality of integer values to be encrypted;
[0061] A random generation module, used to determine the generator of elliptic curve encryption and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number;
[0062] An encryption matrix determination module, used to generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key;
[0063] An encryption mode determination module, used for performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption;
[0064] The ciphertext generation module is used to encrypt each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain multiple ciphertexts; the number of the ciphertexts is half of the number of the integer values to be encrypted.
[0065] A text decryption system based on elliptic curve cryptography, the text decryption system comprising:
[0066] A ciphertext acquisition module, used to acquire a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption;
[0067] A decryption matrix determination module, used to generate a session key according to the receiving party's private key and the sending party's public key, and determine a corresponding decryption matrix according to the session key;
[0068] A module for determining integer values to be decrypted, used to decrypt each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts;
[0069] A conversion module, used for converting each of the integer values to be decrypted into a concatenated string to be decrypted according to the set number of digits information; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender;
[0070] A splicing module, used for splicing the spliced character strings to be decrypted to obtain a secondary spliced character string;
[0071] A segmentation module, used for segmenting the secondary concatenated character string according to the set number of bits information to obtain an array of character strings to be decrypted;
[0072] An index arrangement module is used to arrange the ASCII code values of each string in the to-be-decrypted string array according to the position index of each string in the to-be-decrypted string array, so as to obtain an ASCII code array to be decrypted;
[0073] The plaintext message determination module is used to determine the decrypted plaintext message according to the ASCII code array to be decrypted.
[0074] An electronic device includes a first memory and a first processor, wherein the first memory is used to store a first computer program, and the first processor runs the first computer program to enable the electronic device to execute the above-mentioned text encryption method based on elliptic curve cryptography.
[0075] An electronic device includes a second memory and a second processor, wherein the second memory is used to store a second computer program, and the second processor runs the second computer program to enable the electronic device to perform the above-mentioned text decryption method based on elliptic curve cryptography.
[0076] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0077] The text encryption and decryption method based on elliptic curve cryptography provided by the present invention improves the encoding process of mapping plaintext messages to elliptic curves, that is, the method of mapping character values to affine points of elliptic curves in traditional elliptic curve encryption algorithms is not adopted, but the ASCII code values corresponding to the plaintext messages are grouped in combination with modular operations, and then ciphertext is generated according to the encryption matrix corresponding to the session key, and finally sent to the receiver in the form of ciphertext, avoiding expensive mapping and the need to share a public lookup table between the sender and the receiver, and can generate relatively small ciphertext, shortening the encryption and decryption time by reducing the amount of calculation. At the same time, the present invention reduces the mapping overhead while ensuring the security of data transmission and access processes by randomly generating an encryption mode determination number and determining the encryption mode according to the remainder after the modular operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0079] Figure 1 A flowchart of a text encryption method based on elliptic curve cryptography provided by the present invention;
[0080] Figure 2 A flowchart of a text decryption method based on elliptic curve cryptography provided by the present invention;
[0081] Figure 3 A specific flow chart of a text encryption and decryption method based on elliptic curve cryptography provided by an embodiment of the present invention;
[0082] Figure 4 A schematic diagram of the decryption result of the ciphertext pair corresponding to the original session key provided in an embodiment of the present invention;
[0083] Figure 5 A schematic diagram of a decryption result of a ciphertext pair corresponding to a modified session key provided in an embodiment of the present invention;
[0084] Figure 6 A schematic diagram of a ciphertext pair generated by the first encryption provided by an embodiment of the present invention;
[0085] Figure 7 A schematic diagram of a ciphertext pair generated by the second encryption provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0086] 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.
[0087] The purpose of the present invention is to provide a text encryption and decryption method, system and device based on elliptic curve cryptography to shorten the encryption and decryption time and ensure the security of data transmission and access while reducing mapping overhead.
[0088] The elliptic curve encryption algorithm is an asymmetric encryption algorithm that maps messages to points on the curve and then uses the sender's private key to perform scalar multiplication to form ciphertext, which is then decoded into the actual message during decryption. The present invention improves the plaintext encoding method. Instead of using the affine point method of mapping character values to elliptic curves in the traditional elliptic curve encryption algorithm, the ASCII values corresponding to the plaintext message are grouped in combination with modular operations, and matrix multiplication is performed with the encryption matrix corresponding to the session key to generate ciphertext pairs, which are finally sent to the receiver in the form of ciphertext pairs, avoiding expensive mapping and the need to share a common lookup table between the sender and the receiver.
[0089] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0090] Embodiment 1
[0091] This embodiment provides a text encryption method based on elliptic curve cryptography, a text decryption method based on elliptic curve cryptography, and a text encryption and decryption method based on elliptic curve cryptography. The above three methods are discussed in detail below.
[0092] First, the elliptic curve encryption algorithm adopted by the present invention is briefly discussed.
[0093] Elliptic curves are continuous and not suitable for encryption. Therefore, it is necessary to define elliptic curves on finite fields to make them discrete points. If the field F contains only a finite number of elements, it is called a finite field. The number of its elements is called the order of the finite field. The finite field is also called the Galois field, that is, GF(p n ), where p is a prime number and n is a positive integer. The general equation of the elliptic curve is as follows:
[0094] y 2 =x 3 +ax+b(modp); where coefficients a,b∈GF(p), and 4a3 +27b 2 ≠0(modp).
[0095] The operations on elliptic curves mainly include point addition and point multiplication. The functions used to perform these operations are as follows:
[0096] 1) Point addition [Point_add(Point1,Point2)]
[0097] Let P(x 1 ,y 2 ) and Q(x 2 ,y 2 ) are two points on the curve, P+Q=(x 3 ,y 3 ).
[0098] If P = Q, then (At this time x 3 =(λ 2 -2x 1 )modp,y 3 =λ(x 1 -x 3 )-y 1 modp); if P≠Q, then (At this time x 3 =(λ 2 -x 1 -x 2 )modp,y 3 =λ(x 1 -x 3 )-y 1 modp).
[0099] 2) Point multiplication [S_mult(k 1 ,Point)]
[0100] To generate a public key, an elliptic curve-based cryptosystem must perform point multiplication, i.e., scalar multiplication: Let P(x 1 ,y 1 ) is a point on the curve, where P≠-P, then 2P=2(x 1 ,y 1 ).
[0101] The ECC algorithm used in the present invention uses the NIST-192 elliptic curve equation and defined parameters. The selected elliptic curve equation is y 2 =x 3 +ax+b(modp), the specific parameter values are as follows:
[0102] a=-3,
[0103] b=2455155546008943817740293915197451784769108058161191238065,
[0104] p=6277101735386680763835789423207666416083908700390324961279,
[0105] G=(602046282375688656758213480587526111916698976636884684818 ,174050332293622031404857552280219410364023488927386650641),
[0106] n=6277101735386680763835789423176059013767194773182842284081.
[0107] Where a and b are the coefficients of the elliptic curve equation, p is a prime number, G is a point on the elliptic curve Ep(a,b) (ie, generator G), and n is the order of G.
[0108] The public keys of the sender and receiver are calculated based on the above parameters.
[0109] Sender:
[0110] Sender's private key Pr s =ran1 (a random number between 1 and n), sender's public key Pu s = S_mult(Pr s ,G).
[0111] Recipient:
[0112] Receiver's private key Pr r =ran2 (a random number between 1 and n), the recipient's public key Pu r = S_mult(Pr r ,G).
[0113] Use the sender's private key Pr s , the recipient's private key Pr r Point multiplication with generator G can generate the session key S of the ECC encryption algorithm k In order to ensure data security, the sender's private key Pr s , the recipient's private key Pr r Not public, but the sender's public key Pu s and the recipient's public key Pu ris public, so the session key S k It can be expressed as S k =S_mult(Pu r ,Pr s )=S_mult(Pu s ,Pr r ), converted to point coordinate form, i.e. S k =(x k ,y k ), where x k is the point coordinate on the horizontal axis, y k is the point coordinate of the vertical axis.
[0114] like Figure 1 As shown, the text encryption method based on elliptic curve cryptography provided by the present invention includes:
[0115] Step 101: Obtain a plaintext message to be encrypted.
[0116] Step 102: Convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same.
[0117] Step 103: sequentially add position indexes to the ASCII code values in the ASCII code array to be encrypted to obtain a character string array to be encrypted; the number of bits of each position index is the same.
[0118] Step 104: performing a modular operation of a set modulus on the ASCII code values in each string in the array of strings to be encrypted, and grouping each string in the array of strings to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus.
[0119] Step 105: concatenate the strings in each of the string groups to obtain a plurality of concatenated strings to be encrypted, and convert each of the concatenated strings to be encrypted into an integer to obtain a plurality of integer values to be encrypted.
[0120] Step 106: Determine the generator of elliptic curve encryption, and randomly generate a sender private key, a receiver private key and an encryption mode determination number, wherein the sender private key and the receiver private key are both random numbers between 1 and n, and n is the order of the generator.
[0121] Step 107: Generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key.
[0122] Step 108: performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement pattern of the multiple integer values to be encrypted during encryption.
[0123] Step 109: Encrypt each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain a plurality of ciphertexts; the number of the ciphertexts is half the number of the integer values to be encrypted.
[0124] Preferably, step 109 specifically includes: 1) according to the encryption mode, arranging each of the integer values to be encrypted and grouping them in pairs to obtain a plurality of integer pairs to be encrypted; 2) according to the encryption matrix, performing matrix multiplication operations on each of the integer pairs to be encrypted to obtain a plurality of ciphertexts.
[0125] like Figure 2 As shown, the text decryption method based on elliptic curve cryptography provided by the present invention includes:
[0126] Step 201: Obtain the receiver's private key, sender's public key, encryption mode and ciphertext sent by the sender; the sender's public key is generated based on the sender's private key and the generator of elliptic curve encryption.
[0127] Step 202: Generate a session key according to the receiver's private key and the sender's public key, and determine a corresponding decryption matrix according to the session key.
[0128] Step 203: Decrypt each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts.
[0129] Step 204: According to the set number of digits information, each of the integer values to be decrypted is converted into a concatenated string to be decrypted; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender.
[0130] Step 205: concatenate the concatenated character strings to be decrypted to obtain a secondary concatenated character string.
[0131] Step 206: Segment the secondary concatenated character string according to the set bit number information to obtain an array of character strings to be decrypted.
[0132] Step 207: Arrange the ASCII code values of each string in the to-be-decrypted string array according to the position index of each string in the to-be-decrypted string array to obtain an ASCII code array to be decrypted.
[0133] Step 208: Determine the decrypted plaintext message according to the array of ASCII codes to be decrypted.
[0134] Preferably, step 203 specifically includes: 1) performing matrix multiplication operations on each of the ciphertexts according to the decryption matrix to obtain multiple integer pairs to be decrypted; 2) splitting and arranging each of the integer pairs to be decrypted according to the encryption mode to obtain multiple integer values to be decrypted.
[0135] Correspondingly, the text encryption and decryption method based on elliptic curve cryptography provided by the present invention includes: an encryption process and a decryption process. The encryption process is shown in steps 101 to 109 above, and the decryption process is shown in steps 201 to 208 above, which will not be described in detail here.
[0136] Further, step 204 specifically includes: 1) converting each of the integer values to be decrypted into a corresponding character string to obtain multiple converted character strings; 2) if the number of bits of the converted character string is not an integer multiple of the third set number of bits, appending 0 before the converted character string until the number of bits of the converted character string is an integer multiple of the third set number of bits; the third set number of bits is the sum of the first set number of bits and the second set number of bits; 3) if the number of bits of the converted character string is an integer multiple of the third set number of bits, determining the converted character string as the concatenated character string to be decrypted.
[0137] Furthermore, the encryption process also includes: generating a sender public key based on the sender private key and the generator.
[0138] Furthermore, the decryption process also includes: obtaining set bit number information sent by the sender.
[0139] As a specific implementation, the set modulus is 4; the ASCII code value and the position index are both decimal values, and the number of bits of the ASCII code value is 3.
[0140] The following takes the setting of the modulus to 4 and the plaintext message to be encrypted as image copyright information as an example to discuss in detail the text encryption / decryption method based on elliptic curve cryptography provided by the present invention.
[0141] like Figure 3 As shown, the encryption process specifically includes:
[0142] Step 1: Convert the original plaintext message M into the corresponding ASCII code value, recorded as array Asc.
[0143] Step 2: Increase the position index according to the initial arrangement order of the values in Asc, respectively determine the lengths of the index and the ASCII code values, and pad each digit with "0" to process them into fixed-length strings. Perform a modulo operation (taking the modulus as 4) on each ASCII value in Asc, and divide them into 4 groups according to the remainder values.
[0144] Step 3: Concatenate the strings in each group, and intercept the strings. Determine whether the characters in the strings are 0. If they are 0, remove them until the first non-0 character. Convert Asc into the corresponding four strings str_mode0, str_mode1, str_mode2, str_mode3, and further convert them into integers int_mode0, int_mode1, int_mode2, int_mode3.
[0145] Step 4: Generate random numbers ran1, ran2, ran3 (0 < ran1 < n, 0 < ran2 < n, 0 < ran3 < n), where the random number ran1 is used as the private key Pr of the sender s , the random number ran2 is used as the private key Pr of the receiver r , and the random number ran3 is used as the encryption mode determination number to determine the encryption mode.
[0146] Step 5: Generate the session key S according to the random numbers ran1, ran2 and the generator G k =(x k , y k ), and obtain the corresponding encryption matrix
[0147] Step 6: Perform a modulo operation (taking the modulus as 4) on the random number ran3, and determine the following encryption mode according to the obtained remainder:
[0148] ① When the remainder is 0, the encryption mode is mode0, and the corresponding ciphertext pairs are Mat1=(int_mode0×x k , int_mode1×y k ), Mat2=(int_mode2×x k , int_mode3×y k );
[0149] ② When the remainder is 1, the encryption mode is mode1, and the corresponding ciphertext pairs are Mat1=(int_mode1×x k , int_mode2×y k ), Mat2=(int_mode3×x k , int_mode0×y k );
[0150] ③ When the remainder is 2, the encryption mode is mode2, and the corresponding ciphertext pair is Mat1 = (int_mode2 × x k ,int_mode3×y k )、Mat2=(int_mode0×x k ,int_mode1×y k );
[0151] ④ When the remainder is 3, the encryption mode is mode3, and the corresponding ciphertext pair is Mat1 = (int_mode3 × x k ,int_mode0×y k )、Mat2=(int_mode1×x k ,int_mode2×y k ).
[0152] Step 7: Encrypt the matrix M e Perform matrix multiplication with the integer pair in random encryption mode to generate ciphertext pairs Mat1 and Mat2, according to the sender's private key Pr s Generate the sender's public key Pu s , and the ciphertext pair Mat1 and Mat2, the determined encryption mode and the sender's public key Pu s Send to the receiving end.
[0153] like Figure 3 As shown, the decryption process specifically includes:
[0154] Step 1: According to the recipient's private key Pr r and the sender's public key Pu s Generate session key S k , and get the corresponding decryption matrix
[0155] Step 2: Based on the ciphertext Mat1 and Mat2, the determined encryption mode and the decryption matrix M d , by decrypting the matrix M d Perform matrix multiplication with the received ciphertext pairs Mat1 and Mat2 to obtain integers int_mode0, int_mode1, int_mode2, int_mode3, which are converted into strings str_mode0, str_mode1, str_mode2, str_mode3.
[0156] Step 3: Calculate whether the length of the string str_mode0, str_mode1, str_mode2, and str_mode3 can divide the sum of the index length and the ASCII code length. If not, add "0" to the beginning of the string and repeat step 3. If it can be divided, it means that the string has not been deleted, and concatenate the strings str_mode0, str_mode1, str_mode2, and str_mode3 and proceed to step 4.
[0157] Step 4: Convert the concatenated strings into integers and split them, arrange them into corresponding ASCII value array De_Asc according to the index, and convert the ASCII values in De_Asc into corresponding characters to obtain the original plaintext message M.
[0158] Embodiment 2
[0159] This embodiment takes the plaintext information to be encrypted as "Copyright owner information (owner name): Zhang Zhao" as an example, and conducts experimental tests and performance evaluations on the hardware platform of Intel(R) Core(TM) i5-6200U CPU, 2.30GHz, memory 12GB and software environment of Windows 10, python3.7. Among them, the elliptic curve parameters used have been described in the "Elliptic Curve Encryption Algorithm" described in Example 1.
[0160] First, the encryption process in Example 1 is executed to obtain the following encryption results for each step:
[0161] (1) Convert the plaintext information M (image copyright message) into an ASCII code array Asc.
[0162] M = "Copyright owner information (owner name): Zhang Zhao";
[0163] Asc=[231,137,136,230,157,131,230,137,128,230,156,137,232,128,133,228,191,161,230,129,175,40,230, 137,128,230,156,137,232,128,133,229,167,147,229,144,141,41,239,188,154,229,188,160,230,152,173].
[0164] (2) Divided into four groups (converted to 47-bit ASCII values, so the number of bits of the index position is 2):
[0165] str0=['02136','08128','10156','12232','13128','15228','21040','2412 8','26156','28232','29128','35144','39188','42188','43160','45152'];
[0166] str1=['01137','04157','07137','11137','14133','17161','19129','2313 7','27137','30133','31229','34229','36141','37041','41229','46173'];
[0167] str2=['03230','06230','09230','18230','22230','25230','40154','44230'];
[0168] str3=['00231','05131','16191','20175','32167','33147','38239'].
[0169] (3) Concatenate the strings and convert them into integers as follows:
[0170] int_mode0=02136081281015612232131281522821040241282615628232291283514439188421884316045152;
[0171] int_mode1=1137041570713711137141331716119129231372713730133312293422936141370414122946173;
[0172] int_mode2=323006230092301823022230252304015444230;
[0173] int_mode3=231051311619120175321673314738239.
[0174] (4) The generated random numbers ran1, ran2, and ran3 are used as the sender's private key Pr s , the recipient's private key Pr rAnd the encryption mode determination number:
[0175] Pr s =ran1=4740495114492921958327401514830598901320398072753940462096;
[0176] Pr r =ran2=575577878210774215491390010288217430518904357233988380136;
[0177] ran3=309488725767425625935329630793774233564555912890646912644.
[0178] (5) According to the sender's private key Pr s , the recipient's private key Pr r and generator G to generate session key S k :
[0179] S k =(1642697802618745131050633899712508933532442905078451269526
[0180] 047652883973495201009434700247514810609429930779938724204642453955857729317224851463623038620037350607759954199808,47490052969944357728864770159 7310448964376083739047651868964486420661006019966421090644545460564892081559559174164123838000292542847604363929284915486551502608397537760896).
[0181] (6) Perform a modulus operation on the random number ran3 (taking the modulus as 4). In this example, (ran3) mod4 = 0, so the encryption mode uses mode0. The generated ciphertext pairs Mat1 and Mat2 are:
[0182] Mat1=[350893602653938043356318086195731996140423460092906432770 2053389227601726126181878951026391803852766678001541817813391324 4600003613771751047019058828753373267900543409457335526288131784827868437167028984816035611161875250065093363003229028633577308 16,5399816442222287503275109764634313690722847423404985054427696782607423624252615504874423073353570069823485270481434845234336 62791094328324900696913922807916627170347653769046000516496855837042450693874905350488917344694296150313596495461269152251008];
[0183] Mat2=[530601624404788993967843131236149475096509990620328541379352678023534674846684156380681148396185693 3114738422419686084706611236669431854262107862022033763965061837201302773368476347429115645931528750833007 07840,109726390275671373710946909404134495440734278942389767770825272690080797893075798995063633551145068228479362730023870434957254093043799730725888056411128351292851885587811376382350214611908345808410102144].
[0184] (7) According to the sender's private key Prs Calculate the sender's public key Pu s , the sender's public key Pu s , encryption mode mode0, and ciphertext pair Mat1 and Mat2 are sent to the receiving end.
[0185] Pu s =(285399746030057822225989029322968086802226959670100766891
[0186] 2160118709847079644589648836335320824558018165548235658528,82508474991378488387918892753210050946290599626194904997968864052080425024533953604365409722062599492593725460353).
[0187] Next, the decryption process in the first embodiment is executed, and the decryption results of each step are obtained as follows:
[0188] (1) According to the recipient's private key Pr r and the sender's public key Pu s Generate session key S k :
[0189] S k =(1642697802618745131050633899712508933532442905078451269526
[0190] 047652883973495201009434700247514810609429930779938724204642453955857729317224851463623038620037350607759954199808,47490052969944357728864770159 7310448964376083739047651868964486420661006019966421090644545460564892081559559174164123838000292542847604363929284915486551502608397537760896).
[0191] (2) Based on the ciphertext Mat1 and Mat2, encryption mode mode0 and session key S k The corresponding decryption matrix M d Calculate the corresponding string:
[0192] str_mode0=02136081281015612232131281522821040241282615628232291283514439188421884316045152;
[0193] str_mode1=01137041570713711137141331716119129231372713730133312293422936141370414122946173;
[0194] str_mode2=0323006230092301823022230252304015444230;
[0195] str_mode3=00231051311619120175321673314738239.
[0196] (3) Concatenate the strings. The concatenated string is: 02136081281015612232131281522821040241282615628232291283514439188421884316045152011370415707137111371413317 16119129231372713730133312293422936141370414122946173032300623009230182302223025230401544423000231051311619120175321673314738239.
[0197] (4) Split according to index length and ASCII value, restore ASCII value array De_Asc according to index arrangement, convert array De_Asc into corresponding characters according to ASCII mapping rules, and the decrypted text data is: "Copyright owner information (owner name): Zhang Zhao".
[0198] The time performance analysis results are as follows:
[0199] After selecting the basic parameters of the elliptic curve Ep(a,b) (coefficients a, b, prime number p, generator G, and order n of G), the traditional ECC algorithm first converts the plaintext message M to be sent into ASCII code, which is then further converted into large integers after grouping and mapped to the elliptic curve scatter graph. s and the recipient's public key Pu r The corresponding points of the plaintext information on the scatter plot are encrypted using point addition, and finally the ciphertext data and the sender's public key Pu are encrypted. s The receiver uses its private key Pu to decrypt the r , the received ciphertext data and the sender's public key Pu s Decryption is done using point subtraction.
[0200] The present invention improves the plaintext encoding method, combines the modular operation to group the plaintext data converted to ASCII code, and combines the matrix multiplication to replace the point addition and point subtraction operations in the encryption and decryption process. By testing the time performance of the ECC algorithm for text information with different numbers of characters, the time consumption comparison before and after the improvement of the plaintext encoding method is shown in Table 1.
[0201] Table 1 Comparison of time consumption before and after the improvement of plaintext encoding method
[0202]
[0203] As can be seen from Table 1, as the number of characters to be encrypted increases, the encryption and decryption time also increases regularly. After the plaintext encoding method is improved, the encryption time is increased by 18% on average, and the decryption time is increased by 45% on average. Therefore, it is proved that the present invention effectively shortens the encryption and decryption time by improving the plaintext encoding method and combining matrix multiplication.
[0204] The safety analysis results are as follows:
[0205] 1) Key space
[0206] The security of encryption technology depends largely on the size of the key used. Generally speaking, the longer the encryption algorithm key is, the larger the key space is, and the more difficult it is to crack it by exhaustive method. However, increasing the key length often leads to an increase in the amount of calculation. k is generated by random numbers ran1, ran2 and generator G, so for S k Coordinate x of the mid-horizontal axis point k and the y-axis coordinate k The value is taken in the range of 57≤x k ≤173、57≤y k≤173. Compared with the RSA algorithm, the ECC algorithm achieves strong security in a smaller key space, and the amount of key required is much smaller than the amount of key in the public key system based on the discrete logarithm problem over a finite field.
[0207] 2) Key sensitivity
[0208] Key sensitivity means that during the encryption and decryption process, if the initial key undergoes a slight change, the key generated by the key sequence generator or iterative function will undergo a huge change, thus causing a huge change in the encrypted and decrypted data. Assume that the sender sends the message "Copyright owner information (owner name): Zhang Zhao) to the receiver. At this time, the original session key, the modified session key, and the ciphertext pair decryption results are shown in Table 2.
[0209] Table 2 Comparison of original session key, modified session key and corresponding ciphertext pair decryption results
[0210]
[0211] As can be seen from Table 2, the original session key S is slightly modified. k =(x s ,y s ) s for y s After -1, when restoring the corresponding ASCII value, the position index character will be out of bounds and the information cannot be restored normally.
[0212] 3) Ciphertext-only attack
[0213] Assuming that the cryptanalyst knows the encryption algorithm and the ciphertext, when the key is very large, an exhaustive attack will take several years. Even if it can be cracked, the information will lose its original value. In order to prevent the attacker from discovering patterns from the ciphertext, the present invention uses random numbers to determine the encryption mode for generating ciphertext pairs. The attacker cannot perform frequency analysis on the ciphertext, effectively preventing ciphertext-only attacks.
[0214] 4) Known Plaintext Attack
[0215] Assume that the cryptanalyst knows the encryption algorithm, ciphertext, and one or more plaintext-ciphertext pairs formed by the key. The random numbers ran1 and ran2 generated in the encryption process are used as the private keys of the sender and receiver respectively. Since different session keys are generated in each encryption process and the encryption mode selected each time according to the random numbers is also different, even if the same message is encrypted, the ciphertext pairs generated are different. Therefore, a known plaintext attack will not cause damage to the information.
[0216] Assume that the sender sends the same message "Copyright owner information (owner name): Zhang Zhao" to the receiver twice. The session keys and encryption modes of the two encryptions are shown in Table 3. The generated ciphertext pairs are as follows: Figure 6 and Figure 7 As shown, Figure 6 is the first generated ciphertext pair, Figure 7 is the ciphertext pair generated for the second time.
[0217] Table 3 Comparison of session keys and encryption modes for two encryptions
[0218]
[0219] It can be seen from Table 3 that for the same message, the session keys and corresponding encryption modes generated by the two encryption processes are different, so it has good resistance to ciphertext-only attacks and known plaintext attacks.
[0220] from Figure 6 and Figure 7 As can be seen from the figure, since the sender's private key, the receiver's private key and the encryption mode are all determined by random numbers, even if the same message is encrypted, the ciphertext pairs generated after two encryptions are different.
[0221] The performance comparison results with the existing elliptic curve text encryption method are as follows:
[0222] Table 4 shows the comprehensive performance comparison results of the present invention and the existing text encryption scheme using ECC when the message to be encrypted M = "National Institute of Technology, Manipur, 795004".
[0223] Table 4 Comparison of encryption / decryption performance of the present invention and existing different schemes
[0224]
[0225] As can be seen from Table 4, when the size of the ciphertext pair is relatively small, the encryption time and decryption time consumed by the present invention are also less than other encryption schemes. Scheme 1 encodes characters by dividing the message into blocks and performing XOR operations, and then maps the results to an elliptic curve. This scheme ensures data security and integrity by signing the encrypted message, but the signature increases the complexity of the encryption process. Schemes 2 to 4 all convert the text message into ASCII values first, and then use the method of filling and grouping after the number of digits determined according to the maximum value, converting to hexadecimal and grouping, and grouping first and then forming a large integer from the grouping to complete the message mapping. The key pair size of these three schemes is small, avoiding costly mapping operations, but the ciphertext message is easily cracked by attackers based on frequency analysis and has restrictions on the ASCII value corresponding to the plaintext information. Scheme 5 is very fast for smaller messages, but it is not efficient when the message becomes larger, and the lookup table causes a large transmission overhead.
[0226] By analyzing the problems existing in the plaintext information mapping process of the above elliptic curve text encryption scheme, the present invention improves the encoding method of plaintext, reduces the scalar multiplication related calculations, and the method of determining the encryption mode of the processed string information by random numbers also avoids the frequency mapping problem when generating encrypted text. In addition, the string and the session key are matrix multiplied to generate a ciphertext pair, and the size of the ciphertext pair is jointly determined by the integer pair and the encryption matrix, which solves the overhead problem of sharing a public lookup table between the copyright owner and the user. The mapping security and data encryption also provide double security guarantees for the text of the copyright information.
[0227] Embodiment 3
[0228] In order to execute the method corresponding to the above-mentioned embodiment 1 to achieve the corresponding functions and technical effects, a text encryption system based on elliptic curve cryptography and a text decryption system based on elliptic curve cryptography are provided below.
[0229] Specifically, the text encryption system includes:
[0230] The plaintext message acquisition module is used to obtain the plaintext message to be encrypted.
[0231] The ASCII code conversion module is used to convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same.
[0232] An index adding module is used to sequentially add position indexes to each of the ASCII code values in the ASCII code array to be encrypted to obtain a string array to be encrypted; the number of bits of each position index is the same.
[0233] The modular operation grouping module is used to perform modular operation of a set modulus on the ASCII code value in each string in the string array to be encrypted, and group each string in the string array to be encrypted according to the remainder after the modular operation to obtain multiple string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus.
[0234] The module for determining the integer value to be encrypted is used to concatenate the strings in each string group to obtain a plurality of concatenated strings to be encrypted, and convert each concatenated string to be encrypted into an integer to obtain a plurality of integer values to be encrypted.
[0235] The random generation module is used to determine the generator of elliptic curve encryption and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number.
[0236] The encryption matrix determination module is used to generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key.
[0237] The encryption mode determination module is used to perform a modular operation of the set modulus on the encryption mode determination number and determine the encryption mode according to the remainder after the modular operation; the encryption mode is an arrangement pattern of multiple integer values to be encrypted during encryption.
[0238] The ciphertext generation module is used to encrypt each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain multiple ciphertexts; the number of the ciphertexts is half of the number of the integer values to be encrypted.
[0239] The text decryption system comprises:
[0240] The ciphertext acquisition module is used to obtain the receiver's private key, sender's public key, encryption mode and ciphertext sent by the sender; the sender's public key is generated based on the sender's sender's private key and the generator of elliptic curve encryption.
[0241] The decryption matrix determination module is used to generate a session key according to the receiving party private key and the sending party public key, and determine a corresponding decryption matrix according to the session key.
[0242] The module for determining integer values to be decrypted is used to decrypt each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts.
[0243] A conversion module is used to convert each of the integer values to be decrypted into a concatenated string to be decrypted according to the set number of bits information; the set number of bits information includes: a first set number of bits and a second set number of bits; the first set number of bits is the number of bits of the position index set by the sender; the second set number of bits is the number of bits of the ASCII code value set by the sender.
[0244] The splicing module is used to splice the spliced character strings to be decrypted to obtain a secondary spliced character string.
[0245] The segmentation module is used to segment the secondary concatenated character string according to the set bit number information to obtain an array of character strings to be decrypted.
[0246] The index arrangement module is used to arrange the ASCII code values in each string in the to-be-decrypted string array according to the position index in each string in the to-be-decrypted string array, so as to obtain the to-be-decrypted ASCII code array.
[0247] The plaintext message determination module is used to determine the decrypted plaintext message according to the ASCII code array to be decrypted.
[0248] Embodiment 4
[0249] The embodiment of the present invention also provides two electronic devices.
[0250] A first electronic device includes a first memory and a first processor, wherein the first memory is used to store a first computer program, and the first processor runs the first computer program to enable the electronic device to execute the text encryption method based on elliptic curve cryptography in Example 1.
[0251] A second electronic device includes a second memory and a second processor, wherein the second memory is used to store a second computer program, and the second processor runs the second computer program to enable the electronic device to execute the text decryption method based on elliptic curve cryptography in Example 1.
[0252] Preferably, both of the above two electronic devices can be servers.
[0253] In addition, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the text encryption method, text decryption method or text encryption and decryption method based on elliptic curve cryptography in Example 1.
[0254] The invention discloses a fast text encryption / decryption method based on elliptic curve cryptography, which can realize the network security transmission of Chinese and English text information such as digital image copyright, and reduce the communication and calculation cost of encryption / decryption. First, the text information is converted into ASCII value, and the modulus operation is performed on each ASCII value and the position index is added. It is divided into 4 groups according to the remainder and converted into a string form; then the sender key (i.e. the sender private key), the receiver key (i.e. the receiver private key) and the encryption mode are determined according to the generated random number, the string is converted into an integer, the integer pair is arranged according to the current encryption mode, and the arranged integer pair is matrix multiplied with the session key to generate two ciphertext pairs and send them to the receiver; finally, the receiver decrypts the received ciphertext pair according to the ciphertext information, the encryption mode and the session key. The invention solves the problem that the plaintext can only be composed of English, numbers or symbols, and the difference between Chinese and English after conversion to ASCII code. The improved plaintext encoding method and random encryption mode improve the mapping speed and data security.
[0255] In order to ensure the transmission security of digital image copyright information, the present invention improves the encoding method of plaintext, combines modular operations and random numbers to complete the conversion of plaintext messages to integer pairs before encryption, and reduces the calculation of scalar multiplication. The method of determining the encryption mode of the processed string information by random numbers also avoids the frequency mapping problem when generating encrypted text, and improves the security of the data transmission process. In addition, the string and the session key are matrix multiplied to generate a ciphertext pair, which solves the overhead problem of sharing a public lookup table between the copyright owner and the user. Mapping security and data encryption also provide dual security guarantees for the text. The example results show that the present invention reduces the mapping overhead while ensuring the security of the data transmission and access process, and can be further applied to image encryption to hide the data in the image by grouping pixels and performing corresponding mapping.
[0256] In summary, the present invention has the following advantages:
[0257] 1) An improved plaintext encoding method is designed. By converting the plaintext into ASCII code values and performing modulo operations to group the data, the difference problem after converting Chinese and English into ASCII code values is effectively solved, and the data conversion speed of the encryption process is also improved.
[0258] 2) A random encryption mode is designed, which uses random numbers to determine the encryption mode of the processed string information, so that the generated ciphertext pairs eliminate the frequency mapping phenomenon and effectively solve the security problem in the data transmission process.
[0259] 3) Perform matrix multiplication of the string and the session key to generate a ciphertext pair, which reduces the overhead of sharing a public lookup table between the copyright owner and the user. At the same time, mapping security and data encryption also provide double security guarantees for the text of copyright information.
[0260] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0261] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A text encryption method based on elliptic curve cryptography, characterized in that: The text encryption method comprises: Get the plaintext message to be encrypted; Convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same; Adding position indexes to the ASCII code values in the ASCII code array to be encrypted in sequence to obtain a string array to be encrypted; the number of bits of each position index is the same; Performing a modular operation of a set modulus on the ASCII code value of each string in the array of strings to be encrypted, and grouping each string in the array of strings to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus; The character strings in each of the character string groups are concatenated to obtain a plurality of concatenated character strings to be encrypted, and each of the concatenated character strings to be encrypted is converted into an integer to obtain a plurality of integer values to be encrypted; Determine the generator of elliptic curve encryption, and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number; Generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key; Performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption; According to the encryption matrix and the encryption mode, each of the integer values to be encrypted is encrypted to obtain a plurality of ciphertexts; the number of the ciphertexts is half the number of the integer values to be encrypted.
2. The text encryption method based on elliptic curve cryptography according to claim 1, characterized in that: The step of encrypting each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain a plurality of ciphertexts specifically includes: According to the encryption mode, the integer values to be encrypted are arranged and grouped in pairs to obtain a plurality of integer pairs to be encrypted; According to the encryption matrix, matrix multiplication operations are performed on each pair of integers to be encrypted to obtain multiple ciphertexts.
3. A text decryption method based on elliptic curve cryptography, characterized in that: The text decryption method comprises: Obtaining a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption; Generate a session key according to the receiver's private key and the sender's public key, and determine a corresponding decryption matrix according to the session key; Decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts; According to the set number of digits information, each of the integer values to be decrypted is converted into a concatenated string to be decrypted; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender; Concatenate the concatenated character strings to be decrypted to obtain a secondary concatenated character string; According to the set number of bits information, the secondary concatenated string is segmented to obtain an array of strings to be decrypted; Arrange the ASCII code values of each string in the array of strings to be decrypted according to the position index in each string in the array of strings to be decrypted, to obtain an array of ASCII codes to be decrypted; The decrypted plaintext message is determined according to the array of ASCII codes to be decrypted.
4. The text decryption method based on elliptic curve cryptography according to claim 3, characterized in that: Decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted specifically includes: According to the decryption matrix, matrix multiplication operations are performed on each of the ciphertexts to obtain a plurality of integer pairs to be decrypted; According to the encryption mode, each of the to-be-decrypted integer pairs is split and arranged respectively to obtain a plurality of to-be-decrypted integer values.
5. A text encryption and decryption method based on elliptic curve cryptography, characterized in that: The text encryption and decryption method comprises: an encryption process and a decryption process; The encryption process includes: Get the plaintext message to be encrypted; Convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same; Adding position indexes to the ASCII code values in the ASCII code array to be encrypted in sequence to obtain a string array to be encrypted; the number of bits of each position index is the same; Performing a modular operation of a set modulus on the ASCII code value of each string in the array of strings to be encrypted, and grouping each string in the array of strings to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus; The character strings in each of the character string groups are concatenated to obtain a plurality of concatenated character strings to be encrypted, and each of the concatenated character strings to be encrypted is converted into an integer to obtain a plurality of integer values to be encrypted; Determine the generator of elliptic curve encryption, and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number; Generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key; Performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption; Encrypting each of the to-be-encrypted integer values according to the encryption matrix and the encryption mode to obtain a plurality of ciphertexts; the number of the ciphertexts is half the number of the to-be-encrypted integer values; The decryption process includes: Obtaining a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption; Generate a session key according to the receiver's private key and the sender's public key, and determine a corresponding decryption matrix according to the session key; Decrypting each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts; According to the set number of digits information, each of the integer values to be decrypted is converted into a concatenated string to be decrypted; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender; Concatenate the concatenated character strings to be decrypted to obtain a secondary concatenated character string; According to the set number of bits information, the secondary concatenated string is segmented to obtain an array of strings to be decrypted; Arrange the ASCII code values of each string in the array of strings to be decrypted according to the position index in each string in the array of strings to be decrypted, to obtain an array of ASCII codes to be decrypted; The decrypted plaintext message is determined according to the array of ASCII codes to be decrypted.
6. The text encryption and decryption method based on elliptic curve cryptography according to claim 5, characterized in that: The step of converting each of the integer values to be decrypted into a concatenated string to be decrypted according to the set number of bits information specifically includes: Convert each of the integer values to be decrypted into a corresponding character string to obtain a plurality of converted character strings; If the number of digits of the converted character string is not an integer multiple of the third set number of digits, 0 is added before the converted character string until the number of digits of the converted character string is an integer multiple of the third set number of digits; the third set number of digits is the sum of the first set number of digits and the second set number of digits; If the number of digits of the converted character string is an integer multiple of the third set number of digits, the converted character string is determined as the concatenated character string to be decrypted.
7. A text encryption system based on elliptic curve cryptography, characterized in that: The text encryption system comprises: A plaintext message acquisition module, used to obtain the plaintext message to be encrypted; An ASCII code conversion module is used to convert the plaintext message to be encrypted into an ASCII code array to be encrypted; each element in the ASCII code array to be encrypted is an ASCII code value; and the number of bits of each ASCII code value is the same; An index adding module is used to sequentially add position indexes to each of the ASCII code values in the ASCII code array to be encrypted to obtain a string array to be encrypted; the number of bits of each position index is the same; A modular operation grouping module, used for performing a modular operation of a set modulus on the ASCII code value in each string in the string array to be encrypted, and grouping each string in the string array to be encrypted according to the remainder after the modular operation to obtain a plurality of string groups; the set modulus is an integer multiple of 2; and the number of the string groups is equal to the set modulus; A module for determining the integer value to be encrypted, used for concatenating the strings in each of the string groups to obtain a plurality of concatenated strings to be encrypted, and converting each of the concatenated strings to be encrypted into an integer to obtain a plurality of integer values to be encrypted; A random generation module, used to determine the generator of elliptic curve encryption and randomly generate the sender's private key, the receiver's private key and the encryption mode determination number; An encryption matrix determination module, used to generate a session key according to the sender private key, the receiver private key and the generator, and determine a corresponding encryption matrix according to the session key; An encryption mode determination module, used for performing a modular operation of the set modulus on the encryption mode determination number, and determining an encryption mode according to a remainder after the modular operation; the encryption mode is an arrangement mode of the plurality of integer values to be encrypted during encryption; The ciphertext generation module is used to encrypt each of the integer values to be encrypted according to the encryption matrix and the encryption mode to obtain multiple ciphertexts; the number of the ciphertexts is half of the number of the integer values to be encrypted.
8. A text decryption system based on elliptic curve cryptography, characterized in that: The text decryption system comprises: A ciphertext acquisition module, used to acquire a receiver's private key, a sender's public key, an encryption mode, and a ciphertext sent by a sender; the sender's public key is generated based on the sender's private key and a generator of elliptic curve encryption; A decryption matrix determination module, used to generate a session key according to the receiving party's private key and the sending party's public key, and determine a corresponding decryption matrix according to the session key; A module for determining integer values to be decrypted, used to decrypt each of the ciphertexts according to the decryption matrix and the encryption mode to obtain a plurality of integer values to be decrypted; the number of the integer values to be decrypted is twice the number of the ciphertexts; A conversion module, used for converting each of the integer values to be decrypted into a concatenated string to be decrypted according to the set number of digits information; the set number of digits information includes: a first set number of digits and a second set number of digits; the first set number of digits is the number of digits of the position index set by the sender; the second set number of digits is the number of digits of the ASCII code value set by the sender; A splicing module, used for splicing the spliced character strings to be decrypted to obtain a secondary spliced character string; A segmentation module, used for segmenting the secondary concatenated character string according to the set number of bits information to obtain an array of character strings to be decrypted; An index arrangement module is used to arrange the ASCII code values of each string in the to-be-decrypted string array according to the position index of each string in the to-be-decrypted string array, so as to obtain an ASCII code array to be decrypted; The plaintext message determination module is used to determine the decrypted plaintext message according to the ASCII code array to be decrypted.
9. An electronic device, characterized in that: It comprises a first memory and a first processor, wherein the first memory is used to store a first computer program, and the first processor runs the first computer program so that the electronic device executes the text encryption method based on elliptic curve cryptography as described in any one of claims 1 to 2.
10. An electronic device, characterized in that: It comprises a second memory and a second processor, wherein the second memory is used to store a second computer program, and the second processor runs the second computer program to enable the electronic device to execute the text decryption method based on elliptic curve cryptography as described in any one of claims 3 to 4.