CN112668015B - Data processing method and device and data processing device - Google Patents

Data processing method and device and data processing device Download PDF

Info

Publication number
CN112668015B
CN112668015B CN201911275449.8A CN201911275449A CN112668015B CN 112668015 B CN112668015 B CN 112668015B CN 201911275449 A CN201911275449 A CN 201911275449A CN 112668015 B CN112668015 B CN 112668015B
Authority
CN
China
Prior art keywords
matrix
ciphertext data
sorting
columns
index
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911275449.8A
Other languages
Chinese (zh)
Other versions
CN112668015A (en
Inventor
陈琨
王国赛
范晓昱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huakong Tsingjiao Information Technology Beijing Co Ltd
Original Assignee
Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huakong Tsingjiao Information Technology Beijing Co Ltd filed Critical Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority to CN201911275449.8A priority Critical patent/CN112668015B/en
Publication of CN112668015A publication Critical patent/CN112668015A/en
Application granted granted Critical
Publication of CN112668015B publication Critical patent/CN112668015B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Complex Calculations (AREA)

Abstract

The embodiment of the invention provides a data processing method and device and a device for data processing. The method comprises the following steps: combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns; constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix; determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix; and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data. The embodiment of the invention can improve the efficiency of ciphertext data processing.

Description

Data processing method and device and data processing device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data processing method and apparatus, and an apparatus for data processing.
Background
Currently, for the sake of information security, the processed data is usually protected by encryption, for example, during the data transmission between servers, terminals and servers, during the statistical analysis of the data, and so on. After data is encrypted into ciphertext, the ciphertext is transmitted or analyzed and the like, so that important information is prevented from being leaked, and loss is brought to individuals or enterprises.
In the process of processing the ciphertext data, the ciphertext data sometimes needs to be sorted. For example, for the array a ═ a1, a2, …, an]If n ciphertext data in the array are sorted, nlogn to n ciphertext data are required to be executed2Sub groupIn the ciphertext comparison operation, each comparison operation needs a round of communication between the computing nodes. When the value of n is large, the communication overhead is large, and the efficiency of ciphertext data processing is affected.
Disclosure of Invention
The embodiment of the invention provides a data processing method and device and a device for data processing, which can improve the efficiency of ciphertext data processing.
In order to solve the above problem, an embodiment of the present invention discloses a data processing method, where the method includes:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
In another aspect, an embodiment of the present invention discloses a data processing apparatus, where the apparatus includes:
the first construction module is used for combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
a second constructing module, configured to construct, according to the first matrix, a second matrix and a third matrix, where the second matrix is used to indicate whether an element in the first matrix is smaller than or larger than an element in a transpose of the first matrix, and the third matrix is used to indicate whether an element in the first matrix is equal to an element in the transpose;
an index determining module, configured to determine, according to the second matrix and the third matrix, a sorting index corresponding to the n ciphertext data;
and the data sorting module is used for sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data.
In yet another aspect, an embodiment of the present invention discloses an apparatus for data processing, including a memory, and one or more programs, where the one or more programs are stored in the memory, and configured to be executed by the one or more processors includes instructions for:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
In yet another aspect, an embodiment of the invention discloses a machine-readable medium having stored thereon instructions, which, when executed by one or more processors, cause an apparatus to perform a data processing method as described in one or more of the preceding.
The embodiment of the invention has the following advantages:
firstly, sequences corresponding to n ciphertext data to be sorted are combined according to columns to construct a first matrix with n rows and n columns; then, according to the first matrix, a second matrix and a third matrix can be constructed, wherein the second matrix is used for indicating whether the elements in the first matrix are smaller than or larger than the elements in the transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix; determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix; and finally, sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
The embodiment of the invention combines n ciphertext data to be sorted into a matrix, converts the comparison operation required by the original sorting into the calculation of the matrix, and compared with the exponential calculation amount required by the comparison operation, the calculation amount of the matrix is only constant, so that the communication overhead among the calculation nodes can be greatly reduced, the sorting efficiency of the ciphertext data can be improved, and the efficiency of subsequent data processing or transmission can be further improved. In addition, in the process of sequencing the n ciphertext data, the ciphertext data does not need to be decrypted, and the calculation process is carried out on the basis of the ciphertext, so that the data security can be ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flow chart of the steps of one data processing method embodiment of the present invention;
FIG. 2 is a flow chart of steps in another data processing method embodiment of the present invention;
FIG. 3 is a block diagram of an embodiment of a data processing apparatus according to the present invention;
FIG. 4 is a block diagram of an apparatus 800 for data processing of the present invention; and
fig. 5 is a schematic diagram of a server in some embodiments of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a data processing method according to the present invention is shown, which may specifically include the following steps:
101, combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
102, constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether elements in the first matrix are equal to elements in the transposed matrix;
103, determining a sorting index corresponding to the n ciphertext data according to the second matrix and the third matrix;
and step 104, sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
In the embodiment of the present invention, the device for executing the data processing method may provide a multi-party secure computing service, the multi-party secure computing is ciphertext-based computing, the data participating in the computing includes ciphertext data, and the intermediate result and the final computing result generated in the computing process may also be ciphertext data. In the calculation process based on the ciphertext, the data plaintext is not exposed, and the safety of the data can be ensured.
Optionally, the ciphertext-based computation may be performed by at least two of the four compute nodes that communicate with other compute nodes participating in the ciphertext computation based on a multi-party secure computing protocol to complete the computation task.
In the embodiment of the invention, one multi-party safe computing task can be completed by distributing four computing nodes in a cooperative manner. These four compute nodes are referred to as S1, S2, Sa, Sb, respectively. For part of multi-party security computing tasks, only two computing nodes are needed to complete cooperatively, and only two computing nodes S1 and S2 are needed to participate, for example, only two computing nodes are needed for addition computing to perform computing. The embodiment of the invention does not limit the number of the computing nodes.
The calculation is used for data processing of the ciphertext data. In some examples, the ciphertext data is a private data, and the technician stores a program containing a business logic for processing the private data in the task management platform in advance, wherein the business logic describes a processing process of the private data through a computer program language, and the processing process can contain one or more computing tasks. The business logic refers to a process that a technician performs data processing on private data by using one or more computing tasks and obtains the private data according to a natural law. For example, one business logic comprises: the plurality of businesses are ranked according to credit rating scores without knowing the cleartext of the credit rating values of the businesses. Another business logic includes: and (3) confirming the evaluation flow of the repayment capacity of the user A by using the bank deposit amount, the bank loan amount, the bank repayment history and the like of the user A in the banks B1 and B2. As another example, a business logic comprises: and providing a distance and route information distance prompting flow between the P1 and the P2 to the terminal equipment held by the user P1 by utilizing the current position information of the users P1 and P2. The scheme of the invention is suitable for any scene of calculation based on the ciphertext. The method comprises the scenes of fusion calculation and the like of the private data.
In an optional embodiment of the present invention, the ciphertext data is obtained by performing a decentralized processing on plaintext data, where the decentralized processing includes: and carrying out fragmentation processing on the plaintext data to obtain at least two ciphertext fragments, and dispersedly storing the at least two ciphertext fragments in at least two storage nodes.
In order to ensure the security of information, the data participating in the multi-party security computing task may be ciphertext data, and the ciphertext data is obtained by encrypting plaintext data. For example, as for the plaintext data x, ciphertext data x ' is obtained through encryption processing, if the ciphertext data x ' is leaked, x ' may be decrypted to recover the plaintext data x, and the plaintext data x is leaked.
In order to avoid the above situation, the embodiments of the present invention may perform a distributed process on plaintext data. The distributed processing is used for encrypting and storing data in a distributed mode, so that the risk that all ciphertext data are stored in the same computing node to cause data leakage is reduced. Specifically, the plaintext data may be sliced to obtain at least two ciphertext slices.
The embodiment of the invention can utilize the encryption algorithm to carry out the fragmentation processing on the plaintext data to obtain at least two ciphertext fragments. For example, for plaintext data x, an encryption algorithm may be used to perform fragmentation processing on plaintext data x to obtain two ciphertext fragments x1 and x2, and only by obtaining x1 and x2 at the same time, plaintext data x may be obtained through decryption.
In the ciphertext-based calculation process, n (n is a positive integer) pieces of ciphertext data may be sorted, for example, n pieces of ciphertext data, a1, a2, … and an, are sorted, and nlogn to n pieces of ciphertext data need to be executed2Next time, the comparison operation based on the ciphertext needs four computing nodes to be completed through at least one round of communication each time, which causes a large communication overhead, and further affects the sorting efficiency of the ciphertext data, and further affects the efficiency of subsequent data processing or transmission.
The core idea of the invention is to combine n cipher text data to be sorted into a matrix, convert the comparison operation required by the original sorting into the calculation of the matrix, and the calculation amount of the matrix is only constant level compared with the exponential calculation amount required by the comparison operation, so that the communication overhead between the calculation nodes can be greatly reduced, the sorting efficiency of the cipher text data can be further improved, and the efficiency of the subsequent data processing or transmission can be further improved.
Specifically, in the embodiment of the present invention, sequences corresponding to n ciphertext data to be sorted are first combined according to columns to construct a first matrix with n rows and n columns.
It can be understood that the embodiment of the present invention does not limit the specific form of the n ciphertext data to be sorted. For example, the n ciphertext data to be sorted may be an array, such as sorting the n ciphertext data in an array a ═ a1, a2, …, an ]; or the n ciphertext data to be sorted can also be a linked list and the like. In addition, the data type of the ciphertext data is not limited in the embodiment of the present invention, for example, the n pieces of ciphertext data to be sorted may be an integer type or a fixed point type.
In an application example of the present invention, it is assumed that the elements in the array a ═ 3,5,3,3,2,1] need to be sorted from small to large. Firstly, sequences corresponding to elements in the array are combined according to columns, and a first matrix X with 6 rows and 6 columns is constructed.
X=[[3,3,3,3,3,3]
[5,5,5,5,5,5]
[3,3,3,3,3,3]
[3,3,3,3,3,3]
[2,2,2,2,2,2]
[1,1,1,1,1,1]]
Then, according to the first matrix X, a second matrix L and a third matrix E are constructed, the second matrix being used for indicating whether elements in the first matrix are smaller/larger than elements in a transposed matrix of the first matrix, and the third matrix being used for indicating whether elements in the first matrix are equal to elements in the transposed matrix.
It should be noted that, in a specific application, if n pieces of ciphertext data to be sorted need to be sorted from small to large, a second matrix smaller than the relationship is constructed, that is, the second matrix is used to indicate whether an element in the first matrix is smaller than an element in a transpose matrix of the first matrix. If the n ciphertext data to be sorted need to be sorted from large to small, a second matrix larger than the relationship is constructed, that is, the second matrix is used for indicating whether the elements in the first matrix are larger than the elements in the transpose matrix of the first matrix. For convenience of description, the embodiments of the present invention are described by taking the sorting from small to large as an example, and the sorting from large to small is similar, and the processes may be referred to each other.
Specifically, a transposed matrix X of the first matrix X is setTA second matrix L and a third matrix E can be obtained by comparison with the first matrix X, where L ═ XT< X, or L ═ XT>X,E=XT==X。
With L ═ XT< X, for example, in the process of constructing the second matrix L, X is judgedTIf the element in (b) is smaller than the corresponding element in (X), if so, the element in the corresponding position of the second matrix L may be represented as a ciphertext of 1, otherwise, the element may be represented as a ciphertext of 0. Similarly, in the process of constructing the third matrix E, X is judgedTIs equal to the corresponding element in X, if so, the element in the corresponding position of the third matrix E may be represented as the ciphertext of 1, otherwise, it may be represented as the ciphertext of 0.
In the above example, the following second matrix L and third matrix E may be constructed.
Figure GDA0003319804950000071
Then, according to the second matrix and the third matrix, a sorting index corresponding to the n ciphertext data may be determined, and then the n ciphertext data may be sorted according to the sorting index, so as to obtain n sorted ciphertext data.
In an optional embodiment of the present invention, the determining, according to the second matrix and the third matrix, the sorting indexes corresponding to the n ciphertext data may specifically include:
step S11, determining the sorting index corresponding to the n ciphertext data according to the second matrix;
and step S12, correcting the sorting index according to the third matrix to obtain a corrected sorting index.
And if the sizes of the n cipher text data to be sorted are different, determining the sorting index corresponding to the n cipher text data according to the second matrix.
Optionally, the determining, according to the second matrix, the sorting index corresponding to the n ciphertext data may specifically include: and respectively performing addition calculation on the second matrix according to columns to obtain a first vector, wherein each element in the first vector corresponds to the sorting index of each ciphertext data in the n ciphertext data.
Specifically, the second matrix L is respectively subjected to addition calculation by columns to obtain a first vector, and each element in the first vector corresponds to the sorting index of each ciphertext data in the n ciphertext data. And the sorting index corresponding to each ciphertext data is smaller than the number of the ciphertext data. For example, if the array a to be sorted is [ a1, a2, …, an ], if the sorting index corresponding to a1 is determined to be 5 according to the first vector, it is indicated that 5 data in the array a are smaller than a1, that is, a1 should be sorted at the 6 th bit.
The sorting indexes corresponding to the n pieces of ciphertext data may be determined according to the second matrix L, but if there are equal pieces of ciphertext data in the n pieces of ciphertext data, the sorting indexes corresponding to the equal pieces of ciphertext data are also equal in the sorting indexes calculated according to the second matrix L. Therefore, in the embodiment of the present invention, the sorting index is corrected according to the third matrix, so as to obtain a corrected sorting index.
After the modified sorting index is obtained, the n ciphertext data may be sorted according to the modified sorting index to obtain n ciphertext data after sorting.
In an optional embodiment of the present invention, the modifying the sorting index according to the third matrix to obtain a modified sorting index specifically may include:
step S21, constructing a bias matrix according to the third matrix;
step S22, respectively performing addition calculation on the offset matrix according to columns to obtain a second vector;
step S23, performing addition calculation on the first vector and the second vector to obtain a position vector, where each element in the position vector corresponds to the modified sorting index of each ciphertext data in the n pieces of ciphertext data.
The third matrix can be used for biasing the sorting index corresponding to the equal ciphertext data, so that a correct sorting index is obtained. Because the calculation in the embodiment of the present invention is based on ciphertext, in order to prevent data plaintext from being leaked, in the embodiment of the present invention, a bias matrix is first constructed according to the third matrix, and the sorting index is corrected by the bias matrix.
In an optional embodiment of the present invention, the constructing a bias matrix according to the third matrix specifically may include:
step S31, updating the column elements in the third matrix that represent the equality between the first matrix and the transposed matrix to obtain a fourth matrix;
step S32, subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and step S33, multiplying the fifth matrix and the fourth matrix by elements to obtain an offset matrix.
In the process of constructing the bias matrix according to the third matrix, the third matrix needs to be updated first to obtain a fourth matrix. The purpose of updating the third matrix is to remove the first matrix X and its transposed matrix XTThe resulting fully equal columns after performing the equality relationship comparison. For example, in the above example, the first, third and fourth columns in the third matrix E are all equal, and therefore the third matrix E needs to be updated to remove all equal columns.
In an optional embodiment of the present invention, the updating the column elements in the third matrix that represent the equality between the first matrix and the transposed matrix to obtain a fourth matrix specifically may include:
sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix; wherein the kth column is updated by:
step S41, products of the first k-1 columns and the first k-1 elements of the kth column are summed respectively to obtain column vectors;
and step S42, updating the k column according to the result obtained by subtracting the column vector from the k column.
In the above example, the third matrix E may be updated according to the above steps. Specifically, the 2 nd column to the nth column of the third matrix E are sequentially updated in order from left to right. That is, the update is started with the second column, and the product of the first column and the first element of the second column is subtracted from the second column. Since the first element of the second column is 0, which means that the first column is not the same as the second column, the subtraction of the first column by the second column by one column is zero, and does not have any effect on the second column. When the third column is updated, the third column subtracts the sum of the products of the first column, the second column (all its front columns) and the first two elements of the third column. Since the third column has a first element of 1 indicating that the first column is identical to the third column and a second element of 0 indicating that the second column is different from the third column, the effect of the subtraction is realized in that the third column subtracts each original value of the first column in turn, but does not subtract the second column which is not equal to the original value.
It should be noted that, during the process of updating the third matrix E, for example, after the second column is updated, when the third column is updated, the updated second column is used to update the third column. By analogy, after the nth column is updated, a fourth matrix can be obtained, and the fourth matrix is removed due to the fact that the first matrix X and the transposed matrix X thereof are updatedTThe resulting fully equal columns after performing the equality relationship comparison. After updating the third matrix in the above example, the following fourth matrix E can be obtained1
E1=[[1,0,0,0,0,0]
[0,1,0,0,0,0]
[1,0,0,0,0,0]
[1,0,0,0,0,0]
[0,0,0,0,1,0]
[0,0,0,0,0,1]]
It can be seen that the fourth matrix E1The third and fourth columns of the same as the first column are all replaced with 0 and the other mutually unequal columns remain unchanged. In addition, a fourth matrix E1There are three non-zero elements in the first column of (a), indicating that there are three ciphertext data to be equal. Taking the first column as an example, a sequence sequentially increasing from 0 needs to be generated at the position where the element is 1, so that the sequential increasing of the sorting index can be realized after the sorting index calculated by the second matrix is biased. Thus, for the fourth matrix E1Subtracting the fourth matrix E from the result of the row-wise accumulation1To obtain the following fifth matrix E2
E2=[[0,0,0,0,0,0]
[1,0,0,0,0,0]
[1,1,0,0,0,0]
[2,1,0,0,0,0]
[3,1,0,0,0,0]
[3,1,0,0,1,0]]
And multiplying the fifth matrix and the fourth matrix by elements to obtain the following bias matrix F.
F=[[0,0,0,0,0,0]
[0,0,0,0,0,0]
[1,0,0,0,0,0]
[2,0,0,0,0,0]
[0,0,0,0,0,0]
[0,0,0,0,0,0]]
After the offset matrix F is obtained through calculation, respectively performing addition calculation on the offset matrix according to columns to obtain a second vector; and performing addition calculation on the first vector and the second vector to obtain a position vector. In the above example, a position vector p of [2,5,3,4,1,0] may be calculated, where each element in the position vector p corresponds to the modified sorting index of each ciphertext data of the n ciphertext data.
After the position vector is obtained, the n ciphertext data may be sorted according to the corrected sorting index in the position vector, so as to obtain n ciphertext data after sorting.
In an optional embodiment of the present invention, the sorting the n ciphertext data according to the modified sorting index to obtain n sorted ciphertext data specifically may include: and sequencing the n ciphertext data according to the position of the sequencing index corresponding to each element in the position vector to obtain n sequenced ciphertext data.
Taking the example of sorting the logarithm array a ═ a1, a2, …, an ], each element in the array is moved to the corresponding position according to the sorting index in the position vector p. In the above example, it can be known from the position vector p that, for the array a ═ 3,5,3,3,2,1, the sorting index of the first element is 2, which means that the index of the first element "3" in the array a in the sorted array should be 2, that is, a' [2] ═ 3. By analogy, a '5 is 5, a' 3 is 3, a '4 is 3, a' 1 is 2, and a '0 is 1, that is, the ordered array a' is [1,2,3,3,3,5 ].
Since the position vector p is also a ciphertext, in order not to leak a data plaintext, in the embodiment of the present invention, the position vector p is used to construct the transformation matrix T, and the transformation matrix T is used to sort the array a to obtain the sorted array a'.
In an optional embodiment of the present invention, the sorting the n ciphertext data according to the position of the sorting index corresponding to each element in the position vector to obtain n sorted ciphertext data specifically may include:
step S51, combining the n position vectors according to columns to construct a position matrix with n rows and n columns;
s52, combining n sequences with the numerical value of 0-n-1 according to columns to construct a comparison matrix with n rows and n columns;
step S53, obtaining a conversion matrix according to the comparison result between the transposed matrix of the position matrix and the comparison matrix;
step S54, multiplying the transpose matrix of the first matrix and the conversion matrix according to elements to obtain a sorting matrix;
and step S55, respectively executing addition calculation to the sorting matrix according to columns to obtain sorted ciphertext data.
Specifically, in the above example, after the position vector P is calculated to be [2,5,3,4,1,0], n (n is 6) position vectors P are combined in columns to construct the following position matrix P having 6 rows and 6 columns.
P=[[2,2,2,2,2,2]
[5,5,5,5,5,5]
[3,3,3,3,3,3]
[4,4,4,4,4,4]
[1,1,1,1,1,1]
[0,0,0,0,0,0]]
N (N ═ 6) sequences with values from 0 to N-1 were combined in columns, and the following comparison matrix N of N rows and N columns was constructed.
N=[[0,0,0,0,0,0]
[1,1,1,1,1,1]
[2,2,2,2,2,2]
[3,3,3,3,3,3]
[4,4,4,4,4,4]
[5,5,5,5,5,5]]
A transposed matrix P from the position matrix PTComparing the obtained result with the comparison matrix N to obtain a conversion matrix T, wherein T is PTN. Specifically, the transposed matrix P is determinedTIf the element in (b) is equal to the corresponding element in the comparison matrix N, the element at the corresponding position of the transformation matrix T may be represented as the ciphertext of 1, otherwise, the element may be represented as the ciphertext of 0. The following conversion matrix T can thus be obtained.
T=[[0,0,0,0,0,1]
[0,0,0,0,1,0]
[1,0,0,0,0,0]
[0,0,1,0,0,0]
[0,0,0,1,0,0]
[0,1,0,0,0,1]]
Each column of the transformation matrix T may be used to indicate the position of each element in the array a after sorting, for example, the first column of the transformation matrix T is [0,0,1,0,0,0], indicating that the first element in the array a should be placed in the third position after sorting.
The conversion matrix T is then used to order the elements in the array a from small to largeThe orders are sorted. Specifically, a transposed matrix X of the first matrix X is formedTAnd multiplying the conversion matrix T by elements to obtain a sorting matrix Y as follows.
Y=[[0,0,0,0,0,1]
[0,0,0,0,2,0]
[3,0,0,0,0,0]
[0,0,3,0,0,0]
[0,0,0,3,0,0]
[0,5,0,0,0,0]]
And respectively executing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data. Specifically, adding the sorting matrix Y in columns may obtain an array a ═ 1,2,3,3,3,5], that is, a result of sorting the array a from small to large.
It can be understood that, if n ciphertext data to be sorted are sorted from large to small, the n ciphertext data may be sorted from small to large according to the processing method of the embodiment of the present invention, and then the sorting result is reversed to obtain the sorting result from large to small.
To sum up, in the embodiment of the present invention, sequences corresponding to n ciphertext data to be sorted are first combined according to columns to construct a first matrix with n rows and n columns; then, according to the first matrix, a second matrix and a third matrix can be constructed, wherein the second matrix is used for indicating whether the elements in the first matrix are smaller than or larger than the elements in the transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix; determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix; and finally, sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
The embodiment of the invention combines n ciphertext data to be sorted into a matrix, converts the comparison operation required by the original sorting into the calculation of the matrix, and compared with the exponential calculation amount required by the comparison operation, the calculation amount of the matrix is only constant, so that the communication overhead among the calculation nodes can be greatly reduced, the sorting efficiency of the ciphertext data can be improved, and the efficiency of subsequent data processing or transmission can be further improved. In addition, in the process of sequencing the n ciphertext data, the ciphertext data does not need to be decrypted, and the calculation process is carried out on the basis of the ciphertext, so that the data security can be ensured.
Referring to fig. 2, a flowchart illustrating steps of an embodiment of a data processing method according to the present invention is shown, which may specifically include the following steps:
step 201, combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns.
Assume that the array to be sorted is a ═ a1, a2, …, an ], where n pieces of ciphertext data are included. Assuming that array a is sorted in order from small to large, the first matrix X is constructed first as follows.
X=[[a1,a1,a1,a1,a1,a1]
[a2,a2,a2,a2,a2,a2]
[a3,a3,a3,a3,a3,a3]
……
[an,an,an,an,an,an]]
Taking the array a ═ 3,5,3,3,2,1 as an example, the first matrix X is specifically as follows.
X=[[3,3,3,3,3,3]
[5,5,5,5,5,5]
[3,3,3,3,3,3]
[3,3,3,3,3,3]
[2,2,2,2,2,2]
[1,1,1,1,1,1]]
Step 202, constructing a second matrix and a third matrix according to the first matrix.
Wherein the second matrix is used for representing whether elements in the first matrix are smaller than or larger than elements in a transpose of the first matrix, and the third matrix is used for representing whether elements in the first matrix are equal to elements in the transpose.
In the present example, the second matrix L and the third matrix E are specifically as follows.
Figure GDA0003319804950000131
And step 203, sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix. Wherein the kth column is updated by:
step 2031, summing the products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
step 2032, updating the kth column according to a result obtained by subtracting the column vector from the kth column.
And step 204, subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix.
And step 205, multiplying the fifth matrix and the fourth matrix by elements to obtain a bias matrix.
After the third matrix E is updated, a fourth matrix E is obtained1. In this example, the fourth matrix E1A fifth matrix E2And the bias matrix F are specifically as follows.
Figure GDA0003319804950000132
And step 206, respectively performing addition calculation on the second matrix according to columns to obtain a first vector, and respectively performing addition calculation on the offset matrix according to columns to obtain a second vector.
And step 207, performing addition calculation on the first vector and the second vector to obtain a position vector.
In this example, an addition calculation is performed on the first vector and the second vector, resulting in a position vector p of [2,5,3,4,1,0 ].
And 208, combining the n position vectors according to columns to construct a position matrix with n rows and n columns.
And 209, combining n sequences with the numerical value of 0 to n-1 according to columns to construct a comparison matrix with n rows and n columns.
Assuming that a position vector P is obtained, n of the position vectors P are combined by columns, and a position matrix P of n rows and n columns is constructed [ P, P, P, …, P ]. In the present example, the position matrix P and the comparison matrix N are specifically as follows.
Figure GDA0003319804950000141
In this example, since N is 6, the comparison matrix N is specifically as follows.
N=[[0,0,0,0,0,0]
[1,1,1,1,1,1]
[2,2,2,2,2,2]
[3,3,3,3,3,3]
[4,4,4,4,4,4]
[5,5,5,5,5,5]]
Step 210, obtaining a transformation matrix according to a comparison result between the transpose matrix of the position matrix and the comparison matrix.
Step 211, multiplying the transpose matrix of the first matrix by the conversion matrix according to elements to obtain a sorting matrix.
Wherein, T ═ PTN. In the present example, the conversion matrix T and the sorting matrix Y are specifically as follows.
Figure GDA0003319804950000142
And step 212, respectively performing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data.
In this example, adding the sorting matrix Y in columns may result in an array a ═ 1,2,3,3,3,5], i.e., a result of sorting the array a from small to large.
The embodiment of the invention combines n ciphertext data to be sorted into a matrix, converts the comparison operation required by the original sorting into the calculation of the matrix, and compared with the exponential calculation amount required by the comparison operation, the calculation amount of the matrix is only constant, so that the communication overhead among the calculation nodes can be greatly reduced, the sorting efficiency of the ciphertext data can be improved, and the efficiency of subsequent data processing or transmission can be further improved. In addition, in the process of sequencing the n ciphertext data, the ciphertext data does not need to be decrypted, and the calculation process is carried out on the basis of the ciphertext, so that the data security can be ensured.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
The sorting method provided by the embodiment of the invention is a stable sorting method, namely equal elements are sorted before and after, and the relative front and back orders of the elements in the sequence are unchanged.
Device embodiment
Referring to fig. 3, a block diagram of a data processing apparatus according to an embodiment of the present invention is shown, where the apparatus may specifically include:
the first constructing module 301 is configured to combine sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
a second constructing module 302, configured to construct, according to the first matrix, a second matrix and a third matrix, where the second matrix is used to indicate whether elements in the first matrix are smaller than or larger than elements in a transpose of the first matrix, and the third matrix is used to indicate whether elements in the first matrix are equal to elements in the transpose;
an index determining module 303, configured to determine, according to the second matrix and the third matrix, a sorting index corresponding to the n ciphertext data;
and the data sorting module 304 is configured to sort the n ciphertext data according to the sorting index to obtain n sorted ciphertext data.
Optionally, the index determining module 303 may specifically include:
the index determining submodule is used for determining a sorting index corresponding to the n ciphertext data according to the second matrix;
the index correction submodule is used for correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the data sorting module is specifically configured to sort the n ciphertext data according to the corrected sorting index, so as to obtain n sorted ciphertext data.
Optionally, the index determining sub-module is specifically configured to perform addition calculation on the second matrix in rows to obtain a first vector, where each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the index modification sub-module may specifically include:
the offset construction unit is used for constructing an offset matrix according to the third matrix;
the offset calculation unit is used for respectively performing addition calculation on the offset matrix according to columns to obtain second vectors;
and the index correction unit is used for performing addition calculation on the first vector and the second vector to obtain a position vector, and each element in the position vector corresponds to the corrected sorting index of each ciphertext data in the n ciphertext data.
Optionally, the data sorting module 304 is specifically configured to sort the n ciphertext data according to the position of the sorting index corresponding to each element in the position vector, so as to obtain n sorted ciphertext data.
Optionally, the data sorting module 304 may specifically include:
the position construction submodule is used for combining the n position vectors according to columns to construct a position matrix of n rows and n columns;
the comparison construction submodule is used for combining n sequences with the numerical value of 0 to n-1 according to columns to construct a comparison matrix with n rows and n columns;
the conversion construction submodule is used for obtaining a conversion matrix according to a comparison result between the transposition matrix of the position matrix and the comparison matrix;
the sorting calculation submodule is used for multiplying the transposed matrix of the first matrix and the conversion matrix according to elements to obtain a sorting matrix;
and the data sorting submodule is used for respectively performing addition calculation on the sorting matrix according to columns to obtain the sorted ciphertext data.
Optionally, the bias building unit may specifically include:
a matrix updating subunit, configured to update column elements in the third matrix, which represent that the first matrix and the transposed matrix are equal to each other, so as to obtain a fourth matrix;
the matrix accumulation submodule is used for subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and the offset calculation submodule is used for multiplying the fifth matrix and the fourth matrix according to elements to obtain an offset matrix.
Optionally, the matrix updating subunit is specifically configured to sequentially update the 2 nd column to the nth column of the third matrix according to a left-to-right sequence to obtain a fourth matrix; wherein, the matrix updating subunit includes:
the calculation module is used for summing the products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and the updating module is used for updating the kth column according to a result obtained by subtracting the column vector from the kth column.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present invention provides an apparatus for data processing, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors include instructions for: combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns; constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix; determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix; and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
Fig. 4 is a block diagram illustrating an apparatus 800 for data processing in accordance with an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 4, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 5 is a schematic diagram of a server in some embodiments of the invention. The server 1900 may vary widely by configuration or performance and may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a series of instructions operating on a server. Still further, a central processor 1922 may be provided in communication with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input-output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform the data processing method shown in fig. 1.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform a data processing method, the method comprising: combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns; constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix; determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix; and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
The embodiment of the invention discloses A1 and a data processing method, which comprises the following steps:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
A2, according to the method in A1, the determining the sorting indexes corresponding to the n pieces of ciphertext data according to the second matrix and the third matrix, includes:
determining sorting indexes corresponding to the n ciphertext data according to the second matrix;
correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data includes:
and sequencing the n ciphertext data according to the corrected sequencing index to obtain n sequenced ciphertext data.
A3, according to the method in A2, the determining the sorting index corresponding to the n pieces of ciphertext data according to the second matrix includes:
performing addition calculation on the second matrix according to columns to obtain a first vector, wherein each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the modifying the sorting index according to the third matrix to obtain a modified sorting index includes:
constructing a bias matrix according to the third matrix;
respectively performing addition calculation on the bias matrix according to columns to obtain second vectors;
and performing addition calculation on the first vector and the second vector to obtain a position vector, wherein each element in the position vector corresponds to the modified sorting index of each ciphertext data in the n ciphertext data.
A4, according to the method of A3, the sorting the n ciphertext data according to the modified sorting index to obtain n sorted ciphertext data, including:
and sequencing the n ciphertext data according to the position of the sequencing index corresponding to each element in the position vector to obtain n sequenced ciphertext data.
A5, according to the method of a4, the sorting the n ciphertext data according to the position of the sorting index corresponding to each element in the position vector to obtain n sorted ciphertext data includes:
combining the n position vectors according to columns to construct a position matrix with n rows and n columns;
combining n sequences with the numerical value of 0-n-1 according to columns to construct a comparison matrix with n rows and n columns;
obtaining a conversion matrix according to a comparison result between the transposed matrix of the position matrix and the comparison matrix;
multiplying the transposed matrix of the first matrix by the conversion matrix according to elements to obtain a sorting matrix;
and respectively executing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data.
A6, the method of A3, the constructing a bias matrix according to the third matrix, comprising:
updating column elements in the third matrix, which represent that the first matrix is equal to the transposed matrix, to obtain a fourth matrix;
subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and multiplying the fifth matrix and the fourth matrix according to elements to obtain a bias matrix.
A7, according to the method of a6, the updating column elements in the third matrix that represent equality between the first matrix and the transposed matrix to obtain a fourth matrix, including:
sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix; wherein the kth column is updated by:
summing products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and updating the kth column according to a result obtained by subtracting the column vector from the kth column.
The embodiment of the invention discloses B8 and a data processing device, which comprises:
the first construction module is used for combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
a second constructing module, configured to construct, according to the first matrix, a second matrix and a third matrix, where the second matrix is used to indicate whether an element in the first matrix is smaller than or larger than an element in a transpose of the first matrix, and the third matrix is used to indicate whether an element in the first matrix is equal to an element in the transpose;
an index determining module, configured to determine, according to the second matrix and the third matrix, a sorting index corresponding to the n ciphertext data;
and the data sorting module is used for sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data.
B9, the apparatus of B8, the index determination module comprising:
the index determining submodule is used for determining a sorting index corresponding to the n ciphertext data according to the second matrix;
the index correction submodule is used for correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the data sorting module is specifically configured to sort the n ciphertext data according to the corrected sorting index, so as to obtain n sorted ciphertext data.
B10, according to the apparatus described in B9, the index determining submodule is specifically configured to perform addition calculation on the second matrix by columns, respectively, to obtain a first vector, where each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the index modification submodule includes:
the offset construction unit is used for constructing an offset matrix according to the third matrix;
the offset calculation unit is used for respectively performing addition calculation on the offset matrix according to columns to obtain second vectors;
and the index correction unit is used for performing addition calculation on the first vector and the second vector to obtain a position vector, and each element in the position vector corresponds to the corrected sorting index of each ciphertext data in the n ciphertext data.
B11, the device according to B10, and the data sorting module are specifically configured to sort the n ciphertext data according to the positions of the sorting indexes corresponding to the elements in the position vector, so as to obtain n sorted ciphertext data.
B12, the apparatus of B11, the data sorting module comprising:
the position construction submodule is used for combining the n position vectors according to columns to construct a position matrix of n rows and n columns;
the comparison construction submodule is used for combining n sequences with the numerical value of 0 to n-1 according to columns to construct a comparison matrix with n rows and n columns;
the conversion construction submodule is used for obtaining a conversion matrix according to a comparison result between the transposition matrix of the position matrix and the comparison matrix;
the sorting calculation submodule is used for multiplying the transposed matrix of the first matrix and the conversion matrix according to elements to obtain a sorting matrix;
and the data sorting submodule is used for respectively performing addition calculation on the sorting matrix according to columns to obtain the sorted ciphertext data.
B13, the apparatus according to B10, the bias building unit comprising:
a matrix updating subunit, configured to update column elements in the third matrix, which represent that the first matrix and the transposed matrix are equal to each other, so as to obtain a fourth matrix;
the matrix accumulation submodule is used for subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and the offset calculation submodule is used for multiplying the fifth matrix and the fourth matrix according to elements to obtain an offset matrix.
B14, according to the apparatus of B13, the matrix updating subunit is specifically configured to sequentially update the 2 nd column to the nth column of the third matrix from left to right to obtain a fourth matrix; wherein, the matrix updating subunit includes:
the calculation module is used for summing the products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and the updating module is used for updating the kth column according to a result obtained by subtracting the column vector from the kth column.
The embodiment of the invention discloses C15, an apparatus for data processing, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors comprise instructions for:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
and sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data.
C16, the apparatus according to C15, the determining the sorting index corresponding to the n pieces of ciphertext data according to the second matrix and the third matrix, including:
determining sorting indexes corresponding to the n ciphertext data according to the second matrix;
correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data includes:
and sequencing the n ciphertext data according to the corrected sequencing index to obtain n sequenced ciphertext data.
C17, the apparatus according to C16, the determining the sorting index corresponding to the n pieces of ciphertext data according to the second matrix, including:
performing addition calculation on the second matrix according to columns to obtain a first vector, wherein each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the modifying the sorting index according to the third matrix to obtain a modified sorting index includes:
constructing a bias matrix according to the third matrix;
respectively performing addition calculation on the bias matrix according to columns to obtain second vectors;
and performing addition calculation on the first vector and the second vector to obtain a position vector, wherein each element in the position vector corresponds to the modified sorting index of each ciphertext data in the n ciphertext data.
C18, the sorting the n ciphertext data according to the modified sorting index to obtain n sorted ciphertext data according to the apparatus of C17, including:
and sequencing the n ciphertext data according to the position of the sequencing index corresponding to each element in the position vector to obtain n sequenced ciphertext data.
C19, according to the apparatus described in C18, the obtaining n pieces of ciphertext data after sorting by sorting the n pieces of ciphertext data according to the position of the sorting index corresponding to each element in the position vector includes:
combining the n position vectors according to columns to construct a position matrix with n rows and n columns;
combining n sequences with the numerical value of 0-n-1 according to columns to construct a comparison matrix with n rows and n columns;
obtaining a conversion matrix according to a comparison result between the transposed matrix of the position matrix and the comparison matrix;
multiplying the transposed matrix of the first matrix by the conversion matrix according to elements to obtain a sorting matrix;
and respectively executing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data.
C20, the apparatus of C17, the constructing a bias matrix from the third matrix, comprising:
updating column elements in the third matrix, which represent that the first matrix is equal to the transposed matrix, to obtain a fourth matrix;
subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and multiplying the fifth matrix and the fourth matrix according to elements to obtain a bias matrix.
C21, according to the apparatus of C20, the updating column elements in the third matrix that represent equality between the first matrix and the transposed matrix to obtain a fourth matrix includes:
sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix; wherein the kth column is updated by:
summing products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and updating the kth column according to a result obtained by subtracting the column vector from the kth column.
Embodiments of the present invention disclose D22, a machine-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a data processing method as described in one or more of a 1-a 7.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims. The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
The data processing method, the data processing apparatus and the apparatus for data processing provided by the present invention are described in detail above, and specific examples are applied herein to illustrate the principles and embodiments of the present invention, and the description of the above embodiments is only used to help understand the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (16)

