Security encryption sorting method and system, computer equipment, readable storage medium and program product

By using the Paillier encryption algorithm and matrix encoding technology, the problems of approximation error and dataset size limitation in encrypted data sorting are solved, achieving highly accurate and efficient encrypted data analysis and supporting sorting of data of any size.

CN120956455APending Publication Date: 2025-11-14ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511043199.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as approximation errors, dataset size limitations, and high comparison overhead in encrypted data sorting, which cannot meet the needs of practical applications for deterministic results and arbitrary data scales.

Method used

The system uses a pre-defined Paillier encryption algorithm to generate public and private key shares. It performs secure comparison operations by constructing row and column repeat matrices, sorts the encrypted data using rank calculation and matrix encoding, and obtains the plaintext sorting result by combining partial decryption on the server.

Benefits of technology

It achieves highly accurate and efficient sorting of encrypted data, supports arbitrary data size, eliminates approximation errors, breaks through the power of 2 limitation of traditional schemes, and significantly optimizes computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120956455A_ABST
    Figure CN120956455A_ABST
Patent Text Reader

Abstract

The invention relates to a security encryption sorting method and system, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: realizing key processing and data set encryption based on a preset Paillier encryption algorithm; the server performs matrix coding and comparison operation on the encrypted data set and outputs a sorting result matrix; and the two servers cooperate with each other to complete decryption of the sorting result matrix, and a plaintext sorting result is fed back to the data holder. By adopting the method, the encrypted data is sorted, the privacy leakage risk is avoided, the approximate error in the traditional technology is eliminated, and the encrypted data analysis capability which supports any data scale, is higher in accuracy and is better in calculation efficiency is realized by designing a matrix coding technology and a security comparison protocol.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information security technology, and in particular to a secure encryption sorting method, system, computer device, computer-readable storage medium, and computer program product. Background Technology

[0002] With the rapid development of cloud computing and big data technologies, data outsourcing storage and computing services are becoming increasingly popular, but data privacy protection issues are becoming more prominent. In application scenarios such as medical data analysis, financial risk control, and business intelligence, it is necessary to sort, rank, and statistically analyze sensitive data, but traditional methods require data to be processed in plaintext, posing a serious risk of privacy leakage.

[0003] Furthermore, implementing comparison operations between data elements on encrypted data faces the following technical challenges: 1. Comparison operations on encrypted data require special cryptographic protocols, resulting in high computational overhead. The complexity and depth of the comparison operations will affect overall efficiency; 2. Although the current CKKS scheme (Ciphertext-Policy K-Anonymous Encryption, a homomorphic encryption scheme) supports floating-point operations, it suffers from approximation error and strictly requires the dataset size to be a power of 2, limiting the flexibility of practical applications; 3. It is difficult to achieve a balance between maintaining data privacy and ensuring computational efficiency.

[0004] Therefore, traditional techniques face problems such as approximation errors, limitations on dataset size, and significant comparison overhead, making them unable to meet the practical application requirements for deterministic results and arbitrary data scales. Summary of the Invention

[0005] Therefore, it is necessary to provide a secure encrypted sorting method, system, computer device, computer-readable storage medium, and computer program product to address the above-mentioned technical problems, which can achieve encrypted data analysis capabilities that support arbitrary data scales, have higher accuracy, and better computational efficiency.

[0006] In a first aspect, this application provides a secure encrypted sorting method, which is applied in a first server, and the method includes:

[0007] Receives a first private key share and an encrypted dataset distributed by the data holder; the data holder manages the public key, distributes the first private key share to the first server, and distributes the second private key share to the second server; the public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm; the encrypted dataset is obtained by the data holder encrypting the original dataset using the public key;

[0008] Construct row repeating matrices and column repeating matrices based on the encrypted dataset;

[0009] For each element pair in the row-repeating matrix and the column-repeating matrix, perform a safe comparison operation to obtain a comparison matrix;

