A vector sorting method and apparatus based on homomorphic encryption

By repeatedly expanding and comparing vectors using fully homomorphic encryption and SIMD batch processing methods, counting and flag vectors are generated, solving the problems of low sorting efficiency and insufficient privacy protection in existing technologies. This achieves efficient and secure ciphertext sorting, which is suitable for multi-party data collaborative processing.

CN122507338APending Publication Date: 2026-08-04BEIJING ELECTRONICS SCI & TECH INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING ELECTRONICS SCI & TECH INST
Filing Date
2026-05-12
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing sorting methods are insufficient in terms of privacy protection and cannot meet the needs of data privacy protection. Furthermore, encrypted sorting methods are inefficient, computationally complex, and accumulate a lot of noise, making it difficult to meet the privacy isolation requirements of multi-party data collaborative processing.

Method used

Employing fully homomorphic encryption technology, the SIMD batch processing method is used to repeatedly expand and compare vectors to generate a counting array and a flag vector, achieving efficient ciphertext sorting, reducing the number of symbol function iterations, decreasing continuous multiplication operations, and utilizing the parallelism of SIMD vectors for sorting.

Benefits of technology

It achieves efficient sorting in a fully homomorphic encryption environment, reduces computational complexity and noise accumulation, improves sorting efficiency, adapts to the privacy protection needs of multi-party data collaborative processing, and has the potential advantage of resisting quantum attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122507338A_ABST
    Figure CN122507338A_ABST
Patent Text Reader

Abstract

The application discloses a vector sorting method and device based on full homomorphic encryption. The method comprises the following steps: repeatedly expanding an original vector to obtain a first repeated expansion array S1 and a second repeated expansion array S2, respectively; obtaining a counting array C according to the difference value; expanding the counting array C to obtain a third repeated expansion array S3; constructing a reference sorting index array S4; generating a flag vector F according to the difference value between the array S3 and the array S4; and finally extracting elements in the original vector in a grouping manner based on the flag vector F, and placing the extracted elements in a sorting array in sequence. In the homomorphic encryption environment, the method can achieve efficient sorting in a smart way through counting and SIMD batch processing, and the noise accumulation is very small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data privacy protection technology, and more specifically to a vector sorting method and apparatus based on fully homomorphic encryption. Background Technology

[0002] Driven by the digital wave, data has become a core production factor driving socio-economic development and technological innovation. Sorting methods, as a fundamental core technology for data processing, analysis and utilization, are widely used in various scenarios such as database retrieval, data mining, machine learning, e-government, and financial services.

[0003] With the deep integration of technologies such as cloud computing, big data, artificial intelligence, and the Internet of Things, data is showing significant characteristics of being large-scale, fragmented, cross-domain, and sensitive. Privacy protection has become a key bottleneck restricting the release of data value.

[0004] Traditional sorting methods, such as quicksort, mergesort, and heapsort, are designed primarily to optimize time and space complexity to improve data sorting efficiency and performance. Their underlying logic is based on the premise that "data is visible in plaintext and can be directly compared," which fails to meet the current demand for privacy protection. On the one hand, during plaintext sorting, the original information of the data (such as sensitive data like personal salaries, medical records, transaction logs, and location information) must be exposed throughout the process, easily leading to security risks such as data leakage, misuse, and tampering. This not only infringes on user privacy but may also lead to the leakage of corporate trade secrets and damage to government data security. On the other hand, the widespread adoption of new data processing models such as cloud storage, outsourced computing power, and cross-institutional collaboration has resulted in diversified and untrustworthy data processing entities. Traditional plaintext sorting cannot achieve "data usable but not visible," making it difficult to meet the privacy isolation requirements in multi-party collaborative data processing.

[0005] Existing ciphertext sorting methods often require multiple rounds of sign function iterations when comparing numbers. Due to the complexity of the sign function, their efficiency is often greatly limited. At the same time, there are many consecutive multiplication operations during the calculation process, which leads to a large accumulation of noise. When sorting a large number of numbers, expensive bootstrapping operations are required.

[0006] Therefore, overcoming the above-mentioned shortcomings is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] In view of the above problems, the present invention is proposed to provide a vector sorting method and apparatus based on fully homomorphic encryption to overcome or at least partially solve the above problems.

