Privacy Data Aggregation and Query Methods and Systems

By employing a privacy-focused data aggregation query method, utilizing hash functions and homomorphic encryption, a ciphertext query request is constructed and aggregated, thus resolving the security issues in multi-party data joint queries and achieving both security and efficiency in cross-institutional queries.

CN123116333APending Publication Date: 2026-11-17BEIJING NATIONAL FINANCIAL TECHNOLOGY RISK MONITORING CENTER CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611416044.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-11
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing technologies, when multiple parties jointly query data, the query conditions are sent in plaintext, which results in the query object being known to the data party and the detailed data of each data party being known to the querying party, thus affecting security.

Method used

A privacy-preserving data aggregation query method is adopted. Candidate location data and identifier digest data are determined by hash function. Homomorphic encryption is used to construct location selection ciphertext and digest matching ciphertext. The query request data is sent to the relay end in ciphertext form. The relay end performs homomorphic addition and slot reduction processing and returns the aggregated ciphertext. The query end decrypts the data to obtain the aggregated value data.

Benefits of technology

It enables the querying party to obtain cross-institutional aggregated results without disclosing the query conditions, the data party cannot know the query object, the query process is transparent and scalable and the latency is independent of the database size, ensuring that the query object is not missed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123116333A_ABST
    Figure CN123116333A_ABST
Patent Text Reader

Abstract

This application proposes a method and system for privacy-preserving data aggregation query. The method includes: determining identifier digest data based on target identifier data and a preset hash function; constructing location indication data; performing homomorphic encryption on each location indication data to determine location selection ciphertext data corresponding to each candidate location data; constructing digest indication data; performing homomorphic encryption on each digest indication data to determine digest matching ciphertext data; determining query request data based on row index data, each location selection ciphertext data, and each digest matching ciphertext data; receiving reduced aggregation ciphertext data sent by a relay end; and decrypting the reduced aggregation ciphertext data based on private key data to determine the aggregation value data corresponding to the target identifier data. In this application, the querying party only obtains the total aggregation value, while the data party is unaware of the query object, thus realizing privacy-preserving aggregation query across multiple encrypted domains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data security technology, and more specifically, to a method and system for aggregated querying privacy data. Background Technology

[0002] In related technologies, a common multi-party data joint query involves the querying party directly sending query conditions to each data party and obtaining the query results from each data party. However, since the query conditions are sent in plaintext and the query results from each data party are returned to the querying party separately, the query object and the detailed data of each data party can be obtained by the querying party, which affects security. Summary of the Invention

[0003] This application aims to address at least one of the technical problems existing in the prior art or related technologies.

[0004] Therefore, the first aspect of this application proposes a method for aggregated querying of privacy data.

[0005] The second aspect of this application proposes a method for aggregated querying of privacy data.

[0006] The third aspect of this application proposes a method for aggregated querying of privacy data.

[0007] The fourth aspect of this application proposes a privacy data aggregation query system.

[0008] In view of this, the first aspect of this application provides a privacy data aggregation query method for a query terminal. The privacy data aggregation query method includes: obtaining target identifier data; determining at least two candidate position data and identifier digest data corresponding to the target identifier data based on the target identifier data and a preset hash function, wherein each candidate position data includes row index data and slot index data, and the identifier digest data includes multiple digest bit data; constructing position indication data for each candidate position data, wherein in each position indication data, the slot corresponding to the slot index data of the corresponding candidate position data is a first preset value, and the remaining slots are second preset values; performing homomorphic encryption processing on each position indication data to determine the position selection ciphertext data corresponding to each candidate position data; and constructing digest indication data for each digest bit data of the identifier digest data. In each digest indicator data, each slot is set to the value of the corresponding digest bit data; homomorphic encryption is performed on each digest indicator data to determine the digest matching ciphertext data corresponding to each digest bit data; based on the row index data of each candidate position data, the ciphertext data of each position selection, and the ciphertext data of each digest matching, the query request data is determined and sent to the relay end so that the relay end can send the query request data to multiple data ends; the row index data is included in the query request data in plaintext form; the reduced aggregation ciphertext data sent by the relay end is received; the reduced aggregation ciphertext data is obtained by the relay end through homomorphic addition and slot reduction processing on the local result ciphertext data of multiple data ends; based on the private key data, the reduced aggregation ciphertext data is decrypted to determine the aggregation value data corresponding to the target identifier data.

[0009] This application enables the querying party to perform a multi-party joint aggregation query on target identifier data without disclosing query conditions to multiple data parties and only obtaining cross-organizational aggregation results without seeing details of any individual data party. The target identifier data is obtained locally by the querying end, and the target identifier data itself remains on the querying end. Subsequent content is all derived encrypted text from the target identifier data, ensuring that the queried object never leaves the querying end, thus achieving the technical effect of preventing the queried object from being captured. This application determines at least two candidate location data and corresponding identifier digest data based on target identifier data and a preset hash function. Each candidate location data includes row index data and slot index data, and the identifier digest data includes multiple digest bits. The query by identifier is transformed into a query by candidate location data. The candidate location data is expressed by two-dimensional grid coordinates composed of row index data and slot index data, and is uniquely determined by the target identifier data through a preset hash function. It is independent of the data distribution and insertion order of each data end, so that multiple parties can still hit the same target under the condition that there is no unified number and each party prepares data independently. This achieves the technical effect of unified addressing independent of data distribution. The identifier digest data provides a basis for the bit-by-bit equality determination of the ciphertext field in the form of multiple digest bits.

[0010] This application constructs location indication data for each candidate location data. In each location indication data, the slot corresponding to the slot index data of the corresponding candidate location data is a first preset value, and the remaining slots are second preset values. The candidate slot is expressed as location indication data where the first preset value is taken at the slot corresponding to the slot index data, and the second preset value is taken at the remaining slots. This forms a precise gating structure for the target slot. The slot position is directly determined by hashing rather than a fixed container, achieving the technical effect of precise candidate slot positioning. This application performs homomorphic encryption on each location indication data to determine the location selection ciphertext data corresponding to each candidate location data. The location indication data is homomorphically encrypted into location selection ciphertext data, so the data end can only access the ciphertext and cannot identify which slot is selected, achieving the technical effect of hiding the queried location from the data end. This application constructs separate summary indicator data for each summary bit of the identifier summary data. In each summary indicator data, each slot is set to the value of the corresponding summary bit. The identifier summary data is expanded bit by bit into summary indicator data, so that all slots carry the value of the corresponding summary bit, providing parallel input for bit-by-bit equality comparison of the ciphertext field and achieving the technical effect of parallel expression of summary bits. This application performs homomorphic encryption on each summary indicator data to determine the summary matching ciphertext data corresponding to each summary bit. Each summary indicator data is homomorphically encrypted into summary matching ciphertext data, and the query conditions are sent in bit-by-bit ciphertext form. The data end cannot know the target identifier summary content throughout the entire process, achieving the technical effect of keeping the query conditions confidential. This application determines the query request data based on the row index data of each candidate position, the ciphertext data of each position selection, and the ciphertext data of each digest matching, and sends the query request data to the relay end so that the relay end can send the query request data to multiple data ends. Among them, the row index data is included in the query request data in plaintext form, so that the query end constructs the query request data once and broadcasts it to multiple data ends through the relay end. The query overhead is decoupled from the number of data ends. Although the row index data is included in the query request data in plaintext form, the row index data is generated by cryptographic hash mapping, has a pseudo-random distribution, and is irreversible. The data ends cannot deduce the target identifier data from the row index data alone. This achieves the technical effect of transparent expansion of the data ends and the row index plaintext does not reveal the query target. This application receives reduced and aggregated ciphertext data sent by a relay end. The reduced and aggregated ciphertext data is obtained by the relay end performing homomorphic addition and slot reduction processing on the local result ciphertext data of multiple data ends. This allows the query end to receive a unique ciphertext after the local result ciphertext data of each data end is first mixed by homomorphic addition and then folded into a single slot by slot reduction. The individual contributions of each data end are indistinguishably mixed in the ciphertext, and the query end cannot distinguish the individual contribution value of any data end, thus achieving the technical effect that the query end only obtains the aggregated result.This application decrypts the reduced aggregated ciphertext data based on the private key data to determine the aggregated value data corresponding to the target identifier data. This allows the query end to obtain the aggregated value data with only one decryption, converging the query process into one request and one decryption. The number of interaction rounds is fixed, and the online overhead is independent of the database size of each data end, achieving the technical effect that query latency is independent of database size. This solves the problems of the querying party obtaining individual results for each institution when querying each institution individually, and the data provider obtaining the query object during processing.

[0011] In some technical solutions of this application, the candidate position data includes first candidate position data, second candidate position data, and third candidate position data; based on the target identifier data and the three position hash salt values, hash operations are performed respectively to determine the row index data of each candidate position data; based on the target identifier data and the three slot hash salt values, hash operations are performed respectively to determine the slot index data of each candidate position data; based on the target identifier data and the digest hash salt value data, hash operations are performed, and the hash operation result data is truncated to determine the identifier digest data; wherein, each candidate position data consists of corresponding row index data and slot index data; the candidate position data is determined by the target identifier data, a preset hash function, and salt value data.

[0012] In some technical solutions of this application, the privacy data aggregation query method further includes: determining private key data, first evaluation key data, and second evaluation key data based on homomorphic encryption parameters; saving the private key data; including the first evaluation key data in the query request data; using the first evaluation key data for relinearization processing after ciphertext multiplication; storing the second evaluation key data at a relay end; using the second evaluation key data for ciphertext rotation processing in slot reduction processing; performing content hashing on the first evaluation key data to determine key tag data; and enabling the query request data to carry the key tag data.

[0013] The second aspect of this application provides a privacy data aggregation query method for a data end, wherein the data end pre-stores a data grid and an overflow area; the data grid includes multiple data rows, each data row includes multiple slots, and each occupied slot stores identifier digest data and associated value data corresponding to local identifier data; the privacy data aggregation query method includes: receiving query request data sent by a relay end; the query request data includes row index data of candidate position data, position selection ciphertext data corresponding to each candidate position data, and digest matching ciphertext data corresponding to each digest bit data of the identifier digest data; reading each candidate data row in the data grid according to the row index data; for each candidate data row, according to the data stored in each slot of the candidate data row... The system performs bit-by-bit equality comparisons on the stored identifier digest data and each digest matching ciphertext data within the ciphertext field, and performs ciphertext multiplication and reduction processing on each bit-by-bit comparison result to determine the candidate matching ciphertext data corresponding to the candidate data row; based on each candidate matching ciphertext data, each position selection ciphertext data, and the associated value data stored in each candidate data row, it determines the candidate value ciphertext data; based on the identifier digest data and each digest matching ciphertext data stored in the overflow area, it performs ciphertext field equality comparisons, and determines the overflow value ciphertext data based on the comparison result data and the associated value data stored in the overflow area; it performs homomorphic addition processing on each candidate value ciphertext data and the overflow value ciphertext data to determine the single local result ciphertext data; and it sends the local result ciphertext data to the relay end.

