[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AF26ER6S13YRZSD5WEP250":3,"skill-same:01M6AF26ER6S13YRZSD5WEP250":96},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":17,"ownerHtmlUrl":52,"ownerBlogUrl":53,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M6AF26ER6S13YRZSD5WEP250","privacy-record-linkage","隐私保护记录链接","Implement privacy-preserving record linkage across datasets using Bloom filter encoding, secure hash matching, threshold tuning for precision and recall, and false positive management. Enables entity resolution without exposing raw personally identifiable information between parties.","使用布隆过滤器（Bloom filter）编码、安全哈希匹配、用于调优精确率与召回率的阈值调整以及误报管理，实现跨数据集的隐私保护记录链接。使各方在互不暴露原始个人身份信息的情况下完成实体解析。","mukul975\u002FPrivacy-Data-Protection-Skills","mukul975","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42860185?v=4","01M6ADEQR8T5M4EEG6C67BQCWF","Mahipal","01M6ADNKWX1HF4Q5DKEXT5M774",338,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BTGTEHKD89NSZ5CT4Y5AGV","数据工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C8DHMF0ZN1BNFR3MYR05ZS","隐私计算与加密实现","SCENARIO","使用场景",[31,32,33,34,35,36,37],"privacy","privacy record linkage","implement","secure","encoding","engineering","tuning","2026-11-10 10:12:30",false,"---\nname: privacy-record-linkage\ndescription: >-\n  Implement privacy-preserving record linkage across datasets using Bloom filter\n  encoding, secure hash matching, threshold tuning for precision and recall,\n  and false positive management. Enables entity resolution without exposing\n  raw personally identifiable information between parties.\nlicense: Apache-2.0\nmetadata:\n  author: mukul975\n  version: \"1.0\"\n  domain: privacy\n  subdomain: privacy-engineering\n  tags: \"record-linkage, bloom-filters, entity-resolution, secure-matching, pprl\"\n---\n\n# Privacy-Preserving Record Linkage\n\n## Overview\n\nPrivacy-Preserving Record Linkage (PPRL) enables two or more organizations to identify matching records across their datasets without revealing the underlying personal data to each other. This is critical for healthcare research, fraud detection, national statistics, and cross-organizational analytics where direct data sharing is prohibited by privacy regulations.\n\n## Approach Comparison\n\n| Approach | Privacy Level | Accuracy | Scalability | Communication Cost |\n|----------|--------------|----------|-------------|-------------------|\n| Bloom Filter Encoding | High | Good (>95% F1) | Very High | Low |\n| Secure Hash Matching | Very High | High (exact match only) | Very High | Very Low |\n| Secure Multi-Party Computation | Cryptographic | Very High | Medium | High |\n| Trusted Third Party | Depends on TTP | Very High | High | Medium |\n| Differential Privacy Linkage | Formally private | Moderate | High | Low |\n\n## Bloom Filter-Based PPRL\n\n### How It Works\n\n1. Each organization encodes their quasi-identifiers (name, date of birth, address) into Bloom filters\n2. The Bloom filter encoding uses cryptographic hash functions with a shared secret key\n3. Encoded Bloom filters are compared using similarity metrics (Dice coefficient, Jaccard)\n4. Matching pairs above a threshold are identified as linked records\n5. Raw data is never exchanged — only Bloom filter bit arrays\n\n### Bloom Filter Encoding Implementation\n\n```python\n\"\"\"\nPrivacy-preserving record linkage using Bloom filter encoding.\nImplements the approach described by Schnell, Bachteler, and Reiher (2009).\n\"\"\"\n\nimport hashlib\nimport hmac\nimport math\nfrom typing import Optional\nimport numpy as np\n\n\nclass BloomFilterEncoder:\n    \"\"\"\n    Encode string attributes into Bloom filters for privacy-preserving\n    record linkage using cryptographic keyed hashing.\n    \"\"\"\n\n    def __init__(\n        self,\n        filter_size: int = 1024,\n        num_hash_functions: int = 30,\n        ngram_size: int = 2,\n        secret_key: bytes = b\"\"\n    ):\n        \"\"\"\n        Args:\n            filter_size: Number of bits in the Bloom filter\n            num_hash_functions: Number of hash functions (k)\n            ngram_size: Size of character n-grams (bigrams = 2)\n            secret_key: Shared secret key for HMAC hashing\n        \"\"\"\n        self.filter_size = filter_size\n        self.num_hash_functions = num_hash_functions\n        self.ngram_size = ngram_size\n        self.secret_key = secret_key\n\n    def _generate_ngrams(self, value: str) -> list[str]:\n        \"\"\"Generate character n-grams from a string value.\"\"\"\n        # Pad the string to handle edge characters\n        padded = f\"_{value}_\"\n        return [\n            padded[i:i + self.ngram_size]\n            for i in range(len(padded) - self.ngram_size + 1)\n        ]\n\n    def _hash_ngram(self, ngram: str, hash_index: int) -> int:\n        \"\"\"\n        Hash an n-gram using HMAC with the shared key and hash index.\n        Returns a bit position in the Bloom filter.\n        \"\"\"\n        message = f\"{hash_index}:{ngram}\".encode(\"utf-8\")\n        digest = hmac.new(self.secret_key, message, hashlib.sha256).digest()\n        # Convert first 4 bytes to integer and modulo by filter size\n        position = int.from_bytes(digest[:4], byteorder=\"big\") % self.filter_size\n        return position\n\n    def encode_value(self, value: str) -> np.ndarray:\n        \"\"\"\n        Encode a single attribute value into a Bloom filter.\n\n        Args:\n            value: The string value to encode (e.g., a name)\n\n        Returns:\n            Numpy array of bits (0\u002F1) representing the Bloom filter\n        \"\"\"\n        bloom_filter = np.zeros(self.filter_size, dtype=np.uint8)\n\n        # Normalize the input\n        normalized = value.strip().lower()\n\n        # Generate n-grams\n        ngrams = self._generate_ngrams(normalized)\n\n        # Hash each n-gram with each hash function\n        for ngram in ngrams:\n            for h in range(self.num_hash_functions):\n                position = self._hash_ngram(ngram, h)\n                bloom_filter[position] = 1\n\n        return bloom_filter\n\n    def encode_record(self, attributes: dict[str, str]) -> np.ndarray:\n        \"\"\"\n        Encode multiple attributes into a single composite Bloom filter\n        using Cryptographic Longterm Key (CLK) approach.\n\n        Args:\n            attributes: Dict mapping attribute names to values\n                       e.g., {\"first_name\": \"John\", \"last_name\": \"Smith\", \"dob\": \"1990-01-15\"}\n\n        Returns:\n            Composite Bloom filter as numpy array\n        \"\"\"\n        composite = np.zeros(self.filter_size, dtype=np.uint8)\n\n        for attr_name, attr_value in attributes.items():\n            if attr_value:\n                # Use attribute name as additional salt\n                salted_key = self.secret_key + attr_name.encode(\"utf-8\")\n                encoder = BloomFilterEncoder(\n                    filter_size=self.filter_size,\n                    num_hash_functions=self.num_hash_functions,\n                    ngram_size=self.ngram_size,\n                    secret_key=salted_key\n                )\n                attr_bf = encoder.encode_value(attr_value)\n                composite = np.bitwise_or(composite, attr_bf)\n\n        return composite\n\n\nclass BloomFilterMatcher:\n    \"\"\"\n    Compare Bloom filter-encoded records to find matching pairs.\n    \"\"\"\n\n    @staticmethod\n    def dice_coefficient(bf1: np.ndarray, bf2: np.ndarray) -> float:\n        \"\"\"\n        Calculate the Dice coefficient between two Bloom filters.\n\n        Dice = 2 * |bf1 AND bf2| \u002F (|bf1| + |bf2|)\n\n        Returns a similarity score between 0 and 1.\n        \"\"\"\n        intersection = np.sum(np.bitwise_and(bf1, bf2))\n        cardinality_sum = np.sum(bf1) + np.sum(bf2)\n\n        if cardinality_sum == 0:\n            return 0.0\n\n        return 2.0 * intersection \u002F cardinality_sum\n\n    @staticmethod\n    def jaccard_similarity(bf1: np.ndarray, bf2: np.ndarray) -> float:\n        \"\"\"\n        Calculate the Jaccard similarity between two Bloom filters.\n\n        Jaccard = |bf1 AND bf2| \u002F |bf1 OR bf2|\n        \"\"\"\n        intersection = np.sum(np.bitwise_and(bf1, bf2))\n        union = np.sum(np.bitwise_or(bf1, bf2))\n\n        if union == 0:\n            return 0.0\n\n        return intersection \u002F union\n\n    def find_matches(\n        self,\n        encodings_a: list[tuple[str, np.ndarray]],\n        encodings_b: list[tuple[str, np.ndarray]],\n        threshold: float = 0.8,\n        similarity_metric: str = \"dice\"\n    ) -> list[tuple[str, str, float]]:\n        \"\"\"\n        Find matching record pairs between two encoded datasets.\n\n        Args:\n            encodings_a: List of (record_id, bloom_filter) from organization A\n            encodings_b: List of (record_id, bloom_filter) from organization B\n            threshold: Minimum similarity score for a match\n            similarity_metric: \"dice\" or \"jaccard\"\n\n        Returns:\n            List of (id_a, id_b, similarity_score) for matching pairs\n        \"\"\"\n        metric_fn = (\n            self.dice_coefficient if similarity_metric == \"dice\"\n            else self.jaccard_similarity\n        )\n\n        matches = []\n\n        for id_a, bf_a in encodings_a:\n            best_score = 0.0\n            best_id_b = None\n\n            for id_b, bf_b in encodings_b:\n                score = metric_fn(bf_a, bf_b)\n                if score > best_score:\n                    best_score = score\n                    best_id_b = id_b\n\n            if best_score >= threshold and best_id_b is not None:\n                matches.append((id_a, best_id_b, best_score))\n\n        return matches\n```\n\n## Secure Hash Matching\n\nFor exact matching scenarios where approximate matching is not needed.\n\n```python\n\"\"\"\nSecure hash-based record linkage for exact matching.\nUses keyed HMAC to prevent rainbow table attacks.\n\"\"\"\n\nimport hashlib\nimport hmac\n\n\nclass SecureHashLinker:\n    \"\"\"\n    Link records across organizations using keyed hash matching.\n    Suitable for exact match on standardized identifiers.\n    \"\"\"\n\n    def __init__(self, shared_key: bytes):\n        self.shared_key = shared_key\n\n    def hash_identifier(self, *fields: str) -> str:\n        \"\"\"\n        Create a keyed hash of concatenated identifier fields.\n\n        Args:\n            fields: Identifier fields in standardized order\n                    e.g., (\"john\", \"smith\", \"19900115\")\n\n        Returns:\n            Hex-encoded HMAC-SHA256 hash\n        \"\"\"\n        # Normalize and concatenate fields\n        normalized = \"|\".join(f.strip().lower() for f in fields)\n\n        # Generate keyed hash\n        digest = hmac.new(\n            self.shared_key,\n            normalized.encode(\"utf-8\"),\n            hashlib.sha256\n        ).hexdigest()\n\n        return digest\n\n    def hash_dataset(\n        self,\n        records: list[dict],\n        id_field: str,\n        linkage_fields: list[str]\n    ) -> dict[str, str]:\n        \"\"\"\n        Hash all records in a dataset for linkage.\n\n        Returns mapping of hash -> record_id.\n        \"\"\"\n        hash_map = {}\n\n        for record in records:\n            fields = [str(record.get(f, \"\")) for f in linkage_fields]\n            record_hash = self.hash_identifier(*fields)\n            hash_map[record_hash] = record[id_field]\n\n        return hash_map\n\n    @staticmethod\n    def find_exact_matches(\n        hashes_a: dict[str, str],\n        hashes_b: dict[str, str]\n    ) -> list[tuple[str, str]]:\n        \"\"\"\n        Find exact matches between two hash maps.\n\n        Returns list of (id_a, id_b) pairs.\n        \"\"\"\n        common_hashes = set(hashes_a.keys()) & set(hashes_b.keys())\n        return [(hashes_a[h], hashes_b[h]) for h in common_hashes]\n```\n\n## Threshold Tuning\n\n### Methodology\n\n| Threshold Range | Precision | Recall | Use Case |\n|----------------|-----------|--------|----------|\n| 0.90 - 1.00 | Very High | Low | High-stakes decisions (medical records) |\n| 0.80 - 0.90 | High | Medium | Standard record linkage |\n| 0.70 - 0.80 | Medium | High | Exploratory analysis, broad matching |\n| 0.60 - 0.70 | Low | Very High | Candidate generation (with manual review) |\n\n### Optimal Threshold Selection Process\n\n1. **Generate labeled pairs**: Create a sample of known matches and non-matches\n2. **Compute similarity scores**: Calculate Dice\u002FJaccard for all pairs in the sample\n3. **Plot precision-recall curve**: Sweep threshold from 0 to 1\n4. **Select threshold**: Choose based on acceptable false positive rate for the use case\n5. **Validate**: Test on held-out labeled data\n\n### False Positive Management\n\n```python\n\"\"\"\nPost-linkage false positive reduction through multi-stage verification.\n\"\"\"\n\n\nclass FalsePositiveManager:\n    \"\"\"\n    Reduce false positive matches through additional verification stages\n    without revealing raw data between parties.\n    \"\"\"\n\n    def __init__(self, primary_threshold: float = 0.8, verification_threshold: float = 0.9):\n        self.primary_threshold = primary_threshold\n        self.verification_threshold = verification_threshold\n\n    def multi_field_verification(\n        self,\n        candidate_pairs: list[tuple[str, str, float]],\n        secondary_encodings_a: dict[str, dict[str, np.ndarray]],\n        secondary_encodings_b: dict[str, dict[str, np.ndarray]],\n        matcher: BloomFilterMatcher\n    ) -> list[tuple[str, str, float, bool]]:\n        \"\"\"\n        Verify candidate matches using additional encoded fields.\n\n        Args:\n            candidate_pairs: (id_a, id_b, primary_score) from initial matching\n            secondary_encodings_a: {record_id: {field: bloom_filter}} from org A\n            secondary_encodings_b: {record_id: {field: bloom_filter}} from org B\n\n        Returns:\n            (id_a, id_b, composite_score, verified) for each candidate\n        \"\"\"\n        verified_pairs = []\n\n        for id_a, id_b, primary_score in candidate_pairs:\n            secondary_scores = []\n\n            fields_a = secondary_encodings_a.get(id_a, {})\n            fields_b = secondary_encodings_b.get(id_b, {})\n\n            common_fields = set(fields_a.keys()) & set(fields_b.keys())\n\n            for field_name in common_fields:\n                score = matcher.dice_coefficient(\n                    fields_a[field_name],\n                    fields_b[field_name]\n                )\n                secondary_scores.append(score)\n\n            if secondary_scores:\n                avg_secondary = sum(secondary_scores) \u002F len(secondary_scores)\n                composite = 0.6 * primary_score + 0.4 * avg_secondary\n                verified = composite >= self.verification_threshold\n            else:\n                composite = primary_score\n                verified = primary_score >= self.verification_threshold\n\n            verified_pairs.append((id_a, id_b, composite, verified))\n\n        return verified_pairs\n```\n\n## Security Considerations\n\n| Attack | Description | Mitigation |\n|--------|-------------|------------|\n| Frequency analysis | Analyzing bit patterns to infer common values | Use composite Bloom filters (CLK), add noise bits |\n| Dictionary attack | Pre-computing Bloom filters for known values | Use strong shared secret keys, rotate keys periodically |\n| Bit pattern cryptanalysis | Exploiting structure in Bloom filter bit patterns | Sufficient filter size (>= 1024), adequate hash functions (>= 20) |\n| Collision exploitation | Deliberately crafting records to match target hashes | HMAC-based hashing, input validation |\n\n## References\n\n- Schnell, R., Bachteler, T., and Reiher, J. \"Privacy-Preserving Record Linkage Using Bloom Filters.\" BMC Medical Informatics and Decision Making, 9(1):41, 2009.\n- Vatsalan, D., Christen, P., and Verykios, V.S. \"A Taxonomy of Privacy-Preserving Record Linkage Techniques.\" Information Systems, 38(6):946-969, 2013.\n- Randall, S.M. et al. \"Privacy-Preserving Record Linkage on Large Real World Datasets.\" Journal of Biomedical Informatics, 50:205-212, 2014.\n- AIHW (Australian Institute of Health and Welfare) PPRL Implementation Guide\n- Christen, P. \"Data Matching: Concepts and Techniques for Record Linkage, Entity Resolution, and Duplicate Detection.\" Springer, 2012.\n","# Privacy-Preserving Record Linkage\n\n## Overview\n\nPrivacy-Preserving Record Linkage (PPRL) enables two or more organizations to identify matching records across their datasets without revealing the underlying personal data to each other. This is critical for healthcare research, fraud detection, national statistics, and cross-organizational analytics where direct data sharing is prohibited by privacy regulations.\n\n## Approach Comparison\n\n| Approach | Privacy Level | Accuracy | Scalability | Communication Cost |\n|----------|--------------|----------|-------------|-------------------|\n| Bloom Filter Encoding | High | Good (>95% F1) | Very High | Low |\n| Secure Hash Matching | Very High | High (exact match only) | Very High | Very Low |\n| Secure Multi-Party Computation | Cryptographic | Very High | Medium | High |\n| Trusted Third Party | Depends on TTP | Very High | High | Medium |\n| Differential Privacy Linkage | Formally private | Moderate | High | Low |\n\n## Bloom Filter-Based PPRL\n\n### How It Works\n\n1. Each organization encodes their quasi-identifiers (name, date of birth, address) into Bloom filters\n2. The Bloom filter encoding uses cryptographic hash functions with a shared secret key\n3. Encoded Bloom filters are compared using similarity metrics (Dice coefficient, Jaccard)\n4. Matching pairs above a threshold are identified as linked records\n5. Raw data is never exchanged — only Bloom filter bit arrays\n\n### Bloom Filter Encoding Implementation\n\n```python\n\"\"\"\nPrivacy-preserving record linkage using Bloom filter encoding.\nImplements the approach described by Schnell, Bachteler, and Reiher (2009).\n\"\"\"\n\nimport hashlib\nimport hmac\nimport math\nfrom typing import Optional\nimport numpy as np\n\n\nclass BloomFilterEncoder:\n    \"\"\"\n    Encode string attributes into Bloom filters for privacy-preserving\n    record linkage using cryptographic keyed hashing.\n    \"\"\"\n\n    def __init__(\n        self,\n        filter_size: int = 1024,\n        num_hash_functions: int = 30,\n        ngram_size: int = 2,\n        secret_key: bytes = b\"\"\n    ):\n        \"\"\"\n        Args:\n            filter_size: Number of bits in the Bloom filter\n            num_hash_functions: Number of hash functions (k)\n            ngram_size: Size of character n-grams (bigrams = 2)\n            secret_key: Shared secret key for HMAC hashing\n        \"\"\"\n        self.filter_size = filter_size\n        self.num_hash_functions = num_hash_functions\n        self.ngram_size = ngram_size\n        self.secret_key = secret_key\n\n    def _generate_ngrams(self, value: str) -> list[str]:\n        \"\"\"Generate character n-grams from a string value.\"\"\"\n        # Pad the string to handle edge characters\n        padded = f\"_{value}_\"\n        return [\n            padded[i:i + self.ngram_size]\n            for i in range(len(padded) - self.ngram_size + 1)\n        ]\n\n    def _hash_ngram(self, ngram: str, hash_index: int) -> int:\n        \"\"\"\n        Hash an n-gram using HMAC with the shared key and hash index.\n        Returns a bit position in the Bloom filter.\n        \"\"\"\n        message = f\"{hash_index}:{ngram}\".encode(\"utf-8\")\n        digest = hmac.new(self.secret_key, message, hashlib.sha256).digest()\n        # Convert first 4 bytes to integer and modulo by filter size\n        position = int.from_bytes(digest[:4], byteorder=\"big\") % self.filter_size\n        return position\n\n    def encode_value(self, value: str) -> np.ndarray:\n        \"\"\"\n        Encode a single attribute value into a Bloom filter.\n\n        Args:\n            value: The string value to encode (e.g., a name)\n\n        Returns:\n            Numpy array of bits (0\u002F1) representing the Bloom filter\n        \"\"\"\n        bloom_filter = np.zeros(self.filter_size, dtype=np.uint8)\n\n        # Normalize the input\n        normalized = value.strip().lower()\n\n        # Generate n-grams\n        ngrams = self._generate_ngrams(normalized)\n\n        # Hash each n-gram with each hash function\n        for ngram in ngrams:\n            for h in range(self.num_hash_functions):\n                position = self._hash_ngram(ngram, h)\n                bloom_filter[position] = 1\n\n        return bloom_filter\n\n    def encode_record(self, attributes: dict[str, str]) -> np.ndarray:\n        \"\"\"\n        Encode multiple attributes into a single composite Bloom filter\n        using Cryptographic Longterm Key (CLK) approach.\n\n        Args:\n            attributes: Dict mapping attribute names to values\n                       e.g., {\"first_name\": \"John\", \"last_name\": \"Smith\", \"dob\": \"1990-01-15\"}\n\n        Returns:\n            Composite Bloom filter as numpy array\n        \"\"\"\n        composite = np.zeros(self.filter_size, dtype=np.uint8)\n\n        for attr_name, attr_value in attributes.items():\n            if attr_value:\n                # Use attribute name as additional salt\n                salted_key = self.secret_key + attr_name.encode(\"utf-8\")\n                encoder = BloomFilterEncoder(\n                    filter_size=self.filter_size,\n                    num_hash_functions=self.num_hash_functions,\n                    ngram_size=self.ngram_size,\n                    secret_key=salted_key\n                )\n                attr_bf = encoder.encode_value(attr_value)\n                composite = np.bitwise_or(composite, attr_bf)\n\n        return composite\n\n\nclass BloomFilterMatcher:\n    \"\"\"\n    Compare Bloom filter-encoded records to find matching pairs.\n    \"\"\"\n\n    @staticmethod\n    def dice_coefficient(bf1: np.ndarray, bf2: np.ndarray) -> float:\n        \"\"\"\n        Calculate the Dice coefficient between two Bloom filters.\n\n        Dice = 2 * |bf1 AND bf2| \u002F (|bf1| + |bf2|)\n\n        Returns a similarity score between 0 and 1.\n        \"\"\"\n        intersection = np.sum(np.bitwise_and(bf1, bf2))\n        cardinality_sum = np.sum(bf1) + np.sum(bf2)\n\n        if cardinality_sum == 0:\n            return 0.0\n\n        return 2.0 * intersection \u002F cardinality_sum\n\n    @staticmethod\n    def jaccard_similarity(bf1: np.ndarray, bf2: np.ndarray) -> float:\n        \"\"\"\n        Calculate the Jaccard similarity between two Bloom filters.\n\n        Jaccard = |bf1 AND bf2| \u002F |bf1 OR bf2|\n        \"\"\"\n        intersection = np.sum(np.bitwise_and(bf1, bf2))\n        union = np.sum(np.bitwise_or(bf1, bf2))\n\n        if union == 0:\n            return 0.0\n\n        return intersection \u002F union\n\n    def find_matches(\n        self,\n        encodings_a: list[tuple[str, np.ndarray]],\n        encodings_b: list[tuple[str, np.ndarray]],\n        threshold: float = 0.8,\n        similarity_metric: str = \"dice\"\n    ) -> list[tuple[str, str, float]]:\n        \"\"\"\n        Find matching record pairs between two encoded datasets.\n\n        Args:\n            encodings_a: List of (record_id, bloom_filter) from organization A\n            encodings_b: List of (record_id, bloom_filter) from organization B\n            threshold: Minimum similarity score for a match\n            similarity_metric: \"dice\" or \"jaccard\"\n\n        Returns:\n            List of (id_a, id_b, similarity_score) for matching pairs\n        \"\"\"\n        metric_fn = (\n            self.dice_coefficient if similarity_metric == \"dice\"\n            else self.jaccard_similarity\n        )\n\n        matches = []\n\n        for id_a, bf_a in encodings_a:\n            best_score = 0.0\n            best_id_b = None\n\n            for id_b, bf_b in encodings_b:\n                score = metric_fn(bf_a, bf_b)\n                if score > best_score:\n                    best_score = score\n                    best_id_b = id_b\n\n            if best_score >= threshold and best_id_b is not None:\n                matches.append((id_a, best_id_b, best_score))\n\n        return matches\n```\n\n## Secure Hash Matching\n\nFor exact matching scenarios where approximate matching is not needed.\n\n```python\n\"\"\"\nSecure hash-based record linkage for exact matching.\nUses keyed HMAC to prevent rainbow table attacks.\n\"\"\"\n\nimport hashlib\nimport hmac\n\n\nclass SecureHashLinker:\n    \"\"\"\n    Link records across organizations using keyed hash matching.\n    Suitable for exact match on standardized identifiers.\n    \"\"\"\n\n    def __init__(self, shared_key: bytes):\n        self.shared_key = shared_key\n\n    def hash_identifier(self, *fields: str) -> str:\n        \"\"\"\n        Create a keyed hash of concatenated identifier fields.\n\n        Args:\n            fields: Identifier fields in standardized order\n                    e.g., (\"john\", \"smith\", \"19900115\")\n\n        Returns:\n            Hex-encoded HMAC-SHA256 hash\n        \"\"\"\n        # Normalize and concatenate fields\n        normalized = \"|\".join(f.strip().lower() for f in fields)\n\n        # Generate keyed hash\n        digest = hmac.new(\n            self.shared_key,\n            normalized.encode(\"utf-8\"),\n            hashlib.sha256\n        ).hexdigest()\n\n        return digest\n\n    def hash_dataset(\n        self,\n        records: list[dict],\n        id_field: str,\n        linkage_fields: list[str]\n    ) -> dict[str, str]:\n        \"\"\"\n        Hash all records in a dataset for linkage.\n\n        Returns mapping of hash -> record_id.\n        \"\"\"\n        hash_map = {}\n\n        for record in records:\n            fields = [str(record.get(f, \"\")) for f in linkage_fields]\n            record_hash = self.hash_identifier(*fields)\n            hash_map[record_hash] = record[id_field]\n\n        return hash_map\n\n    @staticmethod\n    def find_exact_matches(\n        hashes_a: dict[str, str],\n        hashes_b: dict[str, str]\n    ) -> list[tuple[str, str]]:\n        \"\"\"\n        Find exact matches between two hash maps.\n\n        Returns list of (id_a, id_b) pairs.\n        \"\"\"\n        common_hashes = set(hashes_a.keys()) & set(hashes_b.keys())\n        return [(hashes_a[h], hashes_b[h]) for h in common_hashes]\n```\n\n## Threshold Tuning\n\n### Methodology\n\n| Threshold Range | Precision | Recall | Use Case |\n|----------------|-----------|--------|----------|\n| 0.90 - 1.00 | Very High | Low | High-stakes decisions (medical records) |\n| 0.80 - 0.90 | High | Medium | Standard record linkage |\n| 0.70 - 0.80 | Medium | High | Exploratory analysis, broad matching |\n| 0.60 - 0.70 | Low | Very High | Candidate generation (with manual review) |\n\n### Optimal Threshold Selection Process\n\n1. **Generate labeled pairs**: Create a sample of known matches and non-matches\n2. **Compute similarity scores**: Calculate Dice\u002FJaccard for all pairs in the sample\n3. **Plot precision-recall curve**: Sweep threshold from 0 to 1\n4. **Select threshold**: Choose based on acceptable false positive rate for the use case\n5. **Validate**: Test on held-out labeled data\n\n### False Positive Management\n\n```python\n\"\"\"\nPost-linkage false positive reduction through multi-stage verification.\n\"\"\"\n\n\nclass FalsePositiveManager:\n    \"\"\"\n    Reduce false positive matches through additional verification stages\n    without revealing raw data between parties.\n    \"\"\"\n\n    def __init__(self, primary_threshold: float = 0.8, verification_threshold: float = 0.9):\n        self.primary_threshold = primary_threshold\n        self.verification_threshold = verification_threshold\n\n    def multi_field_verification(\n        self,\n        candidate_pairs: list[tuple[str, str, float]],\n        secondary_encodings_a: dict[str, dict[str, np.ndarray]],\n        secondary_encodings_b: dict[str, dict[str, np.ndarray]],\n        matcher: BloomFilterMatcher\n    ) -> list[tuple[str, str, float, bool]]:\n        \"\"\"\n        Verify candidate matches using additional encoded fields.\n\n        Args:\n            candidate_pairs: (id_a, id_b, primary_score) from initial matching\n            secondary_encodings_a: {record_id: {field: bloom_filter}} from org A\n            secondary_encodings_b: {record_id: {field: bloom_filter}} from org B\n\n        Returns:\n            (id_a, id_b, composite_score, verified) for each candidate\n        \"\"\"\n        verified_pairs = []\n\n        for id_a, id_b, primary_score in candidate_pairs:\n            secondary_scores = []\n\n            fields_a = secondary_encodings_a.get(id_a, {})\n            fields_b = secondary_encodings_b.get(id_b, {})\n\n            common_fields = set(fields_a.keys()) & set(fields_b.keys())\n\n            for field_name in common_fields:\n                score = matcher.dice_coefficient(\n                    fields_a[field_name],\n                    fields_b[field_name]\n                )\n                secondary_scores.append(score)\n\n            if secondary_scores:\n                avg_secondary = sum(secondary_scores) \u002F len(secondary_scores)\n                composite = 0.6 * primary_score + 0.4 * avg_secondary\n                verified = composite >= self.verification_threshold\n            else:\n                composite = primary_score\n                verified = primary_score >= self.verification_threshold\n\n            verified_pairs.append((id_a, id_b, composite, verified))\n\n        return verified_pairs\n```\n\n## Security Considerations\n\n| Attack | Description | Mitigation |\n|--------|-------------|------------|\n| Frequency analysis | Analyzing bit patterns to infer common values | Use composite Bloom filters (CLK), add noise bits |\n| Dictionary attack | Pre-computing Bloom filters for known values | Use strong shared secret keys, rotate keys periodically |\n| Bit pattern cryptanalysis | Exploiting structure in Bloom filter bit patterns | Sufficient filter size (>= 1024), adequate hash functions (>= 20) |\n| Collision exploitation | Deliberately crafting records to match target hashes | HMAC-based hashing, input validation |\n\n## References\n\n- Schnell, R., Bachteler, T., and Reiher, J. \"Privacy-Preserving Record Linkage Using Bloom Filters.\" BMC Medical Informatics and Decision Making, 9(1):41, 2009.\n- Vatsalan, D., Christen, P., and Verykios, V.S. \"A Taxonomy of Privacy-Preserving Record Linkage Techniques.\" Information Systems, 38(6):946-969, 2013.\n- Randall, S.M. et al. \"Privacy-Preserving Record Linkage on Large Real World Datasets.\" Journal of Biomedical Informatics, 50:205-212, 2014.\n- AIHW (Australian Institute of Health and Welfare) PPRL Implementation Guide\n- Christen, P. \"Data Matching: Concepts and Techniques for Record Linkage, Entity Resolution, and Duplicate Detection.\" Springer, 2012.\n",{"name":5,"license":16,"metadata":43,"description":7},{"tags":44,"author":10,"domain":31,"version":45,"subdomain":46},"record-linkage, bloom-filters, entity-resolution, secure-matching, pprl","1.0","privacy-engineering","main","9b2ef9eae161c00a17241d42a388571321b33e9f","plugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage",68,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills","https:\u002F\u002Fgithub.com\u002Fmukul975","Mahipal.engineer","🔐 Cybersecurity | 💻 Dev | 📷 Street Photographer\r\n🎓 MSc | 📚 Research & AI Security","2026-03-17 04:06:52",{"source":9,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add mukul975\u002FPrivacy-Data-Protection-Skills --skill privacy-record-linkage",{"tool":62,"command":63},"bunx","bunx skills add mukul975\u002FPrivacy-Data-Protection-Skills --skill privacy-record-linkage",{"tool":65,"command":66},"pnpm","pnpm dlx skills add mukul975\u002FPrivacy-Data-Protection-Skills --skill privacy-record-linkage","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002FSKILL.md",true,[70,76,82,86,90],{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},"assets\u002Ftemplate.md","ASSET","资产文件",835,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002Fassets\u002Ftemplate.md",{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Flegacy-command.md","REFERENCE","参考文档",24055,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcopilot-pr-processing\u002Freferences\u002Flegacy-command.md",{"path":83,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fstandards.md",1136,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002Freferences\u002Fstandards.md",{"path":87,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fworkflows.md",1287,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002Freferences\u002Fworkflows.md",{"path":91,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":95},"scripts\u002Fprocess.py","SCRIPT","脚本",6071,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprivacy-skills-complete\u002Fskills\u002Fprivacy-record-linkage\u002Fscripts\u002Fprocess.py",[97,121,142,160,182,198],{"skillNo":98,"name":99,"nameZh":100,"description":101,"descriptionZh":102,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":103,"categories":104,"keywords":111,"publishedAt":38},"01M6AG6K8R3XW10ENWH2FH18RH","workplace-email-privacy","职场邮件监控合规","Implements email and internet monitoring compliance in the workplace per Barbulescu v Romania (ECHR Grand Chamber), EDPB guidance, and national labour law. Covers acceptable use policies, legitimate expectation of privacy, proportionality testing, and content vs metadata monitoring. Keywords: email monitoring, Barbulescu, workplace privacy, internet monitoring, acceptable use policy, ECHR, proportionality.","依据 Barbulescu 诉罗马尼亚案（欧洲人权法院大法庭）、EDPB 指引及各国劳动法，实施工作场所电子邮件与互联网监控合规。涵盖可接受使用政策、合理的隐私期待、比例原则测试以及内容监控与元数据监控的区别。关键词：邮件监控、Barbulescu、职场隐私、互联网监控、可接受使用政策、ECHR、比例原则。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fworkplace-email-privacy\u002FSKILL.md",[105,108],{"categoryNo":106,"categoryName":107,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BZ8629M5XJGKJA00EMEKY5","人力资源与劳动法咨询",{"categoryNo":109,"categoryName":110,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BZ862SE2RVA3NWBPE38BDA","人力资源专员",[112,113,31,114,115,116,117,118,119,120],"email","workplace email privacy","compliance","content","data","policy","testing","monitoring","metadata",{"skillNo":122,"name":123,"nameZh":124,"description":125,"descriptionZh":126,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":127,"categories":128,"keywords":135,"publishedAt":38},"01M6AG6FRCBJY7D061BJZMNV49","whistleblower-data","举报人数据保护合规","Implements data protection compliance for whistleblowing systems under EU Directive 2019\u002F1937 and GDPR. Covers anonymous reporting channels, identity protection for whistleblowers and accused persons, retention limits, access restrictions, and retaliation prevention. Addresses national transpositions and DPA guidance. Keywords: whistleblower, Directive 2019\u002F1937, anonymous reporting, identity protection, retaliation, retention, reporting channel.","依据欧盟指令 2019\u002F1937 和 GDPR，为举报（吹哨）系统实施数据保护合规。涵盖匿名举报渠道、举报人与被指控人的身份保护、保存期限限制、访问限制以及反报复措施。涉及成员国转化立法与数据保护机构（DPA）指引。关键词：举报人、指令 2019\u002F1937、匿名举报、身份保护、报复、保存期限、举报渠道。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fwhistleblower-data\u002FSKILL.md",[129,132],{"categoryNo":130,"categoryName":131,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C8829FDNTDYQRD7JSR70R9","数据保护法合规",{"categoryNo":133,"categoryName":134,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8C8X73GN95MVD9ZBEFQ388G","隐私合规专员",[116,136,137,138,114,139,140,31,141],"whistleblower data","identity","reporting","data protection","gdpr","prevention",{"skillNo":143,"name":144,"nameZh":145,"description":146,"descriptionZh":147,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":148,"categories":149,"keywords":154,"publishedAt":38},"01M6AG6CJP0PW3X65HC7VP9SR9","vendor-termination-data","供应商终止数据返还与删除","Vendor termination data return and deletion procedures per GDPR Article 28(3)(g). Covers data extraction formats, deletion certification requirements, transition planning, residual data handling, and post-termination verification.","依据 GDPR 第 28(3)(g) 条的供应商终止数据返还与删除流程。涵盖数据提取格式、删除证明要求、过渡规划、残留数据处理以及终止后核验。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fvendor-termination-data\u002FSKILL.md",[150,153],{"categoryNo":151,"categoryName":152,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C86Y048YZK87F0K9M849KD","GDPR合规管理",{"categoryNo":133,"categoryName":134,"taxonomyType":23,"taxonomyTypeDesc":24},[116,155,156,157,158,140,31,159],"vendor termination data","planning","verification","extraction","certification",{"skillNo":161,"name":162,"nameZh":163,"description":164,"descriptionZh":165,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":166,"categories":167,"keywords":172,"publishedAt":38},"01M6AG69E277DXZB2NF6KV17ZA","vendor-risk-scoring","供应商隐私风险评分","Vendor privacy risk tiering methodology for processor management. Covers scoring factors including data volume, sensitivity, transfer locations, certifications, breach history, and control maturity with weighted risk calculation and tier assignment.","面向数据处理者管理的供应商隐私风险分级方法论。涵盖数据量、敏感度、传输地点、认证情况、泄露历史和控制成熟度等评分要素，通过加权风险计算进行风险分级与等级划分。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fvendor-risk-scoring\u002FSKILL.md",[168,171],{"categoryNo":169,"categoryName":170,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C0H4NZYRXY1BY7X3G295NB","供应商准入与绩效管理",{"categoryNo":133,"categoryName":134,"taxonomyType":23,"taxonomyTypeDesc":24},[173,174,175,176,177,178,179,180,31,116,181],"vendor risk scoring","risk","risk scoring","methodology","risk-scoring","assessment","transfer","certifications","processor",{"skillNo":183,"name":184,"nameZh":185,"description":186,"descriptionZh":187,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":188,"categories":189,"keywords":192,"publishedAt":38},"01M6AG6655ABFKT2BBWHCP4PAT","vendor-privacy-due-diligence","供应商隐私尽职调查","Pre-contract vendor privacy due diligence per GDPR Article 28(1). Covers risk questionnaires, technical controls assessment, certification review, data flow analysis, and documented sufficiency decisions for processor engagement.","依据 GDPR 第 28(1) 条的签约前供应商隐私尽职调查。涵盖风险问卷、技术控制评估、认证审查、数据流分析以及针对处理者合作的书面充分性决策。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fvendor-privacy-due-diligence\u002FSKILL.md",[190,191],{"categoryNo":169,"categoryName":170,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":133,"categoryName":134,"taxonomyType":23,"taxonomyTypeDesc":24},[31,193,140,194,178,195,196,116,181,174,159,197],"vendor privacy due diligence","review","onboarding","flow","analysis",{"skillNo":199,"name":200,"nameZh":201,"description":202,"descriptionZh":203,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":204,"categories":205,"keywords":208,"publishedAt":38},"01M6AG62C3VD8SYNGH4N7RHZTE","vendor-privacy-audit","供应商隐私合规审计","On-site and remote vendor audit procedures per GDPR Article 28(3)(h). Covers audit planning, evidence collection methodologies, finding classification, remediation tracking, and audit report generation for processor compliance verification.","依据 GDPR 第 28(3)(h) 条进行现场和远程供应商审计程序。涵盖审计计划、证据收集方法、问题发现分类、整改跟踪以及用于处理者合规验证的审计报告生成。","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FPrivacy-Data-Protection-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fprivacy\u002Fvendor-privacy-audit\u002FSKILL.md",[206,207],{"categoryNo":151,"categoryName":152,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":133,"categoryName":134,"taxonomyType":23,"taxonomyTypeDesc":24},[209,210,31,211,157,212,114,140,213,181,214,215,216,156],"vendor privacy audit","audit","report","audit report","remediation","collection","remediation-tracking","classification"]