[0008] To achieve the above objectives, the present invention adopts the following technical solution:

[0009] In a first aspect, embodiments of the present invention provide a vector sorting method based on fully homomorphic encryption. First, an original vector of length n is obtained, wherein the original vector is in SIMD representation form under fully homomorphic encryption; the sorting steps include: Step 1: Repeat the original vector according to the first repeating rule to obtain the first repeating extended array S1; repeat the original vector according to the second repeating rule to obtain the second repeating extended array S2. Step 2: Based on the difference between the second repeated extended array S2 and the first repeated extended array S1, determine the comparison results of the relationship between the corresponding vectors in each array; Step 3: Sum the comparison results of the relationships in groups to obtain the count array C; Step 4: Repeat the expansion of the counting array C according to the first repeating rule to obtain the third repeating expansion array S3; at the same time, construct the sorted index array S4 for reference. Step 5: Generate a flag vector F based on the difference between the reference sorted index array S4 and the third repeated extended array S3; Step 6: Based on the flag vector F, extract the elements from the original vector in a grouped manner, and put the extracted elements into a sorted array in order.

[0010] Preferably, in step one, the first repetition rule is: repeat the original vector as a whole n times in the original order; the second repetition rule is: repeat each element in the original vector n times consecutively.

[0011] Preferably, in step two, a sign function approximation iteration is performed on the difference between the second repeated extended array S2 and the first repeated extended array S1, and the iteration result is mapped to the [0,1] interval to obtain the relationship comparison result; including: The sign function is approximated by polynomial iteration, so that for the input value, the output value approximates -1, 0 or 1; Apply the first mapping function to the output value of the symbolic function. This maps -1 to 0, 0 to 0.5, and 1 to 1.

[0012] Preferably, the comparison results are divided into groups of n components, and a tree-like summation is performed on each group. The sums of each group are then placed into the counting array C in sequence.

[0013] Subtract the self-comparison bias of 0.5 from each component of the counting vector to obtain the final counting vector C.

[0014] Preferably, step five includes: The difference between the reference sorted index array S4 and the third repeated extended array S3 is subjected to a sign function approximation iteration, and the iteration result is mapped to the interval [0,1] to obtain an intermediate result; A second mapping function is applied to the intermediate result, such that when the intermediate result is 0.5, the output is 1, and when the intermediate result is 0 or 1, the output is 0.

[0015] Preferably, the second mapping function is:

[0016] Preferably, step six includes: Divide the n components in the flag vector F into a group, and perform the following operations on each group: Construct a first mask with the first n bits set to 1 and the rest to 0, and extract the n components of the current group; multiply the extracted vector by the original vector according to the components, and then perform tree summation so that the first bit of the resulting vector is the sorting element corresponding to the current group; Construct a second mask that retains only the first bit, remove the remaining redundant bits, and then add the retained elements to the first slot of the sorted array. Rotate the currently accumulated result vector one position to the right, and update the sorted array after the next group of elements has been extracted.

[0017] Preferably, in step four, the reference sorted index array S4 is composed of n-1, n-2, ..., nn arranged sequentially, where each element is repeated n times, and n is a positive integer.

[0018] Secondly, embodiments of the present invention provide a vector sorting apparatus based on fully homomorphic encryption, used to implement the vector sorting method based on fully homomorphic encryption as described in any of the preceding claims, comprising: The acquisition module is used to acquire an original vector of length n, wherein the original vector is in the SIMD representation form under fully homomorphic encryption; An extension module is used to repeatedly extend the original vector according to a first repeating rule to obtain a first repeating extended array S1; and to repeatedly extend the original vector according to a second repeating rule to obtain a second repeating extended array S2. The counting vector determination module is used to determine the relationship comparison results of corresponding vectors in each array based on the difference between the second repeated extended array S2 and the first repeated extended array S1; and to sum the relationship comparison results in groups to obtain the counting array C; The flag vector generation module is used to repeatedly expand the counting array C according to the first repeating rule to obtain a third repeating expanded array S3; at the same time, it obtains or constructs a reference sorting index array S4; and generates a flag vector F based on the difference between the reference sorting index array S4 and the third repeating expanded array S3. The extraction and placement module is used to extract elements from the original vector in a grouped manner based on the flag vector F, and to place the extracted elements into a sorted array in order.

