Extracting Sensitive Information from Aggregated Data - Part 2
Consider a hospital dataset with 100,000 patients, where only one has a rare genetic disease. To protect privacy, the hospital enforces 50,000-anonymity: it only answers aggregate queries covering at least half of the records. But can the record of the patient with the rare disease still be isolated? And if so, how many queries would it take? In this post, I show that, perhaps surprisingly, as few as 20 queries - each covering on average 50,000 patients - can be enough to isolate the single patient with the rare genetic disease.
A similar situation arises when aggregating the decisions or contributions of multiple agents or experts across several rounds to improve robustness and protect privacy, for example, by mitigating hallucinations, correcting erroneous (or even malicious) individual decisions, or aggregating model parameters in collaborative (federated) learning to avoid directly sharing sensitive training data. To guarantee confidentiality for participants, cryptographic primitives such as secure aggregation ensures that one can only access aggregate statistics over a random subset of at least participants in each round, but never the individual contributions. But is this level of protection sufficient? And if not, how many rounds (or queries) would be enough to reveal the private contributions of all participants?
The Problem
We assume that all queries are counting queries represented by a binary query matrix , where if query covers record , and otherwise. For example, the SQL query
SELECT COUNT(*) FROM Patients WHERE AGE = 32 and SEX = 'F'
counts the number of HIV+ patients who are both 32 years old and female. In terms of the matrix , such a query corresponds to a row selecting exactly those records that satisfy the predicate after the WHERE clause.
Suppose we have patients and counting queries. Let be a Boolean value indicating whether patient is HIV-positive. Then, for query , the result is
where is the number of HIV-positive patients covered by query .
We consider an adversary who (1) aims to design the query structure (i.e., which patients are covered by which queries), and (2) knows the query results . The adversary’s goal is to reconstruct the unknown vector . Importantly, the database manager only answers a query if it covers at least patients, ensuring a minimal privacy guarantee with -anonymity.
The key questions we explore in this post are:
How an adversary should choose the queries, and hence design , so that can be reconstructed from ?
How many queries are required for such an attack?
The fewer queries needed, the cheaper the attack becomes, and the harder it is to detect.
The Theory
In the previous post, I showed how individual records can be reconstructed from the results of aggregated SUM queries by solving a system of equations of the form , where is the query matrix, is the vector of unknowns, and contains the query results. In that setting, any unknown can be recovered if its corresponding column is linearly independent of all other columns of .
Let us look for a matrix whose columns are linearly independent, assuming for simplicity that . Rather than verifying linear independence directly, it is often easier to check orthogonality, which is a stronger condition and automatically implies linear independence.
Why?
Vectors are linearly independent if no nontrivial linear combination of them equals zero, i.e. . In other words, they span a vector space with dimension and the are not "linearly redundant". are orthogonal if their inner product is zero: for . Orthogonality is the same as saying that the vectors are perpendicular, or equivalently, the cosine of their angle (aka cosine similarity) is 0. If, in addition, each vector has unit norm , the set is orthonormal.
Orthogonality implies linear independence, because if , then . Since also holds due to pairwise orthogonality, where , must be zero 0. On the other hand, linear independence does not imply orthogonality; for example, and are linearly independent but not orthogonal. A set of linearly independent vectors can be orthogonalized with the Gram-Schmidt orthogonalization.
All these mean that if are the columns of a matrix , then
the columns are orthogonal is diagonal
the columns are orthonormal
the columns are linearly independent only for , that is, the only vector in the null space of is the zero vector. In that case only for , because , and only if . This means that is positive definite is invertible and symmetric, but not necessarily diagonal
Because is restricted to be binary (each query either includes or not), there is in fact only a single binary matrix with orthogonal columns: the standard basis (aka identity matrix), in which each column is a unit (one-hot) vector. For example, for four records (and queries) the standard basis is:
Why?
We want that for all , which is only possible if, for any position , there is at most one column which has a value of 1 at position . Since is a squared and binary matrix with non-zero column vectors, this is only possible if every column has 1 at a single position, or in other words, if each column is a different unit vector.
The problem with using the standard basis is that each query covers only a single record. This corresponds to a trivial disclosure with zero anonymity and would never be answered by a database manager providing -anonymity for any . We are interested in the more realistic case where every query covers multiple records, that is, is a binary matrix in which each row contains multiple ones. However, based on the argument above, no such square binary matrix with orthogonal columns exists.
However, the situation changes if we allow negative entries in the query matrix, that is, we can not only add but also subtract attribute values from the aggregates. Consider the Hadamard matrix, where the first row and column are constant , and every other row and column contains an equal number of and . For example, the Hadamard matrix of size 4 is
In general, a Hadamard matrix of size can be constructed recursively as
with . Because Hadamard matrices are orthogonal by construction, every pair of columns (and rows) is linearly independent.
Although the Hadamard matrix is not strictly binary (entries are rather than ), its rows are the linear combination of strictly binary queries; the sum of the records with negative entries in a row can be expressed as the total sum of all records minus the sum of the records with positive entries. More precisely, define a binary matrix by replacing each in with :
Then, for any row ,
where is the vector of all-ones, hence . This means the adversary can request the database to evaluate all binary queries in , obtaining . From these query results, the adversary can reconstruct the original Hadamard query responses , and then solve the resulting system of equations to recover . The Hadamard matrix is particularly appealing since each query (row) covers half of the records (so it appears "highly aggregated" and compliant with -anonymity type privacy rules), and the resulting system can be inverted efficiently using the fast Walsh–Hadamard transform in time.
In conclusion, the adversary can recover every record using a number of queries equal to the total number of records, even though each query aggregates over half of the database.
Can the adversary reconstruct all records with less than queries?
If we have more unknowns (records) than equations (queries), the above system of linear equations is underdetermined and cannot be solved in general. However, it is no longer the case if is sparse, that is, it has less than non-zero elements like in the hospital dataset above where we have only a single HIV-positive patient. Indeed, we only need to determine the non-zero elements in whose number is significantly smaller than . Vectors with nonzero entries are also called -sparse vectors, and the set of non-zero positions is called the support of this vector.
Our objective is to minimize the number of queries, given that the dataset is -sparse, i.e., it contains only nonzero entries. Equivalently, we seek a query matrix with as few rows as possible. Trivially, , as shown above. On the other hand, , since is a linear combination of the columns of . If we knew which coordinates were nonzero, we could simply query those coordinates with linearly independent rows, which would be sufficient for recovery (because the number of linearly independent rows equals the number of independent columns). Thus, in principle, the answers to queries contain enough information.
However, the indices of the nonzero entries is unknown. A classical result in linear algebra states that if every subset of columns of is linearly independent, then the sparsest solution to is unique for any -sparse vector . Consequently, linear (not necessarily binary) queries are sufficient to guarantee unique recovery of any -sparse vector.
Why?
We will first show that has a unique -sparse solution if and only if () there is no vector with sparsity at most (except the zero vector) that maps to 0 (in other words, the null space of contains no nonzero vector with sparsity ).
(:) Suppose there exists a vector with nonzero entries such that . Write , where both and has support size and . Such a decomposition is always possible by splitting the nonzero coordinates of into two disjoint parts, each of size at most , and assigning them to and , respectively. Then, . Since by construction, is not a unique -sparse solution, yielding a contradiction.
(:) Conversely, let and be -sparse vectors such that and . Then, , where the difference vector has at most nonzero entries (since both and are -sparse). Hence, if the null space of contains only the zero vector with support size , it follows that .
Finally, if does not map any nonzero vector with nonzeros to 0, then by the definition of linear independence, every subset of columns of must be linearly independent. Therefore, the uniqueness of the sparse solution is guaranteed if and only if every set of columns of is linearly independent.
This proof suggests a simple brute-force search to recover : enumerate all possible -sparse candidates and select the one that satisfies , which must be the single correct solution. Unfortunately, this requires solving linear systems, which quickly becomes infeasible as grows. In fact, it can be shown that finding the sparsest solution (i.e., solving the -minimization problem) is NP-complete for arbitrary choices of and (unless ). Fortunately, for specially designed matrices , there exist efficient algorithms that can recover -sparse signals. These will be discussed next.
We're looking for a rectangular matrix such that every set of columns of this matrix is linearly independent. More formally, the question: is there a rectangular matrix whose any-sized submatrix is invertible? One construction is the Vandermonde matrix:
if are all positive and distinct.
Why?
It's enough to show that the determinant of any -sized submatrix of the Vandermonde matrix is non-zero with the above conditions. Let where is a weakly increasing sequence of non-negative integers. Using this notation, with defines the determinant of a squared Vandermonde matrix. If , then where is the Shur function. Since the Vandermonde determinant is always non-zero if are all distinct, we have to show that the Shur function is non-zero. This follows from the combinatorial definition of Shur function if all are positive (selecting columns from the -sized Vandermonde matrix, ).
Error correcting codes for reconstruction
We require a binary query matrix , where an attribute is either included in the aggregate () or excluded () for a given query. As shown above, there is no such square matrix that allows reconstruction of , except for the trivial and non-private choice of the standard basis. However, this limitation no longer holds if we consider finite field arithmetic, which connects the problem to binary error-correcting codes.
In particular, a practical instantiation of a Vandermonde matrix is the parity-check matrix of a binary BCH code:
where are distinct elements of a finite field of size at least . In practice, the field is typically , while the code symbols are restricted to , yielding binary codewords. The code length is then , and if , the BCH code can correct up to errors in a codeword as long as all are distinct field elements. Therefore, if is interpreted as a potentially corrupted codeword of this BCH code, then the nonzero locations of can be identified from its syndrome using any efficient BCH decoding procedure. This is because the zero vector is always a valid codeword of linear code, and all vectors with at most nonzero entries will decode to the zero vector. Put simply, once can be computed, the adversary can in principle solve for in .
The problem that is not binary, its entries live in . Therefore, the inner products must be computed over , requiring finite-field arithmetic, which is seemingly not realizable in SQL. However, one can expand each field element of into a binary vector of length (via a basis representation of the field). With this expansion, the parity-check matrix can be represented as a binary matrix which means that a single query can be realized with exactly binary queries.
Why?
Each element of finite field can be represented as polynomials over , reduced modulo an irreducible polynomial of degree . Field operations (addition and multiplication) are therefore carried out as polynomial operations modulo this irreducible polynomial.
For a concrete example, consider , i.e., the field . This field has elements. A common irreducible polynomial of degree 3 is . Each element of can be expressed as a binary polynomial of degree at most 2, with coefficients in . Using the basis , we can represent the field elements by 3-bit vectors (coefficients of ):
If we denote by a primitive element of (e.g., ), then is the th row of a valid parity matrix. Following the above polynomial representation, , , and so on. Thus, each has a unique binary vector representation.
For example, has a binary form .
When computing the dot product in , the operation in polynomial form is equivalent to evaluating the same dot product in the vector space representation over . In other words, in corresponds exactly to in , where each field element is expanded into its binary vector representation. For example, let . Then, in the field representation, . In the vector space representation, this is computed as , which also corresponds to the polynomial .
Therefore, the adversary can transform into a binary matrix with rows. By querying the database to compute instead of using standard integer arithmetic, and then reducing the result elementwise modulo 2, the adversary obtains the binary representation of the syndrome in which then can be directly mapped to its original representation in . Finally, standard BCH decoding can be applied on in to efficiently reconstruct . In total, this reconstruction procedure requires binary queries.
How many records are covered by a binary query ? It is not hard to see that if used in the parity check matrix is a primitive element of , then every query covers about half of the records.
Why?
If is a primitive element of , then it has multiplicative order . Therefore, each entry of is a distinct field element, which in the binary expansion maps to a unique nonzero -bit vector. Each row of corresponds to a single bit position across all these vectors. Since there are nonzero vectors in total, and exactly half of the possible vectors have a 1 in any given bit position, each row of contains ones and zeros. Thus, every binary query covers exactly records.
In conclusion, an adversary can exactly reconstruct all records in a database containing nonzero entries using only binary queries, even though each individual query covers roughly half of the records, that is, they are -anonym.
Stable reconstruction
The reconstruction techniques described above work only under strong assumptions: namely, that the sparsity of is known in advance, that the database manager returns exact query results (i.e., without perturbations as in Differential Privacy), and that the adversary has fairly accurate knowledge of patients' non-sensitive attributes (those appearing in the WHERE clause of SQL queries) in order to select the exact records targeted by the pre-defined queries. If these conditions are not satisfied, the recovered vector may significantly differ from the true , rendering these techniques unstable. This concern is realistic; for example, an adversary may not know the exact number of AIDS patients, especially if the number is small, and querying it directly would violate -anonymity.
Moreover, the binary code construction described earlier is not even asymptotically optimal in terms of the number of binary queries required. While a naive argument suggests that identifying a single non-zero position among requires bits and thus at least binary queries in total, support recovery does not require distinguishing every position individually. Instead, to uniquely identify all subsets of size s, one needs
binary queries.
This raises a natural question: is there a stable reconstruction technique that does not rely on rigidly pre-defined query structures? The answer comes from compressed sensing, which provides methods that are not only stable but also asymptotically optimal. Using a carefully designed random query matrix, the support of an -sparse vector can be reconstructed with only queries, while tolerating noise and perturbations in the responses. As a plus, the same techniques also work for non-binary queries!
We want a matrix such that every submatrix (formed by selecting columns of ) is close to orthogonal. Orthogonality guarantees that the columns are linearly independent, meaning the dot product between any pair of columns (rows) is zero, or equivalently, . In practice, exact orthogonality is often too strong to require, so we instead demand that be close to the identity matrix, or in other words, is small according to a suitable norm, such as the matrix (or operator) norm. Formally, this means that is as small as possible. Intuitively, this condition says that squeezes any unit vector to almost zero. Equivalently, since is symmetric, we have for any vector :
Why?
We'll show that for unit vectors where are the eigenvalues of .
Since is symmetric, the Spectral theorem guarantees that its eigenvectors form an orthonormal basis with real eigenvalues . Therefore any unit vector can be expanded as . Thus,
by the definition of eigenvectors and eigenvalues.
Then,
and similarly,
for any unit vector. In both cases, the maximum is attained when equals the eigenvector corresponding to the eigenvalue with the largest magnitude. This implies that .
But the left-hand side equals
so we obtain:
and hence:
Thus, when is small, the “stretching” or “shrinking” effect of the transformation is negligible: acts almost like an isometry that preserves -norms (and hence distances between vectors). Orthogonal matrices achieve this exactly, since they preserve the inner product: and therefore the -norm: . The constant measures how far deviates from perfect orthogonality; if the same works for all submatrices of , it is called the restricted isometry constant of .
Random query matrix
Let be or with equal probability for every independently. Then, for any row ,
due to independence (i.e., for and 0 otherwise) and is the variance. For the whole matrix :
which means that, on expectation, the matrix will preserve the norm and has a good chance to be "quasi-orthogonal". However, to have a better estimate on how close we are to perfect orthogonality, we need to know how well concentrates around its mean , that is, what's the probability that is outside of a certain range of 0.
We will derive a more general result for a wider family of random matrices that will reveal a few design principles about the queries. We will show that if the elements of the matrix “tightly” concentrate around their mean 0, then the same holds for the inner products . Consequently, the squared quantities also “tightly” concentrate around their mean value , and therefore the average does as well. More precisely, if the entries of are subgaussian, then it follows that both the random variables and are subexponential in . Intuitively, this means that the probability that deviates from perfect orthogonality is exponentially small in the number of rows . Thus, the larger the number of rows, the more “orthogonal” the columns of become, on average.
Subgaussian vs Subexponential concentration
A random variable has subgaussian concentration (or subgaussian tails) if the probability that it deviates from its mean by more than a threshold decays exponentially fast. Formally, for all and some constants . Sub-exponential distribution has fatter tails as they are bounded above with exponential tails; . Hence, they decay slower than Gaussian, albeit still exponentially fast. For example, the normal (Gaussian) distribution is subgaussian, or any bounded random variable (such as the Bernoulli random variables taking values with equal probability), as guaranteed by Hoeffding’s inequality.
But why do we want subexponential concentration? Because we want "approximate orthogonality" to hold not just for a single submatrix of , but any submatrices of a given size simultaneously. Indeed, if is subexponential then roughly
Applying a union bound over all possible subsets of size , we obtain
We want this overall failure probability to be much smaller than 1. Therefore, we require . Taking logarithms on both sides gives the condition:
Using the standard combinatorial upper bound and ignoring constants and , we find that
In other words, subexponential concentration is useful because it gives you exponentially small failure probabilities for each event, which allows us to extend guarantees that hold for a single submatrix to exponentially many submatrices simultaneously, without requiring exponentially many queries (rows).
Next, we will provide more mathematical details on how to prove subexponential (or subgaussian) concentration using one of the most versatile tools in the theory of randomized algorithms: the Chernoff bound. In particular, we will show the following chain of implications for a single submatrix :
Any entry of is subgaussian is subgaussian is subexponential is subexponential is "quasi-orthogonal"
Finally, we extend this subexponential concentration for all submatrices of .
Concentration of a single submatrix
To decide if a random variable is subgaussian (or subexponential), one need to check the moment generating function (MGF) of , which is intimately related to the tail bound based on Chernoff bounds:
Why?
By Markov's inequality, for any non-negative random variable and any :
Since is increasing for , the event is the same as . Applying Markov's inequality to the non-negative random variable with :
This holds for every , so it also holds for the smallest right-hand side:
Therefore, the upper tail of is bounded by the moment generating function of the centered variable , multiplied by and optimized over .
One direct implication of Chernoff bound that if for a constant , then is subgaussian:
Why?
For any and any , Chernoff gives
The quadratic in the exponent is minimised at . Plugging in gives
Applying the same argument on , we can prove that for the other tail. Combining the two tails by a union bound we get , which means is subgaussian.
In fact, for any centered subgaussian random variable , implies that that is also called the proxy variance of .
Why?
Let . It follows from the Taylor expansion of the exponential function and the linearity of expectation that
because .
Similarly,
Therefore, if then
Dividing both sides by :
This must also hold for all even when , in which case and vanish yielding .
From now on, we’ll assume that is a subgaussian random variable: with proxy variance .
For example, when or with probability , the moment generating function (MGF) of is
and therefore (the same bound can also be derived from Hoeffding's inequality). The proxy variance equals the true variance.
Step 1: is i.i.d subgaussian is subgaussian
One can show that if is subgaussian with proxy variance , then is also subgaussian with proxy variance .
Why?
Suppose is subgaussian: . Hence:
where is constant, therefore is also subgaussian.
Step 2: is subgaussian subexponential
Recall that . Let's assume (we'll relax this later) that .
Then,
Why?
Let be a subgaussian random variable such that where , , and . We start from the general Chernoff bound:
This requires to upper bound the moment generating function of :
This can be optimized in closed form. Differentiate the exponent and set to zero:
which gives lying in the allowed range. Plugging into gives the explicit exponent at optimum:
Hence, we obtain the closed-form Chernoff bound:
After bounding the exponent:
Why?
Let . The exponent in the Chernoff bound above equals . Let . We will give a quadratic upper bound on when , and a linear upper bound if . This implies that for .
Small deviations (): . Since is monotonically increasing, it takes the maximum at : .
Large deviations (): . is monotonically decreasing and hence takes the maximum at :
Therefore, we get
We get similar result for . The lower and upper tail inequalities can be combined with a union bound:
Step 3: is subexponential is subexponential
Since , we need to upper bound the probability
where the centered random variable is subexponential as we showed above, and .
Why?
We need to derive another tail inequality for the sum of independent random variables with zero mean. We start again from the general Chernoff bound:
where the last equality is due to independence.
Since for ,
Define the exponent
We minimize over . Differentiate:
Set . Solving gives the interior minimizer (valid for ):
Plugging into yields the closed-form exponent:
and the final Chernoff bound:
Put . Then the exponent:
We can bound just like above. Hence we get:
Therefore, in the general case when , the above tail bounds extend to normalized vectors :
for any , where . Informally, this inequality says that if the entries of are independent, mean-zero subgaussian random variables, then preserves the norm of any vector fixed vector up to a relative error , with high probability as soon as is large enough.
Concentration of all submatrices
To simplify exposition, suppose that is binary with support . Then,
where is the restricted isometry constant of matrix . This confirms that the required number of measurements scales as .
Why?
Since is binary, its Euclidean norm satisfies . The total number of distinct supports - and hence distinct binary vectors - is .
For a fixed vector , the probability that the concentration fails is given by
Applying the union bound over all possible supports of size s, the probability that the concentration fails for any s-sparse binary vector is bounded by
Using the standard inequality , we obtain
If we require this failure probability to be at most , we set
Taking the logarithms and rearranging yields
Here, corresponds to the restricted isometry constant of the matrix (with probability at least ). Finally, if we set the failure probability to , we obtain Formula ( ** ).
Beyond symmetric Bernoulli matrices
So far we assumed that every entry of is or with equal probability. However, the analysis above relied on only two properties of the distribution of , so it carries over to other distributions, up to constant factors:
Property 1 (isotropy): , that is, every row follows an isotropic distribution: its covariance matrix is the identity. If the entries of are independent, have zero mean and unit variance (), this holds by the same calculation as in the #Random query matrix section.
Property 2 (subgaussianity): for every , every , and a constant . This guarantees that queries are enough for reconstruction, and only shows up in the constant factor of Formula ( ** ). Based on Hoeffding's lemma, every bounded random variable is subgaussian, though the constant given by Hoeffding is often not the best one.
When , that is, the proxy variance equals the true variance , the random variable is called strictly subgaussian. The symmetric entries are strictly subgaussian (), and Steps 1-3 apply to them word for word.
What if ?
In Step 2, we used to center the moment generating function of . If the proxy variance is strictly larger than the true variance , this shortcut is not valid, and one has to use the general Bernstein inequality for sums of independent subexponential random variables instead (see Theorem 2.8.1 and Section 5.3 in R. Vershynin, High-Dimensional Probability). The conclusion is the same, , but the constant in Formula ( ** ) becomes for some absolute constant . In other words, the number of queries grows (at most) with the square of the proxy variance.
We demonstrate the above conditions on two practical examples:
follows a sparse Rademacher distribution: , and , where corresponds to the fully dense case analyzed above. If , then zeros appear, but and still occur with equal probability, hence is symmetric.
follows a non-symmetric Bernoulli distribution: and . This is the most natural query model: every query includes each record independently with probability , so the numbers of ones and zeros differ when .
Sparse Rademacher
If each entry of follows a sparse Rademacher distribution, then
Property 1 holds if each entry of is scaled by . Indeed, , and hence if all entries of are chosen independently.
Property 2 holds with :
Why?
This follows from the dense case. With ,
where the first inequality holds because , and the second one is the bound we used for the dense entries. Hoeffding's lemma gives the same constant, since lies in an interval of length .
This bound is not tight, because the first inequality treats the zeros as if they were , ignoring that most of the probability mass sits at 0. For , it gives as in the dense case, but grows as when the matrix becomes sparser. A finer analysis, shows that the entries are strictly subgaussian () for every , and that for . The argument carries over to any larger . Therefore, the entries are strictly subgaussian exactly as long as at most two thirds of them are zero.
This means that sparse Rademacher queries with , that is, entries with probabilities , give exactly the same guarantee as the dense matrix, even though two thirds of the entries are zero. For sparser matrices (), the number of queries in Formula ( ** ) grows by at most a factor (or with the simpler constant ).
How can we realize a sparse Rademacher row with binary queries? Let and be the binary indicator vectors of the and positions in row . Then , which requires two binary queries. Each of them covers only about records, which may be too few for the database manager. However, the complement trick of the Hadamard construction helps again. Since , where is the complement query (and similarly for ),
where both and cover about records. For , every query covers about of the database. Hence, a sparse Rademacher attack needs twice as many binary queries as the dense one, but each query looks more aggregated.
Non-symmetric Bernoulli
Let with probability and otherwise. If each entry of the query matrix follows this non-symmetric Bernoulli distribution, then
Property 1 does not hold. cannot be even approximately orthogonal, since the inner product of two non-negative vectors is never negative. Indeed,where the second term, which comes from the non-zero mean , breaks isotropy. To fix this, we center and normalize:where is the variance of . Hence, with probability , and with probability . has zero mean and unit variance, so holds.
Property 2 holds because is bounded. In particular, it follows from Hoeffding's lemma thatthat is, .
Why?
Let be a mean-zero and bounded random variable: , so its range has length 1. Hoeffding's lemma states that any mean-zero random variable with range length satisfies
Since and , we get the bound by the substitution : .
Unlike the sparse Rademacher case, for every . This is not an artifact of Hoeffding's lemma: a centered Bernoulli variable is never strictly subgaussian unless , because it is not symmetric. Its third moment is non-zero, which adds a term to its MGF that cannot dominate for small (with the appropriate sign). Hoeffding's constant is not optimal though; the best possible constant is known to be :
(or )
0.5
0.75
0.9
0.99
(Hoeffding)
1
1.33
2.78
25.3
(optimal)
1
1.21
2.02
10.8
Both constants are symmetric in and , and they grow only when the queries become very small () or cover almost the whole database ().
How can we realize with strictly binary queries? Records with get weight and records with get weight , so
This means that can be realized with the binary queries plus a single query returning the total count , which covers all records and is therefore always allowed. If , the adversary can also ask the complement query instead of , since .
What does this mean for -anonymity? Suppose the database manager answers only queries covering at least records, for any . The adversary picks slightly above (or asks the complements of queries with slightly below ), so that every query passes the threshold. The price is the factor in Formula ( ** ) (or less with ), which does not depend on . Raising does not stop the attack; it only makes it a constant factor more expensive. In a quick simulation with records and non-zero entries, OMP (see below) reconstructed in all trials with 140 queries for , 200 queries for , and 800 queries for , where every query covered about 4950 of the 5000 records.
As a consequence, the numbers of ones and zeros in the queries do not need to be balanced. A random 0/1 query matrix, where every query covers a fraction of the records, plus a single query for the total count, still reconstructs an -sparse dataset from queries. The imbalance only costs a constant factor, which grows as the queries shrink () or approach the full database (). Sparse Rademacher rows with cost nothing extra asymptotically, and need two binary queries per row.
Reconstruction
We still need an efficient algorithm which computes from , or from noisy answers . Least squares methods from the previous post are not suitable: if , they return the solution with minimum -norm, which is dense and usually far from the sparse . Good decoders exploit the sparsity of , and they come in two flavors.
Convex relaxation. Finding the sparsest solution (-minimization) is NP-hard, so we replace the number of non-zero entries with the -norm, which is convex but still favors sparse solutions:
With , this is called Basis Pursuit and can be solved as a linear program. With (noisy answers), it is called Basis Pursuit Denoising, whose Lagrangian form is the well-known LASSO. Why does promote sparsity? The -ball is a "spiky" polytope whose corners lie on the coordinate axes, so when we inflate it until it touches the set of solutions , it typically touches it at a corner, which is a sparse vector. The key guarantee is from Candès: if the restricted isometry constant of for -sparse vectors satisfies , then
where is the best -sparse approximation of , and are small constants. Hence, recovery is exact if is -sparse and the answers are exact, and the error grows only linearly with the noise otherwise. This is exactly the stability we were looking for. Note that -minimization does not need to know at all. If is binary, one can also add the constraints and round the result.
Greedy methods.Orthogonal Matching Pursuit (OMP) builds the support of one index at a time. We apply OMP due to its simplicity and scalability; it works well even with many queries (i.e., larger ). The basic idea is quite simple:
Start with the residual and an empty support .
Find the column of which is the most correlated with the residual, , and add to .
Solve least squares restricted to the columns in , , and update the residual .
Repeat steps 2-3 until or is small enough.
Why does it work? Since (after scaling with ) is quasi-orthogonal, . Therefore, is a noisy copy of the not yet recovered part of , and its largest entry points to a non-zero record. Each iteration costs a single matrix-vector product and a small least squares problem, so the total cost is . It is known that that OMP recovers any fixed -sparse vector from random subgaussian queries with high probability. Variants such as CoSaMP and Iterative Hard Thresholding select several indices per iteration and come with the same RIP-based stability guarantees as -minimization. In practice, OMP is a good default when the answers are exact and (or an upper bound on it) is known, while LASSO is preferable for noisy answers.
Summary
The table below summarizes the reconstruction techniques discussed in this post. is the number of records, is the number of non-zero records, and "records per query" shows how aggregated each query looks to a -anonymity type defense.
Method (decoder)
Queries needed
Query type
Records per query
Sparsity assumption
Noisy answers
Identity (baseline)
0/1
1
None
Robust
Hadamard (fast Walsh-Hadamard transform)
0/1, complement + total count
None
Robust unless the noise is
Vandermonde / Fourier (Prony's method)
Weighted SUM (real or complex weights)
-sparse, known
Very unstable
BCH syndrome (Berlekamp-Massey)
0/1, answers taken mod 2
Binary , upper bound on
Fails (a single error flips a parity)
Random (-minimization or OMP)
0/1, complement + total count
Upper bound on (none for )
Stable: error noise
Sparse Rademacher,
, same constant
Two 0/1 complement queries per row
Upper bound on
Stable
Random 0/1 with
,
0/1 + total count
or
Upper bound on
Stable
Three observations: First, exact algebraic constructions (Vandermonde, BCH) need the fewest queries, but they break down as soon as the answers are perturbed. Second, random query matrices need only a logarithmic factor more queries, and they tolerate noise, do not require the exact sparsity, and do not care whether the queries are balanced. Third, in every row of the table, individual queries can be made to cover at least half of the database.
Conclusion
Aggregation alone does not protect individual records. A -anonymity type threshold on the query size, even or larger, does not prevent an adversary from reconstructing every record with queries. If the sensitive attribute is sparse, like the single patient with a rare genetic disease among 100,000 patients, a logarithmic number of queries is enough. The most practical attack is also the simplest one: ask random queries, each covering a random subset of the records, and decode the answers with -minimization or OMP. This attack does not need a carefully designed query structure, does not need to know the exact number of non-zero records, tolerates noisy answers, and works for any query size threshold at the cost of a constant factor.
The same argument applies beyond databases. If a secure aggregation protocol reveals the sum over a random subset of participants in every round, and the individual contributions stay (approximately) the same across rounds, then the rounds form exactly a random Bernoulli query matrix. In that case, the adversary does not even need to choose the queries; the protocol does it for them.
These techniques come from compressed sensing, which was developed to reconstruct sparse signals from few measurements in signal processing. Many naturally occurring signals are sparse in some basis, such as images in the wavelet domain or audio in the frequency domain, and compressed sensing is used, for example, to speed up MRI scans. All reconstruction techniques above are efficient, but they only work for linear queries such as COUNT and SUM. Non-linear aggregates (MIN, MAX, median) lead to combinatorial problems where SAT or integer programming solvers may be required. Moreover, the adversary must be able to target specific records with the query predicates, which requires fairly accurate knowledge of their non-sensitive attributes.
Interestingly, the key ingredients of this attack have been known for more than two decades, only from the other side of the table. In 2003, Achlioptas showed that random matrices, and even sparse matrices with entries with probabilities , preserve distances as well as Gaussian random matrices in the Johnson-Lindenstrauss lemma. He called them database-friendly random projections, because computing them needs no multiplications: each projected coordinate is the sum of some attributes minus the sum of others, which any database can compute with standard SQL aggregates. Since a random matrix satisfying the concentration inequality behind the Johnson-Lindenstrauss lemma also satisfiesthe restricted isometry property, these matrices are also good reconstruction queries. The property which made these projections friendly to database owners, namely that they can be computed with plain SUM and COUNT queries, is exactly what makes them friendly to the adversary.
What does work as a defense?
Every accurate answer leaks some information, and the leakage accumulates across queries. Dinur and Nissim showed that if every answer is accurate up to an error of , then random queries are enough to reconstruct almost all records in polynomial time. This is known as the Fundamental Law of Information Recovery: overly accurate answers to too many questions destroy privacy. Their attack uses exactly the random 0/1 queries of this post: every query includes each record independently with probability . The decoder is different, though. It does not assume that is sparse, so neither -minimization of nor OMP applies. Instead, it solves a linear program to find any fractional solution which is then rounded. Since sparsity is not exploited, it needs more than queries, as opposed to the queries for sparse data. The extra logarithmic factors pay for the noise, since exact answers would require only queries, as in the Hadamard construction. The exact algebraic constructions (Vandermonde, Prony, BCH) play no role here, since they fail under any noise. The principled defense is therefore to add noise calibrated to the total number of queries and to bound the overall leakage, which is exactly what Differential Privacy does.