[0014] The data terminal pre-stores a data grid and an overflow area. The data grid includes multiple data rows, and each data row includes multiple slots. Each occupied slot stores the identifier digest data and associated value data corresponding to the local identifier data. This allows the data terminal to encode the local identifier data and associated value data into the data grid or overflow area before querying. During the query phase, only a fixed number of candidate data rows and overflow area vectors are read. The online calculation range is determined by the number of slots and is independent of the total number of local data records, achieving the technical effect that query latency is independent of database size. The terminal receives query request data sent by the relay end. The query request data includes row index data of candidate position data, position selection ciphertext data corresponding to each candidate position data, and digest matching ciphertext data corresponding to each digest bit data of the identifier digest data. This allows the data terminal to obtain the row index data required to locate candidate data rows, the position selection ciphertext data required to select target slots, and the digest matching ciphertext data required for ciphertext field matching. These three types of data work together to constitute the ciphertext calculation input that the data terminal can execute, achieving the technical effect of self-sufficient query request data. Based on the index data of each row, each candidate data row in the data grid is read separately. This ensures that the data end only reads the candidate data rows corresponding to the candidate position data, limiting the calculation range to a fixed number of rows and achieving the technical effect that the calculation range does not expand with the database size. For each candidate data row, based on the identifier digest data and the encrypted data matching each digest stored in each slot of the candidate data row, a bit-by-bit equality comparison is performed in the encrypted field. The results of each bit-by-bit comparison are then subjected to encrypted multiplication and reduction processing to determine the candidate matching encrypted data corresponding to the candidate data row. This ensures that both the bit-by-bit equality comparison and reduction processing are performed in the encrypted field. The data end has full access to the encrypted data and cannot know the target identifier digest content, thus keeping the query object confidential from the data end. The candidate matching encrypted data is only 1 in the slot where the target identifier data is actually stored and 0 in the other slots, allowing subsequent value retrieval to accurately lock the target slot, achieving the technical effect of encrypted field matching and precise result positioning. Based on the candidate matching ciphertext data, the position selection ciphertext data, and the associated value data stored in each candidate data row, the candidate value ciphertext data is determined. The candidate matching ciphertext data is multiplied by the associated value plaintext vector and then multiplied by the position selection ciphertext data. The position selection ciphertext data is 1 only at the candidate slot and 0 at the other slots. This ensures that only the associated value of the candidate slot is retained in the candidate data row, while the other slots are cleared to zero, achieving the technical effect of accurate value acquisition and avoiding the erroneous accumulation of values ​​in the entire row. The three candidate position data correspond to three position selection ciphertext data respectively. The position selection ciphertext data is 1 at the slot corresponding to the slot index data of the corresponding candidate position data. Even if any two of the three candidate position data have the same slot index data value, they will not interfere with each other because they are applied to different candidate data rows. The multiplication of the position selection ciphertext data and the candidate matching ciphertext data does not interfere with each other.Based on the identifier digest data and the encrypted data matching each digest stored in the overflow area, an equivalence comparison is performed on the encrypted domain. Based on the comparison result data and the associated value data stored in the overflow area, the overflow value encrypted data is determined. This allows overflow area entries to complete equivalence comparisons and extract associated values ​​in the encrypted domain. Overflow area entries can be queried and covered even without grid coordinates, achieving query coverage with the same privacy protection as the data grid. Homomorphic addition is performed on the encrypted data of each candidate value and the encrypted data of the overflow value to determine a single local result encrypted data. This homomorphically merges the four results from the three candidate positions and the overflow area into a single local result encrypted data. The data end outputs only one encrypted data. The relay end and the query end cannot distinguish which candidate position or overflow area the result comes from, preventing the inference of the query target based on the result source, while reducing uplink communication traffic, achieving the technical effects of four-way merging and source anonymization. The local result encrypted data is sent to the relay end, allowing the data end to return the result with a single encrypted data. Subsequent aggregation only requires addition to this single encrypted data, achieving the technical effect of minimizing the data end output.

[0015] In some technical solutions of this application, the data grid and overflow area are established in the following way: For the local identification data to be stored, three candidate position data and the corresponding identification digest data of the local identification data are determined according to a preset hash function; when there is free candidate position data among the three candidate position data, the identification digest data and associated value data corresponding to the local identification data are stored in the free slot; when all three candidate slots are occupied, a kick-out replacement is performed: using the identification digest data of the current identification data to be placed and the kick-out round number as seeds, the candidate slot to be kicked out in this round is determined by taking the modulo of the total number of candidate numbers through deterministic hashing; wherein, when the kick-out replacement is performed for the first time, the kick-out round number is zero, and the kick-out round number is incremented once for each kick-out replacement.

[0016] Write the identifier summary data and associated value data of the currently placed identifier data into the selected slot and perform a kick-out replacement; take the kick-out identifier data originally stored in the slot as the new identifier data to be placed, and repeat the above kick-out replacement based on its corresponding candidate position data until the identifier data to be placed falls into an empty slot or the kick-out round number reaches the preset limit; when the number of re-placement reaches the preset limit, store the identifier summary data and associated value data corresponding to the currently placed identifier data into the overflow area; wherein, the candidate position data of any local identifier data is uniquely determined by the local identifier data and the preset hash function.

[0017] In some technical solutions of this application, based on the identifier digest data and digest matching ciphertext data stored in each slot of the candidate data row, a bit-by-bit equality comparison is performed in the ciphertext field, and ciphertext multiplication and reduction processing is performed on each bit-by-bit comparison result. This includes: determining the first coded data and the second coded data based on the digest bit data of the identifier digest data stored in each slot of the candidate data row; performing multiplication and addition processing on the corresponding digest matching ciphertext data, the first coded data, and the second coded data to determine the bit-by-bit matching ciphertext data; wherein, when the target digest bit data is the same as the stored digest bit data, the value of the corresponding slot is 1; when the target digest bit data is different from the stored digest bit data, the value of the corresponding slot is 0; performing multi-level ciphertext multiplication and reduction processing on each bit-by-bit matching ciphertext data to determine the candidate matching ciphertext data; wherein, relinearization processing is performed after each ciphertext multiplication processing.

[0018] In some technical solutions of this application, an equivalent comparison of the ciphertext fields is performed based on the identifier digest data stored in the overflow area and the ciphertext data matching each digest. This includes: performing parallel processing on the ciphertext data matching each digest and the identifier digest data stored in the overflow area to determine the overflow matching result ciphertext data; determining the overflow value ciphertext data based on the overflow matching result ciphertext data and the associated value data stored in the overflow area; wherein, in the overflow area slots that match the identifier digest data, the overflow value ciphertext data retains the corresponding associated value data; in the other overflow area slots, the corresponding value in the overflow value ciphertext data is zero.

[0019] A third aspect of this application provides a privacy data aggregation query method for a relay terminal. The privacy data aggregation query method includes: receiving query request data sent by a query terminal; the query request data includes location selection encrypted data and digest matching encrypted data; sending the query request data to multiple data terminals; receiving local result encrypted data sent by each data terminal; performing slot-by-slot homomorphic addition processing on the local result encrypted data of each data terminal to determine aggregated encrypted data; performing slot reduction processing on the aggregated encrypted data to determine reduced aggregated encrypted data; wherein, the slot reduction processing merges values ​​distributed in multiple slots into a single slot; and sending the reduced aggregated encrypted data to the query terminal.

[0020] This application receives query request data sent by the query end. The query request data includes location selection ciphertext data and digest matching ciphertext data, ensuring that the relay end only receives ciphertext-based query request data. The relay end has no plaintext input to observe, achieving zero plaintext contact for the relay end. The query request data is sent to multiple data ends, allowing the query request data to be constructed once by the query end and uniformly forwarded by the relay end. This decouples the query end and data ends, eliminating the need for the query end to reconstruct the query when the number of data ends increases, achieving transparent data end expansion. The application also receives local result ciphertext data sent by each data end, enabling the relay end to aggregate the single ciphertext results from each data end. Since the aggregation object is ciphertext, the relay end cannot know any plaintext contribution from any data end, achieving zero plaintext leakage during the aggregation process. The local result ciphertext data at each data endpoint undergoes slot-by-slot homomorphic addition to determine the aggregated ciphertext data. This ensures that candidate slots for the same preset hash function, salt value data, and target identifier data are aligned across all data endpoints. Slot-by-slot homomorphic addition superimposes and mixes the corresponding contributions from each data endpoint onto the ciphertext. Homomorphic addition is algebraically irreversible; even if the relay end saves all intermediate ciphertext, it cannot deduce the individual contribution value of any data endpoint, achieving the technical effect of aggregation privacy protection. Slot reduction processing is then applied to the aggregated ciphertext data to determine the reduced aggregated ciphertext data. This process merges values ​​distributed across multiple slots into a single slot, distributing the contributions from the three candidate positions and the overflow area across different slots. Slot reduction folds all slot values ​​into a single slot, making it impossible for the query endpoint to distinguish which candidate position or data endpoint the aggregated value data originated from, preventing the deduction of the query target through slot source and achieving the technical effect of slot source anonymization. The reduced and aggregated ciphertext data is sent to the query end, ensuring that the relay end outputs only one ciphertext, maintaining a constant return communication volume and minimizing the returned result. When the query end queries the same target identifier data multiple times, the aggregated value data obtained each time is the same sum. The aggregation process does not introduce randomness and does not additionally leak the distribution information of each data end. The relay end is a relay device that executes according to the protocol, only performing forwarding, slot-by-slot homomorphic addition, and slot reduction processing. It does not participate in plaintext calculation. The limited role of the relay end further ensures that the aggregation process is transparent to the relay end.

[0021] In some technical solutions of this application, slot reduction processing is performed on the aggregated ciphertext data, including: performing ciphertext rotation processing and homomorphic addition processing on the aggregated ciphertext data to reduce the values ​​in multiple slots to the first slot; wherein, the private key data used to decrypt the reduced aggregated ciphertext data is stored by the query end; the number of data ends is not less than 3.

[0022] The fourth aspect of this application provides a privacy data aggregation query system, including a query terminal, a relay terminal, and multiple data terminals. The query terminal is used to determine candidate position data and identifier digest data based on target identifier data and a preset hash function; to perform homomorphic encryption processing on the candidate position data and identifier digest data respectively to determine position selection ciphertext data and digest matching ciphertext data; to generate query request data based on the position selection ciphertext data and digest matching ciphertext data, and send it to the relay terminal; the relay terminal is used to send the query request data to multiple data terminals; the data terminals pre-store a data grid including multiple data rows and an overflow area; the data terminals are used to perform identifier digest matching and position selection in the ciphertext domain based on the query request data and locally stored identifier digest data and associated value data to determine local result ciphertext data, and send it to the relay terminal; the relay terminal is also used to perform homomorphic addition processing and slot reduction processing on the local result ciphertext data to determine reduced aggregate ciphertext data, and send it to the query terminal; the query terminal is also used to decrypt the reduced aggregate ciphertext data based on private key data to determine the aggregate value data corresponding to the target identifier data. The query request data does not need to include the position selection ciphertext data corresponding to the overflow area. The overflow area entries occupy independent slots in the vector according to the append order, and their matching and value retrieval do not require position selection ciphertext data.

[0023] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0024] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:

[0025] Figure 1 This is one of the flowcharts illustrating a privacy data aggregation query method according to an embodiment of this application;

[0026] Figure 2 This is a second schematic flowchart of a privacy data aggregation query method according to an embodiment of this application;

[0027] Figure 3 This is a third flowchart illustrating a privacy data aggregation query method according to an embodiment of this application;

[0028] Figure 4 This is a schematic block diagram of a privacy data aggregation query system according to an embodiment of this application;

[0029] Figure 5 This is a fourth flowchart illustrating a privacy data aggregation query method according to an embodiment of this application. Detailed Implementation

[0030] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.

[0031] Many specific details are set forth in the following description in order to provide a full understanding of this application. However, this application may also be implemented in other ways different from those described herein. Therefore, the scope of protection of this application is not limited to the specific embodiments disclosed below.

[0032] The following reference Figures 1 to 5 This application describes a privacy data aggregation query method and system according to some embodiments.

[0033] like Figure 1 As shown, embodiments of this application provide a privacy data aggregation query method for use on a query terminal. The privacy data aggregation query method includes:

