[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79CM13P2VSQES8WAB91RXDR":3,"skill-same:01M79CM13P2VSQES8WAB91RXDR":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M79CM13P2VSQES8WAB91RXDR","differential-privacy-mechanisms",null,"Implement rigorous epsilon-delta differential privacy mechanisms (Laplace mechanism, Gaussian mechanism, Exponential mechanism) and DP-SGD (Differentially Private Stochastic Gradient Descent) using Opacus and PyTorch. Track cumulative privacy loss budgets (Rényi Differential Privacy), clip gradient norms, and prevent membership inference attacks. Trigger when training ML models on sensitive data or releasing aggregated statistical datasets.","hamzabellouch\u002Fagent-skills","hamzabellouch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F237856042?v=4","01M79BRYW7XAMK3YDWQEMTWGWS","Hamza Bellouch","01M79BRYWXQV3JK2TGVTX8GN2A",8,"MIT","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FMath\u002FDifferential_Privacy_and_Synthetic_Data\u002Fdifferential-privacy-mechanisms\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: differential-privacy-mechanisms\nmetadata:\n  category: Privacy-Preserving AI and Synthetic Data\ndescription: Implement rigorous epsilon-delta differential privacy mechanisms (Laplace mechanism, Gaussian mechanism, Exponential mechanism) and DP-SGD (Differentially Private Stochastic Gradient Descent) using Opacus and PyTorch. Track cumulative privacy loss budgets (Rényi Differential Privacy), clip gradient norms, and prevent membership inference attacks. Trigger when training ML models on sensitive data or releasing aggregated statistical datasets.\ncompatibility: Python 3.10+, PyTorch 2.0+, Opacus 1.4+, NumPy\n---\n\n# Differential Privacy Mechanisms Skill Guide\n\nThis skill governs the mathematical formulation and machine learning implementation of \\((\\epsilon, \\delta)\\)-differential privacy to guarantee statistical anonymity.\n\n---\n\n## 1. Mathematical Fundamentals & Noise Perturbation\n\nA randomized algorithm $\\mathcal{M}$ satisfies $(\\epsilon, \\delta)$-differential privacy if for all neighboring datasets $D, D'$ differing by at most one individual record, and for all query outputs $S \\subseteq \\text{Range}(\\mathcal{M})$:\n\n$$\\mathbb{P}[\\mathcal{M}(D) \\in S] \\le e^{\\epsilon} \\cdot \\mathbb{P}[\\mathcal{M}(D') \\in S] + \\delta$$\n\n```text\n[ True Query Result \u002F Gradient ] (Sensitivity = Delta f)\n                 |\n                 +---> Add Calibrated Noise\n                         |-- Laplace Noise: Lap(scale = Delta f \u002F epsilon)  [Pure epsilon-DP]\n                         |-- Gaussian Noise: N(0, sigma^2) where            [(epsilon, delta)-DP]\n                         |   sigma = sqrt(2 * ln(1.25 \u002F delta)) * Delta f \u002F epsilon\n                 |\n                 v\n[ Private Sanitized Output (Mathematically bounded re-identification risk) ]\n```\n\n---\n\n## 2. Production Code Implementations\n\n### A. Calibrated Laplace & Gaussian Query Perturbation (Python)\n\n```python\nimport numpy as np\n\n\nclass DPQueryEngine:\n    def __init__(self, epsilon: float, delta: float = 1e-5):\n        if epsilon \u003C= 0:\n            raise ValueError(\"Epsilon must be strictly positive\")\n        self.epsilon = epsilon\n        self.delta = delta\n\n    def private_count(self, true_count: int) -> int:\n        \"\"\"Counts have an L1 sensitivity of exactly 1.\"\"\"\n        scale = 1.0 \u002F self.epsilon\n        noise = np.random.laplace(0, scale)\n        return max(0, int(round(true_count + noise)))\n\n    def private_mean(self, values: list[float], lower_bound: float, upper_bound: float) -> float:\n        \"\"\"Clips values to [lower_bound, upper_bound] to enforce bounded sensitivity.\"\"\"\n        n = len(values)\n        if n == 0:\n            return 0.0\n\n        clipped = np.clip(values, lower_bound, upper_bound)\n        sum_sensitivity = upper_bound - lower_bound\n\n        # Gaussian Mechanism for bounded sum\n        sigma = np.sqrt(2 * np.log(1.25 \u002F self.delta)) * sum_sensitivity \u002F self.epsilon\n        noisy_sum = np.sum(clipped) + np.random.normal(0, sigma)\n\n        return float(noisy_sum \u002F n)\n```\n\n### B. DP-SGD Neural Network Training with Opacus (PyTorch)\n\n```python\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import DataLoader\nfrom opacus import PrivacyEngine\n\n\ndef train_differentially_private_model(\n    model: nn.Module,\n    train_loader: DataLoader,\n    optimizer: torch.optim.Optimizer,\n    target_epsilon: float = 3.0,\n    target_delta: float = 1e-5,\n    max_grad_norm: float = 1.0,\n    epochs: int = 5,\n):\n    criterion = nn.CrossEntropyLoss()\n\n    # Attach Opacus Privacy Engine\n    privacy_engine = PrivacyEngine()\n    model, optimizer, train_loader = privacy_engine.make_private_with_epsilon(\n        module=model,\n        optimizer=optimizer,\n        data_loader=train_loader,\n        target_epsilon=target_epsilon,\n        target_delta=target_delta,\n        epochs=epochs,\n        max_grad_norm=max_grad_norm,\n    )\n\n    model.train()\n    for epoch in range(epochs):\n        for data, target in train_loader:\n            optimizer.zero_grad()\n            output = model(data)\n            loss = criterion(output, target)\n            loss.backward()\n            optimizer.step()\n\n        spent_epsilon = privacy_engine.get_epsilon(target_delta)\n        print(f\"Epoch {epoch+1} Complete | Current Privacy Spent: eps={spent_epsilon:.2f}, delta={target_delta}\")\n\n    return model\n```\n\n---\n\n## 3. Best Practices Checklist\n\n- [ ] **Data Clipping:** Never apply noise without first clipping data features into an explicit numeric range $[a, b]$; otherwise sensitivity is unbounded ($\\Delta f = \\infty$).\n- [ ] **Privacy Budget Accounting:** Enforce a cumulative privacy budget tracker across multiple queries on the same dataset to prevent budget exhaustion.\n- [ ] **Replace Batch Normalization:** In DP-SGD, replace `BatchNorm2d` with `GroupNorm` or `LayerNorm` because batch normalization leaks cross-sample statistical gradients within the batch.\n","# Differential Privacy Mechanisms Skill Guide\n\nThis skill governs the mathematical formulation and machine learning implementation of \\((\\epsilon, \\delta)\\)-differential privacy to guarantee statistical anonymity.\n\n---\n\n## 1. Mathematical Fundamentals & Noise Perturbation\n\nA randomized algorithm $\\mathcal{M}$ satisfies $(\\epsilon, \\delta)$-differential privacy if for all neighboring datasets $D, D'$ differing by at most one individual record, and for all query outputs $S \\subseteq \\text{Range}(\\mathcal{M})$:\n\n$$\\mathbb{P}[\\mathcal{M}(D) \\in S] \\le e^{\\epsilon} \\cdot \\mathbb{P}[\\mathcal{M}(D') \\in S] + \\delta$$\n\n```text\n[ True Query Result \u002F Gradient ] (Sensitivity = Delta f)\n                 |\n                 +---> Add Calibrated Noise\n                         |-- Laplace Noise: Lap(scale = Delta f \u002F epsilon)  [Pure epsilon-DP]\n                         |-- Gaussian Noise: N(0, sigma^2) where            [(epsilon, delta)-DP]\n                         |   sigma = sqrt(2 * ln(1.25 \u002F delta)) * Delta f \u002F epsilon\n                 |\n                 v\n[ Private Sanitized Output (Mathematically bounded re-identification risk) ]\n```\n\n---\n\n## 2. Production Code Implementations\n\n### A. Calibrated Laplace & Gaussian Query Perturbation (Python)\n\n```python\nimport numpy as np\n\n\nclass DPQueryEngine:\n    def __init__(self, epsilon: float, delta: float = 1e-5):\n        if epsilon \u003C= 0:\n            raise ValueError(\"Epsilon must be strictly positive\")\n        self.epsilon = epsilon\n        self.delta = delta\n\n    def private_count(self, true_count: int) -> int:\n        \"\"\"Counts have an L1 sensitivity of exactly 1.\"\"\"\n        scale = 1.0 \u002F self.epsilon\n        noise = np.random.laplace(0, scale)\n        return max(0, int(round(true_count + noise)))\n\n    def private_mean(self, values: list[float], lower_bound: float, upper_bound: float) -> float:\n        \"\"\"Clips values to [lower_bound, upper_bound] to enforce bounded sensitivity.\"\"\"\n        n = len(values)\n        if n == 0:\n            return 0.0\n\n        clipped = np.clip(values, lower_bound, upper_bound)\n        sum_sensitivity = upper_bound - lower_bound\n\n        # Gaussian Mechanism for bounded sum\n        sigma = np.sqrt(2 * np.log(1.25 \u002F self.delta)) * sum_sensitivity \u002F self.epsilon\n        noisy_sum = np.sum(clipped) + np.random.normal(0, sigma)\n\n        return float(noisy_sum \u002F n)\n```\n\n### B. DP-SGD Neural Network Training with Opacus (PyTorch)\n\n```python\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import DataLoader\nfrom opacus import PrivacyEngine\n\n\ndef train_differentially_private_model(\n    model: nn.Module,\n    train_loader: DataLoader,\n    optimizer: torch.optim.Optimizer,\n    target_epsilon: float = 3.0,\n    target_delta: float = 1e-5,\n    max_grad_norm: float = 1.0,\n    epochs: int = 5,\n):\n    criterion = nn.CrossEntropyLoss()\n\n    # Attach Opacus Privacy Engine\n    privacy_engine = PrivacyEngine()\n    model, optimizer, train_loader = privacy_engine.make_private_with_epsilon(\n        module=model,\n        optimizer=optimizer,\n        data_loader=train_loader,\n        target_epsilon=target_epsilon,\n        target_delta=target_delta,\n        epochs=epochs,\n        max_grad_norm=max_grad_norm,\n    )\n\n    model.train()\n    for epoch in range(epochs):\n        for data, target in train_loader:\n            optimizer.zero_grad()\n            output = model(data)\n            loss = criterion(output, target)\n            loss.backward()\n            optimizer.step()\n\n        spent_epsilon = privacy_engine.get_epsilon(target_delta)\n        print(f\"Epoch {epoch+1} Complete | Current Privacy Spent: eps={spent_epsilon:.2f}, delta={target_delta}\")\n\n    return model\n```\n\n---\n\n## 3. Best Practices Checklist\n\n- [ ] **Data Clipping:** Never apply noise without first clipping data features into an explicit numeric range $[a, b]$; otherwise sensitivity is unbounded ($\\Delta f = \\infty$).\n- [ ] **Privacy Budget Accounting:** Enforce a cumulative privacy budget tracker across multiple queries on the same dataset to prevent budget exhaustion.\n- [ ] **Replace Batch Normalization:** In DP-SGD, replace `BatchNorm2d` with `GroupNorm` or `LayerNorm` because batch normalization leaks cross-sample statistical gradients within the batch.\n",{"name":5,"metadata":24,"description":7,"compatibility":26},{"category":25},"Privacy-Preserving AI and Synthetic Data","Python 3.10+, PyTorch 2.0+, Opacus 1.4+, NumPy","main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Math\u002FDifferential_Privacy_and_Synthetic_Data\u002Fdifferential-privacy-mechanisms",1,"https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills","https:\u002F\u002Fhamzabellouch.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhamzabellouch","hamzabellouch.github.io","CEO & Founder of @tknoglobal | Researcher in Technology & Applied Sciences.","2026-10-17 03:20:19",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add hamzabellouch\u002Fagent-skills --skill differential-privacy-mechanisms",{"tool":43,"command":44},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill differential-privacy-mechanisms",{"tool":46,"command":47},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill differential-privacy-mechanisms","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FMath\u002FDifferential_Privacy_and_Synthetic_Data\u002Fdifferential-privacy-mechanisms\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M79FHH2H815A9TAP6WNKH4Q8","security-audit","Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FSecurity_Audit_and_Code_Review\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M79FHBGXVBY6VQ1X7ETAZMF1","malware-analysis-reversing","Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static\u002Fdynamic binary analysis, memory forensics, and YARA detection rule authoring.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fmalware-analysis-reversing\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M79FH6EACDR801TZCE4R8SAC","application-security-pentesting","Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST\u002FDAST pipeline integration, secure code review, threat modeling, and defensive security posture.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fapplication-security-pentesting\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows","Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening","Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256\u002FEdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79FGNCPZ85CVEY0B3NE4H3B","soc2-compliance-automation","Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI\u002FCD security gates.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fsoc2-compliance-automation\u002FSKILL.md",[],[]]