[0019] Thirdly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the vector sorting method based on fully homomorphic encryption as described in any of the preceding claims.

[0020] This invention provides a data sorting method and apparatus under fully homomorphic encryption, aiming to achieve an efficient sorting method in a homomorphic encryption environment through counting and SIMD batch processing. Compared with the prior art, the beneficial effects include at least: 1. Significantly reduces the number of iterations of the sign function. The original method required n-1 iterations to compare n numbers because it did not rearrange the vector. This invention cleverly rearranges the vector and makes full use of the empty space in the SIMD vector. The comparison result can be obtained in one iteration, which greatly reduces the computational complexity. 2. This application involves almost no calculations with extremely high depth, such as continuous multiplication, outside of the sign function. The overall depth is almost constant, so the noise accumulation is very small. After setting appropriate initial parameters, bootstrapping is not required, and time efficiency can be greatly optimized while ensuring accuracy. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0022] Figure 1 This is a flowchart of a vector sorting method based on fully homomorphic encryption provided in an embodiment of the present invention; Figure 2 This is an example diagram of the vector sorting process provided in an embodiment of the present invention; Figure 3 This is another example diagram of the vector sorting process provided in the embodiments of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] This invention discloses a vector sorting method and apparatus based on fully homomorphic encryption. It aims to further propose an efficient sorting method under homomorphic encryption by using counting and SIMD batch processing to solve the above-mentioned problems in the prior art.

[0025] In one specific embodiment, a raw vector of length n is first obtained, which is in the SIMD representation form under fully homomorphic encryption. In homomorphic encryption, SIMD (Single Instruction Multiple Data) technology encodes the plaintext vector into multiple independent "slots" of a single ciphertext, so that a homomorphic operation performed on the ciphertext can be performed natively in parallel on different elements in all slots, thereby significantly improving the computational throughput in a batch processing manner.

[0026] Furthermore, such as Figure 1 As shown, the vector sorting method based on fully homomorphic encryption includes the following steps: Step 1: Repeat the original vector according to the first repeating rule to obtain the first repeating extended array S1; repeat the original vector according to the second repeating rule to obtain the second repeating extended array S2. Step 2: Based on the difference between the second repeated extended array S2 and the first repeated extended array S1, determine the comparison results of the relationship between the corresponding vectors in each array; Step 3: Sum the comparison results of the relationships in groups to obtain the count array C; Step 4: Repeat the expansion of the counting array C according to the first repeating rule to obtain the third repeating expansion array S3; at the same time, construct the sorted index array S4 for reference. Step 5: Generate a flag vector F based on the difference between the reference sorted index array S4 and the third repeated extended array S3; Step 6: Based on the flag vector F, extract the elements from the original vector in a grouped manner, and put the extracted elements into a sorted array in order.

[0027] In some optional implementations, the sorting process is as follows: Figure 2 As shown; Step 1: Repeatedly expand the original vector to obtain the first repeated expansion array S1 and the second repeated expansion array S2. The two arrays are represented by different SIMD vectors. In this embodiment, the repetition rules are as follows: repeat the original vector as a whole in the original order n times; and repeat each element in the original vector consecutively n times.

[0028] For example, suppose the original vector is , That is, n=3, then The array S1 obtained after repetition is , The array S2 obtained after repetition is , Step 2: Obtain array D1 based on the difference between the second repeated extended array S2 and the first repeated extended array S1. And determine the relationship comparison result B based on each vector in array D1; In this embodiment, the vector in the difference D1 is substituted into the sign function for iteration, and the iteration result is mapped to the interval [0,1] to obtain array B; wherein, the component greater than 0 is mapped to 1, the component equal to 0 is mapped to 0.5, and the component less than 0 is mapped to 0.

[0029] For example, the sign function is approximated by polynomial iteration, such that for the input value, the output value approximates -1, 0, or 1; the sign function is essentially a polynomial approximation of the sign function in the real number field in the range [0,1]. Then apply the first mapping function to the output value of the symbolic function. This maps -1 to 0, 0 to 0.5, and 1 to 1.

[0030] Step 3: Process array B to obtain the counting array C; The comparison results are divided into groups of n components (which can be extracted based on a mask), and then a tree-like summation is performed on each group. The sums of each group are then placed into the counting array C in sequence.