[0034] Step 102, obtain target identifier data;

[0035] Step 104: Based on the target identifier data and the preset hash function, determine at least two candidate position data and the identifier digest data corresponding to the target identifier data. Each candidate position data includes row index data and slot index data, and the identifier digest data includes multiple digest bit data.

[0036] Step 106: For each candidate location data, construct location indication data respectively. In each location indication data, the slot corresponding to the slot index data of the corresponding candidate location data is the first preset value, and the remaining slots are the second preset values.

[0037] Step 108: Perform homomorphic encryption on each location indication data to determine the location selection ciphertext data corresponding to each candidate location data;

[0038] Step 110: Construct summary indicator data for each summary bit data that identifies the summary data; wherein, in each summary indicator data, each slot is set to the value of the corresponding summary bit data;

[0039] Step 112: Perform homomorphic encryption on each digest indicator data to determine the ciphertext data that matches the digest corresponding to each digest bit data;

[0040] Step 114: Based on the row index data of each candidate position data, the ciphertext data of each position selection, and the ciphertext data of each digest matching, determine the query request data and send the query request data to the relay end so that the relay end can send the query request data to multiple data ends; wherein, the row index data is included in the query request data in plaintext form;

[0041] Step 116: Receive the reduced and aggregated ciphertext data sent by the relay end; wherein, the reduced and aggregated ciphertext data is obtained by the relay end performing homomorphic addition and slot reduction processing on the local result ciphertext data of multiple data ends;

[0042] Step 118: Based on the private key data, decrypt the reduced aggregate ciphertext data to determine the aggregate value data corresponding to the target identifier data.

[0043] In the privacy data aggregation query method provided in this application, the target identifier data refers to the unique identifier of the object to be queried, such as a user identifier; the preset hash function refers to a pre-agreed cryptographic hash function, such as SM3 or SHA-256, which can be used with salt to derive hash results for different purposes; the candidate position data refers to a two-dimensional grid coordinate composed of row index data and slot index data, where the row index data indicates the data row number and the slot index data indicates the slot number within the data row; the identifier digest data refers to a fixed-length digest obtained by truncating the hash result of the target identifier data, which consists of multiple digest bits; the position indicator data refers to a vector with the same length as the number of slots in the data row, where the first preset value is used at the slot corresponding to the slot index data of the candidate position data, and the second preset value is used at the other slots; position selection Ciphertext data refers to the ciphertext obtained by homomorphically encrypting the location indicator data; digest indicator data refers to the vector corresponding to each digest bit data, with each slot set to the value of the corresponding digest bit data; digest matching ciphertext data refers to the ciphertext obtained by homomorphically encrypting the digest indicator data; query request data refers to the query message composed of row index data, location selection ciphertext data, and digest matching ciphertext data; reduction aggregation ciphertext data refers to the single ciphertext obtained by the relay end performing homomorphic addition on the ciphertext data of the local results of each data end and reducing the slots; slot reduction processing refers to the ciphertext operation of merging values ​​distributed in multiple slots into a single slot; private key data refers to the decryption key that is paired with the homomorphic encryption public key and stored by the query end; aggregated value data refers to the cross-data end aggregation result obtained after decrypting the reduction aggregation ciphertext data.

[0044] This application enables the querying party to perform a multi-party joint aggregation query on target identifier data without disclosing query conditions to multiple data parties and only obtaining cross-organizational aggregation results without seeing details of any individual data party. The target identifier data is obtained locally by the querying end, and the target identifier data itself remains on the querying end. Subsequent content is all derived encrypted text from the target identifier data, ensuring that the queried object never leaves the querying end, thus achieving the technical effect of preventing the queried object from being captured. This application determines at least two candidate location data and corresponding identifier digest data based on target identifier data and a preset hash function. Each candidate location data includes row index data and slot index data, and the identifier digest data includes multiple digest bits. The query by identifier is transformed into a query by candidate location data. The candidate location data is expressed by two-dimensional grid coordinates composed of row index data and slot index data, and is uniquely determined by the target identifier data through a preset hash function. It is independent of the data distribution and insertion order of each data end, so that multiple parties can still hit the same target under the condition that there is no unified number and each party prepares data independently. This achieves the technical effect of unified addressing independent of data distribution. The identifier digest data provides a basis for the bit-by-bit equality determination of the ciphertext field in the form of multiple digest bits.

[0045] This application constructs location indication data for each candidate location data. In each location indication data, the slot corresponding to the slot index data of the corresponding candidate location data is a first preset value, and the remaining slots are second preset values. The candidate slot is expressed as location indication data where the first preset value is taken at the slot corresponding to the slot index data, and the second preset value is taken at the remaining slots. This forms a precise gating structure for the target slot. The slot position is directly determined by hashing rather than a fixed container, achieving the technical effect of precise candidate slot positioning. This application performs homomorphic encryption on each location indication data to determine the location selection ciphertext data corresponding to each candidate location data. The location indication data is homomorphically encrypted into location selection ciphertext data, so the data end can only access the ciphertext and cannot identify which slot is selected, achieving the technical effect of hiding the queried location from the data end. This application constructs separate summary indicator data for each summary bit of the identifier summary data. In each summary indicator data, each slot is set to the value of the corresponding summary bit. The identifier summary data is expanded bit by bit into summary indicator data, so that all slots carry the value of the corresponding summary bit, providing parallel input for bit-by-bit equality comparison of the ciphertext field and achieving the technical effect of parallel expression of summary bits. This application performs homomorphic encryption on each summary indicator data to determine the summary matching ciphertext data corresponding to each summary bit. Each summary indicator data is homomorphically encrypted into summary matching ciphertext data, and the query conditions are sent in bit-by-bit ciphertext form. The data end cannot know the target identifier summary content throughout the entire process, achieving the technical effect of keeping the query conditions confidential. This application determines the query request data based on the row index data of each candidate position, the ciphertext data of each position selection, and the ciphertext data of each digest matching, and sends the query request data to the relay end so that the relay end can send the query request data to multiple data ends. Among them, the row index data is included in the query request data in plaintext form, so that the query end constructs the query request data once and broadcasts it to multiple data ends through the relay end. The query overhead is decoupled from the number of data ends. Although the row index data is included in the query request data in plaintext form, the row index data is generated by cryptographic hash mapping, has a pseudo-random distribution, and is irreversible. The data ends cannot deduce the target identifier data from the row index data alone. This achieves the technical effect of transparent expansion of the data ends and the row index plaintext does not reveal the query target. This application receives reduced and aggregated ciphertext data sent by a relay end. The reduced and aggregated ciphertext data is obtained by the relay end performing homomorphic addition and slot reduction processing on the local result ciphertext data of multiple data ends. This allows the query end to receive a unique ciphertext after the local result ciphertext data of each data end is first mixed by homomorphic addition and then folded into a single slot by slot reduction. The individual contributions of each data end are indistinguishably mixed in the ciphertext, and the query end cannot distinguish the individual contribution value of any data end, thus achieving the technical effect that the query end only obtains the aggregated result.This application decrypts the reduced aggregated ciphertext data based on the private key data to determine the aggregated value data corresponding to the target identifier data. This allows the query end to obtain the aggregated value data with only one decryption, converging the query process into one request and one decryption. The number of interaction rounds is fixed, and the online overhead is independent of the database size of each data end, achieving the technical effect that query latency is independent of database size. This solves the problems of the querying party obtaining individual results for each institution when querying each institution individually, and the data provider obtaining the query object during processing.

[0046] In one embodiment, the preset hash function is SM3 or SHA-256, the total number of slots N=32768, the number of rows P=1024, the identifier digest data is 32 bits, the position selection ciphertext data is 3, and the digest matching ciphertext data is 32. The query client's encryption time is less than 0.1 seconds, the decryption time is less than 0.1 seconds, and the compressed query message is approximately 85MB. The above parameters indicate that the online overhead of the query client is constant and does not change with the size of the database.

[0047] In some embodiments of this application, the candidate position data includes first candidate position data, second candidate position data, and third candidate position data; hash operations are performed on the target identifier data and the three position hash salt values ​​respectively to determine the row index data of each candidate position data; hash operations are performed on the target identifier data and the three slot hash salt values ​​respectively to determine the slot index data of each candidate position data; hash operations are performed on the target identifier data and the digest hash salt value data, and the hash operation result data is truncated to determine the identifier digest data; wherein, each candidate position data consists of corresponding row index data and slot index data; the candidate position data is determined by the target identifier data and the preset hash function and salt value data.

[0048] In the above embodiments, the three position hash salt values ​​in this application refer to three independent salt values ​​used to derive row index data; the three slot hash salt values ​​refer to three independent salt values ​​used to derive slot index data; the digest hash salt value refers to the salt value used to derive identifier digest data; the hash operation result data refers to the output of the hash function; and truncation refers to taking a fixed-length segment from the hash operation result data.

[0049] Candidate position data includes first, second, and third candidate position data, ensuring that the query simultaneously covers all three candidate position data. This guarantees that the target identifier data will be hit regardless of which of the three candidate position data falls into, achieving the technical effect of query coverage of all possible landing points. Hash operations are performed on the target identifier data and the hash salt values ​​of the three positions to determine the row index data for each candidate position data. Similarly, hash operations are performed on the target identifier data and the hash salt values ​​of the three slots to determine the slot index data for each candidate position data. This ensures that the row and slot index data are derived from different salt values, and the row and slot coordinates of the same target identifier data are independently randomized. The candidate position data is evenly distributed in the data grid, reducing the probability of placement collisions. Since all data ends use the same salt value data, the same target identifier data generates the same three candidate position data across all data ends. Even with different data distributions, insertion orders, and no unified numbering, each data end can still hit the same set of candidate positions based on the same target identifier data, achieving unified addressing without the need for coordination among multiple parties. Based on the target identifier data and digest hash salt value data, a hash operation is performed, and the hash result data is truncated to determine the identifier digest data. This ensures that the identifier digest data and the position hash are isolated using different salt values, and that the digest bit distribution and candidate position distribution are independent. The truncating method allows for configurable digest length, achieving a balance between matching accuracy and encrypted communication throughput. Each candidate position data consists of corresponding row index data and slot index data. The candidate position data is determined by the target identifier data, a preset hash function, and salt value data. This ensures that the generation of candidate position data depends only on the target identifier data, the preset hash function, and salt value data, and is independent of the data insertion order and collision process, achieving the technical effect of addressing determinism and reproducibility.

[0050] In one embodiment, the seven salt values ​​are derived from the suffixes _poly1 to _poly3, _slot1 to _slot3, and _fp, respectively. The identifier digest data is taken from the high 32 bits of the hash operation result. Different salt values ​​are used to isolate hashes for different purposes, preventing the same target identifier data from being correlated across different hash uses, further reducing the risk of correlation analysis by the data end. The preset hash function output length is no less than 256 bits, providing collision resistance. After the same target identifier data is hashed using 256 bits, 32 bits are truncated as the identifier digest data. The false positive probability of the identifier digest data is guaranteed by the uniform distribution property of the hash function, and the truncating method achieves a balance between digest length and matching accuracy.

[0051] In some embodiments of this application, the privacy data aggregation query method further includes: determining private key data, first evaluation key data, and second evaluation key data based on homomorphic encryption parameters; saving the private key data; including the first evaluation key data in the query request data; using the first evaluation key data for relinearization processing after ciphertext multiplication; storing the second evaluation key data at a relay end; using the second evaluation key data for ciphertext rotation processing in slot reduction processing; performing content hashing on the first evaluation key data to determine key tag data; and enabling the query request data to carry the key tag data.