[0010] Summing each column of the comparison matrix yields the rank matrix;

[0011] Construct a rank-valued row repeating matrix from the rank matrix, and then construct a constant matrix from the rank-valued row repeating matrix; the elements in each row of the constant matrix are the same, and the values ​​of the elements in each column increase sequentially.

[0012] Calculate the difference matrix based on the rank-valued row repetition matrix and the constant matrix, and generate the mask matrix based on the difference matrix;

[0013] The sorting result matrix is ​​determined based on the row repetition matrix and the mask matrix;

[0014] The sorted matrix is ​​partially decrypted based on the first private key share to obtain the first decrypted information;

[0015] Based on the first decryption information and the second decryption information from the second server, the plaintext sorting result is obtained; the second decryption information is obtained by the second server partially decrypting the sorting result matrix according to the second private key share;

[0016] The plaintext sorting results are then fed back to the data holder.

[0017] In one embodiment, constructing a row repetition matrix and a column repetition matrix based on the encrypted dataset includes:

[0018] Perform a row copying operation on the encrypted dataset to obtain a row repeating matrix;

[0019] Perform transpose and column copy operations on the row repeating matrix to obtain the column repeating matrix.

[0020] In one embodiment, a secure comparison operation is performed for each element pair in the row repeating matrix and the column repeating matrix to obtain a comparison matrix, including:

[0021] For each pair of elements in the row-repeating matrix and the column-repeating matrix, the normalized difference is calculated using a first preset formula; the first preset formula is: ;in, To preset the maximum difference range, i and j represent the row and column of the matrix, respectively. Represents a row repeating matrix. Represents a matrix with repeated columns;

[0022] The normalized difference is processed according to the approximation function and the approximation function, and the processing result is mapped to the [0,1] interval to obtain the target result;

[0023] The comparison results are calculated using a second preset formula; the second preset formula is: Where CMP represents the comparison result, Indicates the target result;

[0024] The comparison matrix is ​​obtained by comparing each pair of elements in the row repeating matrix and the column repeating matrix.

[0025] In one embodiment, determining the sorting result matrix based on the row repetition matrix and the mask matrix includes:

[0026] Based on the row repetition matrix and the mask matrix, perform element-wise multiplication to obtain the target matrix;

[0027] Summing is performed on each row of the target matrix, and the processed target matrix is ​​transposed to obtain the sorted result matrix.

[0028] In one embodiment, generating a mask matrix based on the difference matrix includes:

[0029] Determine whether each element in the difference matrix is ​​0 to obtain the result;

[0030] Based on the judgment result and the third preset formula, a mask matrix is ​​generated; the third preset formula is: ,in, The elements in the mask matrix are represented by i and j, which represent the row and column of the matrix, respectively.

[0031] In one embodiment, the method further includes:

[0032] Under the coordination of the data holder, the sorting result matrix is ​​partially decrypted according to the first private key share to obtain the first decryption information; correspondingly, under the coordination of the data holder, the second server is partially decrypted according to the second private key share to obtain the second decryption information.

[0033] Secondly, this application also provides a secure encrypted sorting system, which includes a data holder, a first server, and a second server, wherein:

[0034] The data holder generates a public key, a first private key share, and a second private key share. The first private key share is distributed to the first server, and the second private key share is distributed to the second server. The public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm. The original dataset is encrypted using the public key to obtain an encrypted dataset, which is then sent to the first server.

[0035] The first server is used to construct row repeating matrices and column repeating matrices based on the encrypted dataset; perform a secure comparison operation on each element pair in the row repeating matrix and column repeating matrix to obtain a comparison matrix; sum each column of the comparison matrix to obtain a rank matrix; construct a rank-value row repeating matrix based on the rank matrix, and construct a constant matrix based on the rank-value row repeating matrix; the constant matrix has identical elements in each row and its column elements are filled with progressively increasing values; calculate a difference matrix based on the rank-value row repeating matrix and the constant matrix, and generate a mask matrix based on the difference matrix; determine the sorting result matrix based on the row repeating matrix and the mask matrix; and partially decrypt the sorting result matrix based on the first private key share to obtain the first decryption information.