[0031] In this embodiment, tree summation can obtain the sum of all bits of the original vector in the first bit of the SIMD vector in a time complexity of O(logn). Taking the summation of 8 numbers as an example, the process is as follows: a1, a1+a2, a1+a2+a3+a4, a1+a2+a3+a4+a5+a6+a7+a8.

[0032] Since comparing a number to itself yields a result of 0.5, a self-comparison bias of 0.5 is uniformly subtracted from each component of the counting vector to obtain the final counting vector C; that is... , , .

[0033] After subtracting the 0.5 obtained from comparing each number with itself, the sum of each group is its corresponding position number.

[0034] Step 4: Repeat the first repeating rule on the counting array C, that is, repeat the whole array n times, and represent it with a SIMD vector to obtain the third repeating extended array S3; at the same time, construct the reference sorted index array S4. In this embodiment, the sorted index array S4 is composed of n-1, n-2, ..., nn arranged sequentially, where each element is repeated n times, and n is a positive integer. The value of this array is actually a traversal of the index (equivalent to the vector index in the plaintext vector).

[0035] Step 5: Based on the difference between the reference sorted index array S4 and the third repeated extended array S3, array D2 is obtained. The sign function is iterated on array D2 to generate the flag vector F; the 0 values ​​have been changed to 1 and the non-zero values ​​have been changed to 0.

[0036] In this embodiment, the difference between the reference sorted index array S4 and the third repeated extended array S3 is substituted into the sign function sign for iteration, and the iteration result is mapped to the [0,1] interval to obtain the intermediate result; the specific process is referred to Step 2; A second mapping function is applied to the intermediate result, such that when the intermediate result is 0.5, the output is 1, and when the intermediate result is 0 or 1, the output is 0.

[0037] Preferably, the second mapping function is:

[0038] Step 6: Based on the flag vector F, extract the elements from the original vector in a grouping manner, and place the extracted elements into a sorted array in order. In this embodiment, the n components in the flag vector F are divided into a group, and then the following operations are performed group by group: Construct a first mask with the first n bits set to 1 and the rest to 0, and extract the n components of the current group; multiply the extracted vector by the original vector according to the components, and then perform tree summation so that the first bit of the resulting vector is the sorting element corresponding to the current group; Construct a second mask that retains only the first bit, remove the remaining redundant bits, and then add the retained elements to the first slot of the sorted array E. Each time a new number is selected, the original E is right-rotated by one bit, and then summed with the SIMD vector that has been cleaned of redundant terms using a mask. The newly selected number can then be added to E. After repeating this process n times, an array E in ascending order can be obtained, thus realizing the sorting method under homomorphic encryption.

[0039] This application achieves efficient sorting based on SIMD by rearranging the original vector and the counting vector under fully homomorphic encryption, thereby reducing the number of iterations of the sign function to a constant level.

[0040] In a specific application example, the original vector If n is still 3, then the constructed arrays S1 and S2 are respectively: , , Subsequent steps are as follows Figure 3 As shown, the final sorting result is as follows: .

[0041] Supported by fully homomorphic encryption technology, the ciphertext sorting method of this application can achieve secure sorting of encrypted data throughout the entire process. It can complete operations such as size comparison, Top-K filtering, and range sorting without decryption. Moreover, its security can be guaranteed by mathematical proof. It also has the potential advantage of resisting quantum attacks, which meets the dual needs of current data security and future quantum threat response.

[0042] In some specific embodiments, this application can be applied to the following fields: In the financial sector, it is mainly used for cross-institutional risk control ranking and sensitive transaction statistics. Multiple banks or financial institutions can encrypt sensitive data such as customer credit indicators and transaction records, and then use fully homomorphic encrypted ciphertext ranking to complete the ranking of high-risk users and the screening of transaction anomalies. Collaborative risk control can be achieved without sharing plaintext data, which not only avoids the risk of customer privacy leakage, but also improves risk control efficiency and meets financial data compliance requirements.