[0052] In the above embodiments, the homomorphic encryption parameters in this application refer to the common parameters required to generate the key; the first evaluation key data refers to the evaluation key used for relinearization after ciphertext multiplication, i.e., the relinearization key; the second evaluation key data refers to the evaluation key used for ciphertext rotation, i.e., the rotation key; the shared storage location refers to the key directory that can be accessed by the query end, the data end, and the relay end; the content hashing process refers to calculating the hash of the key content itself; and the key tag data refers to the tag determined by the content hash of the first evaluation key data.

[0053] Based on homomorphic encryption parameters, private key data, first evaluation key data, and second evaluation key data are determined, and the private key data is stored. This ensures that the private key data is stored only by the query end, and neither the data end nor the relay end has decryption capabilities. Decryption authority converges to a single point at the query end, achieving the technical effect that intermediate links cannot decrypt any ciphertext. The first evaluation key data is included in the query request data; it is used for relinearization processing after ciphertext multiplication. This ensures that the data end, holding the first evaluation key data, can only perform the ciphertext multiplication and relinearization required for matching calculations. The data end cannot perform rotation reduction, achieving the technical effect of restricted computational permissions at the data end. The second evaluation key data is stored in a shared storage location accessible to the relay end. This second evaluation key data is used for ciphertext rotation in slot reduction processing, ensuring that the relay end, holding the second evaluation key data, can only perform the ciphertext rotation required for slot reduction. The relay end cannot perform multiplication operations, achieving the technical effect of restricted computational permissions for the relay end. The first and second evaluation key data are distributed separately according to computational roles, preventing either end from exceeding its own protocol role, achieving role-based key boundary control and reducing the risk of key surface exposure. The first evaluation key data undergoes content hashing to determine key tag data and to include key tag data in query request data. The key tag data is determined by the key content hash, and the query request data only carries the tag data. The key file is named with the content hash and stored in a shared storage location. The key name does not carry an organization identifier. Each end matches the key based on the tag, making it impossible to identify the key's belonging organization during key distribution, avoiding the leakage of organization identities within the alliance, achieving anonymous key distribution. It also supports key preloading and cross-query reuse, reducing the amount of key transmission per query and achieving flexible deployment.

[0054] In one embodiment, the first evaluation key data is approximately 28MB in size, the second evaluation key data is approximately 413MB in size, and the key tag data is a 32-byte content hash. The large second evaluation key data is preloaded through a shared directory, while the small first evaluation key data is carried with the query request data, so that the query message remains small in size. The first evaluation key data can also be preloaded by scanning the shared directory when the data terminal starts up, in order to adapt to network environments with different security levels.

[0055] like Figure 2 As shown, an embodiment of this application provides a privacy data aggregation query method for a data end. The data end pre-stores a data grid and an overflow area. The data grid includes multiple data rows, and each data row includes multiple slots. Each occupied slot stores identifier digest data and associated value data corresponding to local identifier data. The privacy data aggregation query method includes:

[0056] Step 202: Receive query request data sent by the relay end; the query request data includes row index data of candidate position data, position selection ciphertext data corresponding to each candidate position data, and digest matching ciphertext data corresponding to each digest bit data of the identifier digest data;

[0057] Step 204: Based on the index data of each row, read each candidate data row in the data grid respectively;

[0058] Step 206: For each candidate data row, based on the identifier digest data and digest matching ciphertext data stored in each slot of the candidate data row, perform a bit-by-bit equality comparison in the ciphertext field, and perform ciphertext multiplication reduction processing on each bit-by-bit comparison result to determine the candidate matching ciphertext data corresponding to the candidate data row.

[0059] Step 208: Determine the ciphertext data of each candidate value based on the ciphertext data of each candidate matching, the ciphertext data of each position selection, and the associated value data stored in each candidate data row;

[0060] Step 210: Based on the identifier digest data and each digest matching ciphertext data stored in the overflow area, perform ciphertext field equality comparison, and determine the overflow value ciphertext data based on the comparison result data and the association value data stored in the overflow area.

[0061] Step 212: Perform homomorphic addition on the ciphertext data of each candidate value and the ciphertext data of the overflow value to determine the single local result ciphertext data;

[0062] Step 214: Send the encrypted data of the local result to the relay.

[0063] In the privacy data aggregation query method provided in this application, a data grid refers to a two-dimensional storage structure composed of multiple data rows; a data row refers to a row in the data grid, containing multiple slots; a slot refers to a storage unit within a data row; an overflow area refers to an independent storage area storing entries not placed in the data grid; a candidate data row refers to a data row pointed to by the row index data; candidate matching ciphertext data refers to the matching result ciphertext obtained after comparing and reducing the ciphertext fields bit by bit; candidate value ciphertext data refers to the associated value ciphertext extracted from the candidate data row; overflow value ciphertext data refers to the associated value ciphertext extracted from the overflow area; and local result ciphertext data refers to the single ciphertext after merging the results of the candidate area and the overflow area.

[0064] The data terminal pre-stores a data grid and an overflow area. The data grid includes multiple data rows, and each data row includes multiple slots. Each occupied slot stores the identifier digest data and associated value data corresponding to the local identifier data. This allows the data terminal to encode the local identifier data and associated value data into the data grid or overflow area before querying. During the query phase, only a fixed number of candidate data rows and overflow area vectors are read. The online calculation range is determined by the number of slots and is independent of the total number of local data records, achieving the technical effect that query latency is independent of database size. The terminal receives query request data sent by the relay end. The query request data includes row index data of candidate position data, position selection ciphertext data corresponding to each candidate position data, and digest matching ciphertext data corresponding to each digest bit data of the identifier digest data. This allows the data terminal to obtain the row index data required to locate candidate data rows, the position selection ciphertext data required to select target slots, and the digest matching ciphertext data required for ciphertext field matching. These three types of data work together to constitute the ciphertext calculation input that the data terminal can execute, achieving the technical effect of self-sufficient query request data. Based on the index data of each row, each candidate data row in the data grid is read separately. This ensures that the data end only reads the candidate data rows corresponding to the candidate position data, limiting the calculation range to a fixed number of rows and achieving the technical effect that the calculation range does not expand with the database size. For each candidate data row, based on the identifier digest data and the encrypted data matching each digest stored in each slot of the candidate data row, a bit-by-bit equality comparison is performed in the encrypted field. The results of each bit-by-bit comparison are then subjected to encrypted multiplication and reduction processing to determine the candidate matching encrypted data corresponding to the candidate data row. This ensures that both the bit-by-bit equality comparison and reduction processing are performed in the encrypted field. The data end has full access to the encrypted data and cannot know the target identifier digest content, thus keeping the query object confidential from the data end. The candidate matching encrypted data is only 1 in the slot where the target identifier data is actually stored and 0 in the other slots, allowing subsequent value retrieval to accurately lock the target slot, achieving the technical effect of encrypted field matching and precise result positioning. Based on the candidate matching ciphertext data, the position selection ciphertext data, and the associated value data stored in each candidate data row, the candidate value ciphertext data is determined. The candidate matching ciphertext data is multiplied by the associated value plaintext vector and then multiplied by the position selection ciphertext data. The position selection ciphertext data is 1 only at the candidate slot and 0 at the other slots. This ensures that only the associated value of the candidate slot is retained in the candidate data row, while the other slots are cleared to zero, achieving the technical effect of accurate value acquisition and avoiding the erroneous accumulation of values ​​in the entire row. The three candidate position data correspond to three position selection ciphertext data respectively. The position selection ciphertext data is 1 at the slot corresponding to the slot index data of the corresponding candidate position data. Even if any two of the three candidate position data have the same slot index data value, they will not interfere with each other because they are applied to different candidate data rows. The multiplication of the position selection ciphertext data and the candidate matching ciphertext data does not interfere with each other.Based on the identifier digest data and the encrypted data matching each digest stored in the overflow area, an equivalence comparison is performed on the encrypted domain. Based on the comparison result data and the associated value data stored in the overflow area, the overflow value encrypted data is determined. This allows overflow area entries to complete equivalence comparisons and extract associated values ​​in the encrypted domain. Overflow area entries can be queried and covered even without grid coordinates, achieving query coverage with the same privacy protection as the data grid. Homomorphic addition is performed on the encrypted data of each candidate value and the encrypted data of the overflow value to determine a single local result encrypted data. This homomorphically merges the four results from the three candidate positions and the overflow area into a single local result encrypted data. The data end outputs only one encrypted data. The relay end and the query end cannot distinguish which candidate position or overflow area the result comes from, preventing the inference of the query target based on the result source, while reducing uplink communication traffic, achieving the technical effects of four-way merging and source anonymization. The local result encrypted data is sent to the relay end, allowing the data end to return the result with a single encrypted data. Subsequent aggregation only requires addition to this single encrypted data, achieving the technical effect of minimizing the data end output.

[0065] In one embodiment, the total number of slots N=32768. The data end performs one round of ciphertext field matching and value extraction for each of the three candidate data rows, and performs one SIMD parallel matching for the overflow area. The four results are merged into one ciphertext. Homomorphic encryption uses the BGV scheme, with a ring dimension of 32768, a ciphertext modulus of 2 to the power of 561, and a security strength of no less than 128 bits. Ciphertext field matching and value extraction for the ciphertext digest data takes approximately 3-4 seconds, and the online processing time remains unchanged when the number of records on the data end increases from 10,000 to 10 million. The increase in data volume only affects the collision rate in the offline encoding stage, which is a one-time preprocessing step. The plaintext modulus is approximately 2.25 × 10¹. 5 Furthermore, the plaintext modulus must be greater than the upper limit of the aggregated result of the contribution values ​​of all data ends, that is, greater than the maximum possible value of the sum of the association values ​​of each data end for the target identifier data, in order to avoid modular wrap-around during the homomorphic addition aggregation process, which would lead to incorrect decryption results. In actual deployment, the plaintext modulus can be selected according to the upper limit of the aggregated value data. The production environment adopts a ring dimension of 32768 and a ciphertext modulus of 2 to the power of 561, providing a security strength of no less than 128 bits. The test mode can adopt a ring dimension of 8192 and a ciphertext modulus of 2 to the power of 506, which also provides a security strength of no less than 128 bits, and is only used for functional verification.

[0066] In some embodiments of this application, the data grid and overflow area are established as follows: For the local identification data to be stored, three candidate location data and the corresponding identification digest data of the local identification data are determined according to a preset hash function; when there is free candidate location data among the three candidate location data, the identification digest data and associated value data corresponding to the local identification data are stored in the free slot; when all three candidate slots are occupied, a kick-out replacement is performed: using the identification digest data of the current identification data to be placed and the kick-out round number as seeds, the candidate slot to be kicked out in this round is determined by taking the modulo of the total number of candidate numbers using deterministic hashing; wherein, the kick-out round number is zero when the kick-out replacement is performed for the first time, and the kick-out round number is incremented once for each kick-out replacement.

[0067] Write the identifier summary data and associated value data of the currently placed identifier data into the selected slot and perform a kick-out replacement; take the kick-out identifier data originally stored in the slot as the new identifier data to be placed, and repeat the above kick-out replacement based on its corresponding candidate position data until the identifier data to be placed falls into an empty slot or the kick-out round number reaches the preset limit; when the number of re-placement reaches the preset limit, store the identifier summary data and associated value data corresponding to the currently placed identifier data into the overflow area; wherein, the candidate position data of any local identifier data is uniquely determined by the local identifier data and the preset hash function.