[0036] The second server is used to partially decrypt the sorted matrix according to the second private key share to obtain the second decrypted information.

[0037] The first server is also used to obtain the plaintext sorting result based on the first decryption information and the second decryption information; and to feed back the plaintext sorting result to the data holder.

[0038] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in the first aspect above.

[0039] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.

[0040] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect above.

[0041] The aforementioned secure encryption sorting method, system, computer device, computer-readable storage medium, and computer program product involve the following steps: A first server receives a first private key share and an encrypted dataset distributed by a data holder; the data holder manages a public key, distributes the first private key share to the first server, and distributes a second private key share to a second server; the public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm; the encrypted dataset is obtained by the data holder encrypting the original dataset using the public key; a row repetition matrix and a column repetition matrix are constructed based on the encrypted dataset; a secure comparison operation is performed on each element pair in the row repetition matrix and the column repetition matrix to obtain a comparison matrix; and a secure comparison operation is performed on each column of the comparison matrix. The process involves row summation to obtain a rank matrix; constructing a rank-value row repetition matrix based on the rank matrix, and then constructing a constant matrix based on the rank-value row repetition matrix; the constant matrix has identical elements in each row and its column elements are filled with progressively increasing values; calculating a difference matrix based on the rank-value row repetition matrix and the constant matrix, and generating a mask matrix based on the difference matrix; determining the sorting result matrix based on the row repetition matrix and the mask matrix; partially decrypting the sorting result matrix based on the first private key share to obtain the first decryption information; obtaining the plaintext sorting result based on the first decryption information and the second decryption information from the second server; the second decryption information is obtained by the second server partially decrypting the sorting result matrix based on the second private key share; and finally, feeding back the plaintext sorting result to the data holder. Through this method, the encrypted data is sorted using comparison operations between data elements, such as rank calculation, order statistics, and sorting operations, avoiding the risk of privacy leakage. The pre-set Paillier encryption algorithm is used for precise integer operations, eliminating approximation errors in traditional techniques and improving the accuracy of encrypted data sorting. It supports datasets of arbitrary size, breaking the power-of-two limitation of the CKKS scheme. This application achieves constant-level comparison depth through matrix encoding, significantly outperforming traditional logarithmic complexity. By designing matrix encoding techniques and a secure comparison protocol, it realizes encrypted data analysis capabilities that support arbitrary data sizes, offer higher accuracy, and superior computational efficiency. Attached Figure Description

[0042] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0043] Figure 1 This is a diagram illustrating the application environment of a secure encryption sorting method in one embodiment.

[0044] Figure 2This is a flowchart illustrating a secure encryption sorting method in one embodiment;

[0045] Figure 3 This is a flowchart illustrating a secure encrypted sorting method in another embodiment;

[0046] Figure 4 This is a schematic diagram of the matrix processing flow in one embodiment;

[0047] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0049] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0050] The secure encryption sorting method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, data holder 102 generates a public key, a first private key share, and a second private key share based on a preset Paillier encryption algorithm. The first private key share is distributed to a first server 104, and the second private key share is distributed to a second server 106. Data holder 102 encrypts the original dataset using the public key and sends the encrypted dataset to either the first server 104 or the second server 106. The first server 104 or the second server 106 processes the encrypted dataset using the secure encryption sorting method provided in this embodiment and returns the plaintext sorting result to data holder 102.

[0051] In this system, data holder 102, first server 104, and second server 106 interact with each other via a communication network. Data holder 102 can be a terminal or a server. Terminals can be, but are not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted displays, etc. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Servers (first server 102 or second server 104) can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud computing services.