[0043] In the healthcare field, fully homomorphic encrypted ciphertext sorting provides secure support for collaborative analysis of multi-center medical data. Multiple hospitals can encrypt patient medical record indicators and treatment data to perform operations such as ranking extreme values ​​of diseases, ranking treatment efficacy data, and stratifying patient risk, without exposing patient privacy or medical record details. This achieves collaborative utilization of medical data while complying with relevant regulations on medical privacy protection, and also provides data support for research on difficult diseases and optimization of treatment plans. In the context of federated learning, fully homomorphic encrypted ciphertext sorting can be applied to the sorting and filtering of encrypted model updates. By sorting the encrypted model update data on the client side, trusted and valid data can be selected for model aggregation, effectively resisting poisoning attacks and ensuring the security and accuracy of federated learning models.

[0044] In the fields of government affairs and public services, fully homomorphic encryption can be applied to the statistical sorting of sensitive data across regions, such as population information, livelihood data, and government performance data. This enables collaborative statistics and ranking of data from multiple regions, ensuring the privacy and security of government data while providing accurate data support for government decision-making. In scenarios such as anonymous electronic voting and sealed auctions, fully homomorphic encryption can be used to sort the encrypted ballots and bids. The entire process can be completed without decryption, ensuring the fairness and anonymity of voting and auctions and eliminating the risk of collusion and data leakage.

[0045] In cloud computing and outsourced computing scenarios, fully homomorphic encrypted ciphertext sorting solves the core pain point of sorting sensitive data in the cloud. Data holders encrypt sensitive data and upload it to the cloud or outsourced computing platforms. The platforms can complete sorting, statistics, and other operations without decryption, only returning the encrypted results. Data holders can then decrypt the data locally to obtain the sorting results. This achieves efficient utilization of computing power while ensuring that sensitive data is not leaked throughout the process, meeting the privacy requirements of current large-scale cloud computing applications. Furthermore, in IoT and edge computing scenarios, fully homomorphic encrypted ciphertext sorting can be applied to the encrypted sorting of sensitive terminal data, such as vehicle location data and industrial equipment operating parameters. The cloud performs anomaly detection and trend analysis by sorting the encrypted data, and the terminal keys are not uploaded, further ensuring the privacy and security of IoT terminal data.

[0046] Based on the same inventive concept, embodiments of the present invention also provide a vector sorting device based on fully homomorphic encryption, the device comprising: The acquisition module is used to acquire an original vector of length n, wherein the original vector is in the SIMD representation form under fully homomorphic encryption; An extension module is used to repeatedly extend the original vector according to a first repeating rule to obtain a first repeating extended array S1; and to repeatedly extend the original vector according to a second repeating rule to obtain a second repeating extended array S2. The counting vector determination module is used to determine the relationship comparison results of corresponding vectors in each array based on the difference between the second repeated extended array S2 and the first repeated extended array S1; and to sum the relationship comparison results in groups to obtain the counting array C; The flag vector generation module is used to repeatedly expand the counting array C according to the first repeating rule to obtain a third repeating expanded array S3; at the same time, it obtains or constructs a reference sorting index array S4; and generates a flag vector F based on the difference between the reference sorting index array S4 and the third repeating expanded array S3. The extraction and placement module is used to extract elements from the original vector in a grouped manner based on the flag vector F, and to place the extracted elements into a sorted array in order.

[0047] Since the vector sorting device based on fully homomorphic encryption provided in this embodiment produces the same technical effect as the aforementioned method embodiment, for the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the aforementioned method embodiment, and will not be repeated here.

[0048] Furthermore, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the vector sorting method based on fully homomorphic encryption as described in any of the preceding claims.

[0049] Any content or technical means not mentioned in the embodiments of this invention can be obtained by referring to the prior art. This disclosure does not limit the scope of the invention and therefore will not be elaborated further.

[0050] The embodiments of the present invention have been described in detail above, and the principles and implementation methods of the present invention have been explained. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of the present invention. Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, computer software program products, or electronic devices, etc. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of one or more storage media (including but not limited to disk storage, CDs) containing computer-usable program code. The form of a computer program product implemented on ROM, optical memory, etc.

[0051] It should be noted that the word "comprising" does not exclude the presence of components or steps not listed in the claims. The words "a" or "an" preceding a component do not exclude the presence of a plurality of such components. This invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer.