[0068] In the above embodiments, idle candidate position data refers to candidate position data for which no data is stored in the corresponding slot; occupied status refers to the status of a slot that has stored data; kicked-out flag data refers to stored flag data that has been removed due to a conflict; repositioning refers to finding a new storage location for the kicked-out flag data; preset upper limit refers to the upper limit of the number of repositioning attempts; unique determination means that the result is determined only by the input data and the hash function.

[0069] For the local identification data to be stored, three candidate location data and the corresponding identifier digest data are determined according to a preset hash function. This ensures that each local identification data obtains the same three candidate location data and identifier digest data during the encoding stage as the query stage. Encoding and querying share the same set of hash rules, achieving the technical effect of consistent addressing between encoding and querying. When there is free candidate location data among the three candidate location data, the identifier digest data and associated value data corresponding to the local identification data are stored in the free slot. This ensures that the local identification data preferentially falls into the free slot among the three candidate location data. The placement result depends only on the candidate location set. The query end can cover the storage possibilities of all data ends through the same hash calculation. The addressing result does not change with the data insertion order of each data end, solving the problem of inconsistent addressing when different institutions prepare data independently and the insertion order is different. When all three candidate positions are occupied, a kick-out replacement is performed: using the identifier digest data of the current identifier to be placed and the kick-out round number (incrementing sequentially from zero) as seeds, a deterministic hash is used to take the modulo of the total number of candidate numbers to determine the candidate slot to be kicked out in this round; the identifier digest data and associated value data of the current identifier to be placed are written into the selected slot for kick-out replacement; the kick-out identifier data originally stored in that slot is used as the new identifier to be placed, and the above kick-out replacement is repeated based on its corresponding candidate position data until the identifier to be placed falls into an empty slot or the kick-out round number reaches the preset upper limit. The data grid occupancy rate is significantly higher than that of ordinary three-way hash placement, and most entries fall into the three candidate position data, ensuring that the query terminal can hit the data in the three candidate positions with a high probability, reducing the number of entries falling into the overflow area, and achieving the technical effect of high occupancy rate and high hit rate. When the number of replacements reaches a preset limit, the identifier digest data and associated value data corresponding to the currently placed identifier data are stored in the overflow area. This preset limit ensures the bounded termination of the kick-out chain, making the encoding process controllable. Extreme collisions are handled by the overflow area, and the query end performs a separate match in the overflow area, without affecting the query's correctness. This achieves the technical effect of bounded encoding and guaranteed query correctness. Specifically, the candidate position data for any local identifier data is uniquely determined by the local identifier data and a preset hash function. This ensures that the candidate position data is determined solely by the local identifier data and the preset hash function. The same target identifier data may fall into different candidate position data on different data ends, for example, falling into the first candidate position data on data end A and the second candidate position data on data end B. This is because the datasets and collision distributions are different on each data end. The query end only needs to include all three candidate position data in the query request data to ensure that the target is hit on all data ends. This maintains query correctness even when the placement result changes with the collision distribution, achieving the technical effect of decoupling addressing and placement.

[0070] In one embodiment, the preset upper limit is 64 steps. When kicking out, the identifier digest data of the current identifier data to be placed and the kick-out round number (incrementing sequentially from zero) are used as seeds. The total number of candidate numbers is moduloed by deterministic hashing (processing steps modulo 3). After encoding, the data grid occupancy rate is not less than 80%, and there are very few overflow entries. Offline encoding of 10 million records takes about 3-5 minutes, and the encoding process is a one-time preprocessing that does not affect the online query latency.

[0071] In one embodiment, the data grid and overflow area are established using a randomized, selected cuckoo hashing method.

[0072] Specifically, for the local identifier data to be stored, hash operations are performed according to a preset hash function and the hash salt values ​​of the three positions to determine the row index data of the three candidate positions of the local identifier data; hash operations are performed according to the preset hash function and the hash salt values ​​of the three slots to determine the slot index data of the three candidate positions; hash operations are performed according to the preset hash function and the digest hash salt values, and the result data is truncated to determine the identifier digest data (e.g., 32 bits) corresponding to the local identifier data. The three candidate positions consist of corresponding row index data and slot index data, and are uniquely determined only by the local identifier data, the preset hash function, and the salt values, regardless of the existing data content in the data grid at the data end or the data insertion order.

[0073] During placement, the current identifier data to be placed is initially set to the local identifier data to be stored. The kick-out round number is incremented sequentially from zero, and the following placement and kick-out process is repeated:

[0074] First, check in sequence whether the slots corresponding to the three candidate positions of the current identifier data to be placed are in an empty state; when there is an empty slot among the three candidate positions, write the identifier summary data and association value data of the current identifier data to be placed into the empty slot to complete the placement.

[0075] When all slots corresponding to the three candidate position data are occupied, a kick-out replacement is performed: using the identifier digest data of the current identifier data to be placed and the current kick-out round number as seeds, a deterministic hash operation is performed and modulo the number of candidate position data (i.e., 3) to determine the candidate position data to be kicked out in this round; the identifier data originally stored in the selected slot is used as the kicked-out identifier data, and the identifier digest data and associated value data of the current identifier data to be placed are written into the slot to complete the kick-out replacement in this round, and the kick-out round number is incremented; subsequently, the kicked-out identifier data is used as the new current identifier data to be placed, and based on the three candidate position data of the kicked-out identifier data itself, the above placement and kick-out process is repeated until the current identifier data to be placed falls into an empty slot of one of its own candidate position data, or the kick-out round number reaches the preset upper limit (e.g., 64).

[0076] When the kick-out sequence number reaches the preset upper limit and the currently pending identifier data has not yet fallen into an empty slot, the identifier summary data and associated value data corresponding to the currently pending identifier data are stored in the overflow area in append order, so that the overflow area entries are stored linearly; the datasets of each data end are different, and their overflow area contents are different.

[0077] During the placement process described above, the local identifier data stored in any occupied slot within the data grid is located in one of its three candidate position data. When the data is first directly placed, it is written into an empty slot of its own candidate position data. After being removed, the data becomes the new identifier data to be placed, re-placed based solely on its own three candidate position data. Therefore, each replacement step uses the candidate position of the data to be placed as the landing point, ensuring bounded replacement without duplication or omission. The data grid and overflow area together cover all local identifier data on the data end. Simultaneously, the candidate position removed in this round is determined solely by the identifier digest data of the currently placed identifier data and the removal round number through deterministic hashing. Encoding the same dataset on the same data end allows for a completely consistent layout. Furthermore, the query end only needs to cover the three candidate position data and the overflow area for matching the target identifier data; it does not need to reproduce the selection and removal process on the data end. Therefore, changes in the selection and removal strategy do not affect the query accuracy on the query end, only the data grid occupancy rate and the number of overflow area entries.

[0078] In one embodiment, based on the BGV ring dimension N=32768 (LogN=15), number of rows P=1024, number of slots per row 32768 (total grid slots approximately 33.55 million), a preset upper limit of 64 for kick-out chains, and an overflow area capacity of 256, the above-mentioned randomized kick-out method is used to perform offline encoding on the local dataset of a single node: when the data volume is 10 million records (occupancy rate approximately 0.298), 15 million records (occupancy rate approximately 0.447), 2 When the data volume is 10 million records (occupancy rate of approximately 0.596), the number of overflow entries is 0, and all data falls completely into the data grid; when the data volume is 25 million records (occupancy rate of approximately 0.745), the number of overflow entries is approximately 202 to 210, which is within the overflow capacity budget (256) but close to the budget limit; when the data volume is 28 million records (occupancy rate of approximately 0.834), the number of overflow entries increases sharply to approximately 26,000, exceeding the overflow capacity budget.

[0079] Compared to the round-robin kicking method that modulo the number of candidates based on the kicking round number, randomized kicking increases the safe loading rate for zero overflow entries from approximately 0.40 to approximately 0.60, nearly doubling it; the upper limit of data grid occupancy that can be carried within the overflow capacity budget (256) is approximately 0.745. Therefore, in actual deployment, it is advisable to control the data grid occupancy rate in the range of approximately 0.60 to 0.745 and reserve a margin for the overflow area; when the occupancy rate corresponding to the expected data volume exceeds this range, it can be carried by increasing the preset upper limit of the kicking chain, expanding the data grid, or expanding the overflow area, so as to avoid the overflow entries exceeding the capacity budget.

[0080] In some embodiments of this application, based on the identifier digest data and the digest matching ciphertext data stored in each slot of the candidate data row, a bit-by-bit equality comparison is performed in the ciphertext field, and ciphertext multiplication and reduction processing is performed on each bit-by-bit comparison result. This includes: determining first encoded data and second encoded data based on the digest bit data of the identifier digest data stored in each slot of the candidate data row; performing multiplication and addition processing on the corresponding digest matching ciphertext data, first encoded data, and second encoded data to determine the bit-by-bit matching ciphertext data; wherein, when the target digest bit data is the same as the stored digest bit data, the value of the corresponding slot is 1; when the target digest bit data is different from the stored digest bit data, the value of the corresponding slot is 0; performing multi-level ciphertext multiplication and reduction processing on each bit-by-bit matching ciphertext data to determine the candidate matching ciphertext data; wherein, relinearization processing is performed after each ciphertext multiplication processing.

[0081] In the above embodiments, the first encoded data in this application refers to the multiplicative encoded vector corresponding to the storage bit; the second encoded data refers to the additive encoded vector corresponding to the storage bit; the bit-by-bit matching ciphertext data refers to the ciphertext field equivalent comparison result of a single digest bit data; the multi-layer ciphertext multiplication reduction processing refers to the operation of multiplying multiple bit-by-bit matching ciphertext data pairwise and merging them into a single ciphertext; and the relinearization processing refers to the operation of restoring the ciphertext dimension to two dimensions using the evaluation key after ciphertext multiplication.

[0082] Based on the identifier digest data and the ciphertext data matching each digest stored in each slot of the candidate data row, a bit-by-bit equality comparison is performed in the ciphertext field. The results of each bit-by-bit comparison are then subjected to ciphertext multiplication and reduction processing, including this reference feature. This ensures that the detailed steps of the bit-by-bit equality comparison and reduction processing are all carried out within the framework of the aforementioned ciphertext field matching steps, maintaining the complete connection between the essential reference relationships and the technical logic. Based on the digest bits of the identifier digest data stored in each slot of the candidate data row, the first encoded data and the second encoded data are determined. The data end constructs two sets of vectors—multiplicative and additive—based on the locally stored digest bit values, providing plaintext-side computational material for the bit-by-bit comparison in the ciphertext field. The encoded data corresponds one-to-one with the digest bit values, automating the preparation for the comparison operation. Based on the corresponding digest matching ciphertext data, first encoded data, and second encoded data, multiplication and addition processes are performed to determine the bit-by-bit matching ciphertext data. Specifically, when the target digest bit data and the stored digest bit data are the same, the corresponding slot value is 1; when the target digest bit data and the stored digest bit data are different, the corresponding slot value is 0. The slot with a storage bit of 1 is encoded as having 1 in the first encoded data and 0 in the second encoded data; the slot with a storage bit of 0 is encoded as having -1 in the first encoded data and -1 in the second encoded data. The code data is set to 1. The digest matching ciphertext data is multiplied once by the first encoded data and then added once by the second encoded data. This allows for a bit-by-bit equality comparison in the ciphertext field: when the target bit and the storage bit are both 1, we get 1×1+0=1; when they are both 0, we get 0×(-1)+1=1; and when they are different, we get 0. Bit-by-bit comparison only consumes one ciphertext-plaintext multiplication and one addition. The overhead of ciphertext-plaintext multiplication is much smaller than that of ciphertext-ciphertext multiplication, achieving the technical effect of completing the ciphertext field equality determination at low cost. Multi-level ciphertext multiplication and reduction processing is performed on each bit-by-bit matching ciphertext data to determine candidate matching ciphertext data. Each bit-by-bit matching ciphertext data is multiplied in pairs and merged layer by layer into a single candidate matching ciphertext data. The slot value is 1 only when all digest bits are the same, achieving accurate determination of overall matching of multiple digest bits and avoiding false hits caused by single digest bit collisions. In this process, relinearization is performed after each ciphertext multiplication. This ensures that when the ciphertext dimension grows from two-dimensional to three-dimensional after multiplication, it is immediately relinearized back to two-dimensional. This controls the growth of ciphertext size and noise, guarantees that multi-level reduction can be executed continuously, and ensures that the final ciphertext can be correctly decrypted. This achieves the feasibility and correctness of multi-level ciphertext multiplication.

