Sample matching method, device and readable storage medium
By using the default cache mode during the sample matching process, obtaining and combining the intermediate results to perform the sample matching process, the problem of low sample matching efficiency in the existing technology is solved, and a more efficient sample matching process is achieved.
Patent Information
- Application Number
- CN201911138191.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-19
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2039-11-19
AI Technical Summary
In the prior art, the sample matching efficiency is low and the calculation amount is large, resulting in a long calculation time, which in turn affects the efficiency of sample matching.
By initiating the intersection task to the second device associated with the first device, receiving the public key, and obtaining the first intermediate results based on the public key to determine whether to use the preset cache mode. If you use it, obtain the second intermediate results based on the default cache mode, and combine the two to perform the preset sample matching process.
By using the preset cache mode, the calculation amount during the sample matching process is reduced, the efficiency of the sample matching is improved, and the consumption of system computing resources is reduced.
Smart Images

Figure CN110851472B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology in financial technology (Fintech), and in particular to a sample matching method, device and readable storage medium. Background Art
[0002] With the continuous development of financial technology, especially Internet technology finance, more and more technologies (such as distributed, blockchain, artificial intelligence, etc.) are applied in the financial field, but the financial industry also puts forward higher requirements on technology, such as higher requirements on the distribution of corresponding to-do items in the financial industry.
[0003] With the continuous development of computer software and artificial intelligence, the application of federated learning is becoming more and more extensive. Before conducting federated learning, it is usually necessary to match the samples of each participant in the federated learning. At present, the privacy-preserving sample matching method based on RSA encryption technology can obtain the intersection (common part) samples of the two parties without leaking the non-intersection (privacy part) samples, thereby successfully matching samples while ensuring the security of the data. However, the sample matching process based on the above method has a large amount of calculation, and the sample size of the data source of each participant is often very large, resulting in a large computational overhead and a long calculation time for the entire sample matching process, which in turn leads to low sample matching efficiency. Therefore, there is a technical problem of low sample matching efficiency in the prior art. Summary of the invention
[0004] The main purpose of this application is to provide a sample matching method, device and readable storage medium, aiming to solve the technical problem of low sample matching efficiency in the prior art.
[0005] To achieve the above object, the present application provides a sample matching method, which is applied to a first device and includes:
[0006] Initiating an intersection task to a second device associated with the first device, so as to receive a public key corresponding to the intersection task sent by the second device;
[0007] Based on the public key, obtaining a first intermediate result corresponding to the first device;
[0008] Determine whether to use a preset cache mode, and if the preset cache mode is used, obtain a second intermediate result based on the preset cache mode, so as to perform a preset sample matching process based on the first intermediate result and the second intermediate result;
[0009] If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is performed based on the first intermediate result and the second intermediate result. Optionally, the first device includes a first local cache data,
[0010] The step of obtaining the second intermediate result based on the preset cache mode includes:
[0011] Sending the first version information corresponding to the first local cache data to the second device to verify whether the first version information is consistent with the second version information of the second device, and determining whether consistency determination information sent by the second device is received;
[0012] If the consistency determination information sent by the second device is not received, waiting to receive the second intermediate result sent by the second device;
[0013] If the consistency determination information sent by the second device is received, the second intermediate result is obtained based on the first local cache data.
[0014] Optionally, the step of acquiring the second intermediate result based on the first local cache data includes:
[0015] Determine whether the first local cache data is the latest version of the data;
[0016] If the first local cache data is the latest version data, use the first local cache data as the second intermediate result;
[0017] If the first local cache data is not the latest version of the data, wait to receive the second intermediate result sent by the second device
[0018] Optionally, the step of executing the preset sample matching process based on the first intermediate result and the second intermediate result includes:
[0019] Performing intersection processing on the second intermediate result and the first intermediate result to obtain an intersection processing result;
[0020] The sample matching result corresponding to the intersection processing result is obtained through a preset mapping relationship, and the intersection processing result is sent to the second device.
[0021] Optionally, the first device includes a first sample ID (Identity document), and the step of obtaining a first intermediate result corresponding to the first device based on the public key includes:
[0022] Based on the public key, a preset hash function and a preset random number, encrypt the first sample ID to obtain a first encryption result;
[0023] Sending the first encryption processing result to the second device to obtain a second encryption processing result fed back by the second device based on the first encryption processing result;
[0024] Based on the preset random number and the preset hash function, de-randomization and hashing are performed on the second encryption processing result to obtain the first intermediate result.
[0025] To achieve the above object, the present application further provides a sample matching method, characterized in that the sample matching method is applied to a second device, and the sample matching method includes:
[0026] receiving an intersection task sent by a first device associated with the second device, and determining whether to use a preset cache mode;
[0027] If the preset cache mode is used, obtaining a current version key pair and sending a public key in the current version key pair to the first device;
[0028] Based on the preset cache mode, obtaining a second intermediate result, and sending the second intermediate result to the first device;
[0029] If the preset cache mode is not used, generating a new key pair corresponding to the intersection task, and sending the public key in the new key pair to the first device;
[0030] The second intermediate result is calculated based on the new key pair, and the second intermediate result is sent to the first device.
[0031] Optionally, the step of obtaining the second intermediate result based on the preset cache mode includes:
[0032] Acquire second local cache data, and receive first version information sent by the first device;
[0033] Determine whether the first version information is consistent with the second version information of the second local cache data, and if the first version information is consistent with the second version information, send consistency determination information to the first device to obtain the second intermediate result;
[0034] If the first version information is inconsistent with the second version information, determining whether the second local cache data is available version data; if the second local cache data is not available version data, generating the second intermediate result based on the new key pair;
[0035] If the second local cache data is the available version data, the second local cache data is used as the second intermediate result.
[0036] Optionally, the new key pair includes a private key, the second device includes a second sample ID,
[0037] The step of generating the second intermediate result based on the new key pair comprises:
[0038] Based on a preset hash function, performing hash processing on the second sample ID to obtain a first hash value;
[0039] Based on the private key, encrypt the first Hash value to obtain an encrypted Hash value;
[0040] Based on the preset hash function, the hash processing is performed on the encrypted hash value to obtain the second intermediate result.
[0041] Optionally, the current version key pair includes a private key and a public key.
[0042] If the preset cache mode is used, the step of obtaining the current version key pair and sending the public key in the current version key pair to the first device includes:
[0043] Receiving a first encryption processing result sent by the first device based on the public key;
[0044] The first encryption processing result is encrypted based on the private key to obtain a second encryption processing result, and the second encryption processing result is sent to the first device.
[0045] The present application also provides a sample matching device, which is applied to a first device and includes:
[0046] A first receiving module, configured to initiate an intersection task to a second device associated with the first device, so as to receive a public key corresponding to the intersection task sent by the second device;
[0047] A first acquisition module, configured to acquire, based on the public key, a first intermediate result corresponding to the first device;
[0048] A first execution module, configured to determine whether to use a preset cache mode, and if the preset cache mode is used, obtain a second intermediate result based on the preset cache mode, so as to execute a preset sample matching process based on the first intermediate result and the second intermediate result;
[0049] The second execution module is configured to receive the second intermediate result sent by the second device if the preset cache mode is not used, and execute the preset sample matching process based on the first intermediate result and the second intermediate result.
[0050] Optionally, the first execution module includes:
[0051] A first judgment unit, configured to send the first version information corresponding to the first local cache data to the second device to verify whether the first version information is consistent with the second version information of the second device, and to judge whether consistency determination information sent by the second device is received;
[0052] A first waiting receiving unit, configured to wait for receiving a second intermediate result sent by the second device if the consistency determination information sent by the second device is not received;
[0053] The first acquisition unit is configured to acquire the second intermediate result based on the first local cache data if the consistency determination information sent by the second device is received.
[0054] Optionally, the acquiring unit includes:
[0055] A judging subunit, used for judging whether the first local cache data is the latest version of the data;
[0056] an acquiring subunit, configured to use the first local cache data as the second intermediate result if the first local cache data is the latest version data;
[0057] A waiting receiving subunit is used for waiting to receive the second intermediate result sent by the second device if the first local cache data is not the latest version data.
[0058] Optionally, the second execution module includes:
[0059] An intersection unit, configured to perform intersection processing on the second intermediate result and the first intermediate result to obtain an intersection processing result;
[0060] The second acquisition unit is used to acquire the sample matching result corresponding to the intersection processing result through a preset mapping relationship, and send the intersection processing result to the second device.
[0061] Optionally, the acquisition module includes:
[0062] An encryption processing unit, configured to perform encryption processing on the first sample ID based on the public key, a preset hash function and a preset random number to obtain a first encryption processing result;
[0063] A sending unit, configured to send the first encryption processing result to the second device, so as to obtain a second encryption processing result fed back by the second device based on the first encryption processing result;
[0064] A hash unit is used to perform de-random number processing and hash processing on the second encryption processing result based on the preset random number and the preset hash function to obtain the first intermediate result.
[0065] To achieve the above object, the present application further provides a sample matching device, characterized in that the sample matching device is applied to a second device, and the sample matching device includes:
[0066] A second receiving module, configured to receive the intersection task sent by the first device associated with the second device, and determine whether to use a preset cache mode;
[0067] A second acquisition module, configured to acquire a current version key pair and send a public key in the current version key pair to the first device if the preset cache mode is used;
[0068] A third execution module, configured to obtain a second intermediate result based on the preset cache mode, and send the second intermediate result to the first device;
[0069] a fourth execution module, configured to generate a new key pair corresponding to the intersection task if the preset cache mode is not used, and send the public key in the new key pair to the first device;
[0070] A calculation module is used to calculate the second intermediate result based on the new key pair, and send the second intermediate result to the first device.
[0071] Optionally, the third acquisition module includes:
[0072] an extracting unit, configured to obtain the second local cache data and receive the first version information sent by the first device;
[0073] A second judgment unit, configured to judge whether the first version information is consistent with the second version information of the second local cache data, and if the first version information is consistent with the second version information, send consistency determination information to the first device to obtain the second intermediate result;
[0074] A third judgment unit is used to judge whether the second local cache data is available version data if the first version information is inconsistent with the second version information, and generate the second intermediate result based on the new key pair if the second local cache data is not the available version data;
[0075] A reading unit is used for, if the second local cache data is the available version data, using the second local cache data as the second intermediate result.
[0076] Optionally, the fourth execution module includes:
[0077] A first hash processing unit, configured to perform hash processing on the second sample ID based on a preset hash function to obtain a first hash value;
[0078] an encryption unit, configured to encrypt the first Hash value based on the private key to obtain an encrypted Hash value;
[0079] The second hash processing unit is used to perform the hash processing on the encrypted hash value based on the preset hash function to obtain the second intermediate result.
[0080] Optionally, the sample matching device further includes:
[0081] A third receiving module, configured to receive a first encryption processing result sent by the first device based on the public key;
[0082] An encryption calculation module is used to encrypt the first encryption processing result based on the private key to obtain a second encryption processing result, and send the second encryption processing result to the first device.
[0083] To achieve the above objectives, the present application also provides a sample matching system, characterized in that the sample matching system includes the first device and the second device, and the first device is communicatively connected to the second device, and the sample matching system can implement the steps of the sample matching method as described above.
[0084] The present application also provides a sample matching device, which includes: a memory, a processor, and a program of the sample matching method stored in the memory and executable on the processor. When the program of the sample matching method is executed by the processor, the steps of the sample matching method as described above can be implemented.
[0085] The present application also provides a readable storage medium, on which is stored a program for implementing the sample matching method. When the program of the sample matching method is executed by a processor, the steps of the sample matching method as described above are implemented.
[0086] The present application initiates an intersection task to a second device associated with the first device to receive a public key corresponding to the intersection task sent by the second device, and then obtains a first intermediate result corresponding to the first device based on the public key, and then determines whether to use a preset cache mode. If the preset cache mode is used, the second intermediate result is obtained based on the preset cache mode, and a preset sample matching process is executed based on the first intermediate result and the second intermediate result. If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is executed based on the first intermediate result and the second intermediate result. That is, the present application first initiates an intersection task to the second device associated with the first device, so as to receive the public key corresponding to the intersection task sent by the second device, and then obtains the first intermediate result corresponding to the first device based on the public key, and then determines whether to use the preset cache mode. If the preset cache mode is used, the second intermediate result is obtained based on the preset cache mode, so as to execute the preset sample matching process based on the first intermediate result and the second intermediate result. If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is executed based on the first intermediate result and the second intermediate result. That is, the present application provides a method for accelerating the sample matching, that is, in addition to the method of obtaining the second intermediate result by calculation, the present application can extract the second intermediate result from the local database of the first device by using a preset cache mode, and then execute the preset sample matching process based on the first intermediate result and the second intermediate result, that is, when obtaining the second intermediate result, by using the preset cache mode, the local cache data can be directly extracted as the second intermediate result, and there is no need to obtain the second intermediate result by calculation, thereby reducing the calculation process in the sample matching process, avoiding long and high-cost sample matching calculations when performing sample matching, and achieving the purpose of reducing the consumption of system computing resources when performing sample matching. Further, the sample matching efficiency is improved. Therefore, the present application solves the technical problem of low sample matching efficiency in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0087] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0088] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0089] Figure 1 This is a flow chart of the first embodiment of the sample matching method of the present application;
[0090] Figure 2 This is a flow chart of the second embodiment of the sample matching method of the present application;
[0091] Figure 3 This is a schematic diagram of the interaction between the first device and the second device when performing sample matching in the sample matching method of the present application;
[0092] Figure 4 This is a flow chart of the accelerated acquisition of the second intermediate result in the second embodiment of the sample matching method of the present application combined with the first embodiment of the present application;
[0093] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.
[0094] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0095] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0096] The present application embodiment provides a sample matching method, wherein the sample matching method is applied to a first device. In the first embodiment of the sample matching method of the present application, referring to Figure 1 , the sample matching method comprises:
[0097] Step S10, initiating an intersection task to a second device associated with the first device, to receive a public key corresponding to the intersection task sent by the second device;
[0098] In this embodiment, it should be noted that the intersection task refers to a sample matching task based on an encryption algorithm, wherein the encryption algorithm includes an asymmetric encryption algorithm and a symmetric encryption algorithm, and the asymmetric encryption algorithm includes an RSA encryption algorithm, etc. The intersection task is initiated by the first device to the second device, wherein the intersection task is initiated by sending an email, by sending agreed characters, etc., and the public key is a new key generated by the second device based on the intersection task or a current version key of the second device directly obtained, wherein the current version key is stored in a local database of the second device, the first device is associated with the second device, and the first device and the second device can be communicated with each other.
[0099] An intersection task is initiated to a second device associated with the first device to receive a public key corresponding to the intersection task sent by the second device. Specifically, an intersection task is initiated to a second device associated with the first device, and then the public key corresponding to the intersection task is obtained through the second device, wherein the second device may generate a new key based on the intersection task or directly obtain the current version key of the second device, that is, obtain the public key corresponding to the intersection task, and then receive the public key sent by the second device.
[0100] Step S20: acquiring a first intermediate result corresponding to the first device based on the public key;
[0101] In this embodiment, it should be noted that, based on the public key, the first intermediate result corresponding to the first device is obtained. Specifically, based on the public key and the preset hash function, the first sample ID of the first device is encrypted in a preset encryption method to obtain the first intermediate result, wherein the preset encryption method is associated with the sample matching.
[0102] Wherein, the first device includes a first sample ID,
[0103] The step of obtaining a first intermediate result corresponding to the first device based on the public key includes:
[0104] Step S21, encrypting the first sample ID based on the public key, a preset hash function and a preset random number to obtain a first encryption result;
[0105] In this embodiment, based on the public key, the preset hash function and the preset random number, the first sample ID is encrypted to obtain a first encryption processing result. Specifically, the first sample ID that needs to be encrypted is determined, and each of the first sample IDs is hashed through a preset hash function to obtain a sample ID hash value corresponding to each of the first sample IDs, and then a preset random number is obtained, and the preset random number is encrypted based on the public key to obtain a random number encryption result, and the product of the random number encryption result and the sample ID hash value is calculated to obtain the first encryption processing result. For example, the preset hash function is H, the random number is recorded as r, and the first sample ID is recorded as u, wherein one random number corresponds to one first sample ID, and the first encryption processing result is Y. B = r^e%n*H(u), where e is the public key, r^e means encryption of the random number r by the public key, H(u) is a preset hash function for the first sample ID, %n means modulo n, where n is related to the number of first sample IDs to be encrypted. If n=3, then Y B=r^e%n*H(u)={r1^e*H(u1), r2^e*H(u2), r3^e*H(u3)}.
[0106] Step S22, sending the first encryption processing result to the second device to obtain a second encryption processing result fed back by the second device based on the first encryption processing result;
[0107] In this embodiment, the first encryption processing result is sent to the second device to obtain the second encryption processing result fed back by the second device based on the first encryption processing result. Specifically, the first encryption processing result is sent to the second device, so that the first encryption processing result is encrypted by the second device based on the private key corresponding to the public key in the second device to obtain the second encryption processing result. For example, assuming that the private key is d, the first encryption processing result Y B = r^e*H(u), then based on the public-private key encryption principle of the RSA encryption algorithm, the second encryption processing result Z B =((r^e)*H(u))^d=r*H(u)^d.
[0108] Step S23: Based on the preset random number and the preset hash function, perform de-random number processing and hash processing on the second encryption processing result to obtain the first intermediate result.
[0109] In this embodiment, based on the preset random number and the preset hash function, the second encryption processing result is subjected to de-random number processing and hash processing to obtain the first intermediate result. Specifically, based on the preset random number, the quotient of the second encryption processing result and the preset random number is calculated to obtain the de-random number processing result. Further, based on the preset hash function, the de-random number processing result is subjected to hash processing to obtain the first intermediate processing result. For example, assuming that the second encryption processing result Z B =r*H(u)^d, the preset random number is r, the preset hash function is H, so the de-randomization result is H(u)^d, the first intermediate result D B =H(H(u)^d).
[0110] Step S30, determining whether to use a preset cache mode, and if the preset cache mode is used, obtaining a second intermediate result based on the preset cache mode, so as to perform a preset sample matching process based on the first intermediate result and the second intermediate result;
[0111] In this embodiment, it should be noted that the preset cache mode is a method of obtaining the second intermediate result by reading local cache data, thereby saving a large amount of calculation process with the ultimate goal of obtaining the second intermediate result. The second intermediate result and the first intermediate result are important parameters for executing the preset sample matching process.
[0112] Determine whether to use a preset cache mode. If the preset cache mode is used, obtain a second intermediate result based on the preset cache mode, so as to execute a preset sample matching process based on the first intermediate result and the second intermediate result. Specifically, determine whether to use the preset cache mode based on an instruction input by a user, wherein the instruction includes a keyboard input instruction and a mouse input instruction. For example, assuming that the keyboard input instruction can be set as a string of characters, when the string is 0000, it is determined to use the preset cache mode, and when the string is 1111, it is determined not to use the preset cache mode. If the preset cache mode is used, read the local cache data of the first device based on the preset cache mode to obtain the second intermediate result, or receive the second intermediate result sent by the second device, and then execute the preset sample matching process based on the first intermediate result and the second intermediate result. Before executing the preset sample matching process, the first device and the second device will store the second intermediate result, the version information corresponding to the second intermediate result, and the key pair corresponding to the second intermediate result in their respective local databases, wherein the key pair includes a public key and a private key, and the version information can be represented by the version number.
[0113] Wherein, in step S30, the first device includes first local cache data,
[0114] The step of obtaining the second intermediate result based on the preset cache mode includes:
[0115] Step S31, sending the first version information corresponding to the first local cache data to the second device to verify whether the first version information is consistent with the second version information of the second device, and determining whether consistency determination information sent by the second device is received;
[0116] In this embodiment, it should be noted that the first version information can be represented by a version number, a character string, text, etc.
[0117] The first version information corresponding to the first local cache data is sent to the second device to verify whether the first version information is consistent with the second version information of the second device, and to determine whether the consistency determination information sent by the second device is received. Specifically, the first version number corresponding to the first local cache data is sent to the second device, so that the first version number is compared with the second version number of the second device through the second device to verify whether the first version number is consistent with the second version number, and to determine whether the consistency determination information sent by the second device is received. If the consistency information is received, it indicates that the first version number is consistent with the second version number; if the consistency information is not received, it indicates that the first version number is inconsistent with the second version number.
[0118] Step S32: if the consistency determination information sent by the second device is not received, wait to receive the second intermediate result sent by the second device;
[0119] In this embodiment, if the consistency determination information sent by the second device is not received, the process waits to receive the second intermediate result sent by the second device. Specifically, if the consistency determination information sent by the second device is not received, it indicates that the first version number is inconsistent with the second version number, and further indicates that the first local cache data cannot be used as the second intermediate result, and the process waits to receive the second intermediate result sent by the second device.
[0120] Step S33: If the consistency determination information sent by the second device is received, the second intermediate result is obtained based on the first local cache data.
[0121] In this embodiment, if the consistency determination information sent by the second device is received, the second intermediate result is obtained based on the first local cache data. Specifically, if the consistency determination information sent by the second device is received, it indicates that the first version number is consistent with the second version number, and the second intermediate result can be obtained based on the first local cache data.
[0122] The step of obtaining the second intermediate result based on the first local cache data includes:
[0123] Step S33, determining whether the first local cache data is the latest version of the data;
[0124] In this embodiment, it should be noted that the latest version data is the local data of the first device when the last sample match was performed, and when the sample ID of the first device during this sample match is consistent with the sample ID of the last sample match, the first local cached data is the latest version data; when the sample ID of the first device during this sample match is inconsistent with the sample ID of the last sample match, the first local cached data is not the latest version data.
[0125] Step S34: if the first local cache data is the latest version data, use the first local cache data as the second intermediate result;
[0126] In this embodiment, it should be noted that if the first local cache data is the latest version data, the first local cache data can be directly used as the second intermediate result to save the calculation process of the second intermediate result and thereby reduce the consumption of system computing resources.
[0127] Step S35: if the first local cache data is not the latest version of the data, wait to receive the second intermediate result sent by the second device.
[0128] In this embodiment, if the first local cache data is not the latest version data, then wait to receive the second intermediate result sent by the second device. Specifically, if the first local cache data is not the latest version data, then it indicates that the first local cache data cannot be used as the second intermediate result, and then wait to receive the second intermediate result sent by the second device.
[0129] Step S40: If the preset cache mode is not used, receiving the second intermediate result sent by the second device, and executing the preset sample matching process based on the first intermediate result and the second intermediate result.
[0130] In this embodiment, it should be noted that the second device can obtain the second intermediate result through calculation or directly extract the second intermediate result from its local database through the cache mode of the second device, and the preset sample matching process is a pre-set sample matching process, wherein the sample matching process includes a data transmission process, a data processing process, etc.
[0131] If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is executed based on the first intermediate result and the second intermediate result. Specifically, if the preset cache mode is not used, the encrypted information corresponding to the second intermediate result sent by the second device is received, wherein the encrypted information is the result of the second device encrypting the second intermediate result based on the private key in the key pair, and then decrypting the encrypted information based on the public key to obtain the second intermediate result, and then executing the preset sample matching process based on the first intermediate result and the second intermediate result.
[0132] Wherein, in step S40, the step of executing the preset sample matching process based on the first intermediate result and the second intermediate result includes:
[0133] Step S41, receiving a second intermediate result sent by the second device, and performing intersection processing on the second intermediate result and the first intermediate result to obtain an intersection processing result;
[0134] In this embodiment, it should be noted that the first processing result includes one or more first hash values, and the second processing result includes one or more second hash values.
[0135] The second intermediate result and the first intermediate result are subjected to intersection processing to obtain an intersection processing result. Specifically, the second intermediate result and the first intermediate result are subjected to intersection processing to compare the first hash value with each second hash value one by one to obtain the same hash value, that is, to obtain an intersection processing result. For example, assuming that the first intermediate result D B ={H(H(u1)^d), H(H(u2)^d), H(H(u3)^d)}, the second intermediate result Z A ={H(H(u1)^d), H(H(u2)^d), H(H(u4)^d)}, then the intersection processing result is {H(H(u1)^d), H(H(u2)^d)}.
[0136] Step S42: obtaining a sample matching result corresponding to the intersection processing result through a preset mapping relationship, and sending the intersection processing result to the second device.
[0137] In this embodiment, it should be noted that the preset mapping relationship refers to the mapping relationship between each element in the intersection processing result and the sample ID, wherein the sample ID includes a first sample ID and a second sample ID, and the sample matching result includes a common sample ID between the first device and the second device.
[0138] The sample matching result corresponding to the intersection processing result is obtained through a preset mapping relationship, and the intersection processing result is sent to the second device. Specifically, the sample ID corresponding to each element in the intersection processing result is obtained through a preset mapping relationship to obtain a common sample ID, that is, the sample matching result is obtained, and the intersection processing result is sent to the second device.
[0139] This embodiment initiates an intersection task to a second device associated with the first device to receive a public key corresponding to the intersection task sent by the second device, and then obtains a first intermediate result corresponding to the first device based on the public key, and then determines whether to use a preset cache mode. If the preset cache mode is used, the second intermediate result is obtained based on the preset cache mode, and a preset sample matching process is executed based on the first intermediate result and the second intermediate result. If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is executed based on the first intermediate result and the second intermediate result. That is, this embodiment first initiates an intersection task to the second device associated with the first device, so as to receive the public key corresponding to the intersection task sent by the second device, and then obtains the first intermediate result corresponding to the first device based on the public key, and then judges whether to use the preset cache mode. If the preset cache mode is used, the second intermediate result is obtained based on the preset cache mode, so as to execute the preset sample matching process based on the first intermediate result and the second intermediate result. If the preset cache mode is not used, the second intermediate result sent by the second device is received, and the preset sample matching process is executed based on the first intermediate result and the second intermediate result. That is, the present embodiment provides a method for accelerating the sample matching, that is, in addition to the method of obtaining the second intermediate result by calculation, the present embodiment can extract the second intermediate result from the local database of the first device by using a preset cache mode, and then execute the preset sample matching process based on the first intermediate result and the second intermediate result, that is, when obtaining the second intermediate result, by using the preset cache mode, the local cache data can be directly extracted as the second intermediate result, and there is no need to obtain the second intermediate result by calculation, thereby reducing the calculation process in the sample matching process, avoiding long and high-cost sample matching calculations when performing sample matching, and achieving the purpose of reducing the consumption of system computing resources when performing sample matching. Further, the sample matching efficiency is improved. Therefore, the present embodiment solves the technical problem of low sample matching efficiency in the prior art.
[0140] Further, refer to Figure 2Based on the first embodiment of the present application, in another embodiment of the sample matching method, the sample matching method is applied to a second device, and the sample matching method includes:
[0141] Step A10, receiving an intersection task sent by a first device associated with the second device, and determining whether to use a preset cache mode;
[0142] In this embodiment, it should be noted that the first device and the second device are associated with each other and can be communicatively connected.
[0143] Receive an intersection task sent by a first device associated with the second device, and determine whether to use a preset cache mode. Specifically, after receiving the intersection task sent by the first device associated with the second device, determine whether to use the preset cache mode based on instructions input by a user, wherein the instructions include keyboard input instructions and mouse input instructions. For example, assuming that the instruction is a mouse check command, and the user interface corresponding to the sample match includes a check box, when the user uses the mouse to check the check box, it is determined to use the preset cache mode, and when the user does not use the mouse to check the check box, it is determined not to use the preset cache mode.
[0144] Step A20: if the preset cache mode is used, obtaining a current version key pair and sending a public key in the current version key pair to the first device;
[0145] In this embodiment, if the preset cache mode is used, the current version key pair is obtained and the public key in the current version key pair is sent to the first device. Specifically, if the preset cache mode is used, the current version key pair is extracted from the local database of the second device, and the public key in the current version key pair is sent to the first device, and then the first device can encrypt the first sample ID in the first device based on the public key to obtain a first intermediate result.
[0146] The current version key pair includes a private key and a public key.
[0147] If the preset cache mode is used, the step of obtaining the current version key pair and sending the public key in the current version key pair to the first device includes:
[0148] Step B10, receiving a first encryption processing result sent by the first device based on the public key;
[0149] In this embodiment, a first encryption processing result sent by the first device based on the public key is received. Specifically, the public key is sent to the first device so that the first sample ID is encrypted by the first device to obtain the first encryption processing result, and then the first encryption processing result corresponding to the public key sent by the first device is received, wherein the first device will encrypt the first sample ID based on the public key, a preset random number and a preset hash function to obtain the first encryption processing result.
[0150] Step B20: Based on the private key, encrypt the first encryption processing result to obtain a second encryption processing result, and send the second encryption processing result to the first device.
[0151] In this embodiment, it should be noted that the first device will perform de-random number processing and hash processing based on a preset hash function on the second encryption processing result.
[0152] Step A30: acquiring a second intermediate result based on the preset cache mode, and sending the second intermediate result to the first device;
[0153] In this embodiment, based on the preset cache mode, a second intermediate result is obtained, and the second intermediate result is sent to the first device. Specifically, based on the preset cache mode, the second intermediate result is obtained by directly extracting second local cache data from a local database of the second device as the second intermediate result, or by encrypting a second sample ID of the second device based on a generated new key pair.
[0154] Wherein, in step A30, the step of obtaining the second intermediate result based on the preset cache mode includes:
[0155] Step A31, obtaining second local cache data, and receiving first version information sent by the first device;
[0156] In this embodiment, the second local cache data is obtained, and the first version information sent by the first device is received. Specifically, the second local cache data is extracted from the local database of the second device, and the first version information sent by the first device is received, wherein the first version information includes a version number.
[0157] Step A32, determining whether the first version information is consistent with the second version information of the second local cache data, and if the first version information is consistent with the second version information, sending consistency determination information to the first device to obtain the second intermediate result;
[0158] In this embodiment, it should be noted that the first version information includes a first version number, and the second version information includes a second version number.
[0159] Determine whether the first version information is consistent with the second version information of the second local cache data. If the first version information is consistent with the second version information, send consistency determination information to the first device to obtain the second intermediate result. Specifically, determine whether the first version number and the second version number corresponding to the second local cache data are consistent. If they are consistent, send consistency determination information to the first device to read the first local cache data in the local database of the first device through the first device as the second intermediate result.
[0160] Step A33: if the first version information is inconsistent with the second version information, determining whether the second local cache data is available version data; if the second local cache data is not available version data, generating the second intermediate result based on the new key pair;
[0161] In this embodiment, it should be noted that the available version data refers to the second local version data of the second sample ID in the second device that has not been updated or changed, the new key pair includes a public key and a private key, and if the second intermediate result is encrypted using the new key pair, the first intermediate result will be encrypted accordingly using the new key.
[0162] If the first version information is inconsistent with the second version information, it is determined whether the second local cache data is the available version data. If the second local cache data is not the available version data, the second intermediate result is generated based on the new key pair. Specifically, if the first version number is inconsistent with the second version number, it is determined whether the second local cache data is the available version data. If the second local cache data is not the available version data, the second sample ID of the second device is encrypted based on the private key and the preset hash function to obtain the second intermediate result. For example, assuming that the preset hash function is H, the second sample ID is X1, and the private key is d, the second intermediate result Z A =H(H(X1)^d).
[0163] Step A34: If the second local cache data is the available version data, use the second local cache data as the second intermediate result.
[0164] In this embodiment, if the second local cache data is the available version data, the second local cache data is used as the second intermediate result. Specifically, if the second local cache data is the available version data, the second local cache data is read from the local database of the second device as the second intermediate result.
[0165] Step A40: if the preset cache mode is not used, generating a new key pair corresponding to the intersection task, and sending the public key in the new key pair to the first device;
[0166] In this embodiment, it should be noted that the second device includes a key generation module for generating the new key pair, and the new key pair includes a private key and a public key.
[0167] If the preset cache mode is not used, a new key pair corresponding to the intersection task is generated, and the public key in the new key pair is sent to the first device. Specifically, if the preset cache mode is not used, a new key pair corresponding to the intersection task is generated by a key generation module, and the public key in the new key pair is sent to the first device. Furthermore, the first device can use the public key as its own public key to encrypt the first sample ID of the first device to obtain a first intermediate result.
[0168] Step A50: Calculate the second intermediate result based on the new key pair, and send the second intermediate result to the first device.
[0169] In this embodiment, the second intermediate result is calculated based on the new key pair, and the second intermediate result is sent to the first device. Specifically, based on the private key in the new key and the preset hash function, the second sample ID in the second device is encrypted to obtain the second intermediate result, and the second intermediate result is sent to the first device to assist the first device in performing the preset sample matching process, such as Figure 3 FIG. 1 is a schematic diagram showing the interaction between the first device and the second device during sample matching, wherein “Party B” is the first device, “Party A” is the second device, and X B is the set of the first sample ID, X A is the set of the second sample ID, H(x) is the preset hash function, “public key” is the public key, d is the private key, and Y B is the first encryption result, Z B is the result of the second encryption process, D B is the first intermediate result, Z Ais the second intermediate result, ri is the preset random number, I is the intersection processing result, {u1, u2, u3} is the sample matching result, and "RSA: n, e, d" is the key pair corresponding to the RSA encryption algorithm, wherein the key pair includes the current version key pair and the new key pair, such as Figure 4 FIG. 1 is a schematic diagram of the accelerated acquisition process of the second intermediate result in the second embodiment of the present application combined with the first embodiment of the present application, wherein Z A is the second intermediate result, and the RSA intersection subsequent process is to remove Figure 4 In the other RSA sample matching processes except the steps of , “Party B” is the first device, “Party A” is the second device, and the RSA intersection task is the intersection task.
[0170] Wherein, in step A50, the new key pair includes a private key, the second device includes a second sample ID,
[0171] The step of generating the second intermediate result based on the new key pair comprises:
[0172] Step A51, performing hash processing on the second sample ID based on a preset hash function to obtain a first hash value;
[0173] In this embodiment, based on a preset hash function, the second sample ID is hashed to obtain a first hash value. Specifically, the second sample ID is input as an input value into the preset hash function, and the first hash value is output.
[0174] Step A52: encrypting the first Hash value based on the private key to obtain an encrypted Hash value;
[0175] Step A53: Based on the preset hash function, perform the hash processing on the encrypted hash value to obtain the second intermediate result.
[0176] In this embodiment, based on the preset hash function, the hash processing is performed on the encrypted hash value to obtain the second intermediate result. Specifically, the encrypted hash value is input as an input value into the preset hash function to output the second intermediate result.
[0177] This embodiment receives an intersection task sent by a first device associated with the second device, and determines whether to use a preset cache mode. If the preset cache mode is used, the current version key pair is obtained and the public key in the current version key pair is sent to the first device, and then based on the preset cache mode, a second intermediate result is obtained, and the second intermediate result is sent to the first device. If the preset cache mode is not used, a new key pair corresponding to the intersection task is generated, and the public key in the new key pair is sent to the first device, and then the second intermediate result is calculated based on the new key pair, and the second intermediate result is sent to the first device. That is, this embodiment provides a method for accelerating the sample matching, that is, by receiving the intersection task sent by the first device associated with the second device, and determining whether to use the preset cache mode, if the preset cache mode is used, obtaining the current version key pair and sending the public key in the current version key pair to the first device, and then obtaining the second intermediate result based on the preset cache mode, and sending the second intermediate result to the first device, that is, the second device can obtain the second intermediate result without performing a large amount of calculation, and further, if the preset cache mode is not used, a new key pair corresponding to the intersection task is generated, and the public key in the new key pair is sent to the first device, and then the second intermediate result is calculated based on the new key pair, and the second intermediate result is sent to the first device, that is, when the cache mode is not used, the second intermediate result can also be obtained by calculation. That is, in addition to providing a method for obtaining the second intermediate result through calculation, this embodiment also provides a method for obtaining the second intermediate result without calculation, thereby reducing the calculation process in the sample matching process, reducing the consumption of system computing resources when performing sample matching, and avoiding long and high-cost sample matching calculations when performing sample matching. Further, the sample matching efficiency is improved. Therefore, this embodiment solves the technical problem of low sample matching efficiency in the prior art.
[0178] Reference Figure 5 , Figure 5 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.
[0179] like Figure 5As shown, the sample matching device may include: a processor 1001, such as a CPU, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the processor 1001 and the memory 1005. The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0180] Optionally, the sample matching device may also include a rectangular user interface, a network interface, a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. The rectangular user interface may include a display screen (Display), an input submodule such as a keyboard (Keyboard), and the optional rectangular user interface may also include a standard wired interface and a wireless interface. The network interface may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0181] Those skilled in the art will understand that Figure 5 The sample matching device structure shown in the figure does not constitute a limitation on the sample matching device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0182] like Figure 5 As shown, the memory 1005 as a computer storage readable storage medium may include an operating system, a network communication module and a sample matching program. The operating system is a program that manages and controls the hardware and software resources of the sample matching device, and supports the operation of the sample matching program and other software and / or programs. The network communication module is used to realize the communication between the components inside the memory 1005, and the communication with other hardware and software in the sample matching system.
[0183] exist Figure 5 In the sample matching device shown, the processor 1001 is used to execute the sample matching program stored in the memory 1005 to implement the steps of any of the sample matching methods described above.
[0184] The specific implementation of the sample matching device of the present application is basically the same as the above-mentioned sample matching method embodiments, and will not be repeated here.
[0185] The embodiment of the present application further provides a sample matching device, which is applied to a first device and includes:
[0186] A first receiving module, configured to initiate an intersection task to a second device associated with the first device, so as to receive a public key corresponding to the intersection task sent by the second device;
[0187] A first acquisition module, configured to acquire, based on the public key, a first intermediate result corresponding to the first device;
[0188] A first execution module, configured to determine whether to use a preset cache mode, and if the preset cache mode is used, obtain a second intermediate result based on the preset cache mode, so as to execute a preset sample matching process based on the first intermediate result and the second intermediate result;
[0189] The second execution module is configured to receive the second intermediate result sent by the second device if the preset cache mode is not used, and execute the preset sample matching process based on the first intermediate result and the second intermediate result.
[0190] Optionally, the first execution module includes:
[0191] A first judgment unit, configured to send the first version information corresponding to the first local cache data to the second device to verify whether the first version information is consistent with the second version information of the second device, and to judge whether consistency determination information sent by the second device is received;
[0192] A first waiting receiving unit, configured to wait for receiving a second intermediate result sent by the second device if the consistency determination information sent by the second device is not received;
[0193] The first acquisition unit is configured to acquire the second intermediate result based on the first local cache data if the consistency determination information sent by the second device is received.
[0194] Optionally, the acquiring unit includes:
[0195] A judging subunit, used for judging whether the first local cache data is the latest version of the data;
[0196] an acquiring subunit, configured to use the first local cache data as the second intermediate result if the first local cache data is the latest version data;
[0197] A waiting receiving subunit is used for waiting to receive the second intermediate result sent by the second device if the first local cache data is not the latest version data.
[0198] Optionally, the second execution module includes:
[0199] An intersection unit, configured to perform intersection processing on the second intermediate result and the first intermediate result to obtain an intersection processing result;
[0200] The second acquisition unit is used to acquire the sample matching result corresponding to the intersection processing result through a preset mapping relationship, and send the intersection processing result to the second device.
[0201] Optionally, the acquisition module includes:
[0202] An encryption processing unit, configured to perform encryption processing on the first sample ID based on the public key, a preset hash function and a preset random number to obtain a first encryption processing result;
[0203] A sending unit, configured to send the first encryption processing result to the second device, so as to obtain a second encryption processing result fed back by the second device based on the first encryption processing result;
[0204] A hash unit is used to perform de-random number processing and hash processing on the second encryption processing result based on the preset random number and the preset hash function to obtain the first intermediate result.
[0205] The specific implementation of the sample matching device of the present application is basically the same as the above-mentioned sample matching method embodiments, and will not be repeated here.
[0206] To achieve the above object, an embodiment of the present application further provides a sample matching method, characterized in that the sample matching method is applied to a second device, and the sample matching method includes:
[0207] A second receiving module, configured to receive the intersection task sent by the first device associated with the second device, and determine whether to use a preset cache mode;
[0208] A second acquisition module, configured to acquire a current version key pair and send a public key in the current version key pair to the first device if the preset cache mode is used;
[0209] A third execution module, configured to obtain a second intermediate result based on the preset cache mode, and send the second intermediate result to the first device;
[0210] a fourth execution module, configured to generate a new key pair corresponding to the intersection task if the preset cache mode is not used, and send the public key in the new key pair to the first device;
[0211] A calculation module is used to calculate the second intermediate result based on the new key pair, and send the second intermediate result to the first device.
[0212] Optionally, the third acquisition module includes:
[0213] an extracting unit, configured to obtain the second local cache data and receive the first version information sent by the first device;
[0214] A second judgment unit, configured to judge whether the first version information is consistent with the second version information of the second local cache data, and if the first version information is consistent with the second version information, send consistency determination information to the first device to obtain the second intermediate result;
[0215] A third judgment unit is used to judge whether the second local cache data is available version data if the first version information is inconsistent with the second version information, and generate the second intermediate result based on the new key pair if the second local cache data is not the available version data;
[0216] A reading unit is used for, if the second local cache data is the available version data, using the second local cache data as the second intermediate result.
[0217] Optionally, the fourth execution module includes:
[0218] A first hash processing unit, configured to perform hash processing on the second sample ID based on a preset hash function to obtain a first hash value;
[0219] an encryption unit, configured to encrypt the first Hash value based on the private key to obtain an encrypted Hash value;
[0220] The second hash processing unit is used to perform the hash processing on the encrypted hash value based on the preset hash function to obtain the second intermediate result.
[0221] Optionally, the sample matching device further includes:
[0222] A third receiving module, configured to receive a first encryption processing result sent by the first device based on the public key;
[0223] An encryption calculation module is used to encrypt the first encryption processing result based on the private key to obtain a second encryption processing result, and send the second encryption processing result to the first device.
[0224] The specific implementation of the sample matching device of the present application is basically the same as the above-mentioned sample matching method embodiments, and will not be repeated here.
[0225] An embodiment of the present application also provides a sample matching system, characterized in that the sample matching system includes the first device and the second device, and the first device is communicatively connected to the second device, and the sample matching system can implement the steps of the sample matching method as described above.
[0226] The specific implementation of the sample matching system of the present application is basically the same as the above-mentioned sample matching method embodiments, and will not be repeated here.
[0227] An embodiment of the present application provides a readable storage medium, which stores one or more programs. The one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned sample matching methods.
[0228] The specific implementation of the readable storage medium of the present application is basically the same as the above-mentioned sample matching method embodiments, and will not be repeated here.
[0229] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A sample matching method, characterized in that: The sample matching method is applied to a first device, and the sample matching method includes: Initiating an intersection task to a second device associated with the first device, so as to receive a public key corresponding to the intersection task sent by the second device; Based on the public key, obtaining a first intermediate result corresponding to the first device; Determine whether to use a preset cache mode, and if the preset cache mode is used, obtain a second intermediate result based on the preset cache mode, so as to perform a preset sample matching process based on the first intermediate result and the second intermediate result; If the preset cache mode is not used, receiving the second intermediate result sent by the second device, and executing the preset sample matching process based on the first intermediate result and the second intermediate result; The first device includes a first sample ID, and the step of obtaining a first intermediate result corresponding to the first device based on the public key includes: Based on the public key, a preset hash function and a preset random number, encrypt the first sample ID to obtain a first encryption result; Sending the first encryption processing result to the second device to obtain a second encryption processing result fed back by the second device based on the first encryption processing result; Based on the preset random number and the preset hash function, performing de-random number processing and hash processing on the second encryption processing result to obtain the first intermediate result; The first device includes first local cache data, and the step of obtaining the second intermediate result based on the preset cache mode includes: Sending the first version information corresponding to the first local cache data to the second device to verify whether the first version information is consistent with the second version information of the second device, and determining whether consistency determination information sent by the second device is received; If the consistency determination information sent by the second device is not received, waiting to receive the second intermediate result sent by the second device; If the consistency determination information sent by the second device is received, determining whether the first local cache data is the latest version of the data; If the first local cache data is the latest version data, use the first local cache data as the second intermediate result; If the first local cache data is not the latest version data, wait to receive the second intermediate result sent by the second device.
2. The sample matching method according to claim 1, characterized in that: The step of executing the preset sample matching process based on the first intermediate result and the second intermediate result includes: Performing intersection processing on the second intermediate result and the first intermediate result to obtain an intersection processing result; The sample matching result corresponding to the intersection processing result is obtained through a preset mapping relationship, and the intersection processing result is sent to the second device.
3. A sample matching method, characterized in that: The sample matching method is applied to a second device, and the sample matching method includes: receiving an intersection task sent by a first device associated with the second device, and determining whether to use a preset cache mode; If the preset cache mode is used, obtaining a current version key pair and sending a public key in the current version key pair to the first device; Based on the preset cache mode, obtaining a second intermediate result, and sending the second intermediate result to the first device; If the preset cache mode is not used, generating a new key pair corresponding to the intersection task, and sending the public key in the new key pair to the first device; Calculate the second intermediate result based on the new key pair, and send the second intermediate result to the first device; The step of obtaining the second intermediate result based on the preset cache mode includes: Acquire second local cache data, and receive first version information sent by the first device; Determine whether the first version information is consistent with the second version information of the second local cache data, and if the first version information is consistent with the second version information, send consistency determination information to the first device to obtain the second intermediate result; If the first version information is inconsistent with the second version information, determining whether the second local cache data is available version data; if the second local cache data is not available version data, generating the second intermediate result based on the new key pair; If the second local cache data is the available version data, using the second local cache data as the second intermediate result; The new key pair includes a private key, the second device includes a second sample ID, The step of generating the second intermediate result based on the new key pair comprises: Based on a preset hash function, performing hash processing on the second sample ID to obtain a first hash value; Based on the private key, encrypt the first Hash value to obtain an encrypted Hash value; Based on the preset hash function, the hash processing is performed on the encrypted hash value to obtain the second intermediate result.
4. The sample matching method according to claim 3, characterized in that: The current version key pair includes a private key and a public key. If the preset cache mode is used, the step of obtaining the current version key pair and sending the public key in the current version key pair to the first device includes: Receiving a first encryption processing result sent by the first device based on the public key; The first encryption processing result is encrypted based on the private key to obtain a second encryption processing result, and the second encryption processing result is sent to the first device.
5. A sample matching device, characterized in that: The sample matching device includes: a memory, a processor, and a program stored in the memory for implementing the sample matching method. The memory is used to store a program for implementing a sample matching method; The processor is used to execute a program for implementing the sample matching method, so as to implement the steps of the sample matching method as claimed in any one of claims 1 to 2 or 3 to 4.
6. A readable storage medium, characterized in that: The readable storage medium stores a program for implementing the sample matching method, and the program for implementing the sample matching method is executed by a processor to implement the steps of the sample matching method as described in any one of claims 1 to 2 or 3 to 4.
Citation Information
Patent Citations
Data interacting method and system and computer-readable storage medium
CN107133297A
Caching and interaction method and system for dynamic data of terminal, terminal and computer readable medium
CN107301051A