[0052] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0053] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A vector sorting method based on fully homomorphic encryption, characterized in that, Obtain an original vector of length n, wherein the original vector is in SIMD representation under fully homomorphic encryption; the sorting step includes: Step 1: Repeat the original vector according to the first repeating rule to obtain the first repeating extended array S1; repeat the original vector according to the second repeating rule to obtain the second repeating extended array S2. Step 2: Based on the difference between the second repeated extended array S2 and the first repeated extended array S1, determine the comparison results of the relationship between the corresponding vectors in each array; Step 3: Sum the comparison results of the relationships in groups to obtain the count array C; Step 4: Repeat the expansion of the counting array C according to the first repeating rule to obtain the third repeating expansion array S3; at the same time, construct the sorted index array S4 for reference. Step 5: Generate a flag vector F based on the difference between the reference sorted index array S4 and the third repeated extended array S3; Step 6: Based on the flag vector F, extract the elements from the original vector in a grouped manner, and put the extracted elements into a sorted array in order.

2. The vector sorting method based on fully homomorphic encryption as described in claim 1, characterized in that, In step one, the first repetition rule is: repeat the original vector as a whole n times in its original order; the second repetition rule is: repeat each element of the original vector n times consecutively.

3. The vector sorting method based on fully homomorphic encryption as described in claim 1, characterized in that, In step two, a sign function approximation iteration is performed on the difference between the second repeated extended array S2 and the first repeated extended array S1, and the iteration result is mapped to the interval [0,1] to obtain the relationship comparison result; including: The sign function is approximated by polynomial iteration, so that for the input value, the output value approximates -1, 0 or 1; Apply the first mapping function to the output value of the symbolic function. This maps -1 to 0, 0 to 0.5, and 1 to 1.

4. The vector sorting method based on fully homomorphic encryption as described in claim 1, characterized in that, In step three, the comparison results are divided into groups of n components, and a tree-like summation is performed on each group. The sums of each group are then placed into the counting array C in sequence.

5. The vector sorting method based on fully homomorphic encryption as described in claim 3, characterized in that, Step five includes: The difference between the reference sorted index array S4 and the third repeated extended array S3 is subjected to a sign function approximation iteration, and the iteration result is mapped to the interval [0,1] to obtain an intermediate result; A second mapping function is applied to the intermediate result, such that when the intermediate result is 0.5, the output is 1, and when the intermediate result is 0 or 1, the output is 0.

6. The vector sorting method based on fully homomorphic encryption as described in claim 5, characterized in that, The second mapping function is: 。 7. The vector sorting method based on fully homomorphic encryption as described in claim 1, characterized in that, Step six includes: Divide the n components in the flag vector F into a group, and perform the following operations on each group: Construct a first mask with the first n bits set to 1 and the rest to 0, and extract the n components of the current group; multiply the extracted vector by the original vector according to the components, and then perform tree summation so that the first bit of the resulting vector is the sorting element corresponding to the current group; Construct a second mask that retains only the first bit, remove the remaining redundant bits, and then add the retained elements to the first slot of the sorted array. Rotate the currently accumulated result vector one position to the right, and update the sorted array after the next group of elements has been extracted.

8. The vector sorting method based on fully homomorphic encryption as described in claim 1, characterized in that, In step four, the reference sorted index array S4 is composed of n-1, n-2, ..., nn arranged in sequence, where each element is repeated n times, and n is a positive integer.

9. A vector sorting device based on fully homomorphic encryption, characterized in that, A vector sorting method based on fully homomorphic encryption as described in any one of claims 1 to 8, comprising: The acquisition module is used to acquire an original vector of length n, wherein the original vector is in the SIMD representation form under fully homomorphic encryption; An extension module is used to repeatedly extend the original vector according to a first repeating rule to obtain a first repeating extended array S1; and to repeatedly extend the original vector according to a second repeating rule to obtain a second repeating extended array S2. The counting vector determination module is used to determine the relationship comparison results of corresponding vectors in each array based on the difference between the second repeated extended array S2 and the first repeated extended array S1; and to sum the relationship comparison results in groups to obtain the counting array C; The flag vector generation module is used to repeatedly expand the counting array C according to the first repeating rule to obtain a third repeating expanded array S3; at the same time, it obtains or constructs a reference sorting index array S4; and generates a flag vector F based on the difference between the reference sorting index array S4 and the third repeating expanded array S3. The extraction and placement module is used to extract elements from the original vector in a grouped manner based on the flag vector F, and to place the extracted elements into a sorted array in order.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the vector sorting method based on fully homomorphic encryption as described in any one of claims 1 to 8.