[0083] In some embodiments of this application, determining the first encoded data and the second encoded data includes: when the storage digest bit data is 1, the first encoded data is set to 1 and the second encoded data is set to 0; when the storage digest bit data is 0, the first encoded data is set to -1 and the second encoded data is set to 1. The bit-by-bit matching ciphertext data is obtained by performing a ciphertext-plaintext multiplication on the digest matching ciphertext data and the first encoded data, and then performing a ciphertext-plaintext addition on the second encoded data; thus, when the target digest bit data and the storage digest bit data are the same, the corresponding slot bit value is 1, and when they are different, the corresponding slot bit value is 0, completing the bit-by-bit equality comparison with only one ciphertext-plaintext multiplication and one addition.

[0084] In one embodiment, the identifier digest data is 32 bits, and the digest matching ciphertext data consists of 32 entries. These 32 bit-by-bit matching ciphertext data are reduced through five layers of ciphertext multiplication (32→16→8→4→2→1) to obtain candidate matching ciphertext data, with relinearization performed after each layer of multiplication. The false positive rate of the 32-bit identifier digest data is approximately 1 / 4.3×10⁻⁶. 9 The expected false positive rate for a single candidate data row with 32,768 slots is approximately 7.6 × 10⁻ 6 The combined false positive probability of the three candidate positions and the overflow area is extremely low, and the query results are accurate and reliable.

[0085] In some embodiments of this application, an equivalence comparison of the ciphertext fields is performed based on the identifier digest data stored in the overflow area and the ciphertext data matching each digest. This includes: performing parallel processing on the ciphertext data matching each digest and the identifier digest data stored in the overflow area to determine the overflow matching result ciphertext data; determining the overflow value ciphertext data based on the overflow matching result ciphertext data and the associated value data stored in the overflow area; wherein, in the overflow area slots that match the identifier digest data, the overflow value ciphertext data retains the corresponding associated value data; in the other overflow area slots, the corresponding value in the overflow value ciphertext data is zero.

[0086] In the above embodiments, parallel processing refers to the simultaneous operation on multiple slots using the SIMD characteristics of homomorphic encryption plaintext slots; overflow matching result ciphertext data refers to the ciphertext of the matching result of the overflow area slot by slot; the matching overflow area slot refers to the slot that stores the digest and the identifier digest data are the same.

[0087] Based on the identifier digest data stored in the overflow area and the ciphertext data matching each digest, an equivalence comparison of the ciphertext fields is performed, including this reference feature. This allows the detailed steps of the overflow area comparison to unfold within the framework of the aforementioned overflow area matching steps, maintaining the integrity of the reference relationship. The ciphertext data matching each digest and the identifier digest data stored in the overflow area are processed in parallel to determine the ciphertext data of the overflow matching results. Overflow area entries are encoded into different slots of the vector in append order. Leveraging the SIMD parallel characteristics of homomorphic encryption plaintext slots, the digest equivalence comparison of all overflow area entries is completed simultaneously in a single operation. Overflow area entries can be queried even without grid coordinates, and the matching time does not increase linearly with the number of overflow area entries. This achieves the technical effect of querying entries with extreme conflicts falling into the overflow area with constant overhead. Since overflow area entries are stored linearly in append order, each entry occupies an independent slot in the vector, and the entries themselves have no grid coordinates, the matching and value retrieval of the overflow area do not require position selection ciphertext data. The query request data does not need to construct any additional position indicators for the overflow area, further reducing the amount of construction and communication at the query end. Based on the ciphertext data of the overflow matching result and the associated value data stored in the overflow area, the ciphertext data of the overflow value is determined. The associated value is extracted by multiplying the ciphertext data of the overflow matching result with the associated value in the overflow area, thus achieving the ciphertext extraction of the overflow area value. Specifically, in the overflow area slots that match the identifier digest data, the ciphertext data of the overflow value retains the corresponding associated value data; in the remaining overflow area slots, the corresponding value in the ciphertext data of the overflow value is zero. This ensures that only the matching slots retain the associated value, while the remaining slots are cleared. When the overflow area vector is homomorphically added to the ciphertext data of each candidate value, even if the overflow area content at each data end is different or the same slot index corresponds to different entries, no erroneous contribution will occur, achieving the technical effect of correctly merging the overflow area and the candidate area.

[0088] In one embodiment, the overflow area capacity S=256, the identifier digest data and the associated value data of the overflow entries are encoded as N-dimensional vectors respectively, a parallel equal-value comparison and reduction is performed to match all overflow entries, and then the associated value is extracted by a ciphertext-plaintext multiplication to form the overflow value ciphertext data.

[0089] like Figure 3 As shown, an embodiment of this application provides a privacy data aggregation query method for use at a relay end. The privacy data aggregation query method includes:

[0090] Step 302: Receive query request data sent by the querying end; the query request data includes location selection ciphertext data and digest matching ciphertext data;

[0091] Step 304: Send the query request data to multiple data endpoints;

[0092] Step 306: Receive the local result encrypted data sent by each data terminal;

[0093] Step 308: Perform slot-by-slot homomorphic addition on the local result ciphertext data of each data terminal to determine the aggregated ciphertext data;

[0094] Step 310: Perform slot reduction processing on the aggregated ciphertext data to determine the reduced aggregated ciphertext data; wherein, slot reduction processing merges values ​​distributed in multiple slots into a single slot;

[0095] Step 312: Send the reduced and aggregated ciphertext data to the query terminal.

[0096] In the privacy data aggregation query method proposed in this application, broadcasting refers to sending the same query request data to all data ends; slot-by-slot homomorphic addition refers to ciphertext addition aligned by slot; aggregated ciphertext data refers to the ciphertext obtained by adding multiple local result ciphertext data slot-by-slot; and reduced aggregated ciphertext data refers to the single ciphertext obtained after slot reduction processing.

[0097] The relay terminal receives query request data sent by the query end. This data includes encrypted location selection data and encrypted digest matching data, ensuring the relay only receives encrypted query request data. The relay has no plaintext input to observe, achieving zero plaintext contact for the relay. The relay sends the query request data to multiple data ends, allowing the query request data to be constructed once by the query end and uniformly forwarded by the relay. This decouples the query end from the data ends, eliminating the need for the query end to reconstruct the query as the number of data ends increases, achieving transparent data end expansion. The relay also receives encrypted local results from each data end, enabling it to aggregate single encrypted results from all data ends. Since the aggregation object is encrypted, the relay cannot know any plaintext contribution from any data end, achieving zero plaintext leakage during the aggregation process. The local result ciphertext data at each data endpoint undergoes slot-by-slot homomorphic addition to determine the aggregated ciphertext data. This ensures that candidate slots for the same preset hash function, salt value data, and target identifier data are aligned across all data endpoints. Slot-by-slot homomorphic addition superimposes and mixes the corresponding contributions from each data endpoint onto the ciphertext. Homomorphic addition is algebraically irreversible; even if the relay end saves all intermediate ciphertext, it cannot deduce the individual contribution value of any data endpoint, achieving the technical effect of aggregation privacy protection. Slot reduction processing is then applied to the aggregated ciphertext data to determine the reduced aggregated ciphertext data. This process merges values ​​distributed across multiple slots into a single slot, distributing the contributions from the three candidate positions and the overflow area across different slots. Slot reduction folds all slot values ​​into a single slot, making it impossible for the query endpoint to distinguish which candidate position or data endpoint the aggregated value data originated from, preventing the deduction of the query target through slot source and achieving the technical effect of slot source anonymization. The reduced and aggregated ciphertext data is sent to the query end, ensuring that the relay end outputs only one ciphertext, maintaining a constant return communication volume and minimizing the returned result. When the query end queries the same target identifier data multiple times, the aggregated value data obtained each time is the same sum. The aggregation process does not introduce randomness and does not additionally leak the distribution information of each data end. The relay end is a relay device that executes according to the protocol, only performing forwarding, slot-by-slot homomorphic addition, and slot reduction processing. It does not participate in plaintext calculation. The limited role of the relay end further ensures that the aggregation process is transparent to the relay end.

[0098] In one embodiment, when the number of data endpoints is 5, the relay end only adds one ciphertext addition and one slot reduction. The aggregation and reduction take about 2-3 seconds, and the query end still only receives one reduced and aggregated ciphertext data. The total online time is about 5-7 seconds and does not change with the size of the data endpoint database. Based on an 8-core 16G server, the query encryption time is less than 0.1 seconds, the ciphertext field matching and value extraction of the identifier digest data takes about 3-4 seconds, the aggregation and slot reduction take about 2-3 seconds, the decryption time is less than 0.1 seconds, and the total time for a single query is about 8-12 seconds (or 5-7 seconds). The above online time remains unchanged when the data endpoint database increases from 10,000 records to 10 million records.

[0099] In some embodiments of this application, slot reduction processing is performed on the aggregated ciphertext data, including: performing ciphertext rotation processing and homomorphic addition processing on the aggregated ciphertext data to reduce the values ​​in multiple slots to the first slot; wherein, the private key data used to decrypt the reduced aggregated ciphertext data is stored by the query end; the number of data ends is not less than 3.

[0100] In the above embodiments, the ciphertext rotation processing refers to the cyclic shifting of the ciphertext slots using a rotation key; the first slot refers to the slot with a slot index of 0.

[0101] Slot reduction processing, including this referencing feature, is performed on the aggregated ciphertext data. This allows the detailed steps of slot reduction to unfold within the slot reduction processing framework, maintaining the integrity of the referencing relationships. Ciphertext rotation and homomorphic addition are then applied to the aggregated ciphertext data, reducing values ​​from multiple slots to the first slot. Multiple ciphertext rotations cyclically shift values ​​from different slots to the first slot and then homomorphically accumulate them, ultimately folding all slot values ​​to the first slot. The query end only needs to read the first slot to obtain the total value. The reduction process is performed on the ciphertext, and the relay end cannot know the values ​​of each slot. The source information of the slots is completely erased, achieving the technical effects of slot reduction and source anonymity. The private key data used to decrypt the reduced aggregated ciphertext data is stored by the query end, ensuring that the private key data is only stored at the query end. The relay end has no decryption capability. Even if the relay end is compromised or actively records all intermediate ciphertext, it cannot obtain any plaintext aggregation results or unilateral details, achieving the technical effect of zero plaintext visibility at the relay end. The number of data endpoints should be no less than 3, so that when the number of data endpoints reaches 3 or more, the aggregated value data is the sum of contributions from multiple parties, and the individual contributions are mixed. This avoids the aggregated value from degenerating into transparent transmission and leaking individual data when there is only one data endpoint. At the same time, it raises the threshold for collusion among data endpoints to restore the contributions of the remaining parties, and achieves the technical effect of isolating the aggregated value from individual data.

[0102] In one embodiment, slot reduction is implemented using global summation, performing several rounds of rotation-addition (with the step size doubling in each round) on the aggregated ciphertext data to reduce all valid slots to the first slot. It should be noted that when N-1 data endpoints collude, they can share their received query request data and locally stored identifier digest data and association value data. Since the aggregation result equals the sum of all data endpoint contributions, the colluding parties can infer the contribution value of the remaining data endpoint by subtracting the contributions of N-1 data endpoints from the total aggregation value. This risk is common to all aggregation computing systems and cannot be completely eliminated at the cryptographic level in this application. In actual deployment, it should be mitigated by connecting a sufficient number of data endpoints (e.g., no fewer than 5), prohibiting collusion through business agreements, and using enhancement techniques such as secret sharing or differential privacy to add noise to the output results. For example, differential privacy noise or cancelable masks can be injected before each data endpoint returns to mitigate N-1 collusion attacks.

[0103] like Figure 4 As shown, an embodiment of this application provides a privacy data aggregation query system 400, including a query terminal 402, a relay terminal 404, and multiple data terminals 406. The query terminal 402 is used to determine candidate location data and identifier digest data based on target identifier data and a preset hash function; to perform homomorphic encryption processing on the candidate location data and identifier digest data respectively to determine location selection ciphertext data and digest matching ciphertext data; to generate query request data based on the location selection ciphertext data and digest matching ciphertext data, and send it to the relay terminal 404; the relay terminal 404 is used to send the query request data to the multiple data terminals 406; data Terminal 406 pre-stores a data grid including multiple data rows and an overflow area; terminal 406 is used to perform identifier digest matching and position selection in the ciphertext field according to the query request data and the locally stored identifier digest data and associated value data to determine the local result ciphertext data and send it to relay terminal 404; relay terminal 404 is also used to perform homomorphic addition and slot reduction processing on the local result ciphertext data to determine the reduced aggregate ciphertext data and send it to query terminal 402; query terminal 402 is also used to decrypt the reduced aggregate ciphertext data according to the private key data to determine the aggregate value data corresponding to the target identifier data.

[0104] In this application, query terminal 402 refers to the device that initiates a query, generates a ciphertext query request, and decrypts the aggregated result; relay terminal 404 refers to the device that forwards the query request and performs aggregation and reduction; data terminal 406 refers to the device that holds local identifier data and associated value data and performs ciphertext calculation; local result ciphertext data refers to the single ciphertext output by data terminal 406 after merging the candidate area and overflow area results.

[0105] The query terminal 402 determines candidate location data and identifier digest data based on the target identifier data and a preset hash function; it performs homomorphic encryption on the candidate location data and identifier digest data respectively to determine the location selection ciphertext data and digest matching ciphertext data; based on the location selection ciphertext data and digest matching ciphertext data, it generates query request data and sends it to the relay terminal 404. This limits the responsibilities of the query terminal 402 to addressing, encryption, and decryption, ensuring that the query terminal 402 only receives the reduced aggregation result throughout the process, thus achieving the technical effect of restricted access for the query terminal 402. The relay terminal 404 sends the query request data to multiple data terminals 406, enabling the relay terminal 404 to act as an intermediary for unified forwarding. The query request data is sent once and reused by multiple parties, achieving the technical effect of a simplified system communication structure. Data terminal 406 pre-stores a data grid including multiple data rows and an overflow area. Based on the query request data and locally stored identifier digest data and associated value data, data terminal 406 performs identifier digest matching and position selection within the ciphertext field to determine the local result ciphertext data, which is then sent to relay terminal 404. This limits the responsibility of data terminal 406 to ciphertext field matching and value retrieval; data terminal 406 can only see the ciphertext query and cannot know the query object or obtain any data from other data terminals 406, achieving the technical effect of data privacy protection for data terminal 406. Relay terminal 404 also performs homomorphic addition and slot reduction processing on the local result ciphertext data to determine the reduced aggregate ciphertext data, which is then sent to query terminal 402. This limits the responsibility of relay terminal 404 to forwarding and ciphertext aggregation and reduction; relay terminal 404 does not hold private key data and cannot decrypt any ciphertext, achieving the technical effect of zero plaintext for relay terminal 404. The query endpoint 402 is also used to decrypt the reduced aggregated ciphertext data based on the private key data, determining the aggregated value data corresponding to the target identifier data. This enables the three endpoints to collaboratively form a star-shaped privacy data aggregation query system 400, with strict isolation of permissions at each endpoint. Collusion between any single endpoint or any two endpoints cannot simultaneously obtain the query object and its corresponding details, achieving overall protection of query privacy, aggregation privacy, and data privacy at the data endpoint 406. Simultaneously, each endpoint of the system can be deployed independently and horizontally scaled, achieving the overall beneficial effects of independent data preparation by each institution without coordination, query endpoint 402 obtaining only the aggregated value, online latency being independent of database size, transparent scaling at the data endpoint 406, and flexible deployment. The above system can be applied to cross-institutional joint query scenarios such as bank multi-loan inquiries. Each institution prepares data independently, without unified numbering or data sharing. The querying party only obtains cross-institutional aggregated value data, achieving simultaneous protection of query privacy, aggregation privacy, and data privacy at the data endpoint 406.

[0106] In some embodiments of this application, the overall performance of this application is as follows: the online query overhead is independent of the database size, and the total time for a single query is approximately 8-12 seconds (based on an 8-core 16G server), of which query encryption takes less than 0.1 seconds, ciphertext field matching and value extraction of the identifier digest data takes approximately 3-4 seconds, aggregation and slot reduction take approximately 2-3 seconds, and decryption takes less than 0.1 seconds; when the database on the data side grows from 10,000 records to 10 million records, the above online time remains unchanged, and the increase in data volume only affects the collision rate and grid occupancy rate in the offline encoding stage; offline encoding is a one-time preprocessing, and encoding 10 million records takes approximately 3 seconds to 5 minutes, with a grid occupancy rate of no less than 80% and very few overflow entries; the query message is approximately 85MB after compression, and when the number of data ends increases, the query party does not need to reconstruct the query, and the relay end only adds one ciphertext addition and one slot reduction, so the system can support large database scenarios with massive records, and the online latency remains constant.

[0107] like Figure 5 As shown, Figure 5 To implement the multi-party privacy data aggregation query protocol execution process based on fully homomorphic encryption, the system adopts a star topology, comprising three main roles: the query party (Receiver), the relay party (Forwarder), and multiple data parties (Sender1…N). It is divided into an offline preprocessing stage and an online query interaction stage, as detailed below:

[0108] 1. Query party: Generates BGV key pair; The query party first generates a BGV fully homomorphic encryption key pair, and keeps the private key secret and does not disclose it to the outside world; The relinearized key RLK can be embedded in subsequent query messages, or it can be preloaded by the data party.

[0109] 2. Offline preprocessing of data: Encoding local data;

[0110] Before a query request arrives, each data provider completes offline data encoding. Using a three-choice kick-out hash, local business data is encoded into a two-dimensional grid. Data exceeding the placement limit is stored in the overflow area. This preprocessing is completed offline and does not consume online query time.

[0111] 3. Key transmission: The querying party sends the query message containing the RLK (relinearized key) to the data party; the data party can also preload the RLK from the shared directory. The Galois key GK is preloaded from the shared directory by the relay party and used for subsequent in-slot summation operations. The key is named by content hash and does not carry an organization identity identifier.

[0112] 4. The querying party calculates the query elements and initiates the query; the querying party treats the query UID, calculates 3 candidate positions and 32-bit user fingerprint through password hashing, constructs 3 columns of ciphertext + 32-bit fingerprint ciphertext, assembles them into a query message and sends it to the relay party.

[0113] 5. The relay broadcasts a query message; upon receiving a query message from the querying party, the relay broadcasts the query message to all connected data parties.

[0114] 6. The data provider performs ciphertext matching and value extraction calculations. Upon receiving the broadcast query ciphertext, each data provider performs four-way ciphertext operations: performing three-way XNOR operations on the three candidate positions, followed by ANDtree and tree reduction to complete fingerprint matching; combining this with the column ciphertext to extract the target value; simultaneously, for the overflow region, utilizing BGV's SIMD parallel capability to complete overflow region fingerprint matching; and then performing homomorphic addition between the three candidate results and the overflow region result to merge them into a single merged ciphertext (three candidates + overflow region), which is then sent back to the relay provider. The entire process is completed within the ciphertext field, preventing the data provider from knowing the true identity of the user making the query.

[0115] 7. The relay performs ciphertext aggregation and slot reduction; the relay collects the merged ciphertext returned by all data parties, performs ciphertext homomorphic addition to complete the aggregation of multi-party results, and then calls the InnerSum(MaxSlots) slot summation operation to reduce all values ​​scattered in each slot to the first slot to obtain the aggregated ciphertext; the relay does not have the decryption private key, so it cannot decrypt to obtain plaintext data, nor can it split the contribution value of individual data parties.

[0116] 8. The relay sends the aggregated ciphertext back to the query party for decryption; the relay party sends the reduced aggregated ciphertext back to the query party. The query party uses its local private key to decrypt the ciphertext, reads the first slot content, and finally obtains the aggregated total value of the UID across all data parties. The query party can only obtain the sum and cannot see the detailed data of any single organization. The sequence diagram is divided into two parts: the upper part represents the message and calculation initiation process, and the lower part represents the result return and decryption completion process; the original user data and query identity are not disclosed throughout the entire interaction, and the ciphertext calculation runs through the entire chain of query, matching, and aggregation. In one embodiment, this application is implemented according to the following symbols, terms, codes, and data.

[0117] Symbol definitions: N=32768 is the total number of slots, P=1024 is the number of rows, S=256 is the overflow area capacity, u is the user identifier, v(u) is its associated value, and the plaintext modulus t≈2.25×10¹ 5 Plaintext ring R_t=ℤ_t[X] / (X^N+1), ciphertext ring R_Q=ℤ_Q[X] / (X^N+1).

[0118] Terminology: XNOR refers to bitwise XNOR (same outputs 1, different outputs 0); ANDtree refers to AND tree reduction of 32 bitwise comparison ciphertexts by pairwise multiplication; InnerSum refers to reducing all slots to the first slot after ciphertext rotation and addition; MulRelin refers to immediate relinearization after ciphertext multiplication; MulPlain refers to ciphertext-plaintext multiplication.

[0119] Offline placement (three-choice kick-out hash):

[0120] foreach(u,v):

[0121] fp=H_fp(u);depth=0;entry=(u,v,fp)

[0122] whiledepth<64:

[0123] fork∈{0,1,2}:

[0124] (p,s)=(H_poly(k+1)(u),H_slot(k+1)(u))

[0125] If grid[p][s] is empty: grid[p][s] = entry; go to next

[0126] k=depth%3 / / Rotate candidates 0 / 1 / 2

[0127] evicted=grid[p][s];grid[p][s]=entry;entry=evicted;depth++

[0128] stash.append(entry)

[0129] next:”

[0130] In this case, the round-robin kicking method can also be replaced by randomized kicking that uses the identifier digest and the kicking round number as seeds and is modulo 3 by a deterministic hash.

[0131] Query Encryption:

[0132] "colVec_k[slot_k]=1 (all others are 0) → ct_col_k=Enc(Encode(colVec_k)), k=0..2"

[0133] ct_fp[i]=Enc(Encode(bit_i)), bit_i=(fp>>i)&1, i=0..31

[0134] Q=(pos0,pos1,pos2,ct_col0,ct_col1,ct_col2,{ct_fp[i]},keyTag)”

[0135] Bitwise XNOR truth table (in slots):