1. A method of data processing, the method comprising:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data;
determining the sorting index corresponding to the n ciphertext data according to the second matrix and the third matrix, including:
determining sorting indexes corresponding to the n ciphertext data according to the second matrix;
correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data includes:
sorting the n ciphertext data according to the corrected sorting index to obtain n sorted ciphertext data;
the determining, according to the second matrix, the sorting index corresponding to the n ciphertext data includes:
performing addition calculation on the second matrix according to columns to obtain a first vector, wherein each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the modifying the sorting index according to the third matrix to obtain a modified sorting index includes:
constructing a bias matrix according to the third matrix;
respectively performing addition calculation on the bias matrix according to columns to obtain second vectors;
and performing addition calculation on the first vector and the second vector to obtain a position vector, wherein each element in the position vector corresponds to the modified sorting index of each ciphertext data in the n ciphertext data.
2. The method according to claim 1, wherein the sorting the n ciphertext data according to the modified sorting index to obtain n sorted ciphertext data comprises:
and sequencing the n ciphertext data according to the position of the sequencing index corresponding to each element in the position vector to obtain n sequenced ciphertext data.
3. The method according to claim 2, wherein the sorting the n ciphertext data according to the position of the sorting index corresponding to each element in the position vector to obtain n sorted ciphertext data includes:
combining the n position vectors according to columns to construct a position matrix with n rows and n columns;
combining n sequences with the numerical value of 0-n-1 according to columns to construct a comparison matrix with n rows and n columns;
obtaining a conversion matrix according to a comparison result between the transposed matrix of the position matrix and the comparison matrix;
multiplying the transposed matrix of the first matrix by the conversion matrix according to elements to obtain a sorting matrix;
and respectively executing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data.
4. The method of claim 1, wherein constructing a bias matrix from the third matrix comprises:
updating column elements in the third matrix, which represent that the first matrix is equal to the transposed matrix, to obtain a fourth matrix;
subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and multiplying the fifth matrix and the fourth matrix according to elements to obtain a bias matrix.
5. The method of claim 4, wherein updating column elements in the third matrix that represent equality between the first matrix and the transposed matrix, resulting in a fourth matrix, comprises:
sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix; wherein the kth column is updated by:
summing products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and updating the kth column according to a result obtained by subtracting the column vector from the kth column.
6. A data processing apparatus, characterized in that the apparatus comprises:
the first construction module is used for combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
a second constructing module, configured to construct, according to the first matrix, a second matrix and a third matrix, where the second matrix is used to indicate whether an element in the first matrix is smaller than or larger than an element in a transpose of the first matrix, and the third matrix is used to indicate whether an element in the first matrix is equal to an element in the transpose;
an index determining module, configured to determine, according to the second matrix and the third matrix, a sorting index corresponding to the n ciphertext data;
the data sorting module is used for sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data;
the index determination module includes:
the index determining submodule is used for determining a sorting index corresponding to the n ciphertext data according to the second matrix;
the index correction submodule is used for correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the data sorting module is specifically configured to sort the n ciphertext data according to the corrected sorting index to obtain n sorted ciphertext data;
the index determining submodule is specifically configured to perform addition calculation on the second matrix in rows to obtain a first vector, where each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the index modification submodule includes:
the offset construction unit is used for constructing an offset matrix according to the third matrix;
the offset calculation unit is used for respectively performing addition calculation on the offset matrix according to columns to obtain second vectors;
and the index correction unit is used for performing addition calculation on the first vector and the second vector to obtain a position vector, and each element in the position vector corresponds to the corrected sorting index of each ciphertext data in the n ciphertext data.
7. The apparatus according to claim 6, wherein the data sorting module is specifically configured to sort the n ciphertext data according to a position of a sorting index corresponding to each element in the position vector, so as to obtain n sorted ciphertext data.
8. The apparatus of claim 7, wherein the data sorting module comprises:
the position construction submodule is used for combining the n position vectors according to columns to construct a position matrix of n rows and n columns;
the comparison construction submodule is used for combining n sequences with the numerical value of 0 to n-1 according to columns to construct a comparison matrix with n rows and n columns;
the conversion construction submodule is used for obtaining a conversion matrix according to a comparison result between the transposition matrix of the position matrix and the comparison matrix;
the sorting calculation submodule is used for multiplying the transposed matrix of the first matrix and the conversion matrix according to elements to obtain a sorting matrix;
and the data sorting submodule is used for respectively performing addition calculation on the sorting matrix according to columns to obtain the sorted ciphertext data.
9. The apparatus of claim 6, wherein the bias construction unit comprises:
a matrix updating subunit, configured to update column elements in the third matrix, which represent that the first matrix and the transposed matrix are equal to each other, so as to obtain a fourth matrix;
the matrix accumulation submodule is used for subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and the offset calculation submodule is used for multiplying the fifth matrix and the fourth matrix according to elements to obtain an offset matrix.
10. The apparatus according to claim 9, wherein the matrix updating subunit is configured to sequentially update the 2 nd column to the nth column of the third matrix from left to right, so as to obtain a fourth matrix; wherein, the matrix updating subunit includes:
the calculation module is used for summing the products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and the updating module is used for updating the kth column according to a result obtained by subtracting the column vector from the kth column.
11. An apparatus for data processing, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and wherein execution of the one or more programs by one or more processors comprises instructions for:
combining sequences corresponding to n ciphertext data to be sorted according to columns to construct a first matrix with n rows and n columns;
constructing a second matrix and a third matrix according to the first matrix, wherein the second matrix is used for indicating whether elements in the first matrix are smaller than or larger than elements in a transposed matrix of the first matrix, and the third matrix is used for indicating whether the elements in the first matrix are equal to the elements in the transposed matrix;
determining sorting indexes corresponding to the n ciphertext data according to the second matrix and the third matrix;
sequencing the n ciphertext data according to the sequencing index to obtain n sequenced ciphertext data;
determining the sorting index corresponding to the n ciphertext data according to the second matrix and the third matrix, including:
determining sorting indexes corresponding to the n ciphertext data according to the second matrix;
correcting the sorting index according to the third matrix to obtain a corrected sorting index;
the sorting the n ciphertext data according to the sorting index to obtain n sorted ciphertext data includes:
sorting the n ciphertext data according to the corrected sorting index to obtain n sorted ciphertext data;
the determining, according to the second matrix, the sorting index corresponding to the n ciphertext data includes:
performing addition calculation on the second matrix according to columns to obtain a first vector, wherein each element in the first vector corresponds to a sorting index of each ciphertext data in the n ciphertext data;
the modifying the sorting index according to the third matrix to obtain a modified sorting index includes:
constructing a bias matrix according to the third matrix;
respectively performing addition calculation on the bias matrix according to columns to obtain second vectors;
and performing addition calculation on the first vector and the second vector to obtain a position vector, wherein each element in the position vector corresponds to the modified sorting index of each ciphertext data in the n ciphertext data.
12. The apparatus according to claim 11, wherein the sorting the n ciphertext data according to the modified sorting index to obtain n sorted ciphertext data includes:
and sequencing the n ciphertext data according to the position of the sequencing index corresponding to each element in the position vector to obtain n sequenced ciphertext data.
13. The apparatus according to claim 12, wherein the sorting the n ciphertext data according to the position of the sorting index corresponding to each element in the position vector to obtain n sorted ciphertext data includes:
combining the n position vectors according to columns to construct a position matrix with n rows and n columns;
combining n sequences with the numerical value of 0-n-1 according to columns to construct a comparison matrix with n rows and n columns;
obtaining a conversion matrix according to a comparison result between the transposed matrix of the position matrix and the comparison matrix;
multiplying the transposed matrix of the first matrix by the conversion matrix according to elements to obtain a sorting matrix;
and respectively executing addition calculation on the sorting matrix according to columns to obtain sorted ciphertext data.
14. The apparatus of claim 11, wherein the constructing a bias matrix from the third matrix comprises:
updating column elements in the third matrix, which represent that the first matrix is equal to the transposed matrix, to obtain a fourth matrix;
subtracting the fourth matrix from the row accumulation result of the fourth matrix to obtain a fifth matrix;
and multiplying the fifth matrix and the fourth matrix according to elements to obtain a bias matrix.
15. The apparatus of claim 14, wherein updating column elements in the third matrix that represent equality between the first matrix and the transposed matrix results in a fourth matrix, comprising:
sequentially updating the 2 nd column to the nth column of the third matrix according to the sequence from left to right to obtain a fourth matrix; wherein the kth column is updated by:
summing products of the first k-1 columns and the first k-1 elements of the kth column respectively to obtain column vectors;
and updating the kth column according to a result obtained by subtracting the column vector from the kth column.
16. A machine-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform the data processing method of any of claims 1 to 5.
CN201911275449.8A 2019-12-12 2019-12-12 Data processing method and device and data processing device Active CN112668015B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911275449.8A CN112668015B (en) 2019-12-12 2019-12-12 Data processing method and device and data processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911275449.8A CN112668015B (en) 2019-12-12 2019-12-12 Data processing method and device and data processing device

