Data processing method, device, apparatus, system, storage medium and program product
By using a data spatial connector and a privacy-preserving computation algorithm, and by sorting and comparing data using the target location incremental index and a binary search tree, the problem of large median computation workload in multi-party secure computation is solved, and more efficient median computation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2025-10-15
- Publication Date
- 2026-06-19
AI Technical Summary
Existing median calculation methods involve a large computational workload in multi-party secure computation, especially in privacy-preserving computations where sorting and comparison are computationally intensive.
Secure data is sorted using a data spatial connector, data is inserted using the target location incremental sequence number and a binary search tree, and data is compared and excluded using a privacy computing algorithm to determine the median.
This reduces the overall sorting time and resource consumption for median calculation, thus lowering the computational workload.
Smart Images

Figure CN121365424B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data processing method, apparatus, device, system, storage medium, and program product. Background Technology
[0002] The median is the point at which a set of data is divided into two equal parts: the number of data points greater than the median and the number of data points less than the median. The advantage of the median is that it is insensitive to outliers; therefore, when a dataset contains extreme values or is skewed, the median is often a better indicator of the central tendency of the data than the mean.
[0003] In existing solutions, the median is typically calculated by sorting the dataset from smallest to largest. If the dataset has an odd number of values, the median is the middle value. If the dataset has an even number of values, the median is usually the average of the two middle values. Based on this principle, privacy-preserving computation engines, such as those based on secure multi-party computation, require secretly sharing data between two (or more) parties, sorting the data based on this secret sharing, and then calculating the median based on the total length of the arrays from both (or more) parties. In this process, the comparison and sorting based on privacy computation are computationally intensive tasks, resulting in a large computational workload for existing median determination methods. Summary of the Invention
[0004] This application provides a data processing method, apparatus, device, system, storage medium, and program product to solve the problem that the computational workload for determining the median is too large in existing methods.
[0005] In a first aspect, embodiments of this application provide a data processing method applied to a first device, the first device being connected to a data space connector, the method comprising:
[0006] The first device sorts its security data through a data space connector to obtain first security data;
[0007] The first device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the second device;
[0008] The first device performs steps S1 to S3 until the median is obtained:
[0009] S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data;
[0010] S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device;
[0011] S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median.
[0012] Optionally, the first device sorts its security data via a data space connector to obtain first security data, including:
[0013] A binary search tree for the first secure data is constructed using the data space connector;
[0014] Using the data space connector, starting from the root node of the binary search tree, the data to be inserted in the first secure data is compared with the data of the root node, wherein the data to be inserted is any data in the first secure data to be inserted into the binary search tree;
[0015] If the data to be inserted is less than or equal to the data of the root node, the system enters the left subtree of the binary search tree and compares the data to be inserted with the data of the current node in the left subtree. Based on the comparison results, an empty position is determined in the left subtree, and the data to be inserted is inserted into the empty position. Alternatively, if the data to be inserted is greater than the data of the root node, the system enters the right subtree of the binary search tree and compares the data to be inserted with the data of the current node in the right subtree. Based on the comparison results, an empty position is determined in the right subtree, and the data to be inserted is inserted into the empty position.
[0016] The first safe data is obtained by inserting a binary search tree containing all the data to be inserted.
[0017] Optionally, determining the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data includes:
[0018] Determine the sequence number of the first target data acquisition position;
[0019] The value at the position of the first target data retrieval location number in the first security data is taken as the first target data.
[0020] The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value.
[0021] Optionally, comparing the first target data with the second target data obtained from the second device, and updating the order value and the first initial data retrieval position number according to the comparison result, includes:
[0022] If the first target data is less than or equal to the second target data, an updated order value is obtained based on the current order value, the first target data retrieval position number, and the first initial data retrieval position number. The updated order value is then sent to the second device. Additionally, the first target data retrieval position number is incremented by 1 to obtain an updated first initial data retrieval position number; or...
[0023] The step of sending first information to the second device based on the comparison result includes:
[0024] If the first target data is greater than the second target data, the first information is sent to the second device.
[0025] Optionally, the step of excluding the first security data to obtain the third security data includes:
[0026] If the first target data is less than or equal to the second target data, delete the data in the first security data that is less than or equal to the first target data to obtain the third security data.
[0027] Optionally, the first condition includes:
[0028] The current first initial data retrieval position number is equal to the number of data included in the first security data;
[0029] The current order value is 1.
[0030] Optionally, determining the median when the first condition is met includes:
[0031] The system receives second information sent by the second device, the second information indicating the end of the loop, and determines the median as: the data at the third data retrieval position in the first secure data, the third data retrieval position being equal to the difference between the first value and 1, the first value being equal to the sum of the first initial data retrieval position and the current sequence value, wherein the second information is sent when the second initial data retrieval position is equal to the number of data included in the second secure data; or,
[0032] If the first initial data retrieval position number is equal to the number of data items included in the first secure data, a third message is sent to the second device to indicate the end of the loop and to instruct the second device to determine the median as: the data at the fourth data retrieval position number in the second secure data, where the fourth data retrieval position number is equal to the difference between a second value and 1, and the second value is equal to the sum of the second initial data retrieval position number and the current sequence value of the second device; or...
[0033] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0034] Secondly, embodiments of this application also provide a data processing method applied to a second device, the second device being connected to a data space connector, the method comprising:
[0035] The second device sorts its security data through a data space connector to obtain second security data;
[0036] The second device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the first device;
[0037] The second device performs the following process until the median is obtained:
[0038] The second initial data retrieval position number of the second device security data determines the second target data, and the second target data is sent to the first device;
[0039] Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device.
[0040] Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median.
[0041] Optionally, determining the second target data based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval location sequence number of the second security data includes:
[0042] Determine the sequence number of the second target data acquisition position;
[0043] The value at the position of the second target data acquisition position number in the second security data is taken as the second target data.
[0044] The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value.
[0045] Optionally, updating the sequence value of the second device and the second initial data retrieval position number according to the first information includes:
[0046] Based on the current sequence value, the second target data retrieval position number, and the second initial data retrieval position number, the updated sequence value is obtained;
[0047] Increment the second target data retrieval position number by 1 to obtain the updated second initial data retrieval position number.
[0048] Optionally, the step of excluding the second security data to obtain the fourth security data includes:
[0049] The fourth security data is obtained by deleting data in the second security data that is less than or equal to the second target data.
[0050] Optionally, the second condition includes:
[0051] The current second initial data retrieval position number is equal to the number of data included in the second security data;
[0052] The current order value is 1.
[0053] Optionally, determining the median when the second condition is met includes:
[0054] If the second initial data retrieval position number is equal to the number of data items included in the second secure data, a second message is sent to the first device. This second message indicates the end of the loop and determines the median as: the data item at the third data retrieval position number in the first secure data, where the third data retrieval position number is equal to the difference between a first value and 1, and the first value is equal to the sum of the first initial data retrieval position number of the first device and the current sequence value of the first device; or...
[0055] The system receives a third message from the first device to indicate the end of the loop and instructs the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, where the fourth data retrieval position is equal to the difference between the second value and 1, and the second value is equal to the sum of the second initial data retrieval position and the current sequence value of the second device. The third message is sent when the first initial data retrieval position is equal to the number of data items included in the first secure data; or...
[0056] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0057] Thirdly, embodiments of this application also provide a data processing apparatus, applied to a first device, the first device being connected to a data space connector, the apparatus comprising:
[0058] The first acquisition module is used to sort the security data of the first device through the data space connector to obtain the first security data;
[0059] The second acquisition module is used to determine the target location increment number, which is used to determine the median of the first security data and the second security data of the second device.
[0060] The third acquisition module is used to execute S1 to S3 until the median is obtained:
[0061] S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data;
[0062] S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device;
[0063] S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median.
[0064] Optionally, the first acquisition module is further configured to:
[0065] A binary search tree for the first secure data is constructed using the data space connector;
[0066] Using the data space connector, starting from the root node of the binary search tree, the data to be inserted in the first secure data is compared with the data of the root node, wherein the data to be inserted is any data in the first secure data to be inserted into the binary search tree;
[0067] If the data to be inserted is less than or equal to the data of the root node, the system enters the left subtree of the binary search tree and compares the data to be inserted with the data of the current node in the left subtree. Based on the comparison results, an empty position is determined in the left subtree, and the data to be inserted is inserted into the empty position. Alternatively, if the data to be inserted is greater than the data of the root node, the system enters the right subtree of the binary search tree and compares the data to be inserted with the data of the current node in the right subtree. Based on the comparison results, an empty position is determined in the right subtree, and the data to be inserted is inserted into the empty position.
[0068] The first safe data is obtained by inserting a binary search tree containing all the data to be inserted.
[0069] Optionally, the third acquisition module is further configured to:
[0070] Determine the sequence number of the first target data acquisition position;
[0071] The value at the position of the first target data retrieval location number in the first security data is taken as the first target data.
[0072] The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value.
[0073] Optionally, the third acquisition module is further configured to:
[0074] If the first target data is less than or equal to the second target data, an updated order value is obtained based on the current order value, the first target data retrieval position number, and the first initial data retrieval position number. The updated order value is then sent to the second device. Additionally, the first target data retrieval position number is incremented by 1 to obtain an updated first initial data retrieval position number; or...
[0075] The step of sending first information to the second device based on the comparison result includes:
[0076] If the first target data is greater than the second target data, the first information is sent to the second device.
[0077] Optionally, the third acquisition module is further configured to:
[0078] If the first target data is less than or equal to the second target data, delete the data in the first security data that is less than or equal to the first target data to obtain the third security data.
[0079] Optionally, the first condition includes:
[0080] The current first initial data retrieval position number is equal to the number of data included in the first security data;
[0081] The current order value is 1.
[0082] Optionally, the third acquisition module is further configured to: determine the median when the first condition is met, including:
[0083] The system receives second information sent by the second device, the second information indicating the end of the loop, and determines the median as: the data at the third data retrieval position in the first secure data, the third data retrieval position being equal to the difference between the first value and 1, the first value being equal to the sum of the first initial data retrieval position and the current sequence value, wherein the second information is sent when the second initial data retrieval position is equal to the number of data included in the second secure data; or,
[0084] If the first initial data retrieval position number is equal to the number of data items included in the first secure data, a third message is sent to the second device to indicate the end of the loop and to instruct the second device to determine the median as: the data at the fourth data retrieval position number in the second secure data, where the fourth data retrieval position number is equal to the difference between a second value and 1, and the second value is equal to the sum of the second initial data retrieval position number and the current sequence value of the second device; or...
[0085] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0086] Fourthly, embodiments of this application also provide a data processing apparatus applied to a second device, the second device being connected to a data space connector, the apparatus comprising:
[0087] The first acquisition module is used to sort the security data of the second device through the data space connector to obtain the second security data;
[0088] The second acquisition module is used to determine the target location increment sequence number, which is used to determine the median of the first security data and the second security data of the first device.
[0089] The third acquisition module is used to perform the following process until the median is obtained:
[0090] The second target data is determined based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data, and the second target data is sent to the first device.
[0091] Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device.
[0092] Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median.
[0093] Optionally, the third acquisition module is further configured to:
[0094] Determine the sequence number of the second target data acquisition position;
[0095] The value at the position of the second target data acquisition position number in the second security data is taken as the second target data.
[0096] The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value.
[0097] Optionally, the third acquisition module is further configured to:
[0098] Based on the current sequence value, the second target data retrieval position number, and the second initial data retrieval position number, the updated sequence value is obtained;
[0099] Increment the second target data retrieval position number by 1 to obtain the updated second initial data retrieval position number.
[0100] Optionally, the third acquisition module is further configured to:
[0101] The fourth security data is obtained by deleting data in the second security data that is less than or equal to the second target data.
[0102] Optionally, the second condition includes:
[0103] The current second initial data retrieval position number is equal to the number of data included in the second security data;
[0104] The current order value is 1.
[0105] Optionally, the third acquisition module is further configured to: determine the median when the second condition is met, including:
[0106] If the second initial data retrieval position number is equal to the number of data items included in the second secure data, a second message is sent to the first device. This second message indicates the end of the loop and determines the median as: the data item at the third data retrieval position number in the first secure data, where the third data retrieval position number is equal to the difference between a first value and 1, and the first value is equal to the sum of the first initial data retrieval position number of the first device and the current sequence value of the first device; or...
[0107] The system receives a third message from the first device to indicate the end of the loop and instructs the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, where the fourth data retrieval position is equal to the difference between the second value and 1, and the second value is equal to the sum of the second initial data retrieval position and the current sequence value of the second device. The third message is sent when the first initial data retrieval position is equal to the number of data items included in the first secure data; or...
[0108] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0109] Fifthly, embodiments of this application also provide a data processing system, including: a server, and at least a first device and a second device;
[0110] The first device is configured to perform the method described in any one of the first aspects;
[0111] The second device is used to perform the method described in any one of the second aspects;
[0112] The server includes a spatial data connector for sorting security data from the first device and the second device.
[0113] Sixthly, embodiments of this application also provide a communication device, including: a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the data processing method described above.
[0114] In a seventh aspect, embodiments of this application also provide a readable storage medium storing a program that, when executed by a processor, implements the steps in the data processing method described above.
[0115] Eighthly, embodiments of this application also provide a computer program product, including computer instructions, which, when executed by a processor, implement the steps in the data processing method described above.
[0116] In this embodiment of the application, in the security data of multiple devices after sorting, data is excluded by comparing data at specific data retrieval positions, thereby reducing the time and resource consumption required for overall sorting of all security data and reducing the computational workload of determining the median. Attached Figure Description
[0117] Figure 1 This is one of the flowcharts of the data processing method provided in the embodiments of this application;
[0118] Figure 2 This is a schematic diagram of the data processing process provided in an embodiment of this application;
[0119] Figure 3 This is the second flowchart of the data processing method provided in the embodiments of this application;
[0120] Figure 4 This is one of the structural diagrams of the data processing apparatus provided in the embodiments of this application;
[0121] Figure 5 This is a second structural diagram of the data processing apparatus provided in the embodiments of this application;
[0122] Figure 6 This is a schematic diagram of the data processing system provided in the embodiments of this application. Detailed Implementation
[0123] In the embodiments of this application, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.
[0124] In the embodiments of this application, the term "multiple" refers to two or more, and other quantifiers are similar.
[0125] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0126] See Figure 1 , Figure 1 This is a flowchart of a data processing method provided in an embodiment of this application, applied to a first device connected to a data space connector. The first device includes, but is not limited to, a terminal. Figure 1 As shown, it includes the following steps:
[0127] Step 101: The first device sorts its security data through the data space connector to obtain the first security data;
[0128] Step 102: The first device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the second device;
[0129] Step 103: The first device executes S1 to S3 until the median is obtained:
[0130] S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data;
[0131] S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device;
[0132] S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median.
[0133] In this embodiment of the application, in the security data of multiple devices after sorting, data is excluded by comparing data at specific data retrieval positions, thereby reducing the time and resource consumption required for overall sorting of all security data and reducing the computational workload of determining the median.
[0134] The data space connector can be understood as a trusted computing environment for the data space, a runtime environment based on internal and external environment isolation and task isolation. It typically provides a secure, isolated environment based on virtualization (Kata secure containers) or hardware isolation (Trusted Execution Environment (TEE)). Computation can be performed in plaintext within this environment, but it generally requires that the data not be stored on disk and can only be computed in memory. Due to its isolation and lack of disk storage, a certain level of security is provided even for plaintext computation. This security is based on virtualization or hardware isolation, unlike cryptographic-based multi-party secure computation.
[0135] The solution in this application can actually be extended to a method for determining the k-th order statistic (i.e., the k-th largest value, where K is greater than 1). If the median is calculated, the order statistic (i.e., the order value) corresponding to the median can be derived based on the total amount of security data from multiple devices. For example, multiple devices calculate the total data volume N using a privacy-based computation algorithm (such as MPC based on secret sharing). If the total data volume N is odd, the median is the data at the (N+1) / 2-th position; if the total data volume N is even, the median is the order statistic at the (N) / 2-th and (N+1) / 2-th positions, i.e., the median is the average of the data at the (N) / 2-th and (N+1) / 2-th positions. Therefore, in the above embodiment, the order value k can be set according to actual needs. In other words, the solution in this application can be used to determine the data at any k-th position.
[0136] The security data includes, but is not limited to, data in the fields of security, data circulation, statistics, and communications, such as network bandwidth, latency, and user levels.
[0137] In step 101, the data space connector connected to the first device obtains the secure data from the first device and sorts it in plaintext, such as in ascending order, to obtain the sorted first secure data. This method ensures data security. The following description uses an example where the participants include both the first and second devices; however, the implementation principle remains the same when more devices are involved. Plaintext sorting is performed within the data space connector, which typically uses isolation methods to ensure data security. In this embodiment, the sorting is performed in the following way, which saves memory and allows sorting to be completed simultaneously with data input to the data space connector. Specifically:
[0138] 1011. Construct a binary search tree for the first secure data using the data space connector. That is, initialize an empty binary search tree in the data space connector.
[0139] Perform the insertion operation described in 1012-1013 once for each piece of data inserted:
[0140] 1012. Using the data space connector, starting from the root node of the binary search tree, compare the data to be inserted in the first secure data with the data of the root node, wherein the data to be inserted is any data in the first secure data to be inserted into the binary search tree.
[0141] 1013. If the data to be inserted is less than or equal to the data of the root node, enter the left subtree of the binary search tree, compare the data to be inserted with the data of the current node in the left subtree, determine an empty position in the left subtree based on the comparison result, and insert the data to be inserted into the empty position; or, if the data to be inserted is greater than the data of the root node, enter the right subtree of the binary search tree, compare the data to be inserted with the data of the current node in the right subtree, determine an empty position in the right subtree based on the comparison result, and insert the data to be inserted into the empty position.
[0142] In other words, starting from the root node, the data to be inserted is compared with the data of each current node. If it is less than the data of the root node, the process moves to the left subtree; the nodes in the left subtree become the updated current node, and the data to be inserted is then compared with the data of the updated current node. If it is less than the data of the updated current node, the process moves to the left subtree of the updated current node. This process continues until an empty position is found, and the data to be inserted is placed in that empty position. The processing principle for the right subtree is the same as that for the left subtree.
[0143] 1014. Obtain the first safe data by inserting a binary search tree containing all the data to be inserted.
[0144] In this step, after all data has been inserted, an inorder traversal can be used to output the ordered sequence of all currently inserted data, thus obtaining the sorted and safe data.
[0145] In this embodiment, the first device and the second device exchange data via encrypted means (e.g., based on privacy computing algorithms such as MultiParty Computation (MPC) based on secret sharing), thereby ensuring data security. Assume that the data held by the first device A is SetA, and the data held by the second device B is SetB, where the number of data items in SetA is lengthA, and the number of data items in SetB is lengthB.
[0146] In step 102, if the median is determined directly, then k is the k value corresponding to the median. The k value for determining the median is as described above. Assuming the first initial data acquisition position indexA of the first device A is 0, the first device A calculates the target position increment index based on the order value k to be solved. (k divided by m and the result rounded up, where m represents the number of participating terminals, such as 2).
[0147] The above S1 may include the following process:
[0148] S11. Determine the first target data retrieval position number of the first security data.
[0149] The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value.
[0150] In the above process, the first device can compare the size of indexA+half and lengthA in plaintext via the data space connector.
[0151] S12. Take the value at the position of the first target data retrieval position number in the first security data as the first target data.
[0152] For example, the first target data is the value SetA[indexAnew] at the indexAnew position of the first device A.
[0153] In S2 above, the first device and the second device compare the sizes of SetA[indexAnew] and SetB[indexBnew] based on a privacy-preserving computation algorithm (such as MultiParty Computation (MPC) based on secret sharing). For example, the comparison can be performed by either or both of the first and second devices. Here, taking the comparison by the first device as an example, the first device reassigns values to k, indexA, and indexB based on the comparison result of the data SetA[indexAnew] at the indexAnew position of the first device A and the data SetB[indexBnew] at the indexBnew position of the second device B:
[0154] (1) When the first target data is less than or equal to the second target data, an updated sequence value is obtained based on the current sequence value, the first target data retrieval position number, and the first initial data retrieval position number. The updated sequence value is then sent to the second device. Additionally, the first target data retrieval position number is incremented by 1 to obtain an updated first initial data retrieval position number. Here, the current sequence value refers to the sequence value in the current loop.
[0155] That is: if SetA[indexAnew] <= SetB[indexBnew], then the first device A assigns the value k = k - (IndexAnew - indexA + 1), and the first device A sends the assigned value k to the second device B; then, the first device A reassigns the value indexA = indexAnew + 1 to indexA. The newly assigned values k and indexA participate in the next loop.
[0156] (2) When the first target data is greater than the second target data, send the first information to the second device. The first information is used to instruct the second device to update the sequence value and update the second initial data retrieval position number of the second device, and receive the updated sequence value sent by the second device.
[0157] That is, if SetA[indexAnew] > SetB[indexBnew], then the first device instructs the second device to perform the following operations: the second device B assigns the value k = k - (IndexBnew - indexB + 1), and then the second device B sends the assigned value k to the first device A; the second device B reassigns the value indexB = indexBnew + 1 to indexB. The newly assigned values k and indexB participate in the next loop.
[0158] While obtaining the comparison result, if the first target data is less than or equal to the second target data, the data in the first secure data that is less than or equal to the first target data is deleted to obtain the third secure data. This reduces the amount of data to be compared.
[0159] like Figure 2 As shown in the embodiments of this application, a privacy-preserving computation method is used to compare the first device and the second device. For the data at position (divided by 2 and rounded up), based on the comparison results, k / 2 numbers that cannot be the k-th smallest can be eliminated, thus halving the search range. Simultaneously, a binary search continues on the new data after elimination until the k-th largest value is obtained, thereby further obtaining the median. In the binary search of this embodiment, firstly, both devices (first device A and second device B as examples) perform a forward sorting of their local data. For the data of first device A, data before tmp_halfA is less than tmp_halfA, and data after tmp_halfA is greater than tmp_halfA; for the data of second device B, data before tmp_halfB is less than tmp_halfB, and data after tmp_halfB is greater than tmp_halfB. Then, the data at the middle position of both devices is compared. If we assume that the median data `tmp_halfA` of device A is less than the median data `tmp_halfB` of device B, then all data after `tmp_halfB` on device B are greater than both `tmp_halfA` and the data before `tmp_halfA`. Similarly, all data before `tmp_halfA` held by device A are less than both `tmp_halfB` and the data after `tmp_halfB`. In other words, before `tmp_halfA`, more than half (N / 2+2) of the data on both sides are greater than these values, and after `tmp_halfB`, more than half (N / 2+2) of the data on both sides are less than these values. According to the definition of the median, the median cannot appear in the data before `tmp_halfA` held by device A and the data after `tmp_halfB` held by device B. Therefore, these values can be excluded. By iterating through the data multiple times, eliminating half of the values each time, we can obtain the final median.
[0160] In step S3, the first condition includes:
[0161] The current first initial data retrieval position number (i.e., the first initial data retrieval position number in the current loop) is equal to the number of data included in the first secure data;
[0162] The current sequence value (i.e., the sequence value in the current cycle) is 1.
[0163] In the current loop, the first device determines, via the data space connector, whether the first initial data retrieval position number is equal to the number of data included in the first secure data. If the first initial data retrieval position number is equal to the number of data included in the first secure data, the first device sends a third message to the second device to indicate the end of the loop and instruct the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, where the fourth data retrieval position number is equal to the difference between a second value and 1, and the second value is equal to the sum of the second initial data retrieval position number and the current sequence value of the second device.
[0164] For example, in the current loop, the data space connector can be used to determine in plaintext whether the current indexA is equal to lengthA. If they are equal, the loop is terminated and the second device B is notified. The second device B then obtains the k-order statistical value as the value SetB[indexB+k-1] of the indexB+k-1 position held by the second device B, which is the median: SetB[indexB+k-1].
[0165] For the second device, in the current loop, it can determine whether the second initial data retrieval position number is equal to the number of data included in the second secure data through its connected data space connector. If the second initial data retrieval position number is equal to the number of data included in the second secure data, a second message is sent to the first device. Accordingly, the first device receives the second message sent by the second device, which indicates the end of the loop and determines the median as: the data at the third data retrieval position number in the first secure data, where the third data retrieval position number is equal to the difference between a first value and 1, and the first value is equal to the sum of the first initial data retrieval position number and the current sequence value.
[0166] For example, in the current loop, the second device B checks in plaintext in the data space connector whether the current index B is equal to length B. If they are equal, the loop terminates and notifies the first device A. The first device A then obtains the k-order statistical value: the value at position index A+k-1 held by the first device A, SetA[indexA+k-1], which is the median: SetA[indexA+k-1]. This comparison process can be performed by the first device, the second device, or both devices.
[0167] The judgment process for the first and second devices mentioned above does not have a strict sequential relationship.
[0168] After performing the above two judgments, the first device or the second device determines in plaintext whether the sequence value k is 1 through their respective connected data space connectors. If the current sequence value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0169] For example, the first device A takes SetA[indexA] at the current indexA position, and the second device B takes SetB[indexB] at the current indexB position. Based on a privacy computing algorithm (such as MPC based on secret sharing), the two values are compared. The smaller value is the k-order statistical value, that is, the smaller value between SetA[indexA] and SetB[indexB] is the median.
[0170] The median is thus determined using the method described above. Similarly, this embodiment can be extended to determine data in any k-th order. In this process, since the number of data points for each participant does not need to be known by the other, and participants cannot effectively obtain information about the other's data based on the comparison results of each round, the security of the participants' data privacy is guaranteed.
[0171] In the above embodiments, based on the judgment conditions of local sorting and multi-party privacy computation, data that does not meet the conditions (the sequence number of the held data is changed) is removed from the multi-party held data each time, thereby reducing the computational load of privacy computation, reducing the number of comparisons required for the computation task, and improving the performance of the computation.
[0172] See Figure 3 , Figure 3 This is a flowchart of a data processing method provided in an embodiment of this application, applied to a second device connected to a data space connector. The second device includes, but is not limited to, a terminal. Figure 3 As shown, it includes the following steps:
[0173] Step 301: The second device sorts its security data through the data space connector to obtain the second security data;
[0174] Step 302: The second device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the first device;
[0175] Step 303: The second device performs the following process until the median is obtained:
[0176] The second target data is determined based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data, and the second target data is sent to the first device.
[0177] Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device.
[0178] Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median.
[0179] In this embodiment of the application, in the security data of multiple devices after sorting, data is excluded by comparing data at specific data retrieval positions, thereby reducing the time and resource consumption required for overall sorting of all security data and reducing the computational workload of determining the median.
[0180] For steps 301 and 302, the implementation principle of the second device is the same as that of the first device. For example, in step 302, assuming the second initial data acquisition position indexB of the second device B is 0, the second device B calculates the target position increment index based on the sequence value k to be solved. (k divided by m and the result rounded up, where m represents the number of participating terminals, such as 2).
[0181] In step 303, the second device determines the second target data in the following manner, including:
[0182] Determine the sequence number of the second target data acquisition position;
[0183] The value at the position of the second target data acquisition position number in the second security data is taken as the second target data.
[0184] The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value.
[0185] In step 304, the second device obtains an updated sequence value based on the current sequence value, the second target data retrieval position number, and the second initial data retrieval position number; the second target data retrieval position number is incremented by 1 to obtain an updated second initial data retrieval position number. Here, the current sequence value refers to the sequence value in the current loop.
[0186] That is: if SetA[indexAnew] > SetB[indexBnew], the second device B assigns the value k = k - (IndexBnew - indexB + 1), and then the second device B sends k to the first device A; then the second device B reassigns the value indexB = indexBnew + 1. The newly assigned values k and indexB participate in the next loop. At the same time, data in the second secure data that is less than or equal to the second target data is deleted to obtain the fourth secure data.
[0187] The second condition includes:
[0188] The current second initial data retrieval position number (i.e., the second initial data retrieval position number in the current loop) is equal to the number of data included in the second security data;
[0189] The current sequence value (i.e., the sequence value in the current cycle) is 1.
[0190] Determining the median under the condition that the second condition is met includes:
[0191] If the second initial data retrieval position number is equal to the number of data included in the second secure data, a second message is sent to the first device. The second message is used to indicate the end of the loop and to determine the median as: the data at the position of the third data retrieval position number in the first secure data, wherein the third data retrieval position number is equal to the difference between the first value and 1, and the first value is equal to the sum of the first initial data retrieval position number of the first device and the current sequence value of the first device.
[0192] That is, in the current loop, the second device B determines in plaintext whether the current indexB is equal to lengthB in the data space connector. If they are equal, the loop terminates and the first device A is notified. The first device A obtains the k-order statistical value, i.e., the median, which is: the value of the indexA+k-1 position held by the first device A, SetA[indexA+k-1].
[0193] or,
[0194] The system receives a third message sent by the first device to indicate the end of the loop and to instruct the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, wherein the fourth data retrieval position is equal to the difference between the second value and 1, and the second value is equal to the sum of the second initial data retrieval position and the current sequence value of the second device, wherein the third message is sent when the first initial data retrieval position is equal to the number of data included in the first secure data.
[0195] That is, in the current loop, the first device A determines in plaintext whether the current indexA is equal to lengthA in the data space connector. If they are equal, the loop terminates and the second device B is notified. The second device B obtains the k-order statistical value, i.e., the median, which is the value of the indexB+k-1 position held by the second device B: SetB[indexB+k-1].
[0196] or,
[0197] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0198] That is, the first device A and the second device B determine in plaintext whether k equals 1 in the data space connector. If it does, the first device A takes SetA[indexA] at the current indexA position, and the second device B takes SetB[indexB] at the current indexB position. They then compare the two values based on a privacy computation algorithm (such as MPC based on secret sharing), and the median is the smaller value between SetA[indexA] and SetB[indexB]. This comparison process can be performed by the first device or the second device, or by both devices.
[0199] The solutions in this application are not limited to the case of two devices. The following describes the specific implementation process of this application embodiment using three devices as an example:
[0200] Assume that the first device A holds data SetA, the second device B holds data SetB, and the third device C holds data SetC. SetA contains data of lengthA, SetB contains data of lengthB, and SetC contains data of lengthC.
[0201] 1. The first device A, the second device B, and the third device C sort their respective data SetA, SetB, and SetC in plaintext in the data space connector to obtain sorted_SetA, sorted_SetB, and sorted_SetC.
[0202] 2. Device A sets its initial data acquisition position indexA=0, device B sets its initial data acquisition position indexB=0, and device C sets its initial data acquisition position indexC=0. Devices A, B, and C calculate the target position increment index based on the sequence value k to be solved. (Divide by 3 and round up).
[0203] 3. The first device A, the second device B, and the third device C work together to complete the following cycle:
[0204] (1) If the loop determines that indexA=lengthA, it degenerates into a two-way median problem. The median of the two sides can be calculated based on the current k, indexB, and indexC. If indexB=lengthB or indexC=lengthC, the median of the two sides is also calculated. The principle is the same as the case where indexA=lengthA.
[0205] (2) The first device A determines the new data retrieval position number indexAnew based on indexA and third. The determination method is as follows: compare the size of indexA+third and lengthA in plaintext in the data space connector, and then assign the value indexAnew=min(indexA+third, lengthA)-1.
[0206] (3) The second device B determines the new data retrieval position number indexBnew based on indexB and third. The determination method is as follows: compare the size of indexB+third and lengthB in plaintext in the data space connector, and then assign the value indexBnew=min(indexB+third, lengthB)-1.
[0207] (4) The third device C determines the new data retrieval position number indexCnew based on indexC and third. The determination method is as follows: compare the size of indexC+third and lengthC in plaintext in the data space connector, and then assign the value indexCnew=min(indexC+third, lengthC)-1.
[0208] (5) Based on the data SetA[indexAnew] at the indexAnew position of the first device A, the data SetB[indexBnew] at the indexBnew position of the second device B, and the data SetC[indexCnew] at the indexCnew position of the third device C, the three parties calculate the minimum value among them to obtain minPivot based on privacy.
[0209] ① If SetA[indexAnew] = minPivot, then the first device A assigns the value k = k - (newIndexA - indexA + 1), and then the first device A sends k to the second devices B and C; then the first device A reassigns the value indexA = indexAnew + 1. The newly assigned values k and indexA participate in the next loop.
[0210] ② If SetB[indexAnew] = minPivot, then the second device B assigns the value k = k(newIndexB - indexB + 1), and then the second device B sends k to the first devices A and C; the second device B reassigns the value indexB = indexBnew + 1. The newly assigned values k and indexB participate in the next loop.
[0211] ③ If SetC[indexAnew] = minPivot, then the third device C assigns the value k = k(newIndexB - indexC + 1), and then the third device C sends k to the first devices A and B; the third device C reassigns the value indexC = indexCnew + 1. The newly assigned values k and indexC participate in the next loop.
[0212] If two or three values in SetA[indexAnew], SetB[indexBnew], and SetC[indexCnew] are simultaneously equal to minPivot, then one of the participants holding a value equal to minPivot will be selected to perform the corresponding operation. The remaining participants remain unchanged and only receive the corresponding data.
[0213] (6) In the current round of the loop, any device determines whether the current k is equal to 1. If it is equal to 1, then based on privacy calculation, the minimum value among the following three values is the sequential statistical value of k: the value of indexAnew held by the first device A, the value of indexBnew held by the second device B, the value of indexBnew held by the third device C, and the value of indexCnew held by the third device C.
[0214] If the judgment conditions of step (6) of the first device A, the second device B, and the third device C are not met, the new values of k, indexA, indexB, and indexC obtained in step (5) are used for the next round of loop.
[0215] As can be seen from the description of the above embodiments, in this application embodiment, a hybrid plaintext-ciphertext computation based on data spatial connectors and privacy computation is used. Specifically, a trusted storage environment based on data spatial connectors provides a medium level of security for computation, while privacy computation provides a high level of security. Thus, the median calculation task is completed through the cooperation of these two security levels, improving computational performance while providing a complete high-level security solution. In the above embodiments, it is not necessary to sort the data as a whole; instead, it is based on local sorting, and then the data at specific locations is calculated and compared, reducing the amount of data computation.
[0216] See Figure 4 , Figure 4 This is a structural diagram of a data processing apparatus provided in an embodiment of this application, applied to a first device. The first device is connected to a data space connector. The apparatus includes:
[0217] The first acquisition module 401 is used to sort the security data of the first device through the data space connector to obtain first security data; the second acquisition module 402 is used to determine the target location increment sequence number, which is used to determine the median between the first security data and the second security data of the second device; the third acquisition module 403 is used to execute S1 to S3 until the median is obtained.
[0218] S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data;
[0219] S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device;
[0220] S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median.
[0221] Optionally, the first acquisition module 401 is further configured to:
[0222] A binary search tree for the first secure data is constructed using the data space connector;
[0223] Using the data space connector, starting from the root node of the binary search tree, the data to be inserted in the first secure data is compared with the data of the root node, wherein the data to be inserted is any data in the first secure data to be inserted into the binary search tree;
[0224] If the data to be inserted is less than or equal to the data of the root node, the system enters the left subtree of the binary search tree and compares the data to be inserted with the data of the current node in the left subtree. Based on the comparison results, an empty position is determined in the left subtree, and the data to be inserted is inserted into the empty position. Alternatively, if the data to be inserted is greater than the data of the root node, the system enters the right subtree of the binary search tree and compares the data to be inserted with the data of the current node in the right subtree. Based on the comparison results, an empty position is determined in the right subtree, and the data to be inserted is inserted into the empty position.
[0225] The first safe data is obtained by inserting a binary search tree containing all the data to be inserted.
[0226] Optionally, the third acquisition module 403 is further configured to:
[0227] Determine the sequence number of the first target data acquisition position;
[0228] The value at the position of the first target data retrieval location number in the first security data is taken as the first target data.
[0229] The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value.
[0230] Optionally, the third acquisition module 403 is further configured to:
[0231] If the first target data is less than or equal to the second target data, an updated order value is obtained based on the current order value, the first target data retrieval position number, and the first initial data retrieval position number. The updated order value is then sent to the second device. Additionally, the first target data retrieval position number is incremented by 1 to obtain an updated first initial data retrieval position number; or...
[0232] The step of sending first information to the second device based on the comparison result includes:
[0233] If the first target data is greater than the second target data, the first information is sent to the second device.
[0234] Optionally, the third acquisition module 403 is further configured to:
[0235] If the first target data is less than or equal to the second target data, delete the data in the first security data that is less than or equal to the first target data to obtain the third security data.
[0236] Optionally, the first condition includes:
[0237] The current first initial data retrieval position number is equal to the number of data included in the first security data;
[0238] The current order value is 1.
[0239] Optionally, the third acquisition module 403 is further configured to: determine the median when the first condition is met, including:
[0240] The system receives second information sent by the second device, the second information indicating the end of the loop, and determines the median as: the data at the third data retrieval position in the first secure data, the third data retrieval position being equal to the difference between the first value and 1, the first value being equal to the sum of the first initial data retrieval position and the current sequence value, wherein the second information is sent when the second initial data retrieval position is equal to the number of data included in the second secure data; or,
[0241] If the first initial data retrieval position number is equal to the number of data items included in the first secure data, a third message is sent to the second device to indicate the end of the loop and to instruct the second device to determine the median as: the data at the fourth data retrieval position number in the second secure data, where the fourth data retrieval position number is equal to the difference between a second value and 1, and the second value is equal to the sum of the second initial data retrieval position number and the current sequence value of the second device; or...
[0242] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0243] The apparatus provided in this application embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0244] See Figure 5 , Figure 5 This is a structural diagram of a data processing apparatus provided in an embodiment of this application, applied to a second device. The second device is connected to a data space connector. The apparatus includes:
[0245] The first acquisition module 501 is used to sort the security data of the second device through the data space connector to obtain the second security data; the second acquisition module 502 is used to determine the target location increment sequence number, which is used to determine the median of the first security data and the second security data of the first device; the third acquisition module 503 is used to perform the following process until the median is obtained:
[0246] The second target data is determined based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data, and the second target data is sent to the first device.
[0247] Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device.
[0248] Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median.
[0249] Optionally, the third acquisition module 503 is further configured to:
[0250] Determine the sequence number of the second target data acquisition position;
[0251] The value at the position of the second target data acquisition position number in the second security data is taken as the second target data.
[0252] The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value.
[0253] Optionally, the third acquisition module 503 is further configured to:
[0254] Based on the current sequence value, the second target data retrieval position number, and the second initial data retrieval position number, the updated sequence value is obtained;
[0255] Increment the second target data retrieval position number by 1 to obtain the updated second initial data retrieval position number.
[0256] Optionally, the third acquisition module 503 is further configured to:
[0257] The fourth security data is obtained by deleting data in the second security data that is less than or equal to the second target data.
[0258] Optionally, the second condition includes:
[0259] The current second initial data retrieval position number is equal to the number of data included in the second security data;
[0260] The current order value is 1.
[0261] Optionally, the third acquisition module 503 is further configured to: determine the median when the second condition is met, including:
[0262] If the second initial data retrieval position number is equal to the number of data items included in the second secure data, a second message is sent to the first device. This second message indicates the end of the loop and determines the median as: the data item at the third data retrieval position number in the first secure data, where the third data retrieval position number is equal to the difference between a first value and 1, and the first value is equal to the sum of the first initial data retrieval position number of the first device and the current sequence value of the first device; or...
[0263] The system receives a third message from the first device to indicate the end of the loop and instructs the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, where the fourth data retrieval position is equal to the difference between the second value and 1, and the second value is equal to the sum of the second initial data retrieval position and the current sequence value of the second device. The third message is sent when the first initial data retrieval position is equal to the number of data items included in the first secure data; or...
[0264] Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
[0265] The apparatus provided in this application embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0266] See Figure 6 , Figure 6 This is a structural diagram of a data processing system provided in an embodiment of this application, including: a server 601, at least a first device 602 and a second device 603;
[0267] The first device 602 is used to execute the method described above.
[0268] The second device 603 is used to perform the method described above.
[0269] The server 601 includes a spatial data connector for sorting security data of the first device and the second device.
[0270] It should be noted that the division of units in the embodiments of this application is illustrative and only represents one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units.
[0271] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a processor-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0272] This application provides a communication device, including: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is configured to read the program from the memory to implement the steps in the data processing method described above.
[0273] This application also provides a readable storage medium storing a program. When executed by a processor, this program implements the various processes of the above-described data processing method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic storage (e.g., floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs)).
[0274] This application also provides a computer program product, including computer instructions. When executed by a processor, the computer instructions implement the various processes of the above-described data processing method embodiments and achieve the same technical effects. To avoid repetition, they will not be described again here.
[0275] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0276] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0277] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A data processing method, characterized by, Applied to a first device, the first device being connected to a data space connector, the method includes: The first device sorts its security data through a data space connector to obtain first security data; The first device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the second device; The first device performs steps S1 to S3 until the median is obtained: S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data; S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device; S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median. The step of determining the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data includes: Determine the sequence number of the first target data acquisition position; The value at the position of the first target data retrieval location number in the first security data is taken as the first target data. The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value. The first condition includes: The current first initial data retrieval position number is equal to the number of data included in the first security data; The current order value is 1.
2. The method of claim 1, wherein, The first device sorts its security data via a data space connector to obtain first security data, including: A binary search tree for the first secure data is constructed using the data space connector; Using the data space connector, starting from the root node of the binary search tree, the data to be inserted in the first secure data is compared with the data of the root node, wherein the data to be inserted is any data in the first secure data to be inserted into the binary search tree; If the data to be inserted is less than or equal to the data of the root node, the system enters the left subtree of the binary search tree and compares the data to be inserted with the data of the current node in the left subtree. Based on the comparison results, an empty position is determined in the left subtree, and the data to be inserted is inserted into the empty position. Alternatively, if the data to be inserted is greater than the data of the root node, the system enters the right subtree of the binary search tree and compares the data to be inserted with the data of the current node in the right subtree. Based on the comparison results, an empty position is determined in the right subtree, and the data to be inserted is inserted into the empty position. The first safe data is obtained by inserting a binary search tree containing all the data to be inserted.
3. The method of claim 1, wherein, The step of comparing the first target data with the second target data obtained from the second device, and updating the order value and the first initial data retrieval position number according to the comparison result, includes: If the first target data is less than or equal to the second target data, an updated order value is obtained based on the current order value, the first target data retrieval position number, and the first initial data retrieval position number. The updated order value is then sent to the second device. Additionally, the first target data retrieval position number is incremented by 1 to obtain an updated first initial data retrieval position number; or... The step of sending first information to the second device based on the comparison result includes: If the first target data is greater than the second target data, the first information is sent to the second device.
4. The method of claim 3, wherein, The step of excluding the first security data to obtain the third security data includes: If the first target data is less than or equal to the second target data, delete the data in the first security data that is less than or equal to the first target data to obtain the third security data.
5. The method of claim 1, wherein, Determining the median under the condition that the first condition is met includes: The system receives second information sent by the second device, the second information indicating the end of the loop, and determines the median as: the data at the third data retrieval position in the first secure data, the third data retrieval position being equal to the difference between the first value and 1, the first value being equal to the sum of the first initial data retrieval position and the current sequence value, wherein the second information is sent when the second initial data retrieval position is equal to the number of data included in the second secure data; or, If the first initial data retrieval position number is equal to the number of data items included in the first secure data, a third message is sent to the second device to indicate the end of the loop and to instruct the second device to determine the median as: the data at the fourth data retrieval position number in the second secure data, where the fourth data retrieval position number is equal to the difference between a second value and 1, and the second value is equal to the sum of the second initial data retrieval position number and the current sequence value of the second device; or... Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
6. A data processing method, characterized by, Applied to a second device connected to a data space connector, the method includes: The second device sorts its security data through a data space connector to obtain second security data; The second device determines the target location increment number, which is used to determine the median of the first security data and the second security data of the first device; The second device performs the following process until the median is obtained: The second target data is determined based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data, and the second target data is sent to the first device. Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device. Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median. The step of determining the second target data based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data includes: Determine the sequence number of the second target data acquisition position; The value at the position of the second target data acquisition position number in the second security data is taken as the second target data. The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value. The second condition includes: The current second initial data retrieval position number is equal to the number of data included in the second security data; The current order value is 1.
7. The method according to claim 6, characterized in that, The step of updating the sequence value of the second device and the second initial data retrieval position number according to the first information includes: Based on the current sequence value, the second target data retrieval position number, and the second initial data retrieval position number, the updated sequence value is obtained; Increment the second target data retrieval position number by 1 to obtain the updated second initial data retrieval position number.
8. The method according to claim 6, characterized in that, The process of excluding the second security data to obtain the fourth security data includes: The fourth security data is obtained by deleting data that is less than or equal to the second target data from the second security data.
9. The method according to claim 6, characterized in that, Determining the median under the condition that the second condition is met includes: If the second initial data retrieval position number is equal to the number of data items included in the second secure data, a second message is sent to the first device. This second message indicates the end of the loop and determines the median as: the data item at the third data retrieval position number in the first secure data, where the third data retrieval position number is equal to the difference between a first value and 1, and the first value is equal to the sum of the first initial data retrieval position number of the first device and the current sequence value of the first device; or... The system receives a third message from the first device to indicate the end of the loop and instructs the second device to determine the median as: the data at the fourth data retrieval position in the second secure data, where the fourth data retrieval position is equal to the difference between the second value and 1, and the second value is equal to the sum of the second initial data retrieval position and the current sequence value of the second device. The third message is sent when the first initial data retrieval position is equal to the number of data items included in the first secure data; or... Given that the current order value is 1, the median is determined to be the minimum value between the data at the first initial data retrieval position in the first secure data and the data at the second initial data retrieval position in the second secure data.
10. A data processing apparatus, characterized in that, Applied to a first device, the first device being connected to a data space connector, the device includes: The first acquisition module is used to sort the security data of the first device through the data space connector to obtain the first security data; The second acquisition module is used to determine the target location increment number, which is used to determine the median of the first security data and the second security data of the second device. The third acquisition module is used to execute S1 to S3 until the median is obtained: S1. Determine the first target data in the first security data based on the target location increment sequence number, the data volume of the first security data, and the first initial data retrieval position sequence number of the first security data; S2. Compare the first target data with the second target data obtained from the second device, update the order value and the first initial data retrieval position number according to the comparison result, exclude the first security data to obtain the third security data, and send the updated order value to the second device; or, according to the comparison result, send first information to the second device, the first information being used to instruct the second device to update the order value and update the second initial data retrieval position number of the second device, and receive the updated order value sent by the second device; S3. Determine whether the first condition is met; if the first condition is not met, use the third security data as the updated first security data, and combine it with the updated sequence value and the updated first initial data taking position number to return to step S1; if the first condition is met, determine the median. The third acquisition module is further configured to: Determine the sequence number of the first target data acquisition position; The value at the position of the first target data retrieval location number in the first security data is taken as the first target data. The method for determining the first target data retrieval position number is as follows: indexAnew=min(indexA+half, lengthA)-1, where indexAnew represents the first target data retrieval position number, indexA represents the first initial data retrieval position number, half represents the target position increment number, lengthA represents the number of data included in the first security data, and min represents taking the minimum value. The first condition includes: The current first initial data retrieval position number is equal to the number of data included in the first security data; The current order value is 1.
11. A data processing apparatus, characterized in that, Applied to a second device connected to a data space connector, the device includes: The first acquisition module is used to sort the security data of the second device through the data space connector to obtain the second security data; The second acquisition module is used to determine the target location increment sequence number, which is used to determine the median of the first security data and the second security data of the first device. The third acquisition module is used to perform the following process until the median is obtained: The second target data is determined based on the target location increment sequence number, the data volume of the second security data, and the second initial data retrieval position sequence number of the second security data, and the second target data is sent to the first device. Receive the first information sent by the first device, update the sequence value of the second device and the second initial data retrieval position number according to the first information, send the updated sequence value to the first device, and perform data exclusion on the second security data to obtain the fourth security data; or, receive the updated sequence value sent by the first device. Determine whether the second condition is met; if the second condition is not met, use the fourth security data as the updated second security data, and process it in conjunction with the updated sequence value and the updated second initial data taking position number; if the second condition is met, determine the median. The third acquisition module is further configured to: Determine the sequence number of the second target data acquisition position; The value at the position of the second target data acquisition position number in the second security data is taken as the second target data. The second target data retrieval position number is determined as follows: indexBnew=min(indexB+half,lengthB)-1, where indexBnew represents the second target data retrieval position number, indexB represents the second initial data retrieval position number, half represents the target position increment number, lengthB represents the number of data included in the second security data, and min represents taking the minimum value. The second condition includes: The current second initial data retrieval position number is equal to the number of data included in the second security data; The current order value is 1.
12. A data processing system, characterized in that, include: Servers, at least the first and second devices; The first device is configured to perform the method according to any one of claims 1-5; The second device is used to perform the method according to any one of claims 6-9; The server includes a spatial data connector for sorting security data from the first device and the second device.
13. A communication device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; characterized in that the processor is configured to read the program from the memory to implement the steps of the data processing method as described in any one of claims 1 to 9.
14. A computer-readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps of the data processing method as described in any one of claims 1 to 9.
15. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps in the data processing method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Data median determination method and device
CN114595479A
Safety calculation method and device for realizing statistical analysis, equipment and medium
CN117390238A