[0052] In one exemplary embodiment, such as Figure 2 As shown, a secure encrypted sorting method is provided, which can be applied to... Figure 1 Taking the first server 104 as an example, the explanation includes the following steps:

[0053] Step 202: Receive the first private key share and the encrypted dataset distributed by the data holder; the data holder manages the public key, distributes the first private key share to the first server, and distributes the second private key share to the second server; the public key, the first private key share, and the second private key share are generated by the preset Paillier encryption algorithm; the encrypted dataset is obtained by the data holder encrypting the original dataset using the public key.

[0054] Before executing the secure encryption sorting method, system initialization is required, specifically including: the data holder generating the public key for the (2,2)-threshold Paillier cryptosystem. and private key share and Recruit two independent and trusted first and second servers, and distribute private key shares to the first and second servers respectively.

[0055] Data holders have access to the original dataset Each element Encryption was performed using the (2,2)-threshold Paillier encryption function to obtain the encrypted dataset. The data holder sends the encrypted dataset to the first server for processing. In a specific implementation, a second server may also sort the encrypted dataset; this embodiment does not impose any restrictions on this.

[0056] The (2,2)-threshold Paillier encryption function is specifically expressed as follows: ,in, r is from Random numbers obtained by uniform sampling.

[0057] Step 204: Construct a row repeating matrix and a column repeating matrix based on the encrypted dataset.

[0058] In an exemplary embodiment, step 204 includes: performing a row copy operation on the encrypted dataset to obtain a row repeating matrix; and performing a transpose operation and a column copy operation on the row repeating matrix to obtain a column repeating matrix.

[0059] The following matrix transformation operation is defined to establish comparison relationships between rows and columns in parallel: Execute The row copy operation copies the input vector row by row to obtain: ;implement Column transformation and Column repetition operation: The input vector is first transposed, then copied column by column, resulting in: ,in , and These represent row copying, column copying, and row transpose operations, respectively. , , Specifically, it is expressed as follows:

[0060] ;

[0061] ;

[0062] .

[0063] Step 206: Perform a safe comparison operation on each element pair in the row repeating matrix and the column repeating matrix to obtain the comparison matrix.

[0064] Among them, the ciphertext matrix and Perform a safe comparison operation on each pair of elements in the data. Specifically, by comparing functions The comparison matrix is ​​obtained through processing. .

[0065] In an exemplary embodiment, step 206 includes: calculating a normalized difference for each pair of elements in the row repeating matrix and the column repeating matrix using a first preset formula; the first preset formula is: ;in, To preset the maximum difference range, i and j represent the row and column of the matrix, respectively. Represents a row repeating matrix. The column repeating matrix is ​​represented; the normalized difference is processed according to the approximation function and the approximation function, and the processing result is mapped to the [0,1] interval to obtain the target result; the comparison result is calculated by the second preset formula; the second preset formula is: Where CMP represents the comparison result, The target result is represented by the comparison matrix, which is obtained based on the comparison results of each element pair in the row repeating matrix and the column repeating matrix.

[0066] Specifically, for the two ciphertext matrices input... and Calculate the normalized difference ,in To preset the maximum difference range, i and j represent the row and column of the matrix, respectively;

[0067] Through approximation function and approximation function Process the difference and get the result. Mapped to the [0,1] interval;

[0068] Final output calculation: When the result is close to 1, it means A result of 0.5 indicates... When the result is close to 0, it indicates that... .

[0069] Step 208: Sum each column of the comparison matrix to obtain the rank matrix.

[0070] Among them, the comparison matrix Perform homomorphic addition summation on each row Obtain the rank matrix ,in, This indicates that the ordered ciphertext of each element is obtained by aggregating the results of each column; The operation is specifically represented as follows:

[0071] .

[0072] Step 210: Construct a rank-value row repeating matrix based on the rank matrix, and construct a constant matrix based on the rank-value row repeating matrix; the elements in each row of the constant matrix are the same, and the values ​​filled in each column increase sequentially.

