Algorithm Search⌘K

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 mm-invariance: every group has at least mm 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 mm 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 TT with a quasi-identifier and one categorical sensitive attribute. At time jj the table is T(j)T(j), and the publisher releases a generalized table T∗(j)T^*(j) in which the tuples are split into QI groups, each with one generalized range on every quasi-identifier attribute. A record tt is in T(x),…,T(y)T(x), \ldots, T(y) for a range [x,y][x, y] called its lifespan.

Counterfeited generalization (Definitions 2 and 3 of the paper). A group of T∗(j)T^*(j) may contain counterfeit tuples, which have a sensitive value but match no real record. Together with T∗(j)T^*(j) the publisher releases an auxiliary table R(j)R(j) 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 T∗(j)T^*(j) is mm-unique if each QI group has at least mm tuples, counterfeits included, and all tuples in a group have different sensitive values. A sequence T∗(1),…,T∗(n)T^*(1), \ldots, T^*(n) is mm-invariant if

  1. every T∗(j)T^*(j) is mm-unique, and
  2. for every record tt with lifespan [x,y][x, y], the groups that hold tt in T∗(x),T∗(x+1),…,T∗(y)T^*(x), T^*(x+1), \ldots, T^*(y) all have the same signature.

mm-uniqueness implies distinct mm-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 tt over its lifespan has one element, the attacker learns the value of tt with certainty. The candidate set of tt at time jj is the union of the signatures of all groups whose ranges cover the QI values of tt.
  • Lemma 3 (the guarantee). If the sequence is mm-invariant, the disclosure risk of every record is at most 1/m1/m. 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 T∗(1),…,T∗(n−1)T^*(1), \ldots, T^*(n-1) is mm-invariant, adding T∗(n)T^*(n) keeps it mm-invariant if and only if T∗(n)T^*(n) is mm-unique and every record in both T(n−1)T(n-1) and T(n)T(n) has groups with the same signature in T∗(n−1)T^*(n-1) and T∗(n)T^*(n). 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.

  1. M-INVARIANT(T*(1), ..., T*(n), m)
  2. 1S ← an empty map from records to signatures
  3. 2for j ← 1 to n do
  4. 3for each QI group G of T*(j) do
  5. 4if |G| < m or two tuples of G share a sensitive value then return false
  6. 5σ ← the set of sensitive values in G
  7. 6for each record t in G that is not a counterfeit do
  8. 7if t is a key of S and S[t] ≠ σ then return false
  9. 8S[t] ← σ
  10. 9return true

With hashing, the check takes O(Ns)O(N s) expected time, where NN is the number of tuples over all releases and ss is the largest group size.

Publishing. The paper's algorithm builds T∗(n)T^*(n) from T(n−1)T(n-1), T(n)T(n) and T∗(n−1)T^*(n-1) 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 mm-eligible: at most 1/m1/m 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 m=2m = 2, 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, bronchitis}∩{\} \cap \{dyspepsia, gastritis, flu}={\} = \{dyspepsia}\}, and for Dan, {\{flu, gastritis}∩{\} \cap \{flu, pneumonia}={\} = \{flu}\}. 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 c1c_1 with bronchitis:
group records and sensitive values signature
1 Bob: dyspepsia, c1c_1: bronchitis {dyspepsia, bronchitis}
2 Dan: flu, Eve: gastritis {flu, gastritis}
3 Frank: pneumonia, Gina: flu {pneumonia, flu}

and R(2)={(1,1)}R(2) = \{(1, 1)\}: 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 R(2)R(2) 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.
  • 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 T∗(j)T^*(j) is a partition of the tuples published at time jj into QI groups, where each tuple is a record or a counterfeit. The signature σ(G)\sigma(G) of a group GG is the set of distinct sensitive values in GG. A release is mm-unique if every group has at least mm 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 tt form an interval [x,y][x, y], its lifespan. For x≤j≤yx \le j \le y, let Gj(t)G_j(t) be the group of release jj that holds tt. The sequence T∗(1),…,T∗(n)T^*(1), \ldots, T^*(n) is mm-invariant if (a) every release is mm-unique and (b) for every record tt with lifespan [x,y][x, y], the groups Gx(t),…,Gy(t)G_x(t), \ldots, G_y(t) all have the same signature.

Claim 1 (invariant). Each time line L2 starts a new release jj, if the check has not returned, then all groups of releases 1,…,j−11, \ldots, j-1 are mm-unique, and for each record tt seen so far, all its hosting groups in those releases have one signature, which is stored in S[t]S[t]. Records not seen so far are not keys of SS.

Proof. It holds before release 1, with an empty map from line L1. Suppose it holds when release jj starts and the check does not return during release jj. Line L4 did not return, so every group of release jj is mm-unique. Take a record tt of release jj in group GG. If tt was seen before, line L7 did not return, so S[t]=σ(G)S[t] = \sigma(G), and by the invariant all earlier hosting groups of tt have signature S[t]S[t]. So all hosting groups of tt up to release jj share one signature. If tt is new, line L8 stores σ(G)\sigma(G), which is the signature of its only hosting group so far. Records of earlier releases that are not in release jj keep their entries. □\square

Claim 2 (exactness). M-INVARIANT returns true if and only if the sequence is mm-invariant.

Proof. If it returns true, Claim 1 after the last release gives (a), and gives (b) because the hosting groups Gx(t),…,Gy(t)G_x(t), \ldots, G_y(t) are all the hosting groups of tt. Conversely, suppose it returns false. If line L4 returns, the current group has fewer than mm tuples or two tuples with one value, so (a) fails. If line L7 returns at record tt in group GG of release jj, then tt was seen in an earlier release, and by Claim 1 its earlier hosting groups have signature S[t]≠σ(G)S[t] \ne \sigma(G), so (b) fails for tt. ■\blacksquare

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 T∗(1),…,T∗(n−1)T^*(1), \ldots, T^*(n-1) is mm-invariant. Then T∗(1),…,T∗(n)T^*(1), \ldots, T^*(n) is mm-invariant if and only if T∗(n)T^*(n) is mm-unique and every record tt in both T(n−1)T(n-1) and T(n)T(n) has σ(Gn−1(t))=σ(Gn(t))\sigma(G_{n-1}(t)) = \sigma(G_n(t)).

Proof. The conditions are necessary by (a) and (b). For sufficiency, (a) holds for the first n−1n-1 releases by assumption and for release nn by the first condition. For (b), take a record tt. If nn is not in its lifespan, (b) for tt is the assumption. If its lifespan is [n,n][n, n], there is one group. Otherwise its lifespan is [x,n][x, n] with x<nx < n, and since the lifespan is an interval, tt is in T(n−1)T(n-1). The assumption gives one signature for Gx(t),…,Gn−1(t)G_x(t), \ldots, G_{n-1}(t), and the second condition extends it to Gn(t)G_n(t). □\square

Claim 4 (the persistent set is large). If the sequence is mm-invariant, then for every record tt the intersection of the signatures of its hosting groups has at least mm values and contains the sensitive value of tt.

Proof. By (b) the intersection equals σ(Gx(t))\sigma(G_x(t)). By (a), Gx(t)G_x(t) has at least mm tuples with pairwise different values, so ∣σ(Gx(t))∣=∣Gx(t)∣≥m|\sigma(G_x(t))| = |G_x(t)| \ge m. The value of tt is in σ(Gj(t))\sigma(G_j(t)) for each jj. □\square

The candidate set t.CSS(j)t.CSS(j) of the paper is the union of the signatures of all groups whose QI ranges cover the QI values of tt, so it contains σ(Gj(t))\sigma(G_j(t)). By Claim 4 the intersection of the candidate sets has at least mm values, so for m≥2m \ge 2 the full disclosure of Lemma 1 of the paper cannot happen. The bound of 1/m1/m 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 O(∣G∣)O(|G|) expected time with hashing, and the comparison at line L7 takes O(∣G∣)O(|G|), so the total is O(∑G∣G∣2)=O(Ns)O(\sum_G |G|^2) = O(N s), where NN is the number of tuples over all releases and ss 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.

m_invariance.pyI0RawGitHub
# 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

  1. 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)
  2. 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.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/DJ2GGT/proof-correctness.yaml
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/DJ2GGT/text.yaml