Publications (2)

Publication Number Publication Date
CN112668015A CN112668015A (en) 2021-04-16
CN112668015B true CN112668015B (en) 2022-02-01

Family

ID=75400490

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911275449.8A Active CN112668015B (en) 2019-12-12 2019-12-12 Data processing method and device and data processing device

Country Status (1)

Country Link
CN (1) CN112668015B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104700200A (en) * 2014-12-18 2015-06-10 西安交通大学 Multivariate product quality monitoring method oriented to digital workshop
CN104914433A (en) * 2015-06-15 2015-09-16 南京航空航天大学 Linked list sorting-based OS-CFAR multi-target extraction realization method
CN108429601A (en) * 2017-02-15 2018-08-21 中兴通讯股份有限公司 A kind of data processing method and device, data processing equipment
CN109992995A (en) * 2019-03-05 2019-07-09 华南理工大学 A kind of protection of support position and inquiry privacy can search for encryption method
CN110222081A (en) * 2019-06-08 2019-09-10 西安电子科技大学 Data cryptogram search method based on fine granularity sequence under multi-user environment

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9313028B2 (en) * 2012-06-12 2016-04-12 Kryptnostic Method for fully homomorphic encryption using multivariate cryptography
CN104268142B (en) * 2014-08-05 2018-02-02 河海大学 Based on the Meta Search Engine result ordering method for being rejected by strategy
CN104182483B (en) * 2014-08-07 2017-11-10 蔡剑 The method for building up and service search method of service index database based on community network
US10360390B2 (en) * 2016-12-14 2019-07-23 Sap Se Oblivious order-preserving encryption
US11567765B2 (en) * 2017-03-20 2023-01-31 Intel Corporation Systems, methods, and apparatuses for tile load
CN108171262A (en) * 2017-12-22 2018-06-15 珠海习悦信息技术有限公司 The recognition methods of ciphertext picture/mb-type, device, storage medium and processor

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104700200A (en) * 2014-12-18 2015-06-10 西安交通大学 Multivariate product quality monitoring method oriented to digital workshop
CN104914433A (en) * 2015-06-15 2015-09-16 南京航空航天大学 Linked list sorting-based OS-CFAR multi-target extraction realization method
CN108429601A (en) * 2017-02-15 2018-08-21 中兴通讯股份有限公司 A kind of data processing method and device, data processing equipment
CN109992995A (en) * 2019-03-05 2019-07-09 华南理工大学 A kind of protection of support position and inquiry privacy can search for encryption method
CN110222081A (en) * 2019-06-08 2019-09-10 西安电子科技大学 Data cryptogram search method based on fine granularity sequence under multi-user environment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
A type of sorting based on homomorphic encryption;Xu Chen 等;《2013 IEEE 4th International Conference on Electronics Information and Emergency Communication》;20140619;全文 *
云计算中保护数据隐私的快速多关键词语义排序搜索方案;杨旸 等;《计算机学报》;20181012;第41卷(第6期);全文 *