[0136] Bitwise XNOR truth value: Using slots as the unit, when both the target bit and the storage bit are 1, the multiplicative encoding is 1 and the additive encoding is 0, resulting in 1×1+0=1, indicating a match. When the target bit is 1 and the storage bit is 0, the multiplicative encoding is -1 and the additive encoding is 1, resulting in 1×(-1)+1=0, indicating a mismatch. When the target bit is 0 and the storage bit is 1, the result is 0×1+0=0, indicating a mismatch. When both the target bit and the storage bit are 0, the result is 0×(-1)+1=1, indicating a match. In other words, output 1 only when the two bits are the same, and output 0 when they are different.

[0137] ANDtree: 32→16→8→4→2→1, a total of 5 levels, each level has MulRelin, resulting in ct_match_k (k=0,1,2).

[0138] Value extraction and aggregation: "ct_mid_k=MulPlain(ct_match_k,pt_val_k);ct_sel_k=MulRelin(ct_mid_k,ct_col_k)"

[0139] ct_stash=MulPlain(XNOR+AND(fpCts,storedFP_stash),Encode(val_stash))

[0140] ct_all=ct_sel0+ct_sel1+ct_sel2+ct_stash

[0141] ct_agg=Σⱼct_all_j;ct_result=InnerSum(ct_agg,1,MaxSlots)

[0142] total=Decrypt(ct_result)[0]”

[0143] Performance: Based on an 8-core 16G server, the query encryption time is less than 0.1 seconds, the data fingerprint matching and value extraction time is about 3-4 seconds, the relay aggregation and InnerSum time is about 2-3 seconds, the decryption time is less than 0.1 seconds, and the total time for a single query is about 8-12 seconds. When the database is increased from 10,000 records to 10 million records, the above online time remains unchanged, the offline encoding of 10 million records takes about 3-5 minutes, and the grid utilization rate is not less than 80%.

[0144] When the database is increased from 10,000 to 10 million records, the online processing time remains unchanged; offline encoding of 10 million records takes approximately 3-5 minutes, with a grid occupancy rate of ≥80%.

[0145] Security: This embodiment employs the BGV scheme, based on the Ring-LWE (Learning of Ring Errors) difficulty problem and meeting IND-CPA (Independent Detection and Protection). Production parameters LogN=15, LogQP=561, and test parameters LogN=13, LogQP=506, both meeting at least 128-bit security strength according to the HomomorphicEncryption.org standard. Compared to overtly oblivious (OT) solutions where communication volume is proportional to database size, and SealPIR / Spiral only supporting position-based indexing, this embodiment uses hash-derived candidate positions to achieve covert queries independent of database size.

[0146] Apparatus: This application also provides a privacy data aggregation query apparatus, including a processor and a memory storing executable instructions, which, when executed, implement the method of any of the above embodiments.

[0147] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for aggregating and querying privacy data, characterized in that, For use on the query end, the privacy data aggregation query method includes: Obtain target identifier data; Based on the target identifier data and a preset hash function, at least two candidate position data and identifier digest data corresponding to the target identifier data are determined, wherein each candidate position data includes row index data and slot index data, and the identifier digest data includes multiple digest bit data; For each of the candidate location data, location indication data is constructed respectively, wherein in each location indication data, the slot corresponding to the slot index data of the corresponding candidate location data is a first preset value, and the remaining slots are second preset values; Homomorphic encryption is performed on each of the location indication data to determine the location selection ciphertext data corresponding to each of the candidate location data; For each summary bit of the identified summary data, summary indication data is constructed respectively; wherein, in each summary indication data, each slot is set to the value of the corresponding summary bit data; Homomorphic encryption is performed on each of the aforementioned digest indicator data to determine the ciphertext data that matches the digest corresponding to each digest bit data; Based on the row index data of each candidate position data, the ciphertext data of each position selection, and the ciphertext data of each digest matching, query request data is determined and sent to the relay end, so that the relay end sends the query request data to multiple data ends; wherein, the row index data is included in the query request data in plaintext form; The relay end receives the reduced and aggregated ciphertext data sent by the relay end; wherein the reduced and aggregated ciphertext data is obtained by the relay end performing homomorphic addition and slot reduction processing on the local result ciphertext data of multiple data ends; Based on the private key data, the reduced aggregate ciphertext data is decrypted to determine the aggregate value data corresponding to the target identifier data.

2. The privacy data aggregation and query method according to claim 1, characterized in that, The candidate location data includes first candidate location data, second candidate location data, and third candidate location data; Based on the target identifier data and the three location hash salt values, perform hash operations to determine the row index data for each candidate location data; Based on the target identifier data and the three slot hash salt values, perform hash operations to determine the slot index data for each candidate position data; Based on the target identifier data and digest hash salt value data, a hash operation is performed, and the hash operation result data is truncated to determine the identifier digest data; Each candidate position data consists of corresponding row index data and slot index data; the candidate position data is determined by the target identifier data, the preset hash function, and the salt value data.

3. The privacy data aggregation and query method according to claim 1, characterized in that, Also includes: Based on the homomorphic encryption parameters, determine the private key data, the first evaluation key data, and the second evaluation key data; Save the private key data; The first evaluation key data is included in the query request data; the first evaluation key data is used for relinearization processing after ciphertext multiplication. The second evaluation key data is stored at the relay end; the second evaluation key data is used for ciphertext rotation processing in slot reduction processing; The first evaluation key data is subjected to content hashing to determine the key tag data; The query request data carries the key tag data.

4. A method for aggregating and querying privacy data, characterized in that, For the data end, the data end pre-stores a data grid and an overflow area; the data grid includes multiple data rows, each data row includes multiple slots, and each occupied slot stores the identifier digest data and associated value data corresponding to the local identifier data; The privacy data aggregation query method includes: Receive query request data sent by the relay end; the query request data includes row index data of candidate position data, position selection ciphertext data corresponding to each candidate position data, and digest matching ciphertext data corresponding to each digest bit data of the identifier digest data; Based on the row index data, each candidate data row in the data grid is read respectively; For each candidate data row, based on the identifier digest data stored in each slot of the candidate data row and each digest matching ciphertext data, a bit-by-bit equality comparison is performed in the ciphertext field, and the ciphertext multiplication reduction processing is performed on each bit-by-bit comparison result to determine the candidate matching ciphertext data corresponding to the candidate data row. Based on each of the candidate matching ciphertext data, each of the position selection ciphertext data, and the associated value data stored in each of the candidate data rows, determine the ciphertext data of each candidate value; Based on the identifier digest data stored in the overflow area and the ciphertext data matching each digest, an ciphertext field equality comparison is performed, and based on the comparison result data and the associated value data stored in the overflow area, the overflow value ciphertext data is determined. Homomorphic addition is performed on each candidate value ciphertext data and the overflow value ciphertext data to determine a single local result ciphertext data. The encrypted data of the local result is sent to the relay terminal.

5. The privacy data aggregation and query method according to claim 4, characterized in that, The data grid and the overflow area are established in the following manner: For the local identifier data to be stored, three candidate location data and the identifier digest data corresponding to the local identifier data are determined according to a preset hash function; When there is free candidate location data among the three candidate location data, the identifier summary data and associated value data corresponding to the local identifier data are stored in the free slot; When all three candidate slots are occupied, a kick-out replacement is performed: using the identifier digest data of the current identifier data to be placed and the kick-out round number as seeds, a deterministic hash is used to take the modulo of the total number of candidate numbers to determine the candidate slot to be kicked out in this round; wherein, the kick-out round number is zero when the kick-out replacement is performed for the first time, and the kick-out round number is incremented once for each kick-out replacement; Write the identifier summary data and associated value data of the currently placed identifier data into the selected slot, and then remove and replace it; The kicked-out identifier data originally stored in the slot is used as the new identifier data to be placed. The above kick-out replacement is repeated based on its corresponding candidate position data until the identifier data to be placed falls into an empty slot or the kick-out sequence number reaches the preset upper limit. When the number of repositioning attempts reaches the preset limit, the identifier summary data and associated value data corresponding to the currently placed identifier data are stored in the overflow area; In this context, the candidate location data for any local identifier data is uniquely determined by the local identifier data and the preset hash function.

6. The privacy data aggregation and query method according to claim 4, characterized in that, The step of performing a bit-by-bit equality comparison within the ciphertext field based on the identifier digest data stored in each slot of the candidate data row and the ciphertext matching data of each digest, and performing ciphertext multiplication and reduction processing on each bit-by-bit comparison result, includes: Based on the digest bit data of the identifier digest data stored in each slot of the candidate data row, determine the first coded data and the second coded data; Based on the corresponding digest matching ciphertext data, the first encoded data, and the second encoded data, multiplication and addition processes are performed to determine the bit-by-bit matching ciphertext data; wherein, when the target digest bit data and the stored digest bit data are the same, the value of the corresponding slot is 1; when the target digest bit data and the stored digest bit data are different, the value of the corresponding slot is 0; Perform multi-level ciphertext multiplication and reduction processing on each bit-by-bit matching ciphertext data to determine the candidate matching ciphertext data; In this process, relinearization is performed after each ciphertext multiplication.

7. The privacy data aggregation query method according to claim 5, characterized in that, The step of performing an ciphertext field equality comparison based on the identifier digest data stored in the overflow area and each digest matching ciphertext data includes: The ciphertext data of each digest matching and the identifier digest data stored in the overflow area are processed in parallel to determine the overflow matching result ciphertext data; The overflow value ciphertext data is determined based on the overflow matching result ciphertext data and the associated value data stored in the overflow area; Specifically, in the overflow area slot that matches the identifier digest data, the overflow value ciphertext data retains the corresponding associated value data; in the other overflow area slots, the corresponding value in the overflow value ciphertext data is zero.

8. A method for aggregating and querying privacy data, characterized in that, For use at the relay end, the privacy data aggregation query method includes: Receive query request data sent by the query terminal; the query request data includes location selection ciphertext data and digest matching ciphertext data; The query request data is sent to multiple data terminals; Receive local result encrypted data sent by each data terminal; The local result ciphertext data of each data terminal is subjected to slot-by-slot homomorphic addition to determine the aggregated ciphertext data; The aggregated ciphertext data is subjected to slot reduction processing to determine the reduced aggregated ciphertext data; wherein, the slot reduction processing merges values ​​distributed in multiple slots into a single slot; The reduced and aggregated ciphertext data is sent to the query terminal.

9. The privacy data aggregation query method according to claim 8, characterized in that, The slot reduction process for the aggregated ciphertext data includes: The aggregated ciphertext data is subjected to ciphertext rotation and homomorphic addition to reduce the values ​​in multiple slots to the first slot. The private key data used to decrypt the reduced aggregate ciphertext data is stored by the query terminal; the number of data terminals is not less than 3.

10. A privacy data aggregation and query system, characterized in that, Includes a query terminal, a relay terminal, and multiple data terminals; The query terminal is used to determine candidate location data and identifier digest data based on target identifier data and a preset hash function; to perform homomorphic encryption processing on the candidate location data and the identifier digest data respectively to determine location selection ciphertext data and digest matching ciphertext data; to generate query request data based on the location selection ciphertext data and the digest matching ciphertext data, and send it to the relay terminal; The relay terminal is used to send the query request data to multiple data terminals; The data terminal pre-stores a data grid including multiple data rows and an overflow area; The data terminal is used to perform identifier digest matching and position selection in the encrypted domain based on the query request data and the locally stored identifier digest data and association value data, determine the local result encrypted data, and send it to the relay terminal; The relay terminal is also used to perform homomorphic addition and slot reduction processing on the local result ciphertext data, determine the reduced aggregate ciphertext data, and send it to the query terminal; The query terminal is also used to decrypt the reduced aggregate ciphertext data based on the private key data to determine the aggregate value data corresponding to the target identifier data.