Method for comparing traffic parameters, and device, system and storage medium
By combining local computing and multi-party secure computing, and using the XOR algorithm and random number seeds to perform fragmented calculations of business parameters, the problem of low efficiency in business parameter comparisons in privacy calculations is solved, and efficient and privacy-safe business parameter comparisons are achieved.
Patent Information
- Application Number
- PCT/CN2024/082607
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-27
- Filing Date
- 2024-03-20
- Publication Date
- 2024-10-31
AI Technical Summary
During the privacy calculation process, a large amount of data transmission interaction is required between multiple parties to compare business parameters, resulting in inefficient comparison of business parameters.
Through the combination of local computing and multi-party secure computing, the XOR algorithm and random number seeds are used to perform fragmented calculations of business parameters, reducing the number of communication interactions and achieving efficient comparison of business parameters.
It greatly improves the efficiency of multi-party business parameter comparison, ensures privacy and security, and is suitable for scenarios such as federated learning and secure intersection.
Smart Images

Figure CN2024082607_31102024_PF_FP_ABST
Abstract
Description
Business parameter comparison method, device, system and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application 202310475271.1, filed on April 27, 2023, entitled “Method, device, system and storage medium for comparing business parameters,” and the entire contents of that application are incorporated herein by reference. Technical Field
[0003] The present application relates to the field of big data processing, and in particular to a method, device, system and storage medium for comparing business parameters. Background Art
[0004] With the continuous development of information technology, more and more business scenarios require the participation of multiple parties, such as business scoring, machine learning, business data statistics, and ranking. To ensure the security of the information of multiple parties involved in the same business scenario, privacy computing technology has been introduced.
[0005] During privacy computing, devices from different parties can encrypt information into ciphertext before transmitting it, and perform logical calculations in the ciphertext state to prevent information leakage. In some cases, to implement services, it is necessary to compare the service parameters of different parties. To ensure the privacy and security of these service parameters, the actual service parameters are not transmitted, requiring a large amount of data transmission and interaction between multiple parties. This large amount of data transmission and interaction takes a long time, thereby reducing the efficiency of service parameter comparison.
[0006] Summary of the Invention
[0007] The embodiments of the present application provide a method, device, system, and storage medium for comparing service parameters, which can improve the efficiency of comparing service parameters of multiple parties.
[0008] In a first aspect, an embodiment of the present application provides a method for comparing service parameters, which is applied to a first device. The method includes: converting a first service parameter of the first device into a first binary string, randomly generating a 2 N The first tag string and the 2 N Initial random string, get the first interactive string and the first result string, the first binary string includes 2 N bits, N is a positive integer; the first interactive string is sent to the second device, so that the second device obtains a second result string based on the second binary string converted by the second service parameter of the second device, the initial random string, the randomly generated partial second label string and the first interactive string, and the second binary string includes 2N bits; interact with the second device based on the first result string and the second result string, perform fragmentation calculation, and obtain a first comparison result, the first comparison result characterizing whether the first business parameter is equal to the second business parameter.
[0009] In a second aspect, an embodiment of the present application provides a method for comparing business parameters, which is applied to a second device. The method includes: receiving a first interaction string sent by a first device, where the first interaction string is obtained by the first device based on N randomly generated first label strings; obtaining a second result string based on a second binary string converted from a second business parameter of the second device, an initial random string, a randomly generated partial second label string, and the first interaction string, where the second binary string includes 2 N bits, N is a positive integer; interact with the first device based on the first result string and the second result string, perform fragmentation calculation, and obtain a first comparison result, the first result string is obtained by the first device based on the first service parameter of the first device converted by the first binary string, the first label string and the N initial random strings agreed upon by the first device and the second device, the first comparison result represents whether the first service parameter is equal to the second service parameter, the first binary string includes 2 N bits.
[0010] In a third aspect, an embodiment of the present application provides a first device, comprising: a local computing module for converting a first binary string obtained based on a first service parameter of the first device, a randomly generated 2 N The first tag string and the 2 N Initial random string, get the first interactive string and the first result string, the first binary string includes 2 N bits, N is a positive integer; a communication module, configured to send the first interactive string to the second device, so that the second device obtains a second result string based on a second binary string converted from a second service parameter of the second device, an initial random string, a randomly generated partial second label string, and the first interactive string, wherein the second binary string includes 2 N bits; the communication module and the local calculation module are also used to interact with the second device based on the first result string and the second result string, perform fragmentation calculations, and obtain a first comparison result, the first comparison result characterizing whether the first business parameter is equal to the second business parameter.
[0011] In a fourth aspect, an embodiment of the present application provides a second device, comprising: a communication module for receiving a first interaction string sent by a first device, the first interaction string being obtained by the first device based on N randomly generated first label strings; a local calculation module for obtaining a second result string based on a second binary string converted from a second service parameter of the second device, an initial random string, a randomly generated partial second label string, and the first interaction string, the second binary string comprising 2 N bits, N is a positive integer; the communication module and the local calculation module are also used to interact with the first device based on the first result string and the second result string to perform fragmentation calculation to obtain a first comparison result, the first result string is obtained by the first device based on the first business parameter of the first device converted to obtain a first binary string, a first label string and N initial random strings agreed upon by the first device and the second device, the first comparison result represents whether the first business parameter is equal to the second business parameter, the first binary string includes 2 N bits.
[0012] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for comparing the business parameters of the first aspect or the method for comparing the business parameters of the second aspect is implemented.
[0013] In a sixth aspect, an embodiment of the present application provides a business parameter comparison system, including: a first device, used to execute the business parameter comparison method of the first aspect; and a second device, used to execute the business parameter comparison method of the second aspect.
[0014] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the business parameter comparison method of the first aspect or the business parameter comparison method of the second aspect is implemented.
[0015] The embodiments of the present application provide a method, apparatus, device, and storage medium for comparing business parameters. A first device calculates a first interaction string and a first result string locally on the first device based on a first binary string, a first label string, and an initial random string converted from its own first business parameter. The first device sends the first interaction string to a second device. A second device calculates a second result string locally on the second device based on a second binary string, a second label string, an initial random string, and the first interaction string converted from its own second business parameter. The first device and the second device interact based on the first result string and the second result string, perform fragmented calculations, and obtain a first comparison result of whether the first business parameter is equal to the second business parameter. Most of the calculations in the entire process are performed locally on the first device and the second device. Only a very small amount of communication interaction is generated between the first device and the second device during the transmission and fragmented calculation of the first interaction string, reducing the number of communication interactions between the first device and the second device, thereby improving the efficiency of multi-party business parameter comparison. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0017] FIG1 is a schematic diagram of a system architecture of an example of a method for comparing service parameters provided in an embodiment of the present application;
[0018] FIG2 is a flowchart of a method for comparing service parameters provided in an embodiment of the first aspect of the present application;
[0019] FIG3 is a flowchart of a method for comparing service parameters provided by another embodiment of the first aspect of the present application;
[0020] FIG4 is a flowchart of a method for comparing service parameters provided in yet another embodiment of the first solution of the present application;
[0021] FIG5 is a flowchart of a method for comparing service parameters provided in an embodiment of the second aspect of the present application;
[0022] FIG6 is a flowchart of a method for comparing service parameters provided by another embodiment of the second aspect of the present application;
[0023] FIG7 is a flowchart of a method for comparing service parameters provided in yet another embodiment of the second aspect of the present application;
[0024] FIG8 is a schematic diagram of a curve of an example of a linear rectification function provided in an embodiment of the present application;
[0025] FIG9 is a schematic structural diagram of a first device provided in an embodiment of the third aspect of the present application;
[0026] FIG10 is a schematic structural diagram of a second device provided in an embodiment of the fourth aspect of the present application;
[0027] FIG11 is a schematic structural diagram of an electronic device provided in an embodiment of the fifth aspect of the present application. DETAILED DESCRIPTION
[0028] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating examples of the present application. It should be noted that the acquisition, storage, use, processing, etc. of information and data in the embodiments of the present application are authorized by the user or relevant agencies and comply with the relevant provisions of national laws and regulations.
[0029] With the continuous advancement of information technology, an increasing number of business scenarios require the participation of multiple parties, such as business scoring, machine learning, business data statistics, and ranking. To ensure the security of the information of multiple parties involved in the same business scenario, privacy-preserving computing technology has been introduced. During privacy-preserving computing, devices from different parties can encrypt information into ciphertext before transmitting it, and perform logical calculations in the ciphertext state to prevent information leakage. In some cases, business parameters from different parties need to be compared to ensure the privacy and security of these parameters. To ensure the privacy and security of these parameters, the actual parameters are not transmitted during this comparison process. This requires a large amount of data exchange between multiple parties, which is time-consuming and reduces the efficiency of the comparison.
[0030] For example, a method based on an obfuscation circuit is used to implement multi-party secure computing. The relevant data of the business parameters is L bits of data, and L full adders are correspondingly set in the obfuscation circuit. During the calculation process of each full adder, Party A and Party B holding the business parameters need to conduct multiple interactive communications. In the case of L full adders, the number of interactive communications between Party A and Party B will increase exponentially. The more interactive communications there are, the longer the time taken for the interactive communications, and the lower the efficiency of the business parameter comparison.
[0031] For example, using secret sharing to implement multi-party secure computation requires the implementation of the A2B protocol, which converts a share from an arithmetic share to a Boolean share. The performance of the A2B protocol depends primarily on the selected addition circuit, such as a Kogge-stone or Sklansky structure. However, the addition circuit executes frequently, and each bit of data related to a service parameter processed in the addition circuit requires extensive communication between Party A and Party B, which holds the service parameter. Each carry in the addition circuit also requires extensive communication between Party A and Party B. This high number of interactions reduces the efficiency of service parameter comparison.
[0032] The embodiments of the present application provide a method, device, system and storage medium for comparing business parameters, which combine local computing with secure multi-party computing (MPC). Most of the operations associated with business parameter comparison are performed locally on each of the two parties participating in the business parameter comparison, without the need for homomorphic encryption and decryption, and without the need for additional auxiliary parties. This reduces the number of communication interactions between the two parties participating in the business parameter comparison, minimizes the interactive communication time of the secure multi-party computing, and thus improves the efficiency of the business parameter comparison.
[0033] The service parameter comparison method provided in the embodiment of the present application can be used for comparing service parameters between two parties, and can also be used for comparing service parameters between more parties. In the scenario of comparing service parameters between more parties, any two of the more parties can adopt the service parameter comparison method provided in the embodiment of the present application. For ease of explanation, in the embodiment of the present application, the device on which one party performs the service parameter comparison method is referred to as the first device, and the device on which the other party performs the service parameter comparison method is referred to as the second device. Figure 1 is a schematic diagram of the system architecture of an example of the service parameter comparison method provided in the embodiment of the present application. As shown in Figure 1, the system architecture includes a first device 11 and a second device 12. The first device 11 belongs to the first party, and the second device 12 belongs to the second party. The first party and the second party are different. The first device 11 and the second device 12 can communicate with each other, but in the embodiment of the present application, most of the calculations related to the service parameters of the first device 11 during the service parameter comparison process are performed locally on the first device 11. Similarly, most of the calculations related to the service parameters of the second device 12 during the service parameter comparison process are performed locally on the second device 12. The first device 11 and the second device 12 can be user terminals, servers, and other devices, and the types of the first device 11 and the second device 12 are not limited here.
[0034] The following describes the service parameter comparison method, device, system and storage medium provided in this application.
[0035] A first aspect of the present application provides a method for comparing service parameters, which can be applied to a first device, that is, the method for comparing service parameters can be executed by the first device. Figure 2 is a flowchart of the method for comparing service parameters provided in an embodiment of the first aspect of the present application. As shown in Figure 2, the method for comparing service parameters can include steps S201 to S203.
[0036] In step S201, a first binary string obtained by converting a first service parameter of a first device and a randomly generated 2 N The first tag string and the 2 N An initial random string is used to obtain a first interaction string and a first result string.
[0037] The first business parameters include the business parameters of the first party to which the first device belongs. The business parameters can be used in various business implementation scenarios, such as business scoring, machine learning, business model training, business data statistics, sorting, etc. The specific types of business parameters are not limited here.
[0038] The first binary string is a binary string obtained by converting the first service parameter. The first binary string includes 2 N bits, where N is a positive integer. For example, the first binary string may include 4 bits, 8 bits, 16 bits, 32 bits, 64 bits, or more bits, and may be set based on application scenarios and requirements. In some examples, to improve the accuracy of business parameter comparison, N may be set to ≥ 4.
[0039] The first tag string is randomly generated by the first device. The number of first tag strings is the same as the number of bits in the first binary string. For example, if the first binary string includes four bits, the first device randomly generates four first tag strings, correspondingly, one first tag string for each bit in the first binary string. The first tag string can be used to identify the value of the corresponding bit in the first binary string. In some examples, the number of bits in each first tag string is the same as the number of bits in the first binary string, but this is not limited to this.
[0040] The initial random string is a randomly generated string predetermined by the first device and the second device, and the initial random string in the first device is the same as the initial random string in the second device. In some examples, the DH algorithm (i.e., the Diffie-Hellman algorithm) can be used to complete the secret key interaction between the first device and the second device without directly transmitting the original secret key, thereby obtaining a shared random number seed, which can be used to generate an initial random string in each of the first device and the second device. That is, the first device generates an initial random string using the random number seed, and the second device also generates an initial random string using the random number seed. The number of initial random strings is the same as the number of bits in the first binary string and the number of bits in the second binary string. For example, the first device can select a prime number p, a base g, and a random number a, and then calculate A=g a (mod p), the first device sends the prime number p, the base g, and the calculated A to the second device. The second device can select a random number b and calculate B = g b (mod p) and s1 = A b (mod p), the second device can send the calculated B to the first device, and the first device calculates s2 = B a (mod p), s2 calculated by the first device is equal to s1 calculated by the second device, and s1 can be used as the random number seed. For example, if p = 509, g = 5, a = 123, and b = 456, then the calculated A = 215, B = 181, and the calculated s1 = s2 = 121, so 121 can be used as the random number seed. It should be noted that the random number seed s1 is not transmitted between the first device and the second device. s1 cannot be deduced from the A and B calculated using the prime number p and base g transmitted between the first device and the second device, thus ensuring the security of the random number seed. Since the first device and the second device use the DH algorithm to obtain a shared random number seed, there is no need to distribute the initial random string, which can further reduce the number of communication interactions between the first device and the second device, further improving the efficiency of service parameter comparison.
[0041] By calculating the first binary string, the first tag string, and the initial random string, a first interaction string and a first result string can be obtained. Specifically, the first interaction string and the first result string can be obtained using an exclusive-OR algorithm based on the first binary string, the first tag string, and the initial random string. The calculation of the first interaction string and the first result string is performed locally on the first device and does not involve any interaction with the second device, significantly reducing the time spent on communication interactions with the first device.
[0042] The first interaction string can be derived based on the first tag string and provided to the second device, so that the second device can obtain a second result string based on the first interaction string and its own generated information. The first device can establish an association with the first device using the first interaction string. It should be noted that the first service parameter cannot be derived from the first interaction string, thus ensuring the privacy and security of the first service parameter.
[0043] The first result string can be obtained based on the first tag string, the initial random string, and the first binary string. The first result string can represent the first binary string, but the first binary string cannot be derived from the first result string. The first result string can be used to perform a fragmentation calculation with the second result string generated by the second device to determine whether the first service parameter is equal to the second service parameter in the second device.
[0044] It should be noted that the first label string, the initial random string, the first interaction string, and the first result string are all binary strings.
[0045] In step S202, the first interaction string is sent to the second device, so that the second device obtains a second result string based on the second binary string converted by the second service parameter of the second device, the initial random string, the randomly generated partial second label string and the first interaction string.
[0046] In step S202, the first device performs a communication interaction with the second device and sends a first interaction string to the second device. After receiving the first interaction string, the second device can obtain a second result string based on the second binary string, the initial random string, the randomly generated partial second tag string, and the received first interaction string.
[0047] The second service parameters include service parameters of the second party to which the second device belongs. For specific contents of the service parameters, please refer to the relevant descriptions in the above embodiments and will not be repeated here.
[0048] The second binary string is a binary string obtained by converting the second service parameter. N bits, the number of bits in the second binary string is the same as the number of bits in the first binary string.
[0049] The initial random string in the second device is the same as the initial random string in the first device. For details, please refer to the relevant description in the above embodiment, which will not be repeated here.
[0050] A portion of the second tag string in the second device is randomly generated by the second device, and the other portion is obtained based on the randomly generated portion of the second tag string and the received first interaction string. The number of the second tag string is the same as the number of bits in the second binary string. In some examples, the second device randomly generates 2 N -1 second tag string, the randomly generated second tag string may include the first second tag string to the second N -1 second label string, 2nd N The second tag string can be based on the first second tag string to the second N -1 second tag string, and the first interaction string. For example, the second binary string includes 4 bits. Correspondingly, the second device randomly generates 3 second tag strings. The fourth second tag string can be obtained based on the first 3 randomly generated second tag strings and the first interaction string. Each bit in the second binary string corresponds to a second tag string. The second tag string can be used to identify the value of the corresponding bit in the second binary string. In some examples, the number of bits in each second tag string is the same as the number of bits in the second binary string, but this is not limited to this.
[0051] The second result string can be obtained based on the second binary string, the initial random string, the randomly generated second tag string, and the first interaction string. The second result string can represent the second binary string, but the second binary string cannot be derived from the second result string. The second result string can be used to perform a fragmented calculation with the first result string generated by the first device to determine whether the second service parameter is equal to the first service parameter in the first device.
[0052] It should be noted that the second label character string and the second result character string are both binary character strings.
[0053] In step S203, the first result character string and the second result character string are interacted with the second device to perform fragmentation calculation to obtain a first comparison result.
[0054] The fragmented calculation may include fragmented subtraction. The first device may fragment the first result string, and the second device may fragment the second result string. The first and second devices then perform a multi-party secure computation of the fragmented subtraction to obtain a first comparison result. The first comparison result may indicate whether the first and second result strings are equal, and thus whether the first and second service parameters are equal. The fragmented calculation only involves a few communication interactions between the first and second devices, resulting in a very small number of communication interactions. For example: the first device may fragment the first result string to obtain a first fragment and a second fragment, and the sum of the first fragment and the second fragment is the first result string; the second device may fragment the second result string to obtain a third fragment and a fourth fragment, and the sum of the third fragment and the fourth fragment is the second result string; the first device and the second device exchange the first fragment and the third fragment; the first device calculates a first difference between the first fragment and the third fragment; the second device calculates a second difference between the fourth fragment and the second fragment; the first device sends the first difference to the second device, or the second device sends the second difference to the first device; the first device or the second device calculates the difference between the first difference and the second difference; if the difference is zero, the first comparison result indicates that the first business parameter is equal to the second business parameter; if the difference is not zero, the first comparison result indicates that the first business parameter is not equal to the second business parameter.
[0055] In an embodiment of the present application, a first device locally calculates a first interaction string and a first result string based on a first binary string, a first tag string, and an initial random string converted from its own first business parameter. The first device then sends the first interaction string to a second device. The second device locally calculates a second result string based on a second binary string, a second tag string, an initial random string, and the first interaction string converted from its own second business parameter. The first and second devices interact with each other, performing fragmented calculations to obtain a first comparison result of whether the first and second business parameters are equal. The majority of the calculations in the entire process are performed locally on the first and second devices. Only a very small amount of communication interaction occurs between the first and second devices during the transmission and fragmented calculation of the first interaction string, reducing the number of communication interactions between the first and second devices and thereby improving the efficiency of multi-party business parameter comparisons. Furthermore, the plaintext of the first business parameters in the first device and the second business parameters in the second device are not leaked, ensuring privacy and security. This makes it ideal for scenarios such as federated learning and secure intersection.
[0056] In some embodiments, the first interaction string and the first result string can be calculated using an XOR algorithm. Figure 3 is a flowchart of a method for comparing service parameters provided by another embodiment of the first aspect of the present application. The difference between Figure 3 and Figure 2 is that step S201 in Figure 2 can be specifically refined into steps S2011 to S2013 in Figure 3.
[0057] In step S2011, a first interactive character string is obtained according to the first tag character string using an exclusive OR algorithm.
[0058] The number of the first tag string is the same as the number of bits in the first binary string. N For example, N=2, the first device randomly generates 4 first tag strings, namely a0_0, a1_0, a2_0 and a3_0, then the first interaction string in, It is the XOR calculation symbol.
[0059] In step S2012, based on the first tag string and the initial random string, an XOR algorithm is used to obtain 2 N A third label string.
[0060] The first label string can represent that the value of the corresponding bit in the first binary string is 0. The third label string can represent that the value of the corresponding bit in the first binary string is 1. The number of initial random strings is the same as the number of bits in the first binary string. The first label string and the initial random string corresponding to each bit of the first binary string can be XORed to obtain the third label string corresponding to each bit of the first binary string. For example, N=2, the first device randomly generates 4 first label strings, namely a0_0, a1_0, a2_0 and a3_0; the first device randomly generates 4 initial random strings, namely r0, r1, r2 and r3; then the generated 4 third label strings are a0_1, a1_1, a2_1 and a3_1, respectively, where, The bits of the first binary string are the first to the fourth from the left to the right, a0_0, a0_1, and r0 correspond to the first bit of the first binary string, a1_0, a1_1, and r1 correspond to the second bit of the first binary string, a2_0, a2_1, and r2 correspond to the third bit of the first binary string, and a3_0, a3_1, and r3 correspond to the fourth bit of the first binary string.
[0061] In step S2013 , a first result string is obtained based on the first label string, the third label string, and the first binary string.
[0062] Each bit of the first binary string has a value of 0 or 1. The first tag string and / or third tag string used for the exclusive-OR calculation can be determined based on the bit values of the first binary string. Specifically, the first device can select the first tag string and / or third tag string corresponding to the bit values in the first binary string; and use the exclusive-OR algorithm based on the selected first tag string and / or third tag string to obtain a first result string.
[0063] If the value of a bit in the first binary string is 0, the first label string corresponding to the bit is selected; if the value of a bit in the first binary string is 1, the third label string corresponding to the bit is selected. Perform an XOR algorithm on the selected first label string and / or third label string to obtain a first result string. For example, N=2, corresponding to the four bits of the first binary string, the first label strings are a0_0, a1_0, a2_0 and a3_0, and the third label strings are a0_1, a1_1, a2_1 and a3_1. If the first binary string is 0001, the first bit value is 0, the first label string a0_0 is selected, the second bit value is 0, the first label string a1_0 is selected, the third bit value is 0, the first label string a2_0 is selected, the fourth bit value is 1, the third label string a3_1 is selected, and the first result string
[0064] In some embodiments, the second result string is obtained by the second device based on the second label string, the fourth label string, and the second binary string. The second label string indicates that the value of the corresponding bit in the second binary string is 0. A portion of the second label string is obtained using an exclusive-OR algorithm based on another randomly generated portion of the second label string and the first interaction string. The fourth label string indicates that the value of the corresponding bit in the second binary string is 1. The fourth label string is obtained by the second device using an exclusive-OR algorithm based on the second label string and the initial random string.
[0065] The number of the second tag character strings is the same as the number of bits of the second binary character string, and the second device randomly generates the first second tag character strings to the second N -1 second label string, for the 1st second label string to the 2nd N -1 second label string, and the first interaction string are XORed to obtain the second NFor example, N=2, the first interaction string is a_0, and the second device randomly generates 3 second tag strings, namely b0_0, b1_0 and b2_0. Then the fourth second tag string is
[0066] The second label string corresponding to each bit of the second binary string and the initial random string can be XORed to obtain a fourth label string corresponding to each bit of the second binary string. For example, N = 2, the initial random strings are r0, r1, r2, and r3, and the second label strings are b0_0, b1_0, b2_0, and b3_0, respectively. Then, the four fourth label strings generated are b0_1, b1_1, b2_1, and b3_1, respectively. The bits of the second binary string are the first to the fourth from the left to the right, b0_0, b0_1, and r0 correspond to the first bit of the second binary string, b1_0, b1_1, and r1 correspond to the second bit of the second binary string, b2_0, b2_1, and r2 correspond to the third bit of the second binary string, and b3_0, b3_1, and r3 correspond to the fourth bit of the second binary string.
[0067] Each bit of the second binary string has a value of 0 or 1. The second device may determine the second tag string and / or fourth tag string for exclusive-OR calculation based on the bit values of the second binary string. Specifically, the second device may select the second tag string and / or fourth tag string corresponding to the bit values in the second binary string; and obtain the second result string using an exclusive-OR algorithm based on the selected second tag string and / or fourth tag string.
[0068] If the value of a bit in the second binary string is 0, the second label string corresponding to the bit is selected; if the value of a bit in the second binary string is 1, the fourth label string corresponding to the bit is selected. Perform an XOR algorithm on the selected second label string and / or fourth label string to obtain a second result string. For example, N=2, corresponding to the four bits of the second binary string, the second label strings are b0_0, b1_0, b2_0 and b3_0, and the fourth label strings are b0_1, b1_1, b2_1 and b3_1. If the second binary string is 1001, the value of the first bit is 1, and the fourth label string b0_1 is selected. The value of the second bit is 0, and the second label string b1_0 is selected. The value of the third bit is 0, and the second label string b2_0 is selected. The value of the fourth bit is 1, and the fourth label string b3_1 is selected. The second result string
[0069] In some embodiments, when the first service parameter and the second service parameter are unequal, the magnitude relationship between the first service parameter and the second service parameter needs to be determined. The first device and the second device can each compare the first binary string and the second binary string in half. The binary comparison here refers to splitting the first binary string and the second binary string into a high-order string and a low-order string with equal bit numbers, comparing the high-order string of the first binary string with the high-order string of the second binary string, and comparing the low-order string of the first binary string with the low-order string of the second binary string. The comparison between the high-order strings and the comparison between the low-order strings can also be performed by comparing the first service parameter and the second service parameter for equality as described in the above embodiment. If at least one of the high-order string and the low-order string is unequal, the unequal high-order string and / or the low-order string can be compared again in half until the number of bits in the newly split high-order string and the newly split low-order string is 1. The magnitude relationship between the first service parameter and the second service parameter can then be determined based on the value of this bit.
[0070] FIG4 is a flowchart of a method for comparing service parameters provided in yet another embodiment of the first solution of the present application. FIG4 differs from FIG2 in that the method for comparing service parameters may further include steps S204 to S211.
[0071] In step S204, when the first comparison result indicates that the first service parameter is not equal to the second service parameter, the first binary character string is split in the middle to obtain two first target character strings.
[0072] The first target string includes a high-order string and a low-order string. That is, one of the two first target strings is a high-order string and the other is a low-order string. The high-order string is located at a relatively high position in the segmented string, and the low-order string is located at a relatively low position in the segmented string. For example, the first target string is 01101010. The number of bits in the first target string is 8. From left to right, that is, from high to low, the first to eighth bits are respectively. The first to fourth bits correspond to 0110, which is the high-order string, and the fifth to eighth bits correspond to 1010, which is the low-order string.
[0073] In step S205 , based on the first target string, the first label string corresponding to the first target string, and the initial random string, a target interaction string corresponding to the first target string and a first target result string are obtained.
[0074] The first device may perform step S205 on the high-order string and the low-order string, respectively. Based on the high-order string, the first tag string corresponding to the high-order string, and the initial random string corresponding to the high-order string, the first device may obtain the target interaction string and the first target result string corresponding to the high-order string. Based on the low-order string, the first tag string corresponding to the low-order string, and the initial random string corresponding to the low-order string, the first device may obtain the target interaction string and the first target result string corresponding to the low-order string.
[0075] The target interaction string can be derived based on the first tag string corresponding to the first target string. The target interaction string can be provided to the second device, allowing the second device to obtain a second target result string based on the target interaction string and its own generated information. The first device can use the target interaction string to establish an association with the first device. It should be noted that the first target string cannot be derived from the target interaction string.
[0076] The first target result string can be obtained based on the first target string, the first tag string corresponding to the first target string, and the initial random string corresponding to the first target string. The first target result string can represent the first target result string, but the first target string cannot be derived from the first target result string. The first target result string can be used to perform a fragmentation calculation with the second result string generated by the second device to determine whether the first target string is equal to the second target string in the second device.
[0077] The calculation of step S205 is similar to the calculation of step S201 and steps S2011 to S2013 in the above embodiment, and reference may be made to the relevant content in the above embodiment. The target interaction string can be obtained using an exclusive-OR algorithm based on the first label string corresponding to the first target string; the third label string corresponding to the first target string can be obtained using an exclusive-OR algorithm based on the first label string corresponding to the first target string and the initial random string corresponding to the first target string; and the first target result string can be obtained based on the first label string corresponding to the first target string, the third label string corresponding to the first target string, and the first target string. The third target string corresponding to the first target string can also be directly obtained from the third label string calculated in step S2012.
[0078] For example, if N=2, the number of bits in the first target string is 2. If the four first label strings in the first device are a0_0, a1_0, a2_0, and a3_0, and the initial random strings are r0, r1, r2, and r3, then the first label strings corresponding to the high-order strings include a0_0 and a1_0, and the target interaction strings corresponding to the high-order strings are The initial random strings corresponding to the high-order strings are r0 and r1, and the third label strings corresponding to the high-order strings are a0_1 and a1_1. The first tag string corresponding to the low-order string includes a2_0 and a3_0, and the target interaction string corresponding to the low-order string The initial random strings corresponding to the low-order strings are r2 and r3, and the third label strings corresponding to the low-order strings are a2_1 and a3_1. If the value of a bit in the first target string is 0, the first tag string corresponding to the bit is selected; if the value of a bit in the first target string is 1, the third tag string corresponding to the bit is selected; perform an XOR algorithm on the selected first tag string and / or third tag string to obtain the first target result string. If the high-order string is 01, the first target result string corresponding to the high-order string is If the low-order string is 10, the first target result string corresponding to the low-order string
[0079] In step S206, the target interaction string is sent to the second device, so that the second device obtains a second target result string corresponding to the second target string based on the second target string, the target interaction string, a portion of the second label string corresponding to the second target string, and the initial random string.
[0080] The second target string includes a high-order string and a low-order string obtained by splitting the second binary string. Specifically, one second target string is a high-order string, and the other second target string is a low-order string. The details of the high-order string and the low-order string can be found in the description of the above embodiment and are not further described here.
[0081] The second device may obtain a second target result string corresponding to the second target string based on the second target string, the target interaction string, a portion of the second label string corresponding to the second target string, and the initial random string. The second device may obtain a second target result string corresponding to the high-order string based on the high-order string obtained by segmenting the second binary string, the target interaction string, the second label string corresponding to the high-order string, and the initial random string corresponding to the high-order string. The second device may obtain a second target result string corresponding to the low-order string based on the low-order string obtained by segmenting the second binary string, the target interaction string, the second label string corresponding to the low-order string, and the initial random string corresponding to the low-order string.
[0082] The second target result string can be obtained based on the second target string, the target interaction string, the second tag string corresponding to the second target string, and the initial random string corresponding to the second target string. The second target result string can represent the second target result string, but the second target string cannot be derived from the second target result string. The second target result string can be used to perform a fragmentation calculation with the first result string generated by the first device to determine whether the second target string is equal to the first target string in the first device.
[0083] In step S207 , the second device interacts with the first target result character string and the second target character string to perform fragmentation calculation to obtain a comparison sub-result.
[0084] The specific content of the fragmentation calculation can be referred to the relevant content in the above embodiment, which will not be repeated here. The comparison sub-result can indicate whether the first target string is equal to the second target string.
[0085] In step S208 , when the comparison sub-result indicates that the first target string is not equal to the second target string, the first target string is split in the middle to obtain a new first target string, and a new comparison sub-result is obtained based on the new first target string.
[0086] The new first target string may include a high-order string and a low-order string obtained by splitting the original first target string from the middle. The step of obtaining a new comparison sub-result based on the new first target string may include: obtaining a new target interaction string and a new first target result string corresponding to the new first target string based on the new first target string, the first label string corresponding to the new first target string, and the initial random string; sending the new target interaction string to the second device so that the second device obtains a new second target result string corresponding to the new second target string based on the new second target string, the new target interaction string, the partial second label string corresponding to the new second target string, and the initial random string; and interacting with the second device based on the new first target result string and the new second target result string to perform fragmentation calculation to obtain a new comparison sub-result.
[0087] The above steps may be repeated until a new comparison sub-result indicates that the new first target string is equal to the new second target string, or until the new first target string is a single-digit binary number, and a second comparison result is obtained. The second comparison result may indicate the magnitude relationship between the first service parameter and the second service parameter. The second comparison result indicates that the first service parameter is greater than the second service parameter, or the first service parameter is less than the second service parameter.
[0088] That is, if the new comparison sub-result indicates that the new first target string is equal to the new second target string, step S209 is executed; if the new comparison sub-result indicates that the new first target string is not equal to the new second target string, step S210 is executed.
[0089] In step S209, the new first target character string is not processed. Correspondingly, the second device also does not process the new second target character string.
[0090] If the new first target character string is equal to the new second target character string, there is no point in continuing the comparison. Therefore, the new first target character string and the new second target character string may not be further processed.
[0091] In step S210 , it is determined whether the number of bits in the new first target character string is 1.
[0092] The number of bits in the new first target string is equal to the number of bits in the new second target string. If the new first target string is not equal to the new second target string, further comparison is required to determine the size relationship between the new first target string and the new second target string, thereby determining the size relationship between the first business parameter and the second business parameter. If the number of bits in the new first target string and the new second target string is 1, the second comparison result can be obtained directly. If the number of bits in the new first target string and the new second target string is not 1, it is necessary to continue the half-comparison and repeat the above steps to obtain the new first target result string and the new second target result string.
[0093] That is, if the number of bits in the new first target string and the new second target string is 1, execute step S211; if the number of bits in the new first target string and the new second target string is not 1, return to step S208, execute step S208 to split the first target string in the middle to obtain a new first target string, and obtain the content of a new comparison sub-result based on the new first target string.
[0094] In step S211 , a second comparison result is obtained based on the new first target result character string and the new second target result character string.
[0095] When the number of bits in the new first target string and the new second target string is 1, and the new first target string and the new second target string are not equal, one of the new first target string and the new second target string must be 0 and the other must be 1, 1>0, and a second comparison result can be obtained.
[0096] In some examples, when the new second target string is a binary number, the second label string corresponding to the new second target string is updated by the second device based on the original second label string corresponding to the new second target string and the new target interaction string, and the fourth label string corresponding to the new second target string is obtained by the second device based on the updated second label string corresponding to the new second target string and the initial random string.
[0097] For example, if N=2 and the third bit of the second binary string is the new second target string, then the updated second label string corresponding to the new second target string is b2_0 on the left side of the equal sign is the updated second label string corresponding to the new second target string, b2_0 on the right side of the equal sign is the original second label string corresponding to the new second target string, and a_0 on the right side of the equal sign is the new target interaction string; correspondingly, the fourth label string corresponding to the new second target string b2_0 on the right side of the equal sign is the updated second label string corresponding to the new second target string, and r2 on the right side of the equal sign is the initial random string corresponding to the new second target string.
[0098] In the above embodiment, when it is necessary to obtain the magnitude relationship between the first business parameter and the second business parameter, a binary comparison method can be used for step-by-step judgment. The calculation of the association between the first target string and the second target string obtained in each binary comparison can be performed in parallel, shortening the calculation time, thereby further improving the efficiency of the business parameter comparison.
[0099] A second aspect of the present application provides a method for comparing service parameters, which can be applied to a second device, that is, the method for comparing service parameters can be executed by the second device. Figure 5 is a flowchart of the method for comparing service parameters provided in an embodiment of the second aspect of the present application. As shown in Figure 5, the method for comparing service parameters can include steps S301 to S303.
[0100] In step S301, a first interaction character string sent by a first device is received.
[0101] The first interaction character string is obtained by the first device based on N randomly generated first label character strings.
[0102] In step S302, a second result string is obtained based on a second binary string converted from a second service parameter of the second device, an initial random string, a randomly generated partial second label string, and the first interaction string.
[0103] The second binary string contains 2 N bits, N is a positive integer.
[0104] In step S303, the first device interacts with the first result string and the second result string to perform fragmentation calculation to obtain a first comparison result.
[0105] The first result string is obtained by the first device converting the first binary string obtained based on the first service parameter of the first device, the first label string, and the N initial random strings agreed upon by the first device and the second device. The first comparison result indicates whether the first service parameter is equal to the second service parameter. The first binary string includes 2 N bits.
[0106] In some examples, N≥4.
[0107] The specific contents of the above steps S301 to S303 can be found in the relevant descriptions in the above embodiments, which will not be repeated here.
[0108] In an embodiment of the present application, a first device locally calculates a first interaction string and a first result string based on a first binary string, a first tag string, and an initial random string converted from its own first business parameter. The first device then sends the first interaction string to a second device. The second device locally calculates a second result string based on a second binary string, a second tag string, an initial random string, and the first interaction string converted from its own second business parameter. The first and second devices interact with each other, performing fragmented calculations to obtain a first comparison result of whether the first and second business parameters are equal. The majority of the calculations in the entire process are performed locally on the first and second devices. Only a very small amount of communication interaction occurs between the first and second devices during the transmission and fragmented calculation of the first interaction string, reducing the number of communication interactions between the first and second devices and thereby improving the efficiency of multi-party business parameter comparisons. Furthermore, the plaintext of the first business parameters in the first device and the second business parameters in the second device are not leaked, ensuring privacy and security. This makes it ideal for scenarios such as federated learning and secure intersection.
[0109] Figure 6 is a flowchart of a method for comparing business parameters provided by another embodiment of the second aspect of the present application. The difference between Figure 6 and Figure 5 is that step S302 in Figure 5 can be specifically refined into steps S3021 to S3023 in Figure 6.
[0110] In step S3021, another part of the second label character string is obtained by using an exclusive OR algorithm based on a part of the randomly generated second label character string and the first interaction character string.
[0111] In step S3022, a fourth label character string is obtained according to the second label character string and the initial random character string.
[0112] The second tag string indicates that the value of the corresponding bit in the second binary string is 0. The fourth tag string indicates that the value of the corresponding bit in the second binary string is 1;
[0113] In step S3023 , a second result string is obtained based on the second label string, the fourth label string, and the second binary string.
[0114] In some examples, the second device may select a second label string and / or a fourth label string corresponding to the value of the bit in the second binary string; and obtain a second result string using an XOR algorithm based on the selected second label string and / or fourth label string.
[0115] The specific contents of the above steps S3021 to S3023 can be found in the relevant descriptions in the above embodiments and will not be repeated here.
[0116] In some embodiments, the first result string is obtained by the first device based on the first tag string, the third tag string, and the first binary string. The first tag string indicates that the value of the corresponding bit in the first binary string is 0. The third tag string indicates that the value of the corresponding bit in the first binary string is 1. The third tag string is obtained by the first device using an exclusive OR algorithm based on the first tag string and the initial random string.
[0117] FIG7 is a flowchart of a method for comparing service parameters provided in another embodiment of the second aspect of the present application. FIG7 differs from FIG5 in that the method for comparing service parameters shown in FIG7 may further include steps S304 to S311.
[0118] In step S304, when the first comparison result indicates that the first service parameter is not equal to the second service parameter, the second binary character string is split in the middle to obtain two second target character strings.
[0119] The second target character string includes an upper character string and a lower character string.
[0120] In step S305 , a target interaction character string sent by the first device is received.
[0121] The target interaction string is obtained by the first device based on the first target string, the first tag string corresponding to the first target string, and the initial random string. The first target string includes a high-order string and a low-order string obtained by splitting the first binary string from the middle.
[0122] In step S306 , a second target result string corresponding to the second target string is obtained based on the second target string, the target interaction string, a portion of the second label string corresponding to the second target string, and the initial random string.
[0123] In step S307 , the first device interacts with the first target result character string and the second target result character string to perform fragmentation calculation to obtain comparison sub-results.
[0124] The comparison sub-result indicates whether the first target character string is equal to the second target character string.
[0125] In step S308 , when the comparison sub-result indicates that the first target string is not equal to the second target string, the second target string is split in the middle to obtain a new second target string, and a new comparison sub-result is obtained based on the new second target string.
[0126] The new second target string may include a high-order string and a low-order string obtained by splitting the original second target string from the middle. The step of obtaining a new comparison sub-result based on the new second target string may include: obtaining a new second target result string corresponding to the new second target string based on the new second target string, a new target interaction string, a second tag string corresponding to the new second target string, and an initial random string; and interacting with the first device based on the new first target result string and the new second target result string to perform fragmentation calculation to obtain a new comparison sub-result.
[0127] The above steps may be repeated until a new comparison sub-result indicates that the new first target string is equal to the new second target string, or until the new second target string is a single-digit binary number, and a second comparison result is obtained. The second comparison result indicates that the first service parameter is greater than the second service parameter, or the first service parameter is less than the second service parameter.
[0128] That is, if the new comparison sub-result indicates that the new first target string is equal to the new second target string, step S309 is executed; if the new comparison sub-result indicates that the new first target string is not equal to the new second target string, step S310 is executed.
[0129] In step S309, the new second target character string is not processed. Correspondingly, the first device also does not process the new first target character string.
[0130] In step S310 , it is determined whether the number of bits in the new second target character string is 1.
[0131] The number of bits in the new second target string is equal to the number of bits in the new first target string. If the new first target string is not equal to the new second target string, further comparison is required to determine the size relationship between the new first target string and the new second target string, thereby determining the size relationship between the first business parameter and the second business parameter. If the number of bits in the new first target string and the new second target string is 1, the second comparison result can be obtained directly. If the number of bits in the new first target string and the new second target string is not 1, it is necessary to continue the half-comparison and repeat the above steps to obtain the new first target result string and the new second target result string.
[0132] That is, if the number of bits in the new first target string and the new second target string is 1, execute step S311; if the number of bits in the new first target string and the new second target string is not 1, return to step S308, execute step S308 to split the second target string in the middle to obtain a new second target string, and obtain the content of a new comparison sub-result based on the new second target string.
[0133] In step S311 , a second comparison result is obtained based on the new first target result character string and the new second target result character string.
[0134] In some examples, when the new second target string is a binary number, the second device can obtain an updated second label string corresponding to the new second target string based on the original second label string corresponding to the new second target string and the new target interaction string; and obtain a fourth label string corresponding to the new second target string based on the updated second label string corresponding to the new second target string and the initial random string. For details, please refer to the relevant description in the above embodiments and will not be repeated here.
[0135] The specific contents of the above steps S304 to S311 can be found in the relevant descriptions of the above embodiments, which will not be repeated here.
[0136] For ease of understanding, the following describes the comparison process of service parameters using two specific examples.
[0137] The service parameter comparison process is first described using an example where the first service parameter and the second service parameter are equal. Assume that the first service parameter is 9, the second service parameter is 9, the number of bits in the first binary string and the number of bits in the second binary string obtained by converting the first service parameter and the second service parameter are both 4, and the first binary string and the second binary string are both 1001. This service parameter comparison process may include steps c1 to c11.
[0138] In step c1, the first and second devices obtain a random seed using the DH algorithm. Using the random seed, the first and second devices each randomly generate initial random strings r0, r1, r2, and r3. r0 corresponds to the first bit of the first binary string, r1 corresponds to the second bit of the first binary string, r2 corresponds to the third bit of the first binary string, and r3 corresponds to the fourth bit of the first binary string. Here, r0 = 1111, r1 = 1101, r2 = 1100, and r3 = 1010.
[0139] In step c2, the first device randomly generates four first tag strings: a0_0, a1_0, a2_0, and a3_0. a0_0 corresponds to the first bit of the first binary string, a1_0 corresponds to the second bit of the first binary string, a2_0 corresponds to the third bit of the first binary string, and a3_0 corresponds to the fourth bit of the first binary string. Here, a0_0 = 0001, a1_0 = 1001, a2_0 = 1110, and a3_0 = 1001.
[0140] In step c3, the first device performs an XOR operation on the first tag string and the initial random string corresponding to the same bit position to obtain four third tag strings a0_1, a1_1, a2_1, and a3_1. a0_1 corresponds to the first bit of the first binary string, a1_1 corresponds to the second bit of the first binary string, a2_1 corresponds to the third bit of the first binary string, and a3_1 corresponds to the fourth bit of the first binary string.
[0141] In step c4, the first device performs an XOR operation on the four first tag character strings a0_0, a1_0, a2_0, and a3_0 to obtain a first interaction character string a_0.
[0142] In step c5, the first device sends the first interaction character string a_0 to the second device.
[0143] In step c6, the second device randomly generates three second tag strings: b0_0, b1_0, and b2_0. b0_0 corresponds to the first bit of the second binary string, b1_0 corresponds to the second bit of the second binary string, and b2_0 corresponds to the third bit of the second binary string. Here, b0_0 = 1011, b1_0 = 0011, and b2_0 = 1010.
[0144] In step c7, the second device performs an XOR operation on the second tag string b0_0, b1_0, b2_0 and the first interaction string a_0 to obtain the fourth second tag string b3_0.
[0145] In step c8, the second device performs an XOR operation on the second tag string and the initial random string corresponding to the same bit position to obtain four fourth tag strings b0_1, b1_1, b2_1, and b3_1. b0_1 corresponds to the first bit of the second binary string, b1_1 corresponds to the second bit of the second binary string, b2_1 corresponds to the third bit of the second binary string, and b3_1 corresponds to the fourth bit of the second binary string.
[0146] In step c9, the first device selects the third tag string a0_1, the first tag string a1_0, the first tag string a2_0, and the third tag string a3_1 according to the first binary string 1001, and performs an XOR operation on the selected first tag string and the third tag string to obtain a first result string z_a.
[0147] In step c10, the second device selects the fourth tag string b0_1, the second tag string b1_0, the second tag string b2_0 and the fourth tag string b3_1 according to the second binary string 1001, and performs an XOR operation on the selected second tag string and the fourth tag string to obtain a second result string z_b.
[0148] In step c11, the first device and the second device interact based on the first result string and the second result string, perform fragmentation calculation, and obtain a first comparison result. The first comparison result indicates that the first service parameter is equal to the second service parameter.
[0149] The service parameter comparison process is further described using an example where the first service parameter and the second service parameter are unequal. Assume that the first service parameter is 9, the second service parameter is 9, the number of bits in the first binary string and the number of bits in the second binary string obtained by converting the first service parameter and the second service parameter are both 4, the first binary string is 1000, and the second binary string is 1001. This service parameter comparison process may include steps d1 to d34.
[0150] In step d1, the first and second devices obtain a random seed using the DH algorithm. Using the random seed, the first and second devices each randomly generate initial random strings r0, r1, r2, and r3. r0 corresponds to the first bit of the first binary string, r1 corresponds to the second bit of the first binary string, r2 corresponds to the third bit of the first binary string, and r3 corresponds to the fourth bit of the first binary string. Here, r0 = 1111, r1 = 1101, r2 = 1100, and r3 = 1010.
[0151] In step d2, the first device randomly generates four first tag strings: a0_0, a1_0, a2_0, and a3_0. a0_0 corresponds to the first bit of the first binary string, a1_0 corresponds to the second bit of the first binary string, a2_0 corresponds to the third bit of the first binary string, and a3_0 corresponds to the fourth bit of the first binary string. Here, a0_0 = 0001, a1_0 = 1001, a2_0 = 1110, and a3_0 = 1001.
[0152] In step d3, the first device performs an XOR operation on the first tag string and the initial random string corresponding to the same bit position to obtain four third tag strings a0_1, a1_1, a2_1, and a3_1. a0_1 corresponds to the first bit of the first binary string, a1_1 corresponds to the second bit of the first binary string, a2_1 corresponds to the third bit of the first binary string, and a3_1 corresponds to the fourth bit of the first binary string.
[0153] In step d4, the first device performs an XOR operation on the four first tag strings a0_0, a1_0, a2_0, and a3_0 to obtain a first interaction string a_0.
[0154] In step d5, the first device sends the first interaction character string a_0 to the second device.
[0155] In step d6, the second device randomly generates three second tag strings: b0_0, b1_0, and b2_0. b0_0 corresponds to the first bit of the second binary string, b1_0 corresponds to the second bit of the second binary string, and b2_0 corresponds to the third bit of the second binary string. Here, b0_0 = 1011, b1_0 = 0011, and b2_0 = 1010.
[0156] In step d7, the second device performs an XOR operation on the second tag string b0_0, b1_0, b2_0 and the first interaction string a_0 to obtain the fourth second tag string b3_0.
[0157] In step d8, the second device performs an XOR operation on the second tag string and the initial random string corresponding to the same bit position to obtain four fourth tag strings b0_1, b1_1, b2_1, and b3_1. b0_1 corresponds to the first bit of the second binary string, b1_1 corresponds to the second bit of the second binary string, b2_1 corresponds to the third bit of the second binary string, and b3_1 corresponds to the fourth bit of the second binary string.
[0158] In step d9, the first device selects the third tag string a0_1, the first tag string a1_0, the first tag string a2_0, and the first tag string a3_0 according to the first binary string 1000, and performs an XOR operation on the selected first tag string and the third tag string to obtain a first result string z_a.
[0159] In step d10, the second device selects the fourth tag string b0_1, the second tag string b1_0, the second tag string b2_0 and the fourth tag string b3_1 according to the second binary string 1001, and performs an XOR operation on the selected second tag string and the fourth tag string to obtain a second result string z_b.
[0160] In step d11, the first device and the second device interact based on the first result string and the second result string, perform fragmentation calculation, and obtain a first comparison result. The first comparison result indicates that the first service parameter is not equal to the second service parameter.
[0161] In step d12 , the first device divides the first binary string 1000 into a high-order string 10 and a low-order string 00 .
[0162] In step d13, the first device obtains the first target result string corresponding to the high-order string 10 according to the third tag string a0_1 and the first tag string a1_0 corresponding to the high-order string 10.
[0163] In step d14, the first device obtains the target interaction item a_01 corresponding to the high-order string 10 according to the first tag strings a0_0 and a1_0 corresponding to the high-order string 10.
[0164] In step d15 , the first device sends the target interaction character string a_01 corresponding to the high-order character string to the second device.
[0165] In step d16 , the second device divides the second binary string 1001 into a high-order string 10 and a low-order string 01 .
[0166] In step d17, the second device obtains the second label string b1_0 corresponding to the second bit in the second binary string based on the second label string b0_0 corresponding to the first bit in the second binary string and the received target interaction string a_01.
[0167] In step d18, the second device can obtain the corresponding fourth tag strings b0_1 and b1_1 based on the second tag strings b0_0 and b1_0, and the initial random strings r0 and r1.
[0168] In step d19, the second device obtains the second target result string corresponding to the high-order string 10 according to the fourth tag string b0_1 and the second tag string b1_0 corresponding to the high-order string 10.
[0169] In step d20, the first device and the second device interact based on the first target result string z_a1 and the second target result string z_b1 to perform fragmentation calculations to obtain comparison sub-results. The comparison sub-results indicate that the high-order string 10 of the first binary string is equal to the high-order string 10 of the second binary string.
[0170] In step d21, the first device may repeat the calculations similar to steps d13 to d15 above on the low-order character string 00 to obtain the first target result character string z_a2; the second device may repeat the calculations similar to steps d17 to d19 above on the low-order character string 01 to obtain the second target result character string z_b2.
[0171] In step d22, the first device and the second device interact based on the first target result string z_a1 and the second target result string z_b1, perform fragmentation calculations, and obtain comparison sub-results. The comparison sub-results indicate that the low-order string 00 of the first binary string is not equal to the low-order string 01 of the second binary string.
[0172] In step d23 , the first device splits the unequal low-order string 00 into a new high-order string 0 and a new low-order string 0, where the new high-order string 0 is the third bit of the first binary string and the new low-order string 0 is the fourth bit of the first binary string.
[0173] In step d24, the first device obtains a new target interaction string a_021 according to the first tag string a2_0 corresponding to the third bit of the first binary number, where a_021=a2_0=1110.
[0174] In step d25, the first device obtains a third tag string a2_1 based on the first tag string a2_0 and the initial random string r2.
[0175] In step d26, the first device obtains a new first target result string z_a21 according to the first tag string a2_0 corresponding to the new high-order string 0, where z_a21=a2_0=1110.
[0176] In step d27 , the first device sends the new target interaction string a_021 to the second device.
[0177] In step d28 , the second device splits the unequal low-order string 01 into a new high-order string 0 and a new low-order string 1 , where the new high-order string 0 is the third bit of the second binary string and the new low-order string 1 is the fourth bit of the second binary string.
[0178] In step d29, the second device updates the second label string b2_0 according to the new target interaction string a_021 and the original second label string b2_0. The original second label string b2_0 = 1010, and the updated second label string
[0179] In step d30, the second device obtains a fourth tag string based on the updated second tag string b2_0 and the initial random string r2.
[0180] In step d31, the second device obtains a new first target result string z_b21 according to the second tag string b2_0 corresponding to the new high-order string 0, where z_b21=b2_0=1110.
[0181] In step d32, the first device and the second device interact based on the first target result string z_a21 and the second target result string z_b21, perform fragmentation calculations, and obtain a comparison sub-result. The comparison sub-result indicates that the value 0 of the third bit in the first binary string is equal to the value 0 of the third bit in the second binary string.
[0182] In step d33, the first device may repeat the calculations similar to those in steps d24 to d27 above on the new low-order string 0 (i.e., the value of the fourth bit of the first binary string) to obtain the first target result string z_a22; the second device may repeat the calculations similar to those in steps d29 to d32 above on the new low-order string 1 (i.e., the value of the fourth bit of the second binary string) to obtain the second target result string z_b22.
[0183] In step d34, the first device and the second device interact based on the first target result string z_a21 and the second target result string z_b21 to perform fragmentation calculations and obtain a second comparison result, where the first service parameter is less than the second service parameter.
[0184] The service parameter comparison method of the embodiment of the present application can be applied to a variety of scenarios requiring service parameter comparison, which will not be described in detail here.
[0185] In some examples, in the scenario of using a neural network to train a business model, the linear rectifier function (Rectified Linear Unit, ReLu) f(x) = max(0, wx+b) can be used as the activation function of the neuron in the neural network to define the nonlinear output result of the neuron after the linear transformation wx+b. For the input vector from the previous layer of the neural network entering the neuron, the neuron using this activation function will output max(0, wx+b). The linear rectifier function has sparsity, which enables the sparse model to better mine relevant features and fit the training data. Figure 8 is a curve diagram of an example of a linear rectifier function provided in an embodiment of the present application. In the x>0 region in Figure 8, there will be no problems of gradient saturation and gradient disappearance, and the computational complexity is low. No exponential operation is required, and the activation value can be obtained with just one threshold. The hidden layer in the neural network selects the linear rectifier function as the activation function, which can ensure that the gradient is always 1 when z is greater than zero, thereby improving the computing speed of the neural network gradient descent algorithm. Variant functions derived from the aforementioned linear rectifier function, such as PRelu (Parametric Rectified Linear Unit) and LRelu (Leaky ReLU), can also be used as neuron activation functions. In the activation function formula, a comparison is made between 0 and wx+b to determine the magnitude relationship between them. During this comparison, leakage of wx+b must be prevented.
[0186] In some examples, business processing requires the use of sigmoid functions, which also require comparison of business parameters. Alternatively, business processing requires comparison to distinguish the boundaries of piecewise functions. Alternatively, in deep learning scenarios, the secure intersection (Private Set Intersection, PSI) step requires the densification of the intersection, which also requires comparison of certain business parameters.
[0187] FIG9 is a schematic diagram of the structure of a first device provided by an embodiment of the third aspect of the present application. As shown in FIG9 , the first device 400 includes a local computing module 401 and a communication module 402 .
[0188] The local calculation module 401 can be used to convert the first service parameter of the first device into a first binary string, the randomly generated 2 N The first tag string and the 2 N Initial random string, get the first interactive string and the first result string. The first binary string includes 2 N bits, N is a positive integer.
[0189] The communication module 402 is used to send the first interaction string to the second device, so that the second device can obtain a second result string based on the second binary string converted by the second service parameter of the second device, the initial random string, the randomly generated part of the second label string and the first interaction string. The second binary string includes 2 N bits.
[0190] The communication module 402 and the local calculation module 401 are further configured to interact with the second device based on the first result string and the second result string, perform fragmentation calculation, and obtain a first comparison result.
[0191] The first comparison result indicates whether the first service parameter is equal to the second service parameter.
[0192] In some examples, N≥4.
[0193] In an embodiment of the present application, a first device locally calculates a first interaction string and a first result string based on a first binary string, a first tag string, and an initial random string converted from its own first business parameter. The first device then sends the first interaction string to a second device. The second device locally calculates a second result string based on a second binary string, a second tag string, an initial random string, and the first interaction string converted from its own second business parameter. The first and second devices interact with each other, performing fragmented calculations to obtain a first comparison result of whether the first and second business parameters are equal. The majority of the calculations in the entire process are performed locally on the first and second devices. Only a very small amount of communication interaction occurs between the first and second devices during the transmission and fragmented calculation of the first interaction string, reducing the number of communication interactions between the first and second devices and thereby improving the efficiency of multi-party business parameter comparisons. Furthermore, the plaintext of the first business parameters in the first device and the second business parameters in the second device are not leaked, ensuring privacy and security. This makes it ideal for scenarios such as federated learning and secure intersection.
[0194] In some embodiments, the local computing module 401 is used to: obtain a first interactive string using an XOR algorithm based on the first tag string; obtain 2 using an XOR algorithm based on the first tag string and the initial random string. N A third label string, the first label string represents that the value of the corresponding bit in the first binary string is 0, and the third label string represents that the value of the corresponding bit in the first binary string is 1; based on the first label string, the third label string and the first binary string, a first result string is obtained.
[0195] In some examples, the local computing module 401 is used to: select a first label string and / or a third label string corresponding to the value of the bit in the first binary string; and obtain a first result string using an exclusive-OR algorithm based on the selected first label string and / or third label string.
[0196] In some embodiments, the second result string is obtained by the second device based on the second label string, the fourth label string, and the second binary string. The second label string indicates that the value of the corresponding bit in the second binary string is 0, and a portion of the second label string is obtained using an exclusive-OR algorithm based on another randomly generated portion of the second label string and the first interaction string. The fourth label string indicates that the value of the corresponding bit in the second binary string is 1, and the fourth label string is obtained by the second device using an exclusive-OR algorithm based on the second label string and the initial random string.
[0197] In some embodiments, the local computing module 401 can also be used to: when the first comparison result indicates that the first business parameter is not equal to the second business parameter, split the first binary string from the middle to obtain two first target strings, the first target string including a high-order string and a low-order string; based on the first target string, the first label string corresponding to the first target string and the initial random string, obtain the target interaction string and the first target result string corresponding to the first target string.
[0198] The communication module 402 may also be configured to transmit the target interaction string to the second device, so that the second device obtains a second target result string corresponding to the second target string based on the second target string, the target interaction string, a portion of the second tag string corresponding to the second target string, and the initial random string. The second target string includes a high-order string and a low-order string obtained by splitting the second binary string from the middle.
[0199] The local computing module 401 and the communication module 402 can also be used to interact with the second device based on the first target result string and the second target string to perform fragmented computing to obtain a comparison sub-result, which indicates whether the first target string is equal to the second target string.
[0200] The local computing module 401 and the communication module 402 can also be used to: when the comparison sub-result indicates that the first target string is not equal to the second target string, split the first target string in the middle to obtain a new first target string, and obtain a new comparison sub-result based on the new first target string, until the new comparison sub-result indicates that the new first target string is equal to the new second target string, or until the new first target string is a binary number, and a second comparison result is obtained, and the second comparison result indicates that the first business parameter is greater than the second business parameter or the first business parameter is less than the second business parameter.
[0201] In some embodiments, when the new second target string is a single-bit binary number, the second label string corresponding to the new second target string is updated by the second device based on the original second label string corresponding to the new second target string and the new target interaction string. The fourth label string corresponding to the new second target string is obtained by the second device based on the updated second label string corresponding to the new second target string and the initial random string.
[0202] FIG10 is a schematic diagram of the structure of a second device provided by an embodiment of the fourth aspect of the present application. As shown in FIG10 , the second device 500 includes a communication module 501 and a local computing module 502 .
[0203] The communication module 501 may be configured to receive a first interaction string sent by a first device. The first interaction string is obtained by the first device based on N randomly generated first tag strings.
[0204] The local calculation module 502 can be used to obtain a second result string based on the second binary string converted from the second service parameter of the second device, the initial random string, the randomly generated partial second tag string and the first interaction string. The second binary string includes 2 N bits, N is a positive integer.
[0205] The communication module 501 and the local calculation module 502 can also be used to interact with the first device based on the first result string and the second result string, perform fragmented calculations, and obtain a first comparison result. The first result string is obtained by the first device based on the first service parameter of the first device converted to obtain the first binary string, the first label string, and the N initial random strings agreed upon by the first device and the second device. The first comparison result indicates whether the first service parameter is equal to the second service parameter. The first binary string includes 2 N bits.
[0206] In some examples, N≥4.
[0207] In an embodiment of the present application, a first device locally calculates a first interaction string and a first result string based on a first binary string, a first tag string, and an initial random string converted from its own first business parameter. The first device then sends the first interaction string to a second device. The second device locally calculates a second result string based on a second binary string, a second tag string, an initial random string, and the first interaction string converted from its own second business parameter. The first and second devices interact with each other, performing fragmented calculations to obtain a first comparison result of whether the first and second business parameters are equal. The majority of the calculations in the entire process are performed locally on the first and second devices. Only a very small amount of communication interaction occurs between the first and second devices during the transmission and fragmented calculation of the first interaction string, reducing the number of communication interactions between the first and second devices and thereby improving the efficiency of multi-party business parameter comparisons. Furthermore, the plaintext of the first business parameters in the first device and the second business parameters in the second device are not leaked, ensuring privacy and security. This makes it ideal for scenarios such as federated learning and secure intersection.
[0208] In some embodiments, the local computing module 502 can be used to: obtain another part of the second label string based on a randomly generated part of the second label string and the first interaction string using an exclusive-OR algorithm; obtain a fourth label string based on the second label string and the initial random string, where the second label string represents that the value of the corresponding bit in the second binary string is 0, and the fourth label string represents that the value of the corresponding bit in the second binary string is 1; obtain a second result string based on the second label string, the fourth label string, and the second binary string.
[0209] In some examples, the local computing module 502 may be used to: select a second label string and / or a fourth label string corresponding to the value of a bit in the second binary string; and obtain a second result string using an XOR algorithm based on the selected second label string and / or fourth label string.
[0210] In some embodiments, the first result string is obtained by the first device based on the first tag string, the third tag string, and the first binary string. The first tag string indicates that the value of the corresponding bit in the first binary string is 0. The third tag string indicates that the value of the corresponding bit in the first binary string is 1. The third tag string is obtained by the first device using an exclusive-OR algorithm based on the first tag string and the initial random string.
[0211] In some embodiments, the local calculation module 502 may also be used to: when the first comparison result indicates that the first business parameter is not equal to the second business parameter, split the second binary string in the middle to obtain two second target strings, the second target strings including a high-order string and a low-order string.
[0212] The communication module 501 may also be configured to receive a target interaction string sent by the first device. The target interaction string is obtained by the first device based on a first target string, a first tag string corresponding to the first target string, and an initial random string. The first target string includes a high-order string and a low-order string obtained by splitting the first binary string from the middle.
[0213] The local calculation module 502 may also be configured to obtain a second target result string corresponding to the second target string based on the second target string, the target interaction string, a portion of the second label string corresponding to the second target string, and the initial random string.
[0214] The communication module 501 and the local calculation module 502 can also be used to: interact with the first device based on the first target result string and the second target result string, perform fragmented calculations, and obtain comparison sub-results, which represent whether the first target string is equal to the second target string.
[0215] The communication module 501 and the local computing module 502 may also be configured to: if the comparison sub-result indicates that the first target string and the second target string are not equal, split the second target string in the middle to obtain a new second target string, and obtain a new comparison sub-result based on the new second target string, until the new comparison sub-result indicates that the new first target string and the new second target string are equal, or until the new second target string is a single-digit binary number, and obtain a second comparison result. The second comparison result indicates that the first business parameter is greater than the second business parameter or the first business parameter is less than the second business parameter.
[0216] In some examples, the local computing module 502 can also be used to: when the new second target string is a binary number, obtain an updated second label string corresponding to the new second target string based on the original second label string corresponding to the new second target string and the new target interaction string; and obtain a fourth label string corresponding to the new second target string based on the updated second label string corresponding to the new second target string and the initial random string.
[0217] The fifth aspect of the present application further provides an electronic device. FIG11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the fifth aspect of the present application. As shown in FIG11 , the electronic device 600 includes a memory 601, a processor 602, and a computer program stored in the memory 601 and executable on the processor 602.
[0218] In some examples, the processor 602 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0219] The memory 601 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method for comparing business parameters in the embodiment of the first aspect of the present application or the method for comparing business parameters in the embodiment of the second aspect of the present application.
[0220] The processor 602 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 601, so as to implement the service parameter comparison method in the first aspect embodiment or the service parameter comparison method in the second aspect embodiment.
[0221] In some examples, the electronic device 600 may further include a communication interface 603 and a bus 604. As shown in FIG11 , the memory 601, the processor 602, and the communication interface 603 are connected via the bus 604 and communicate with each other.
[0222] The communication interface 603 is mainly used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. Input devices and / or output devices can also be connected through the communication interface 603.
[0223] The bus 604 includes hardware, software, or both that couples the components of the electronic device 600 to each other. By way of example and not limitation, the bus 604 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-E) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of the above. Where appropriate, the bus 604 may include one or more buses. Although embodiments herein describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.
[0224] In a sixth aspect, the present application provides a service parameter comparison system, which may include a first device and a second device. The first device may execute the service parameter comparison method of the first aspect embodiment, and the second device may execute the service parameter comparison method of the second aspect embodiment, and both achieve the same technical effect. To avoid repetition, these are not described here.
[0225] In a seventh aspect of the present application, a computer-readable storage medium is provided, on which a computer program instruction is stored. When the computer program instruction is executed by a processor, the method for comparing the service parameters in the first embodiment or the method for comparing the service parameters in the second embodiment can be implemented, and the same technical effect can be achieved. To avoid repetition, the details are not described here. The computer-readable storage medium may include a non-transitory computer-readable storage medium, such as a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which is not limited here.
[0226] An embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the service parameter comparison method in the above-mentioned first aspect embodiment or the service parameter comparison method in the second aspect embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0227] It should be clear that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For the first device embodiment, the second device embodiment, the electronic device embodiment, the system embodiment, the computer-readable storage medium embodiment, and the computer program product, the relevant parts can be referred to the description part of the method embodiment. This application is not limited to the specific steps and structures described above and shown in the figures. Those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of this application. In addition, for the sake of brevity, a detailed description of known method technologies is omitted here.
[0228] Aspects of the present application have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed via the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. This processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or the flowchart and the combination of the boxes in the block diagram and / or the flowchart can also be implemented by the dedicated hardware that performs the specified function or action, or can be implemented by the combination of dedicated hardware and computer instructions.
[0229] Those skilled in the art should understand that the above embodiments are illustrative rather than restrictive. Different technical features appearing in different embodiments can be combined to achieve beneficial effects. Based on a study of the drawings, the specification and the claims, those skilled in the art should be able to understand and implement other variations of the disclosed embodiments. In the claims, the term "comprising" does not exclude other devices or steps; the quantifier "one" does not exclude a plurality; the terms "first" and "second" are used to identify names rather than to indicate any specific order. Any figure marks in the claims should not be understood as limiting the scope of protection. The functions of multiple parts appearing in the claims can be implemented by a separate hardware or software module. The fact that certain technical features appear in different dependent claims does not mean that these technical features cannot be combined to achieve beneficial effects.
Claims
1. A method for comparing service parameters, applied to a first device, the method comprising: A first binary string obtained by converting the first service parameter of the first device, a randomly generated N a first tag string and 2 N An initial random string is obtained to obtain a first interactive string and a first result string, wherein the first binary string includes 2 N bits, N is a positive integer; The first interaction string is sent to the second device, so that the second device obtains a second result string based on a second binary string converted from a second service parameter of the second device, the initial random string, a randomly generated part of the second label string, and the first interaction string, wherein the second binary string includes 2 N bits; Interact with the second device based on the first result string and the second result string to perform fragmentation calculation to obtain a first comparison result, where the first comparison result indicates whether the first service parameter is equal to the second service parameter.
2. The method according to claim 1, wherein: the first binary string converted based on the first service parameter of the first device, the randomly generated N a first tag string and 2 N An initial random string is used to obtain a first interactive string and a first result string, including: Obtaining the first interaction string using an XOR algorithm according to the first tag string; According to the first tag string and the initial random string, using the XOR algorithm, 2 N a third label string, wherein the first label string indicates that the value of the corresponding bit in the first binary string is 0, and the third label string indicates that the value of the corresponding bit in the first binary string is 1; The first result string is obtained based on the first label string, the third label string and the first binary string.
3. The method according to claim 2, wherein: The obtaining the first result string based on the first label string, the third label string and the first binary string includes: Selecting the first label string and / or the third label string corresponding to the value of the bit in the first binary string; The first result string is obtained by using an exclusive-OR algorithm according to the selected first label string and / or the third label string.
4. The method according to claim 1, wherein: The second result string is obtained by the second device based on the second label string, the fourth label string and the second binary string. The second label string indicates that the value of the corresponding bit in the second binary string is 0, and a part of the second label string is obtained by using an XOR algorithm based on another part of the second label string and the first interactive string that are randomly generated. The fourth label string indicates that the value of the corresponding bit in the second binary string is 1, and the fourth label string is obtained by the second device according to the second label string and the initial random string by using an exclusive OR algorithm.
5. The method according to claim 1, further comprising: When the first comparison result indicates that the first service parameter is not equal to the second service parameter, the first binary string is split in the middle to obtain two first target strings, where the first target string includes a high-order string and a low-order string; Based on the first target string, the first label string corresponding to the first target string, and the initial random string, a target interaction string and a first target result string corresponding to the first target string are obtained; Sending the target interaction string to the second device, so that the second device obtains a second target result string corresponding to the second target string based on the second target string, the target interaction string, a part of the second label string corresponding to the second target string, and the initial random string, wherein the second target string includes a high-order string and a low-order string obtained by splitting the second binary string from the middle; Interacting with the second device based on the first target result string and the second target string to perform fragmentation calculation to obtain a comparison sub-result, wherein the comparison sub-result indicates whether the first target string is equal to the second target string; The comparison sub-result indicates that the first target character string and the second target character string are different. If the first target string and the second target string are equal, the first target string is split in the middle to obtain a new first target string, and a new comparison sub-result is obtained based on the new first target string, until the new comparison sub-result indicates that the new first target string is equal to the new second target string, or until the new first target string is a binary number, and a second comparison result is obtained, and the second comparison result indicates that the first business parameter is greater than the second business parameter or the first business parameter is less than the second business parameter.
6. The method according to claim 5, wherein: In the case where the new second target string is a binary number, the second label string corresponding to the new second target string is updated by the second device based on the original second label string corresponding to the new second target string and the new target interaction string. The fourth label string corresponding to the new second target string is obtained by the second device based on the updated second label string corresponding to the new second target string and the initial random string.
7. The method according to any one of claims 1 to 6, wherein: N≥4。 8. A method for comparing service parameters, applied to a second device, the method comprising: receiving a first interaction character string sent by the first device, where the first interaction character string is obtained by the first device based on N first label characters randomly generated; A second result string is obtained based on a second binary string converted from a second service parameter of the second device, the initial random string, a randomly generated partial second label string, and the first interaction string, wherein the second binary string includes 2 N bits, N is a positive integer; Interacting with the first device based on the first result string and the second result string, performing fragmentation calculation, and obtaining a first comparison result, wherein the first result string is obtained by the first device based on a first service parameter of the first device converted to obtain a first binary string, the first label string, and N initial random strings agreed upon by the first device and the second device, the first comparison result indicates whether the first service parameter is equal to the second service parameter, and the first binary string includes 2 N bits.
9. The method according to claim 8, wherein: The second result string is obtained by converting the second binary string obtained based on the second service parameter of the second device, the initial random string, the randomly generated partial second label string and the first interaction string, including: Obtain another part of the second label string by using an XOR algorithm according to a part of the second label string and the first interaction string that are randomly generated; A fourth label string is obtained according to the second label string and the initial random string, wherein the second label string indicates that a value of a corresponding bit in the second binary string is 0, and the fourth label string indicates that a value of a corresponding bit in the second binary string is 1; The second result string is obtained based on the second label string, the fourth label string and the second binary string.
10. The method according to claim 9, wherein: The obtaining the second result string based on the second label string, the fourth label string and the second binary string includes: Selecting the second label string and / or the fourth label string corresponding to the value of the bit in the second binary string; The second result string is obtained by using an exclusive-OR algorithm according to the selected second label string and / or the fourth label string.
11. The method according to claim 8, wherein: The first result string is obtained by the first device based on the first label string, the third label string and the first binary string. The first tag string indicates that the value of the corresponding bit in the first binary string is 0. The third label string indicates that the value of the corresponding bit in the first binary string is 1, and the third label string is obtained by the first device according to the first label string and the initial random string by using an exclusive OR algorithm.
12. The method according to claim 8, further comprising: When the first comparison result indicates that the first service parameter is not equal to the second service parameter, the second binary string is split in the middle to obtain two second target characters. string, the second target string includes a high-order string and a low-order string; receiving a target interaction string sent by the first device, wherein the target interaction string is obtained by the first device based on a first target string, the first label string corresponding to the first target string, and the initial random string, wherein the first target string includes a high-order string and a low-order string obtained by splitting the first binary string from the middle; Obtaining a second target result string corresponding to the second target string based on the second target string, the target interaction string, a portion of the second label string corresponding to the second target string, and the initial random string; Interacting with the first device based on the first target result string and the second target result string, performing fragmentation calculation, and obtaining a comparison sub-result, wherein the comparison sub-result indicates whether the first target string is equal to the second target string; When the comparison sub-result indicates that the first target string is not equal to the second target string, the second target string is split in the middle to obtain a new second target string, and a new comparison sub-result is obtained based on the new second target string, until the new comparison sub-result indicates that the new first target string is equal to the new second target string, or until the new second target string is a binary number, and a second comparison result is obtained, wherein the second comparison result indicates that the first business parameter is greater than the second business parameter or the first business parameter is less than the second business parameter.
13. The method according to claim 12, wherein: In the case where the new second target string is a binary number, based on the original second label string corresponding to the new second target string and the new target interaction string, an updated second label string corresponding to the new second target string is obtained; The fourth label string corresponding to the new second target string is obtained based on the updated second label string corresponding to the new second target string and the initial random string.
14. The method according to any one of claims 8 to 13, wherein: N≥4。 15. A first device, comprising: A local computing module is configured to obtain a first service parameter based on the first service parameter of the first device. A binary string, randomly generated 2 N a first tag string and 2 N An initial random string is obtained to obtain a first interactive string and a first result string, wherein the first binary string includes 2 N bits, N is a positive integer; a communication module, configured to send the first interaction string to the second device, so that the second device obtains a second result string based on a second binary string converted from a second service parameter of the second device, the initial random string, a randomly generated partial second label string, and the first interaction string, wherein the second binary string includes 2 N bits; The communication module and the local calculation module are also used to interact with the second device based on the first result string and the second result string to perform fragmentation calculation to obtain a first comparison result, wherein the first comparison result indicates whether the first business parameter is equal to the second business parameter.
16. A second device, comprising: A communication module, configured to receive a first interaction string sent by the first device, where the first interaction string is obtained by the first device based on N first label strings randomly generated; A local computing module is configured to obtain a second result string based on a second binary string converted from a second service parameter of the second device, the initial random string, a randomly generated partial second label string, and the first interaction string, wherein the second binary string includes 2 N bits, N is a positive integer; The communication module and the local computing module are further used to interact with the first device based on the first result string and the second result string to perform fragmented computing to obtain a first comparison result, wherein the first result string is obtained by the first device based on a first service parameter of the first device converted into a first binary string, the first label string, and N initial random strings agreed upon by the first device and the second device, and the first comparison result indicates whether the first service parameter is equal to the second service parameter, and the first binary string includes 2 N bits.
17. An electronic device comprising: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the computer program implements any one of claims 1 to 14. A method for comparing business parameters as described above.
18. A business parameter comparison system, comprising: A first device, configured to execute the service parameter comparison method as claimed in any one of claims 1 to 7; The second device is used to execute the service parameter comparison method as described in any one of claims 8 to 14.
19. A computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the service parameter comparison method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Private data multi-party secure calculation method and system
CN111046409A
Character string matching method and device, data detection method and server
CN111475690A
Multi-party security computing method and device, equipment and storage medium
CN112906044A
Business parameter comparison method, device and system and storage medium
CN116595548A
Machine Learning for a Memory-based Database
US20130262074A1
