Communication encryption and decryption method and device, electronic equipment and storage medium
By using the logical regression calculation model to dynamically generate a key in the communication connection, and randomly replace the number of iterations, the problem that the key cannot be dynamically modified in the existing technology has been solved, the security of communication is improved, and malicious attacks are defended.
Patent Information
- Application Number
- CN202411459964.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-24
AI Technical Summary
In the existing communication encryption technology, the key cannot be dynamically modified during transmission, resulting in insufficient communication security, especially when facing malicious attacks such as scanning and crawlers.
By pre-establishing a communication connection between the server and the client, a logistic regression calculation model is used for iterative calculation, the key is dynamically generated, and the number of iterations is randomly changed during each communication to replace the key.
It realizes the dynamic modification of keys during the communication process, improves the security of communication, defends against malicious attacks such as scanning and crawlers, and ensures the security of the connection and the confidentiality of the communication.
Smart Images

Figure CN119363330A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication encryption technology, and in particular to a communication encryption and decryption method, device, electronic device and storage medium. Background Art
[0002] In the field of communication encryption technology, data encryption has always been an important part of confidential data, and there are many relatively mature encryption methods. Encryption algorithms include reversible encryption algorithms and irreversible encryption algorithms. Reversible encryption algorithms are further divided into symmetric encryption algorithms and asymmetric encryption algorithms. In most cases, both parties in communication need to establish an effective and secure encryption and decryption method, and need to make a trade-off between security and performance consumption. Moreover, whether it is symmetric encryption or asymmetric encryption, the key is generated in advance and cannot be changed during the transmission process. Summary of the invention
[0003] The embodiments of the present application provide a communication encryption and decryption method, device, electronic device and storage medium, which can dynamically modify the key in a more secure connection, thereby ensuring the security of communication.
[0004] The first aspect of the present application provides a communication encryption method, which is applied to a server, wherein the server has pre-established a communication connection with a client, and the server has pre-generated initial parameters for calculating a key, and the method includes:
[0005] Substituting the initial parameters into the pre-obtained calculation model for iterative calculation, the number of iterations being equal to the first number of iterations;
[0006] Obtaining a first key through the iterative calculation;
[0007] Encrypting the original data to be sent to the client using the first key to obtain encrypted data;
[0008] The first iteration number and the encrypted data are sent to the client.
[0009] In some embodiments, the step of pre-establishing a communication connection between the server and the client includes:
[0010] The server receives the connection request sent by the client and information of the computing model used for encryption;
[0011] Generate initial parameters corresponding to the information of the calculation model;
[0012] Sending the initial parameters to the client;
[0013] Receive a second iteration number and a client verification key fed back by the client;
[0014] Substituting the initial parameters into the calculation model corresponding to the information of the calculation model for iterative calculation, wherein the number of iterations is equal to the second number of iterations, and obtaining the server verification key through the iterative calculation;
[0015] When the server authentication key and the client authentication key are the same, a communication connection with the client is established.
[0016] In some embodiments, the calculation model is a logistic regression calculation model, and the initial parameters are parameters used in the calculation of the logistic regression model, including: an initial feature independent variable matrix, an initial parameter vector, an initial constant vector and a step value.
[0017] In some embodiments, the logistic regression model is Wherein, x is the initial feature independent variable matrix, w is the parameter vector, and b is the constant parameter;
[0018] The loss function of the logistic regression model is Among them, n is the number of rows of the initial feature independent variable matrix x, y i is the initial classification vector corresponding to the i-th row of the initial feature independent variable matrix, and the classification vector is expressed as The classification vector is the key; the classification vector is solved by a gradient descent method, including:
[0019] The loss function obtains the gradient of the parameter vector w and the constant parameter b:
[0020]
[0021] Among them, x ij represents the element of the i-th row and j-th column of the initial feature independent variable matrix; the iterative expression of the parameter vector and the constant parameter is:
[0022] Among them, k represents the number of iterations, and α represents the step size;
[0023] When the first iteration number is k+1, the parameter vector w is equal to w k+1 , the constant parameter b is equal to the constant parameter b of the iteration k+1 ;
[0024] Substitute the parameter vector w, constant parameter b and the initial feature independent variable matrix into the classification vector expression to obtain the key.
[0025] A second aspect of the present application provides a communication decryption method, which is applied to a client, where a communication connection is pre-established between the client and the server, and the method includes:
[0026] The client receives the first iteration number and the encrypted data sent by the server;
[0027] Substituting the pre-obtained initial parameters for calculating the key into a pre-set calculation model for iterative calculation, the number of iterations being equal to the first number of iterations;
[0028] Obtaining a first key for the encrypted data through the iterative calculation;
[0029] The received encrypted data is decrypted using the first key to obtain the original data.
[0030] In some embodiments, the step of pre-establishing a communication connection between the client and the server includes:
[0031] The client sends a communication connection request and information of the computing model to the server;
[0032] Receiving the initial parameters for key calculation;
[0033] Substituting the initial parameters into the calculation model for iterative calculation, the number of iterations being equal to the second number of iterations, and obtaining a client verification key through the iterative calculation;
[0034] Feedback the second iteration number and the client verification key to the server;
[0035] When the client authentication key passes the server authentication, a communication connection with the server is established.
[0036] The third aspect of the present application provides a communication encryption device, which is applied to a server, wherein the server has pre-established a communication connection with a client, and the server has pre-generated initial parameters for calculating a key, including:
[0037] An encryption module is used to substitute the initial parameters into a pre-obtained calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain a first key through the iterative calculation; and encrypt the original data to be sent to the client using the first key to obtain encrypted data;
[0038] A sending module is used to send the first iteration number and the encrypted data to the client.
[0039] A fourth aspect of the present application provides a communication decryption device, which is applied to a client, wherein the client has established a communication connection with a server in advance, including:
[0040] A receiving module, used for the client to receive the first iteration number and encrypted data sent by the server;
[0041] A decryption module is used to substitute the pre-obtained initial parameters for calculating the key into a pre-set calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain the first key of the encrypted data through the iterative calculation; and use the first key to decrypt the received encrypted data to obtain the original data.
[0042] A fifth aspect of the present application provides an electronic device, including:
[0043] processor;
[0044] a memory for storing instructions executable by the processor;
[0045] The processor is configured to execute the instructions to implement the communication encryption method as described in any one of the embodiments of the first aspect or the communication decryption method as described in any one of the embodiments of the second aspect.
[0046] The sixth aspect embodiment of the present application provides a storage medium. When the instructions in the storage medium are executed by the processor of an electronic device, the electronic device can execute the communication encryption method as described in any one of the first aspect embodiments or the communication decryption method as described in any one of the second aspect embodiments.
[0047] The technical solution provided by the embodiment of the present application includes at least the following beneficial effects:
[0048] The server and the client have established a communication connection in advance, and the server has generated initial parameters for calculating the key in advance. The method includes: substituting the initial parameters into a pre-obtained calculation model for iterative calculation, and the number of iterations is equal to the first number of iterations; obtaining the first key through the iterative calculation; encrypting the original data to be sent to the client using the first key to obtain encrypted data; and sending the first number of iterations and the encrypted data to the client. The above-mentioned key generation method and encryption method can randomly change the key by dynamically modifying the first number of iterations, thereby ensuring the security of communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of an application scenario of the communication encryption method proposed in an embodiment of the present application;
[0050] Figure 2 A flow chart of the communication encryption method proposed in the embodiment of the present application;
[0051] Figure 3 A schematic diagram of the communication connection authentication process of the communication encryption method proposed in the embodiment of the present application;
[0052] Figure 4 A schematic diagram of the key solving process of the communication encryption method proposed in the embodiment of the present application;
[0053] Figure 5 A schematic diagram of the structure of the communication encryption device proposed in the embodiment of the present application;
[0054] Figure 6 A schematic diagram of the structure of a communication decryption device proposed in an embodiment of the present application;
[0055] Figure 7 A schematic diagram of the structure of a device for the communication encryption method proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0057] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first" and "second" are used to distinguish the same items or similar items with substantially the same functions and effects. For example, the first instruction and the second instruction are to distinguish different user instructions, and their order is not limited. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit them to be different.
[0058] It should be noted that, in the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0059] In addition, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or multiple.
[0060] It should be noted that in the embodiments of the present application, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0061] In the field of communication encryption technology, data encryption has always been an important part of confidential data. At present, there are many relatively mature encryption methods. Encryption algorithms include reversible encryption algorithms and irreversible encryption algorithms. Reversible encryption algorithms are further divided into symmetric encryption algorithms and asymmetric encryption algorithms.
[0062] Symmetric encryption algorithms use the same key to encrypt and decrypt data. The advantage of this encryption method is its high efficiency, because the same key is used in both the encryption and decryption processes, the calculation speed is very fast, and it is suitable for processing large amounts of data. Common symmetric encryption algorithms include Advanced Encryption Standard (AES), Data Encryption Standard (DES) and its variant Triple Data Encryption Standard 3DES. However, the main challenge of symmetric encryption lies in key management. The sender and receiver must securely share the same key, which may become a security risk in practical applications. The defense against malicious events such as scanning and crawler cracking is weak. Once the key is leaked, all data encrypted with the key will be at risk of being cracked.
[0063] Scanning attacks refer to the use of automated tools by attackers to detect target networks or systems to find potential security vulnerabilities or open service ports. This type of attack usually occurs in the early stages of an attack in order to collect information and prepare for subsequent attacks.
[0064] A crawler attack is when an attacker uses an automated program (crawlers) to make large, unconventional visits to a website or web application to obtain information on the website or perform malicious operations. Although legitimate search engine crawlers are also a type of crawler, malicious crawlers are used for illegal purposes. Therefore, the secure storage and transmission of keys is very important.
[0065] For example, attackers use crawlers to capture the content of a website, including web pages, pictures, videos, etc., causing information security problems.
[0066] In contrast, asymmetric encryption algorithms use a pair of keys: a public key and a private key. The public key is used to encrypt data, while the private key is used to decrypt data. This design allows the public key to be shared publicly, while the private key must be kept strictly confidential. The main advantage of asymmetric encryption algorithms is that key management is simple and there is no need to transmit keys through secure channels. In addition, since the private key is not public, the data remains secure even if the public key is widely disseminated. Common asymmetric encryption algorithms include RSA (Rivest–Shamir–Adleman, RSA), Elliptic Curve Cryptography (Elliptic Curve Cryptography, ECC), etc. Although asymmetric encryption provides higher security, it has a higher computational complexity and slower processing speed, and is not suitable for direct encryption of large amounts of data. Therefore, asymmetric encryption is usually used in scenarios such as key exchange, digital signatures, and identity authentication. In most cases, the communicating parties need to establish an effective and secure encryption and decryption method, and need to make a trade-off between security and performance consumption.
[0067] Moreover, whether it is symmetric encryption or asymmetric encryption, the keys are generated in advance and cannot be changed during transmission.
[0068] So how to dynamically modify the key and effectively improve the security of communication connections is an urgent problem to be solved.
[0069] Therefore, in order to make the connection establishment more secure, the embodiments of the present application design different key generation methods so that the keys can be dynamically modified during the connection to ensure the security of communication.
[0070] Based on this, an embodiment of the present application proposes a communication encryption method, which is applied to a server, wherein the server and a client have established a communication connection in advance, and the server has pre-generated initial parameters for calculating a key, and the initial parameters are substituted into a pre-obtained calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; a first key is obtained through the iterative calculation; and the original data to be sent to the client is encrypted using the first key to obtain encrypted data;
[0071] The first iteration number and the encrypted data are sent to the client.
[0072] When the server and the client have established a communication connection in advance, the encryption key for each communication between the server and the client can be dynamically modified, making the key generation method more complex. This can prevent malicious events such as scanning and crawler cracking from cracking passwords, making the connection establishment safer, and the key can be dynamically modified during the connection to ensure the security of communication.
[0073] For example, Figure 1A schematic diagram of an application scenario provided in an embodiment of the present application, wherein a communication connection is established between the client 101 and the server 102 through an encryption and decryption process.
[0074] In the modern information technology environment, client operating systems and server operating systems play a vital role. In some possible embodiments, the operating system running on the client can be Windows 10, macOS or Linux (such as Ubuntu), on which users can run specific applications to protect their data transmission. Similarly, on mobile devices, Android and iOS operating systems also provide a wealth of mobile applications that enable users to communicate securely on smartphones.
[0075] In some possible embodiments, on the server side, the choice of operating system is equally diverse, and they are usually required to handle larger scale data and requests. Linux is a common choice, and many servers run on different Linux distributions such as Ubuntu, CentOS, or Debian because of its flexibility and security. Windows Server, such as Windows Server 2019, is also a common server operating system in enterprises, which provides powerful service programs to handle complex business needs. FreeBSD, known for its stability and performance, is also a choice for some servers. Although less common, macOS Server also provides a stable server platform for enterprises. Which operating system is adopted is not specifically limited in the embodiments of this application.
[0076] Deploy a set of application services on the server, which can be based on the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP). The choice of TCP or UDP usually depends on the needs and characteristics of the application. The TCP protocol provides reliable, connection-oriented communication, ensuring that data arrives in order and without loss, and is suitable for applications that require reliable transmission. The UDP protocol provides connectionless, unreliable communication, which is suitable for applications that have high real-time requirements and can tolerate a certain packet loss rate.
[0077] When establishing communication, the client initiates a connection request. Before encryption and decryption, the server performs the client's identity authentication process, such as Figure 2 shown.
[0078] S201, the client sends a communication connection request and information of the computing model to the server;
[0079] Before the client communicates with the server, the client needs to send an authentication request so that the server can authenticate the identity to ensure the security of communication.
[0080] The information of the computing model may include: what the specific model is and the parameters related to the model. In an embodiment of the present application, the computing model adopted is a logistic regression computing model. The logistic regression model (LR) is a classic classification algorithm, which is widely used in binary classification problems. It maps the output of the linear model to a probability space, that is, from 0 to 1, by using a logical function (usually a Sigmoid function), thereby predicting the probability of an event occurring. In an embodiment of the present application, the initial feature matrix is classified, and the classification vectors at different iteration times are calculated as the encryption key.
[0081] The logistic regression model is Wherein, x is the initial feature independent variable matrix, w is the parameter vector, and b is the constant parameter; the loss function of the logistic regression model is Where n is the number of rows of the initial feature independent variable matrix x, y i is the initial classification vector corresponding to the i-th row of the initial feature independent variable matrix, and the classification vector is expressed as The classification vector is the key.
[0082] The logistic regression model can handle large-scale sparse features while ensuring security and has efficient computing performance. In this model, the logistic regression algorithm is used to train on encrypted data without exposing the original data, thereby protecting the privacy of the data. In general, the logistic regression model maintains an important position in classification tasks due to its simplicity, intuitiveness and ease of implementation. In terms of privacy protection, combined with homomorphic encryption and secret sharing technology, the logistic regression model can be used to perform effective data analysis and prediction while protecting data privacy.
[0083] S202, generating initial parameters corresponding to the information of the calculation model;
[0084] The server generates initial parameters corresponding to the information of the calculation model, and the initial parameters are parameters used in the calculation of the logistic regression model, including: an initial feature independent variable matrix, an initial parameter vector, an initial constant vector and a step value.
[0085] The initial feature independent variable matrix is randomly generated by the server according to the preset dimension size, and the corresponding classification vector is generated. In the calculation process of logistic regression, the parameter vector and constant parameter are two important parameters. The initial parameter vector and initial constant parameter of logistic regression are generated after the preset range. The step size (also known as the learning rate) is an important parameter that determines the amplitude of the movement towards the minimum value of the objective function when updating the parameters in each iteration.
[0086] The step size determines the magnitude of the parameter update in each iteration. If the step size is too long, the minimum value may be exceeded, resulting in oscillation or failure to converge; if the step size is too short, the convergence speed will be very slow and more iterations will be required.
[0087] In addition, the step size plays a role in controlling the speed of the optimization process. A suitable step size can ensure that the algorithm neither stops prematurely nor misses the optimal solution due to excessive updates.
[0088] S203, sending the initial parameters to the client;
[0089] The server sends the generated initial parameters corresponding to the information of the calculation model to the client.
[0090] S204, obtaining a client verification key through the iterative calculation;
[0091] First, the client authentication key is calculated at the client, and the classification vector is the key.
[0092] The categorical vector can be obtained by using the logistic regression model To calculate, it is necessary to solve the parameter vector w and the constant parameter b. In the embodiment of the present application, the gradient descent method is used for solving, and the solving process is shown in Figure 4:
[0093] S401, calculating the gradient of the loss function of the logistic regression calculation model with respect to the parameter vector w and the constant parameter b;
[0094] Loss function for logistic regression model Find the gradient of parameters w and b: The gradient of parameter vector w is For the gradient of the transfer parameter b, we have where x ij is the value in the initial independent variable matrix x0, When i is equal to 1 and j is equal to 2, then x 12 .
[0095] S402, determining the number of iterations, and obtaining a parameter vector w and a constant parameter b corresponding to the number of iterations;
[0096] The iteration expressions for parameter vector and constant parameter are:
[0097] Among them, k represents the number of iterations, and α represents the step size;
[0098] When the second iteration number is k+1, the parameter vector w is equal to w k+1 , the constant parameter b is equal to the constant parameter b of the iteration k+1 .
[0099] S403, substitute the parameter vector w, constant parameter b and the initial feature independent variable matrix into the classification vector expression to obtain the key.
[0100] In order to save the number of second iterations, a small value can be selected and the calculated w=w k+1 and b = b k+1 , substituting back to the logistic regression model In the calculation, the initial feature independent variable matrix is input to obtain the classification vector corresponding to the second iteration number. Then the second iteration number and the corresponding classification vector are sent to the server.
[0101] Among them, the parameter vector w is the weight vector in the logistic regression model, indicating the importance of each feature.
[0102] The constant parameter b is the bias term in the logistic regression model and is used to adjust the location of the decision boundary.
[0103] S205, feeding back the second iteration number and the verification key to the server;
[0104] The client calculates the key corresponding to the second iteration number, and sends both the iteration number and the key to the server for client identity verification.
[0105] S206, obtaining a server verification key through the iterative calculation, the number of iterations being equal to the second number of iterations;
[0106] The server receives the iteration number and key sent by the client, and in the case of the second iteration number, calculates the classification vector under the second iteration, that is, the server verification key, by the same method as the client.
[0107] S207: When the server verification key and the client verification key are the same, establish a communication connection with the client.
[0108] The server verifies the identity of the client, compares the server verification key with the client verification key, and establishes communication if they are consistent, otherwise the connection is disconnected.
[0109] Through the above steps, the client and server are able to generate verification keys through iterative calculations and verify the identities of both parties by comparing the keys. Once the identity authentication is successful, the two parties can establish a secure communication connection. This mechanism ensures the security and reliability of communication.
[0110] The above process is the interaction between the server and the client to complete the server's verification of the client's identity. After the verification is completed, in subsequent communications, each time the communication is encrypted and decrypted, the server only needs to set the random first iteration number to generate the corresponding classification vector. Use this classification vector as the key to encrypt the communication content. At the same time, the server only needs to send the first iteration number and the original data, that is, the encrypted content, to the client, and the client can obtain the corresponding key for decryption. The client's data can also be encrypted in the same way. The encryption process of the server and the decryption process of the client are as follows: Figure 3 As shown:
[0111] S301, substituting the initial parameters into a pre-obtained calculation model for iterative calculation;
[0112] During the encryption process on the server, the randomly generated initial parameters are introduced into the logistic regression model notified in advance by the client, and the parameter vector w and the constant vector b are obtained by iterative calculation through the gradient descent method.
[0113] S302, obtaining a first key through the iterative calculation;
[0114] The server randomly generates the first iteration number and substitutes the iteration number into Calculate the parameter vector w and constant parameter b, and substitute the initial independent variable matrix, w and b into In the first iteration, we get the classification vector corresponding to That is, the first key of the server. Since the first iteration number is randomly generated by the server and the iteration number is dynamically changing, the key is also dynamically changing, that is, the embodiment of the present application can randomly change the key by randomly changing the iteration number to improve data security.
[0115] S303, encrypting the original data to be sent to the client using the first key to obtain encrypted data;
[0116] The server encrypts the data using the first key to obtain encrypted data.
[0117] S304, sending the first iteration number and the encrypted data to the client;
[0118] The first iteration number is automatically generated by the server, and the server should send it to the client so that the client can obtain the first decryption key through the iteration number. Due to the randomness of the randomly generated first iteration number, the embodiment of the present application can randomly change the key to ensure communication security.
[0119] Exemplarily, the first number of iterations and the second number of iterations in the identity authentication process may be the same value or different values. In order to reduce the number of iterations and save calculations, a smaller value may be selected for the second number of iterations in the identity authentication process, which is not limited here. The difference between the first number of iterations and the second number of iterations is that the first number of iterations is randomly generated by the server, and the second number of iterations is pre-set by the client and sent to the server for identity authentication. That is to say, after the identity authentication is completed, the client does not know in advance the value of the first number of iterations of the data to be decrypted, which can further improve the security of the communication.
[0120] S305, obtaining a first key for the encrypted data through the iterative calculation;
[0121] The client receives the first iteration number and the encrypted data sent by the server, and calculates the classification vector corresponding to the first iteration number, that is, the first key of the encrypted data. The steps of calculating the first key are as follows:
[0122] S401, calculating the gradient of the loss function of the logistic regression calculation model with respect to the parameter vector w and the constant parameter b;
[0123] S402, determining the number of iterations, and obtaining a parameter vector w and a constant parameter b corresponding to the number of iterations;
[0124] Different from the authentication process of the server to the client, the first iteration number in the encryption and decryption process is randomly generated by the server so as to randomly change the key to ensure communication security.
[0125] Among them, the iterative expressions of parameter vector and constant parameter are:
[0126] Among them, k represents the number of iterations, and α represents the step size;
[0127] When the first iteration number is k+1, the parameter vector w is equal to w k+1 , the constant parameter b is equal to the constant parameter b of the iteration k+1 .
[0128] S403, substitute the parameter vector w, constant parameter b and the initial feature independent variable matrix into the classification vector expression to obtain the key.
[0129] The calculated w=wk+1 and b = b k+1 , substituting back to the logistic regression model In the process, the initial feature independent variable matrix is input to calculate the classification vector corresponding to the second iteration number. Then the first iteration number and the encrypted content are sent to the client.
[0130] S306: Use the first key to decrypt the received encrypted data to obtain original data.
[0131] In some embodiments, when the communication ends, the server deletes all initial values of this communication, further improving the communication security between the server and the client.
[0132] It should be understood that although Figure 2-4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0133] In some embodiments, Figure 5 As shown, a communication encryption device is provided, wherein the server and the client establish a communication connection in advance, and the server generates initial parameters for calculating a key in advance, including: an encryption module 501 and a sending module 502, wherein:
[0134] The encryption module 501 is used to substitute the initial parameters into the pre-obtained calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain a first key through the iterative calculation; and encrypt the original data to be sent to the client using the first key to obtain encrypted data;
[0135] The sending module 502 is used to send the first iteration number and the encrypted data to the client.
[0136] In another embodiment, Figure 6 As shown, a communication decryption device is provided, wherein the client and the server establish a communication connection in advance, including: a receiving module 601, a decryption module 602, wherein:
[0137] Receiving module 601, used for the client to receive the first iteration number and encrypted data sent by the server;
[0138] The decryption module 602 is used to substitute the pre-obtained initial parameters for calculating the key into a pre-set calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain the first key of the encrypted data through the iterative calculation; and use the first key to decrypt the received encrypted data to obtain the original data.
[0139] For further definition of the communication encryption device and decryption device, please refer to the definition of the communication encryption and decryption method above, which will not be repeated here. The various modules in the above encryption and decryption devices can be implemented in whole or in part by software, hardware and their combination. The above modules can be embedded in or independent of the processor in the terminal device in hardware form, or stored in the memory in the terminal device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0140] Another embodiment provides a computer-readable storage medium, which is used to store a computer program. This computer program includes instructions for implementing the method described in the embodiment of the present application. By installing this computer program on a computer, the computer can execute the corresponding method to perform communication encryption and decryption.
[0141] Another embodiment proposes that this embodiment provides a computer program product, which includes computer program codes. When these computer program codes are run on a computer, they enable the computer to implement the method proposed in the embodiment of the present application. In this way, users can implement communication encryption and decryption by using this computer program product.
[0142] For example, Figure 7 It is a schematic block diagram of a device of another communication encryption method provided in an embodiment of the present application.
[0143] Figure 7 The communication encryption device 700 shown is composed of four main parts: processor 701, memory 702, communication interface 703 and bus 704. Each part has its specific function and role, and these components and their functions in communication encryption will be explained in detail below.
[0144] The processor 701 is the core computing unit of the entire device, responsible for performing various computing tasks and control operations. In communication encryption, the processor 701 generates keys according to a preset algorithm (such as a logistic regression model), and performs iterative calculations to generate verification keys and decryption keys; uses the generated keys to encrypt and decrypt data; participates in the identity authentication process between the client and the server to ensure that the identities of the communicating parties are correct; and processes communication protocols (such as the TCP / IP protocol stack) to ensure the correct transmission and reception of data packets.
[0145] The memory 702 is used to store program codes, data and temporary information. In communication encryption, the memory 702 stores algorithm codes and initial parameters for key generation and data encryption and decryption; caches data to be encrypted, encrypted data and decrypted original data; saves system configuration information, including connection parameters, key length, etc.; and records system operation logs for troubleshooting and performance analysis.
[0146] The communication interface 703 is responsible for exchanging data with other devices or networks. In communication encryption, the communication interface 703 sends a communication connection request to the server and receives the server's response; is responsible for sending encrypted data to the server and receiving encrypted data from the server; participates in the exchange process of verifying the key to ensure that the keys of both parties are consistent; manages the network connection with the server to ensure the stability and security of the connection.
[0147] The bus 704 is a channel for data transmission and communication between various components. In communication encryption, the bus 704 connects the processor 701, the memory 702 and the communication interface 703 to ensure that they can exchange data efficiently; transmit control signals so that the processor 701 can control the operation of other components; ensure the synchronization of operations between various components and ensure the consistency and integrity of data.
[0148] Through the coordinated operation of these components, the communication encryption device 700 can achieve secure and reliable communications and ensure the confidentiality and integrity of data.
[0149] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0150] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in a processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor executes the instructions in the memory, and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.
[0151] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0152] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0153] In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0156] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0157] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiment of the present application, which should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
Claims
1. A communication encryption method, characterized in that: Applied to a server, the server pre-establishes a communication connection with a client, and the server pre-generates initial parameters for calculating a key, the method comprising: Substituting the initial parameters into the pre-obtained calculation model for iterative calculation, the number of iterations being equal to the first number of iterations; Obtaining a first key through the iterative calculation; Encrypting the original data to be sent to the client using the first key to obtain encrypted data; The first iteration number and the encrypted data are sent to the client.
2. The method according to claim 1, characterized in that The step of pre-establishing a communication connection between the server and the client comprises: The server receives the connection request sent by the client and information of the computing model used for encryption; Generate initial parameters corresponding to the information of the calculation model; Sending the initial parameters to the client; Receive a second iteration number and a client verification key fed back by the client; Substituting the initial parameters into the calculation model corresponding to the information of the calculation model for iterative calculation, wherein the number of iterations is equal to the second number of iterations, and obtaining the server verification key through the iterative calculation; When the server authentication key and the client authentication key are the same, a communication connection with the client is established.
3. The method according to claim 2, characterized in that The calculation model is a logistic regression model, and the initial parameters are parameters used in the calculation of the logistic regression model, including: an initial feature independent variable matrix, an initial parameter vector, an initial constant vector and a step value.
4. The method according to claim 3, characterized in that The logistic regression model is Wherein, x is the initial feature independent variable matrix, w is the parameter vector, and b is the constant parameter; The loss function of the logistic regression model is Among them, n is the number of rows of the initial feature independent variable matrix x, y i is the initial classification vector corresponding to the i-th row of the initial feature independent variable matrix, and the classification vector is expressed as The classification vector is the key; the classification vector is solved by a gradient descent method, including: The loss function obtains the gradient of the parameter vector w and the constant parameter b: Among them, x ij represents the element of the i-th row and j-th column of the initial feature independent variable matrix; the iterative expression of the parameter vector and the constant parameter is: Among them, k represents the number of iterations, and α represents the step size; When the first iteration number is k+1, the parameter vector w is equal to w k+1 , the constant parameter b is equal to the constant parameter b of the iteration k+1 ; Substitute the parameter vector w, constant parameter b and the initial feature independent variable matrix into the logistic regression model to obtain the key.
5. A communication decryption method, characterized in that: Applied to a client, the client pre-establishes a communication connection with a server, and the method comprises: The client receives the first iteration number and the encrypted data sent by the server; Substituting the pre-obtained initial parameters for calculating the key into a pre-set calculation model for iterative calculation, the number of iterations being equal to the first number of iterations; Obtaining a first key for the encrypted data through the iterative calculation; The received encrypted data is decrypted using the first key to obtain the original data.
6. The method according to claim 5, characterized in that The step of pre-establishing a communication connection between the client and the server comprises: The client sends a communication connection request and information of the computing model to the server; Receiving the initial parameters for key calculation; Substituting the initial parameters into the calculation model for iterative calculation, the number of iterations being equal to the second number of iterations, and obtaining the client verification key through the iterative calculation; Feedback the second iteration number and the client verification key to the server; When the client authentication key passes the server authentication, a communication connection with the server is established.
7. A communication encryption device, characterized in that: Applied to a server, the server has pre-established a communication connection with a client, and the server has pre-generated initial parameters for calculating a key, including: An encryption module is used to substitute the initial parameters into a pre-obtained calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain a first key through the iterative calculation; and encrypt the original data to be sent to the client using the first key to obtain encrypted data; A sending module is used to send the first iteration number and the encrypted data to the client.
8. A communication decryption device, characterized in that: Applied to a client, the client pre-establishes a communication connection with a server, including: A receiving module, used for the client to receive the first iteration number and encrypted data sent by the server; A decryption module is used to substitute the pre-obtained initial parameters for calculating the key into a pre-set calculation model for iterative calculation, wherein the number of iterations is equal to the first number of iterations; obtain the first key of the encrypted data through the iterative calculation; and use the first key to decrypt the received encrypted data to obtain the original data.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 6.
10. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 6.