[0073] The calculated rank matrix conduct (Row copy) operation, resulting in Matrix, construct a constant matrix , All elements in each row are identical, and the values ​​filled in from row 1 to row n increase sequentially.

[0074] Step 212: Calculate the difference matrix based on the rank row repetition matrix and the constant matrix, and generate the mask matrix based on the difference matrix.

[0075] Among them, use Subtraction operation execution Calculate the difference between each pair of elements to obtain the difference matrix. .

[0076] In an exemplary embodiment, generating a mask matrix based on a difference matrix includes: determining whether each element in the difference matrix is ​​0, obtaining a determination result; and generating a mask matrix based on the determination result and a third preset formula; the third preset formula is: ,in, The elements in the mask matrix are represented by i and j, which represent the row and column of the matrix, respectively.

[0077] Specifically, it involves determining whether each element in the difference matrix is ​​0, and then generating a 0-1 mask matrix according to the third preset formula mentioned above. Identify the location of the target element.

[0078] Step 214: Determine the sorting result matrix based on the row repetition matrix and the mask matrix.

[0079] In an exemplary embodiment, step 214 includes: performing element-wise multiplication based on the row repeating matrix and the mask matrix to obtain a target matrix; summing each row of the target matrix and transposing the processed target matrix to obtain a sorted result matrix.

[0080] Among them, the row repeating matrix With mask matrix Perform element-wise multiplication as follows: for any matrix position implement ,when When this is the position of the target element, it indicates that the position should be preserved. ;when When the value is zero, it indicates that the position is not the target element position and should be set to zero. The resulting... Matrix, execute sequentially Operation and Specifically:

[0081] ;

[0082] ;

[0083] in, This indicates a column summation operation, used to aggregate the results of each row's elements; This indicates the column transpose operation.

[0084] Step 216: Partially decrypt the sorting result matrix according to the first private key share to obtain the first decryption information.

[0085] Step 218: Obtain the plaintext sorting result based on the first decryption information and the second decryption information from the second server; the second decryption information is obtained by the second server partially decrypting the sorting result matrix based on the second private key share.

[0086] In one exemplary embodiment, the method further includes:

[0087] Under the coordination of the data holder, the sorting result matrix is ​​partially decrypted according to the first private key share to obtain the first decryption information; correspondingly, under the coordination of the data holder, the second server is partially decrypted according to the second private key share to obtain the second decryption information.

[0088] The data holder coordinates two servers to perform threshold decryption, decrypting the sorting result matrix to obtain the plaintext's rank, order statistics, and sorting result. For example, the decryption and result acquisition steps are as follows: The data holder coordinates two servers to perform threshold decryption; the first server performs partial decryption: The second server performs partial decryption: Complete threshold decryption: .

[0089] Step 220: Feedback the plaintext sorting results to the data holder.

[0090] The aforementioned secure encrypted sorting method utilizes comparison operations between data elements, such as rank calculation, ordinal statistics, and sorting operations, to sort the encrypted data, thus avoiding the risk of privacy leakage. It employs a pre-defined Paillier encryption algorithm for precise integer arithmetic, eliminating approximation errors in traditional techniques and improving the accuracy of encrypted data sorting. It supports datasets of arbitrary size, overcoming the power-of-two limitation of the CKKS scheme. Constant-level comparison depth is achieved through matrix encoding, significantly outperforming traditional logarithmic complexity. This application, through the design of matrix encoding technology and a secure comparison protocol, achieves encrypted data analysis capabilities that support arbitrary data sizes, offer higher accuracy, and superior computational efficiency.

[0091] In one exemplary embodiment, such as Figure 3 and Figure 4 As shown, the secure encrypted sorting method provided in this embodiment includes the following steps:

[0092] Step 1, System Initialization: The data holder generates the public key for the (2,2)-threshold Paillier cryptosystem. and private key share and Recruit two independent and trusted first and second servers, and distribute private key shares to the first and second servers respectively.

[0093] Step 2: The data holder accesses the original dataset. Each element Encryption was performed using the (2,2)-threshold Paillier encryption function to obtain the encrypted dataset. Transmit the encrypted dataset to the first server.

[0094] Step 3: Construct the comparison matrix: For the input vector Perform row copying to construct a row repeating matrix. :

[0095] ;

[0096] Transpose the input vector to get:

[0097] ;

[0098] Then perform column copying to construct a column repeating matrix. :

[0099] .

[0100] Step 4, Security Matrix Comparison: Compare the ciphertext matrix. and Perform a safe comparison operation on each pair of elements in the array. Each element in the comparison matrix is ​​compared using a comparison function. Obtain the comparison matrix :

[0101] .

[0102] Step 5, Rank Calculation: Compare the matrix Perform homomorphic addition summation operation on each row Obtain the rank matrix ,in:

[0103] .

[0104] Step 6: Sort and calculate:

[0105] Step 61: Calculate the rank matrix. conduct Operations to construct a rank-based row copy matrix :

[0106] ;

[0107] Construct a constant matrix :

[0108] ;

[0109] Step 62, Use Subtraction operation execution The difference matrix is ​​obtained by calculating the position difference. :

[0110] ;

[0111] Step 63: Determine if any element in the matrix is ​​equal to 0, and generate a 0-1 mask matrix. , indicating the location of the target element:

[0112] ;

[0113] Step 64: Convert the element matrix With mask matrix Perform element-wise multiplication:

[0114] ;

[0115] Execute sequentially Operation and The operation yielded the following result:

[0116] ;

[0117] ;

[0118] The first row of the matrix represents the sorted vector result.

[0119] Step 7, Decryption and Result Acquisition: The data holder coordinates two servers to perform threshold decryption, decrypts the sorting result matrix, and obtains the plaintext's rank, order statistics, and sorting result.

[0120] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0121] Based on the same inventive concept, this application also provides a secure encrypted sorting system for implementing the secure encrypted sorting method described above. The solution provided by this system is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more secure encrypted sorting system embodiments provided below can be found in the limitations of the secure encrypted sorting method described above, and will not be repeated here.

[0122] In one exemplary embodiment, such as Figure 1 As shown, a secure encrypted sorting system is provided, including: a data holder 102, a first server 104, and a second server 106, wherein:

[0123] Data holder 102 is used to generate a public key, a first private key share, and a second private key share. The first private key share is distributed to the first server 104, and the second private key share is distributed to the second server 106. The public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm. The original dataset is encrypted according to the public key to obtain an encrypted dataset, and the encrypted dataset is sent to the first server 104.

[0124] The first server 104 is used to construct a row repeating matrix and a column repeating matrix based on the encrypted dataset; perform a secure comparison operation on each pair of elements in the row repeating matrix and the column repeating matrix to obtain a comparison matrix; sum each column of the comparison matrix to obtain a rank matrix; construct a rank value row repeating matrix based on the rank matrix, and construct a constant matrix based on the rank value row repeating matrix; the elements in each row of the constant matrix are the same, and the values ​​filled in each column are sequentially increasing; calculate a difference matrix based on the rank value row repeating matrix and the constant matrix, and generate a mask matrix based on the difference matrix; determine the sorting result matrix based on the row repeating matrix and the mask matrix; and partially decrypt the sorting result matrix based on the first private key share to obtain the first decryption information.

[0125] The second server 106 is used to partially decrypt the sorted result matrix according to the second private key share to obtain the second decrypted information.

[0126] The first server 104 is also used to obtain the plaintext sorting result based on the first decryption information and the second decryption information; and to feed back the plaintext sorting result to the data holder 102.

[0127] The aforementioned secure encrypted sorting system utilizes comparison operations between data elements, such as rank calculation, ordinal statistics, and sorting operations, to sort the encrypted data, thus avoiding the risk of privacy leakage. It employs a pre-defined Paillier encryption algorithm for precise integer arithmetic, eliminating approximation errors in traditional techniques and improving the accuracy of encrypted data sorting. It supports datasets of arbitrary size, overcoming the power-of-two limitation of the CKKS scheme. Constant-level comparison depth is achieved through matrix encoding, significantly outperforming traditional logarithmic complexity. This application, through the design of matrix encoding technology and a secure comparison protocol, achieves encrypted data analysis capabilities that support arbitrary data sizes, offer higher accuracy, and superior computational efficiency.

[0128] In an exemplary embodiment, the first server 104 is further configured to perform row copying operations on the encrypted dataset to obtain a row repeating matrix; and to perform transpose and column copying operations on the row repeating matrix to obtain a column repeating matrix.

[0129] In an exemplary embodiment, the first server 104 is further configured to calculate a normalized difference for each pair of elements in the row repeating matrix and the column repeating matrix using a first preset formula; the first preset formula is: ;in, To preset the maximum difference range, i and j represent the row and column of the matrix, respectively. Represents a row repeating matrix. The column repeating matrix is ​​represented; the normalized difference is processed according to the approximation function and the approximation function, and the processing result is mapped to the [0,1] interval to obtain the target result; the comparison result is calculated by the second preset formula; the second preset formula is: Where CMP represents the comparison result, The target result is represented by the comparison matrix, which is obtained based on the comparison results of each element pair in the row repeating matrix and the column repeating matrix.

[0130] In an exemplary embodiment, the first server 104 is further configured to perform element-wise multiplication operations based on the row repeating matrix and the mask matrix to obtain a target matrix; sum each row of the target matrix; and transpose the processed target matrix to obtain a sorted result matrix.

[0131] In an exemplary embodiment, the first server 104 is further configured to determine whether each element in the difference matrix is ​​0, and obtain a determination result; based on the determination result, and in conjunction with a third preset formula, generate a mask matrix; the third preset formula is: ,in, The elements in the mask matrix are represented by i and j, which represent the row and column of the matrix, respectively.

[0132] In an exemplary embodiment, the first server 104 is further configured to, under the coordination of the data holder 102, partially decrypt the sorting result matrix according to the first private key share to obtain first decryption information; correspondingly, the second server 106 is further configured to, under the coordination of the data holder 102, partially decrypt the sorting result matrix according to the second private key share to obtain second decryption information.

[0133] Each module in the aforementioned secure encryption sorting system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0134] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores key data and matrix data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a secure encrypted sorting method.

[0135] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0136] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the secure encrypted sorting method as described in any of the above embodiments.

[0137] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the secure encrypted sorting method as described in any of the above embodiments.

[0138] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the secure encrypted sorting method as described in any of the above embodiments.

[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0140] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0141] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0142] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A secure encrypted sorting method, characterized in that, The method is applied in a first server, and the method includes: The system receives a first private key share and an encrypted dataset distributed by a data holder; the data holder manages a public key, distributes the first private key share to a first server, and distributes a second private key share to a second server; the public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm; the encrypted dataset is obtained by the data holder encrypting the original dataset using the public key. Construct a row repeating matrix and a column repeating matrix based on the encrypted dataset; For each element pair in the row repeating matrix and the column repeating matrix, a safe comparison operation is performed to obtain a comparison matrix; The rank matrix is ​​obtained by summing each column of the comparison matrix. Construct a rank-value row repeating matrix based on the rank matrix, and construct a constant matrix based on the rank-value row repeating matrix; the elements in each row of the constant matrix are the same, and the values ​​filled in each column element increase sequentially. Calculate the difference matrix based on the rank row repetition matrix and the constant matrix, and generate a mask matrix based on the difference matrix; The sorting result matrix is ​​determined based on the row repetition matrix and the mask matrix; The sorting result matrix is ​​partially decrypted based on the first private key share to obtain the first decryption information; Based on the first decryption information and the second decryption information from the second server, a plaintext sorting result is obtained; the second decryption information is obtained by the second server partially decrypting the sorting result matrix according to the second private key share; The plaintext sorting result is then fed back to the data holder.

2. The method according to claim 1, characterized in that, The step of constructing a row repeating matrix and a column repeating matrix based on the encrypted dataset includes: Perform a row copying operation on the encrypted dataset to obtain a row repetition matrix; Perform transpose and column copy operations on the row repeating matrix to obtain the column repeating matrix.

3. The method according to claim 1, characterized in that, The step of performing a secure comparison operation on each element pair in the row repeating matrix and the column repeating matrix to obtain a comparison matrix includes: For each pair of elements in the row repetition matrix and the column repetition matrix, a normalized difference is calculated using a first preset formula; the first preset formula is: ;in, To preset the maximum difference range, i and j represent the row and column of the matrix, respectively. Represents a row repeating matrix. Represents a matrix with repeated columns; The normalized difference is processed according to the approximation function and the approximation function, and the processing result is mapped to the [0,1] interval to obtain the target result; The comparison result is calculated using a second preset formula; the second preset formula is: Where CMP represents the comparison result, Indicates the target result; A comparison matrix is ​​obtained based on the comparison results of each element pair in the row repetition matrix and the column repetition matrix.

4. The method according to claim 1, characterized in that, The step of determining the sorting result matrix based on the row repetition matrix and the mask matrix includes: Based on the row repetition matrix and the mask matrix, perform element-wise multiplication to obtain the target matrix; The target matrix is ​​summed in each row, and then transposed to obtain a sorted matrix.

5. The method according to claim 1, characterized in that, The step of generating a mask matrix based on the difference matrix includes: Determine whether each element in the difference matrix is ​​0, and obtain the determination result; Based on the judgment result and combined with the third preset formula, a mask matrix is ​​generated; the third preset formula is: ,in, The elements in the mask matrix are represented by i and j, which represent the row and column of the matrix, respectively.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Under the coordination of the data holder, the sorting result matrix is ​​partially decrypted according to the first private key share to obtain first decryption information; correspondingly, under the coordination of the data holder, the second server is partially decrypted according to the second private key share to obtain second decryption information.

7. A secure encrypted sorting system, characterized in that, The system includes a data holder, a first server, and a second server, wherein: The data holder is used to generate a public key, a first private key share, and a second private key share, distribute the first private key share to the first server, and distribute the second private key share to the second server; the public key, the first private key share, and the second private key share are generated by a preset Paillier encryption algorithm; the original dataset is encrypted according to the public key to obtain an encrypted dataset, and the encrypted dataset is sent to the first server. The first server is configured to: construct a row repeating matrix and a column repeating matrix based on the encrypted dataset; perform a secure comparison operation on each element pair in the row repeating matrix and the column repeating matrix to obtain a comparison matrix; sum each column of the comparison matrix to obtain a rank matrix; construct a rank-value row repeating matrix based on the rank matrix, and construct a constant matrix based on the rank-value row repeating matrix; the constant matrix has identical elements in each row and its column elements are filled with progressively increasing values; calculate a difference matrix based on the rank-value row repeating matrix and the constant matrix, and generate a mask matrix based on the difference matrix; determine a sorting result matrix based on the row repeating matrix and the mask matrix; and partially decrypt the sorting result matrix based on the first private key share to obtain first decryption information. The second server is used to partially decrypt the sorting result matrix according to the second private key share to obtain second decryption information; The first server is further configured to obtain a plaintext sorting result based on the first decryption information and the second decryption information; and to feed back the plaintext sorting result to the data holder.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Encrypted data processing method and device, computer equipment and readable storage medium

    CN121462192A