Also Published As

Publication number Publication date
CN112668015A (en) 2021-04-16

Similar Documents

Publication Publication Date Title
CN113315631B (en) Data processing method and device and data processing device
CN113449325B (en) Data processing method and device and data processing device
CN115396101B (en) Secret sharing based careless disorganizing method and system
CN112241250B (en) Data processing method and device and data processing device
CN112667674B (en) Data processing method and device and data processing device
CN115396100B (en) Careless random disorganizing method and system based on secret sharing
CN114840568B (en) Ciphertext sorting method and device and ciphertext sorting device
CN111859035A (en) Data processing method and device
CN113094744A (en) Information processing method, service platform, device for information processing and multi-party secure computing system
CN112307056B (en) Data processing method and device for data processing
CN113392422A (en) Data processing method and device and data processing device
CN115085912A (en) Ciphertext computing method and device for ciphertext computing
CN112487415B (en) Method and device for detecting security of computing task
CN112464257B (en) Data detection method and device for data detection
CN115941181B (en) Out-of-order secret sharing method, system and readable storage medium
CN114885038B (en) Encryption protocol conversion method, result acquisition node and privacy calculation node
CN112583764B (en) Data processing method and device and data processing device
CN112685747B (en) Data processing method and device and data processing device
CN112668015B (en) Data processing method and device and data processing device
CN114448631B (en) Multi-party security computing method, system and device for multi-party security computing
CN112580064B (en) Data processing method and device and data processing device
CN112468290B (en) Data processing method and device and data processing device
CN112861145A (en) Data processing method and device and data processing device
CN112580063B (en) Data processing method and device and data processing device
CN116089990B (en) Multiparty secure computing method, system and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant