Definitionadvanced
m-invariance
Also called m-invariant republication.
A rule for republishing a changing table, which keeps the set of sensitive values of each record's group fixed across releases.
m-invariance is a privacy condition for a table that changes over time and is published again after each change, such as a hospital table that gains new patients and loses old ones every quarter. Each release can be k-anonymous and l-diverse on its own and still disclose a sensitive value: an attacker who knows that a person is in two releases intersects the sets of sensitive values of the person's two groups, and the intersection can have one element. Xiao and Tao (SIGMOD 2007) showed this and defined -invariance: every group has at least tuples with different sensitive values, and all groups that hold the same record over its lifetime have the same set of sensitive values. To make this possible when a value leaves the table, the publisher may add counterfeit tuples and must publish how many each group has. The number is a policy choice. The condition is a property of the sequence of published tables, under the attacker model of the paper.
Definition
The publisher keeps a table with a quasi-identifier and one categorical sensitive attribute. At time the table is , and the publisher releases a generalized table in which the tuples are split into QI groups, each with one generalized range on every quasi-identifier attribute. A record is in for a range called its lifespan.
Counterfeited generalization (Definitions 2 and 3 of the paper). A group of may contain counterfeit tuples, which have a sensitive value but match no real record. Together with the publisher releases an auxiliary table that lists, for each group with counterfeits, the group ID and the number of counterfeits. The counts let an analyst correct aggregate results.
Signature (Definition 16). The signature of a QI group is the set of distinct sensitive values in it.
Definition (Xiao and Tao, Definition 17). A release is -unique if each QI group has at least tuples, counterfeits included, and all tuples in a group have different sensitive values. A sequence is -invariant if
- every is -unique, and
- for every record with lifespan , the groups that hold in all have the same signature.
-uniqueness implies distinct -diversity of each release, but not the other way round.
Results of the paper, each a theorem:
- Lemma 1 (the attack). For any generalization principle, if the intersection of the candidate sensitive sets of over its lifespan has one element, the attacker learns the value of with certainty. The candidate set of at time is the union of the signatures of all groups whose ranges cover the QI values of .
- Lemma 3 (the guarantee). If the sequence is -invariant, the disclosure risk of every record is at most . The risk is the share of the reconstructions of the original tables, among those consistent with the releases and the attacker's knowledge, that give the true value; this is the paper's random-world model.
- Lemma 4 (incremental). If is -invariant, adding keeps it -invariant if and only if is -unique and every record in both and has groups with the same signature in and . The publisher needs only the last release.
The attacker model is strong on purpose (Definition 6). The attacker knows the identity, the exact QI values and the lifespan of every record, and the counterfeit counts. So the attacker knows which releases contain a person.
Condition 2 can be checked in one pass over the releases, with a map from each record to the signature of its first group. proofs/correctness.md proves that the check is exact, and proves Lemma 4 for this check.
M-INVARIANT(T*(1), ..., T*(n), m)- 1
S ← an empty map from records to signatures - 2
for j ← 1 to n do - 3
for each QI group G of T*(j) do - 4
if |G| < m or two tuples of G share a sensitive value then return false - 5
σ ← the set of sensitive values in G - 6
for each record t in G that is not a counterfeit do - 7
if t is a key of S and S[t] ≠ σ then return false - 8
S[t] ← σ - 9
return true
With hashing, the check takes expected time, where is the number of tuples over all releases and is the largest group size.
Publishing. The paper's algorithm builds from , and in four phases. Division puts each record that stays into a bucket by the signature of its old group. Balancing makes every value of a bucket's signature appear the same number of times, with new records where possible and counterfeits otherwise. Assignment places the new records into buckets, and split cuts each bucket into groups, one tuple per value of the signature. Publication is allowed only if the new records are -eligible: at most of them share one sensitive value. The algorithm tries to use few counterfeits and small QI ranges; this is a heuristic aim, measured in the paper's experiments.
Examples and non-examples
The example is small and made up, in the style of Tables 1 to 3 of the paper. Take , and suppose the QI ranges of different groups do not overlap, so the candidate set of each person is the signature of the person's own group. The first release is:
| group | records and sensitive values | signature |
|---|---|---|
| 1 | Bob: dyspepsia, Carol: bronchitis | {dyspepsia, bronchitis} |
| 2 | Dan: flu, Eve: gastritis | {flu, gastritis} |
Before the second release, Carol is deleted, and Frank (pneumonia) and Gina (flu) are inserted. The two new records have different values, so they are 2-eligible.
- Non-example: a fresh 2-diverse release. The publisher ignores the first release and forms groups Bob: dyspepsia, Eve: gastritis, Gina: flu and Dan: flu, Frank: pneumonia. This release is 2-anonymous and 2-unique. But for Bob, dyspepsia, bronchitisdyspepsia, gastritis, fludyspepsia, and for Dan, flu, gastritisflu, pneumoniaflu. Both values are disclosed, as Lemma 1 says. The pair of releases is not 2-invariant.
- Critical absence. Bob's first group had the signature dyspepsia, bronchitis, and after Carol leaves no real record has bronchitis. So no release made only of real records can give Bob a group with that signature. The paper calls this critical absence.
- Example: a 2-invariant second release. The publisher adds one counterfeit with bronchitis:
| group | records and sensitive values | signature |
|---|---|---|
| 1 | Bob: dyspepsia, : bronchitis | {dyspepsia, bronchitis} |
| 2 | Dan: flu, Eve: gastritis | {flu, gastritis} |
| 3 | Frank: pneumonia, Gina: flu | {pneumonia, flu} |
and : group 1 has one counterfeit. Every group has 2 tuples with different values, and Bob, Dan and Eve keep their signatures, so the pair is 2-invariant. The attacker who knows that Bob is in both releases still has two candidate values, and says only that one tuple of group 1 is a counterfeit, not which one.
- Not 3-invariant. The same pair is not 3-invariant, since each group has only 2 tuples.
- Non-example: keeping deleted records. Keeping Carol's tuple in all later releases as if she had not left also keeps the signatures, but the published data then holds a record that is no longer in the table, and the paper notes that the guarantees of insertion-only methods become unclear when the attacker knows the deletion times.
Related definitions
- l-diversity and k-anonymity: conditions on one release. Lemma 1 explains why they fail under republication: each constrains one candidate set, not the intersection of several.
- t-closeness: another refinement of l-diversity for one release.
- Anatomy: by the same authors, publishes groups without generalizing the quasi-identifiers. A group with one tuple per value of its signature is the same shape that m-invariance asks for.
- Generalization and suppression: the operations that make the QI ranges. m-invariance adds a third operation, counterfeit tuples, with published counts.
- Linkage attack: here the attacker links a person to groups in several releases of the same table, not to a second dataset.
- Differential privacy: a guarantee that does not depend on a model of the attacker's knowledge, at the cost of noise.
Proof: The one-pass check decides m-invariance exactlyfull
A release is a partition of the tuples published at time into QI groups, where each tuple is a record or a counterfeit. The signature of a group is the set of distinct sensitive values in . A release is -unique if every group has at least tuples and no two tuples of a group share a sensitive value. Each record occurs in at most one group per release, and the releases that contain a record form an interval , its lifespan. For , let be the group of release that holds . The sequence is -invariant if (a) every release is -unique and (b) for every record with lifespan , the groups all have the same signature.
Claim 1 (invariant). Each time line L2 starts a new release , if the check has not returned, then all groups of releases are -unique, and for each record seen so far, all its hosting groups in those releases have one signature, which is stored in . Records not seen so far are not keys of .
Proof. It holds before release 1, with an empty map from line L1. Suppose it holds when release starts and the check does not return during release . Line L4 did not return, so every group of release is -unique. Take a record of release in group . If was seen before, line L7 did not return, so , and by the invariant all earlier hosting groups of have signature . So all hosting groups of up to release share one signature. If is new, line L8 stores , which is the signature of its only hosting group so far. Records of earlier releases that are not in release keep their entries.
Claim 2 (exactness). M-INVARIANT returns true if and only if the sequence is -invariant.
Proof. If it returns true, Claim 1 after the last release gives (a), and gives (b) because the hosting groups are all the hosting groups of . Conversely, suppose it returns false. If line L4 returns, the current group has fewer than tuples or two tuples with one value, so (a) fails. If line L7 returns at record in group of release , then was seen in an earlier release, and by Claim 1 its earlier hosting groups have signature , so (b) fails for .
The check compares all hosting groups of a record, so it does not need the lifespan to be an interval. The interval is needed for the next claim.
Claim 3 (Lemma 4 of Xiao and Tao). Suppose is -invariant. Then is -invariant if and only if is -unique and every record in both and has .
Proof. The conditions are necessary by (a) and (b). For sufficiency, (a) holds for the first releases by assumption and for release by the first condition. For (b), take a record . If is not in its lifespan, (b) for is the assumption. If its lifespan is , there is one group. Otherwise its lifespan is with , and since the lifespan is an interval, is in . The assumption gives one signature for , and the second condition extends it to .
Claim 4 (the persistent set is large). If the sequence is -invariant, then for every record the intersection of the signatures of its hosting groups has at least values and contains the sensitive value of .
Proof. By (b) the intersection equals . By (a), has at least tuples with pairwise different values, so . The value of is in for each .
The candidate set of the paper is the union of the signatures of all groups whose QI ranges cover the QI values of , so it contains . By Claim 4 the intersection of the candidate sets has at least values, so for the full disclosure of Lemma 1 of the paper cannot happen. The bound of on the disclosure risk is Lemma 3 of the paper, proved there under its random-world model; it is not proved here.
Cost. Each tuple is read once at lines L4 to L6. Building a signature takes expected time with hashing, and the comparison at line L7 takes , so the total is , where is the number of tuples over all releases and is the largest group size.
Code
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/m-invariance/. The authors are listed in prov/DJ2GGT.jsonl.
from collections.abc import Hashable, Sequence
# A release is a list of QI groups. A group is a list of (record id, sensitive value)
# pairs, and a counterfeit tuple has the record id None.
Group = Sequence[tuple[Hashable | None, Hashable]]
Release = Sequence[Group]
def signature(group: Group) -> frozenset[Hashable]:
"""Return the set of distinct sensitive values in a group. Cost: O(|group|)."""
return frozenset(v for _, v in group)
def is_m_unique(release: Release, m: int) -> bool:
"""Return True if every group has at least m tuples, all with different sensitive values.
Counterfeit tuples count as tuples. Cost: O(number of tuples in the release).
"""
for group in release:
if len(group) < m or len(signature(group)) != len(group):
return False
return True
def is_m_invariant(releases: Sequence[Release], m: int) -> bool:
"""Return True if the sequence of releases T*(1), ..., T*(n) is m-invariant.
Precondition: m >= 1, each record id occurs at most once per release, and the
releases that contain a record are consecutive (its lifespan). Raises ValueError
if a record occurs twice in one release.
Cost: O(N s) expected time with hashing, where N is the total number of tuples
over all releases and s is the largest group size (one signature comparison
per tuple).
"""
sig_of: dict[Hashable, frozenset[Hashable]] = {} # @line L1
for release in releases: # @line L2
seen: set[Hashable] = set()
for group in release: # @line L3
if len(group) < m or len(signature(group)) != len(group): # @line L4
return False
sig = signature(group) # @line L5
for rid, _ in group: # @line L6
if rid is None:
continue
if rid in seen:
raise ValueError("a record occurs twice in one release")
seen.add(rid)
if rid in sig_of and sig_of[rid] != sig: # @line L7
return False
sig_of[rid] = sig # @line L8
return True # @line L9
def extends_m_invariant(previous: Release, current: Release, m: int) -> bool:
"""Lemma 4 of Xiao and Tao: the incremental test for one more release.
Given that the releases up to `previous` are m-invariant, the sequence with
`current` appended is m-invariant exactly when `current` is m-unique and every
record in both releases has hosting groups with the same signature.
Precondition: lifespans are consecutive, as in is_m_invariant.
Cost: O((|previous| + |current|) s) expected time, s the largest group size.
"""
if not is_m_unique(current, m):
return False
before = {rid: signature(g) for g in previous for rid, _ in g if rid is not None}
for group in current:
sig = signature(group)
for rid, _ in group:
if rid is not None and rid in before and before[rid] != sig:
return False
return True
def counterfeits(release: Release) -> list[tuple[int, int]]:
"""Return the auxiliary relation R(j): (group index, number of counterfeits) for each group with any.
Groups are numbered from 1 in the order given. Cost: O(number of tuples).
"""
out = []
for i, group in enumerate(release, start=1):
c = sum(1 for rid, _ in group if rid is None)
if c > 0:
out.append((i, c))
return out
test_m_invariance.py 127 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/m-invariance/. The authors are listed in prov/DJ2GGT.jsonl.
import random
import pytest
from m_invariance import counterfeits, extends_m_invariant, is_m_invariant, is_m_unique
R1 = [
[("Bob", "dyspepsia"), ("Carol", "bronchitis")],
[("Dan", "flu"), ("Eve", "gastritis")],
]
NAIVE_R2 = [
[("Bob", "dyspepsia"), ("Eve", "gastritis"), ("Gina", "flu")],
[("Dan", "flu"), ("Frank", "pneumonia")],
]
GOOD_R2 = [
[("Bob", "dyspepsia"), (None, "bronchitis")],
[("Dan", "flu"), ("Eve", "gastritis")],
[("Frank", "pneumonia"), ("Gina", "flu")],
]
def test_example() -> None:
assert is_m_unique(R1, 2) and is_m_unique(NAIVE_R2, 2) and is_m_unique(GOOD_R2, 2)
assert not is_m_invariant([R1, NAIVE_R2], 2)
assert is_m_invariant([R1, GOOD_R2], 2)
assert not extends_m_invariant(R1, NAIVE_R2, 2)
assert extends_m_invariant(R1, GOOD_R2, 2)
assert counterfeits(GOOD_R2) == [(1, 1)]
assert counterfeits(NAIVE_R2) == []
# the candidate values of Bob and Dan in the naive pair
assert {"dyspepsia", "bronchitis"} & {"dyspepsia", "gastritis", "flu"} == {"dyspepsia"}
assert {"flu", "gastritis"} & {"flu", "pneumonia"} == {"flu"}
assert not is_m_invariant([R1, GOOD_R2], 3)
def test_edges() -> None:
assert is_m_invariant([], 3)
assert is_m_invariant([[]], 3)
assert is_m_invariant([R1], 2)
assert not is_m_invariant([R1], 3)
# repeated sensitive value in a group
assert not is_m_invariant([[[("a", "x"), ("b", "x"), ("c", "y")]]], 2)
# a group made only of counterfeits is allowed by the definition
assert is_m_invariant([[[(None, "x"), (None, "y")]]], 2)
with pytest.raises(ValueError):
is_m_invariant([[[("a", "x"), ("b", "y")], [("a", "z"), ("c", "w")]]], 2)
def oracle(releases: list, m: int) -> bool:
for release in releases:
for group in release:
values = [v for _, v in group]
if len(values) < m or len(set(values)) < len(values):
return False
history: dict = {}
for release in releases:
for group in release:
sig = sorted({v for _, v in group})
for rid, _ in group:
if rid is not None:
history.setdefault(rid, []).append(sig)
return all(all(s == sigs[0] for s in sigs) for sigs in history.values())
VALUES = "pqrstu"
def random_case(rng: random.Random) -> tuple[list, int, dict]:
m = rng.randint(1, 3)
n = rng.randint(1, 4)
value = {}
life = {}
bucket = {}
for r in range(rng.randint(0, 10)):
v = rng.choice(VALUES)
others = [x for x in VALUES if x != v]
value[r] = v
bucket[r] = frozenset([v] + rng.sample(others, m - 1 + rng.randint(0, 1)))
x = rng.randint(1, n)
life[r] = (x, rng.randint(x, n))
releases = []
for j in range(1, n + 1):
present = [r for r in value if life[r][0] <= j <= life[r][1]]
release = []
for sig in sorted({bucket[r] for r in present}, key=sorted):
lists = {v: [r for r in present if bucket[r] == sig and value[r] == v] for v in sorted(sig)}
for g in range(max(len(x) for x in lists.values())):
release.append([(lists[v][g], v) if g < len(lists[v]) else (None, v) for v in sorted(sig)])
releases.append(release)
# break the construction in about half of the cases
if releases and rng.random() < 0.5:
rel = rng.choice(releases)
if len(rel) >= 2:
a, b = rng.sample(range(len(rel)), 2)
i, k = rng.randrange(len(rel[a])), rng.randrange(len(rel[b]))
rel[a][i], rel[b][k] = rel[b][k], rel[a][i]
elif rel and rel[0]:
i = rng.randrange(len(rel[0]))
rel[0][i] = (rel[0][i][0], rng.choice(VALUES))
return releases, m, value
def test_against_oracle() -> None:
rng = random.Random(41)
positive = 0
for _ in range(800):
releases, m, value = random_case(rng)
got = is_m_invariant(releases, m)
assert got == oracle(releases, m)
positive += got
# Lemma 4: the incremental test agrees with the full test
chain = is_m_unique(releases[0], m) if releases else True
for j in range(1, len(releases)):
chain = chain and extends_m_invariant(releases[j - 1], releases[j], m)
assert chain == got
# the persistent candidate set of each record has at least m values and holds its value
if got:
for rid in value:
hosts = [g for rel in releases for g in rel if any(r == rid for r, _ in g)]
if hosts:
common = frozenset.intersection(*[frozenset(x for _, x in g) for g in hosts])
own = {x for g in hosts for r, x in g if r == rid}
assert own <= common and len(common) >= m
assert 200 < positive < 800
References
- Xiaokui Xiao and Yufei Tao, m-Invariance: towards privacy preserving re-publication of dynamic datasets, ACM SIGMOD International Conference on Management of Data (SIGMOD 2007), pages 689-700, Section 1 (Tables 1 to 3, the attack that combines two releases, critical absence and counterfeits), Section 2 (Definitions 2 and 3, counterfeited generalization and the auxiliary relation R(j)), Section 3 (Definitions 13 to 17 and Lemmas 1 to 4) and Section 4.1 (m-eligibility and the four phases of the publishing algorithm)
- Ashwin Machanavajjhala, Johannes Gehrke, Daniel Kifer and Muthuramakrishnan Venkitasubramaniam, l-diversity: privacy beyond k-anonymity, 22nd International Conference on Data Engineering (ICDE 2006), page 24, the l-diversity principle, which protects one release but not a sequence of releases
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H2 full proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag DJ2GGT Edit this page History Report an error Markdown