Merge pull request #3 from ShuyaFeng/shuya
Browse filesEnhanced privacy attack visualizations and DP-SGD defense explanations
Files changed (2)
- app/static/js/attacks.js+697-30
- app/templates/attacks.html+689-91
335 unmodified lines33633733833934034134234338 unmodified lines38238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541630 unmodified lines44744844945045145211 unmodified lines4644654664674684694704714724734744754764774786 unmodified lines4854864874884894904914924934944954964974984995005015025035047 unmodified lines51251351451551651710 unmodified lines5285295305315325332 unmodified lines536537538539335 unmodified linesconst successRate = successRates[privacyLevel - 1];// Update confidence differences based on privacyconst confidenceDiffs = [6, 8, 14, 22, 28]; // Confidence differencesconst trainingConf = [88, 90, 92, 94, 96]; // Training confidenceconst testConf = trainingConf.map((tc, i) => tc - confidenceDiffs[i]); // Test confidenceconst currentTrainingConf = trainingConf[privacyLevel - 1];38 unmodified linesconst clipping = parseFloat(document.getElementById('recon-clipping-slider').value);const noise = parseFloat(document.getElementById('recon-noise-slider').value);// Calculate reconstruction qualityconst baseQuality = 0.95;const clippingReduction = (5 - clipping) * 0.1;const noiseReduction = noise * 0.25;const quality = Math.max(0.1, baseQuality - clippingReduction - noiseReduction);const qualityElement = document.getElementById('recon-quality');if (quality > 0.7) {qualityElement.textContent = 'High Quality';qualityElement.className = 'reconstruction-quality quality-high';} else if (quality > 0.4) {qualityElement.textContent = 'Medium Quality';qualityElement.className = 'reconstruction-quality quality-medium';} else {qualityElement.textContent = 'Low Quality';qualityElement.className = 'reconstruction-quality quality-low';}}updateLinkageAttack() {const quality = parseInt(document.getElementById('linkage-quality-slider').value);const privacy = parseInt(document.getElementById('linkage-privacy-slider').value);// Calculate linkage successconst baseSuccess = quality * 15; // Quality factorconst privacyPenalty = (11 - privacy) * 2; // Privacy factorconst successRate = Math.max(25, Math.min(95, baseSuccess + privacyPenalty));document.getElementById('linkage-success').textContent = `${Math.round(successRate)}%`;30 unmodified linesconst simulator = window.attackSimulator;simulator.updateReconstructionAttack();// Add visual feedbackconst button = event.target;const originalText = button.textContent;11 unmodified linesconst privacySlider = document.getElementById('inversion-privacy-slider');const selectedClass = classSelect.value;const privacyLevel = parseInt(privacySlider.value);// Calculate confidence based on privacy levelconst confidence = Math.max(30, 95 - (privacyLevel * 6));document.getElementById('inversion-confidence').textContent = `${confidence}%`;// Update class displaydocument.getElementById('inversion-class').textContent = classSelect.options[classSelect.selectedIndex].text;// Add visual feedbackconst button = event.target;const originalText = button.textContent;6 unmodified lines}, 1800);}function runPropertyAttack() {const propertyType = document.getElementById('property-type').value;const accessLevel = parseInt(document.getElementById('property-access-slider').value);// Calculate property inference accuracyconst baseAccuracy = 70;const accessBonus = accessLevel * 8;const accuracy = Math.min(95, baseAccuracy + accessBonus);// Update uncertainty based on privacy (simulated)const uncertainty = Math.max(3, 15 - accessLevel * 2);document.getElementById('property-male').textContent = `${52}% ± ${uncertainty}%`;document.getElementById('property-female').textContent = `${48}% ± ${uncertainty}%`;// Add visual feedbackconst button = event.target;7 unmodified lines}, 2200);}function runLinkageAttack() {const simulator = window.attackSimulator;simulator.updateLinkageAttack();10 unmodified lines}, 2500);}// Initialize when page loadsdocument.addEventListener('DOMContentLoaded', function() {window.attackSimulator = new AttackSimulator();2 unmodified lineswindow.attackSimulator.updateMembershipDemo();window.attackSimulator.updateReconstructionAttack();window.attackSimulator.updateLinkageAttack();});335 unmodified lines33633733833934034134234338 unmodified lines38238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653730 unmodified lines56856957057157257357457557611 unmodified lines5885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296 unmodified lines6366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547 unmodified lines76276376476576676776876977077110 unmodified lines78278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310842 unmodified lines108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206335 unmodified linesconst successRate = successRates[privacyLevel - 1];// Update confidence differences based on privacyconst confidenceDiffs = [8, 12, 18, 24, 28]; // Confidence differencesconst trainingConf = [76, 80, 86, 92, 96]; // Training confidenceconst testConf = trainingConf.map((tc, i) => tc - confidenceDiffs[i]); // Test confidenceconst currentTrainingConf = trainingConf[privacyLevel - 1];38 unmodified linesconst clipping = parseFloat(document.getElementById('recon-clipping-slider').value);const noise = parseFloat(document.getElementById('recon-noise-slider').value);// Calculate reconstruction quality (SSIM score)const baseQuality = 0.95;const clippingReduction = (5 - clipping) * 0.08;const noiseReduction = noise * 0.22;const quality = Math.max(0.05, baseQuality - clippingReduction - noiseReduction);const ssimScore = quality.toFixed(2);// Update SSIM score displayconst ssimElement = document.getElementById('ssim-score');if (ssimElement) {ssimElement.textContent = ssimScore;ssimElement.style.color = quality > 0.7 ? '#dc3545' : quality > 0.4 ? '#f57c00' : '#28a745';}// Update quality badgeconst qualityElement = document.getElementById('recon-quality');if (qualityElement) {if (quality > 0.7) {qualityElement.textContent = '❌ High Quality (Vulnerable!)';qualityElement.className = 'reconstruction-quality quality-high';} else if (quality > 0.4) {qualityElement.textContent = '⚠️ Medium Quality';qualityElement.className = 'reconstruction-quality quality-medium';} else {qualityElement.textContent = '✅ Low Quality (Protected!)';qualityElement.className = 'reconstruction-quality quality-low';}}// Calculate privacy levelconst epsilon = Math.max(0.5, 10 - (clipping * 0.5 + noise * 2));const privacyStatus = document.getElementById('privacy-status');if (privacyStatus) {if (epsilon > 6) {privacyStatus.textContent = `❌ Low (ε ≈ ${epsilon.toFixed(1)})`;privacyStatus.style.color = '#dc3545';} else if (epsilon > 3) {privacyStatus.textContent = `⚠️ Medium (ε ≈ ${epsilon.toFixed(1)})`;privacyStatus.style.color = '#f57c00';} else {privacyStatus.textContent = `✅ High (ε ≈ ${epsilon.toFixed(1)})`;privacyStatus.style.color = '#28a745';}}// Update attack success rateconst attackSuccess = Math.round(quality * 100);const attackSuccessElement = document.getElementById('attack-success');if (attackSuccessElement) {attackSuccessElement.textContent = `${attackSuccess}%`;attackSuccessElement.style.color = attackSuccess > 70 ? '#dc3545' : attackSuccess > 40 ? '#f57c00' : '#28a745';}// Update reconstructed image visualizationthis.updateReconstructedImage(quality, noise);// Update explanationconst explanationElement = document.getElementById('recon-explanation');if (explanationElement) {if (quality > 0.7) {explanationElement.textContent = '⚠️ Without sufficient privacy protection, attackers can reconstruct training images with high fidelity from gradient information alone!';explanationElement.style.background = '#fff3cd';explanationElement.style.borderLeft = '4px solid #ffc107';} else if (quality > 0.4) {explanationElement.textContent = '🛡️ Medium privacy protection degrades reconstruction quality, but some features may still be visible. Consider increasing noise level.';explanationElement.style.background = '#fff3e0';explanationElement.style.borderLeft = '4px solid #f57c00';} else {explanationElement.textContent = '✅ Excellent! With strong differential privacy, reconstructed images are too noisy to reveal sensitive information. Training data is well protected!';explanationElement.style.background = '#e8f5e9';explanationElement.style.borderLeft = '4px solid #28a745';}}}updateReconstructedImage(quality, noise) {const reconstructedImg = document.getElementById('reconstructed-img');const privacyOverlay = document.getElementById('privacy-overlay');const leakStatus = document.getElementById('leak-status');const modelPrivacyLevel = document.getElementById('model-privacy-level');if (!reconstructedImg) return;// Calculate epsilon for displayconst epsilon = Math.max(0.5, 10 - (parseFloat(document.getElementById('recon-clipping-slider').value) * 0.5 + noise * 2));if (modelPrivacyLevel) {modelPrivacyLevel.textContent = `ε = ${epsilon.toFixed(1)}`;}if (quality < 0.4) {// High privacy - show heavily obscured/protected image with overlayconst svg = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 500'%3E%3Cdefs%3E%3Cfilter id='heavynoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='${1.5 + noise * 0.5}' numOctaves='8' /%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3ClinearGradient id='protectgrad' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' style='stop-color:%23e8f5e9;stop-opacity:1' /%3E%3Cstop offset='100%25' style='stop-color:%23c8e6c9;stop-opacity:1' /%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='400' height='500' fill='url(%23protectgrad)'/%3E%3Crect width='400' height='500' fill='gray' opacity='0.95' filter='url(%23heavynoise)'/%3E%3C/svg%3E`;reconstructedImg.src = svg;if (privacyOverlay) {privacyOverlay.style.display = 'flex';privacyOverlay.innerHTML = '<div style="font-size: 3rem;">🔒</div><div>PROTECTED</div>';}if (leakStatus) {leakStatus.innerHTML = '✅ ATTACK<br/>FAILED!';leakStatus.style.color = '#28a745';}} else if (quality < 0.7) {// Medium privacy - show partially obscured imageconst svg = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 500'%3E%3Cdefs%3E%3Cfilter id='mednoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='${0.8 + noise * 0.3}' numOctaves='5' /%3E%3CfeColorMatrix type='saturate' values='0.2'/%3E%3C/filter%3E%3ClinearGradient id='medgrad' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' style='stop-color:%23fff3e0;stop-opacity:1' /%3E%3Cstop offset='100%25' style='stop-color:%23ffe0b2;stop-opacity:1' /%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='400' height='500' fill='url(%23medgrad)'/%3E%3Crect width='400' height='500' fill='gray' opacity='${0.5 + noise * 0.15}' filter='url(%23mednoise)'/%3E%3Cellipse cx='200' cy='180' rx='80' ry='90' fill='%238b6f47' opacity='0.25'/%3E%3Crect x='140' y='260' width='120' height='160' fill='%236b8e6b' opacity='0.2' rx='8'/%3E%3C/svg%3E`;reconstructedImg.src = svg;if (privacyOverlay) {privacyOverlay.style.display = 'none';}if (leakStatus) {leakStatus.innerHTML = '⚠️ PARTIAL<br/>LEAK';leakStatus.style.color = '#f57c00';}} else {// Low privacy - show clear reconstruction (vulnerable)const svg = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 500'%3E%3Cdefs%3E%3Cfilter id='lightnoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='${0.3 + noise * 0.1}' numOctaves='2' /%3E%3CfeColorMatrix type='saturate' values='0.4'/%3E%3C/filter%3E%3ClinearGradient id='vulngrad' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' style='stop-color:%23e8b4b8;stop-opacity:1' /%3E%3Cstop offset='100%25' style='stop-color:%23d4a5a8;stop-opacity:1' /%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='400' height='500' fill='url(%23vulngrad)'/%3E%3Crect width='400' height='500' fill='gray' opacity='${0.15 + noise * 0.05}' filter='url(%23lightnoise)'/%3E%3Cellipse cx='200' cy='180' rx='80' ry='90' fill='%238b6f47' opacity='0.5'/%3E%3Crect x='140' y='260' width='120' height='160' fill='%236b8e6b' opacity='0.4' rx='8'/%3E%3Ccircle cx='280' cy='140' r='35' fill='%23fff' opacity='0.2'/%3E%3Crect x='80' y='350' width='240' height='100' fill='%23a0826d' opacity='0.3' rx='6'/%3E%3C/svg%3E`;reconstructedImg.src = svg;if (privacyOverlay) {privacyOverlay.style.display = 'none';}if (leakStatus) {leakStatus.innerHTML = '🚨 LEAKED<br/>PRIVATE DATA!';leakStatus.style.color = '#c1272d';}}}updateLinkageAttack() {const quality = parseInt(document.getElementById('linkage-quality-slider').value);const privacySlider = parseInt(document.getElementById('linkage-privacy-slider').value);// Calculate epsilon: epsilon = 11 - privacySlider// privacySlider = 1 → ε = 10.0 (LOW privacy, HIGH success)// privacySlider = 10 → ε = 1.0 (HIGH privacy, LOW success)const epsilon = 11 - privacySlider;// Calculate linkage success// Higher quality = easier to link (increases success)// Higher epsilon (lower privacy) = easier to link (increases success)const qualityBonus = quality * 10; // Quality factor (0-60)const epsilonBonus = epsilon * 4; // Epsilon: 1.0 (high privacy) = 4, 10.0 (low privacy) = 40// Base success is 20%, add quality scaled by epsilon influenceconst successRate = Math.max(15, Math.min(95, 20 + qualityBonus * (epsilon / 10)));document.getElementById('linkage-success').textContent = `${Math.round(successRate)}%`;30 unmodified linesconst simulator = window.attackSimulator;simulator.updateReconstructionAttack();// Update the canvas examplesupdateCurrentReconstructionExamples();// Add visual feedbackconst button = event.target;const originalText = button.textContent;11 unmodified linesconst privacySlider = document.getElementById('inversion-privacy-slider');const selectedClass = classSelect.value;const sliderValue = parseInt(privacySlider.value);// Invert the slider: slider 1 = high privacy (ε=1), slider 10 = low privacy (ε=10)const privacyLevel = 11 - sliderValue; // For drawing functionconst epsilon = sliderValue; // epsilon matches slider position nowconst confidence = Math.max(30, 35 + (sliderValue * 6)); // Higher slider = higher confidence// Update displaysdocument.getElementById('inversion-confidence').textContent = `${confidence}%`;document.getElementById('inversion-class').textContent = classSelect.options[classSelect.selectedIndex].text;// Update privacy barconst privacyLevels = ['Very High', 'Very High', 'High', 'High', 'Medium', 'Medium', 'Low', 'Low', 'Very Low', 'Very Low'];updateInversionPrivacyBar(sliderValue, privacyLevels[sliderValue - 1]);// Update explanation based on slider value (1=high privacy, 10=low privacy)const explanation = document.getElementById('inversion-explanation');if (explanation) {if (sliderValue <= 3) {explanation.textContent = '✅ High privacy! The inverted features are very noisy and don\'t reveal clear class characteristics. Training data is well protected!';explanation.style.background = '#e8f5e9';explanation.style.borderLeft = '4px solid #4caf50';} else if (sliderValue <= 6) {explanation.textContent = '⚠️ Medium privacy. Some class features are visible but degraded. Consider increasing privacy for sensitive data.';explanation.style.background = '#fff3e0';explanation.style.borderLeft = '4px solid #ff9800';} else {explanation.textContent = '❌ Low privacy! The model reveals clear, detailed class features. An attacker can learn what the model associates with this class.';explanation.style.background = '#ffebee';explanation.style.borderLeft = '4px solid #f44336';}}// Draw the inverted features on canvasdrawInvertedFeatures(selectedClass, privacyLevel);// Add visual feedbackconst button = event.target;const originalText = button.textContent;6 unmodified lines}, 1800);}function getPrivacyLevelText(level) {if (level <= 2) return 'Very High';if (level <= 4) return 'High';if (level <= 6) return 'Medium';if (level <= 8) return 'Low';return 'Very Low';}function updateInversionPrivacyBar(sliderValue, privacyText) {// Privacy bar has been removed - function kept for compatibility}function drawInvertedFeatures(classDigit, privacyLevel) {const canvas = document.getElementById('inversion-canvas');if (!canvas) return;const ctx = canvas.getContext('2d');const width = canvas.width;const height = canvas.height;ctx.clearRect(0, 0, width, height);// Backgroundctx.fillStyle = '#e3f2fd';ctx.fillRect(0, 0, width, height);// Calculate noise level based on privacy (1=high privacy/more noise, 10=low privacy/less noise)const noiseLevel = (privacyLevel - 1) / 9; // 0 to 1, where 0 = most noiseconst clarity = 1 - noiseLevel; // Inverted: high privacy = low clarity// Draw the digit with varying clarityctx.save();ctx.globalAlpha = Math.max(0.3, clarity);// Draw digit based on selected class - scale font size based on canvas sizectx.fillStyle = '#1976d2';ctx.font = `bold ${Math.floor(width * 0.6)}px Arial`;ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText(classDigit, width / 2, height / 2);ctx.restore();// Add noise based on privacy levelif (privacyLevel <= 7) {const noiseIntensity = (7 - privacyLevel) / 7; // More noise for higher privacyaddCanvasNoise(ctx, noiseIntensity, width, height);}// For very high privacy, add blur effectif (privacyLevel <= 3) {ctx.filter = `blur(${(4 - privacyLevel) * 4}px)`;ctx.drawImage(canvas, 0, 0);ctx.filter = 'none';}}function addCanvasNoise(ctx, intensity, width, height) {if (intensity < 0.1) return;const imageData = ctx.getImageData(0, 0, width, height);const data = imageData.data;for (let i = 0; i < data.length; i += 4) {const noise = (Math.random() - 0.5) * intensity * 200;data[i] += noise; // Rdata[i + 1] += noise; // Gdata[i + 2] += noise; // B}ctx.putImageData(imageData, 0, 0);}function runPropertyAttack() {const propertyType = document.getElementById('property-type').value;const accessLevel = parseInt(document.getElementById('property-access-slider').value);const privacySlider = document.getElementById('property-privacy-slider');const sliderValue = privacySlider ? parseInt(privacySlider.value) : 5;// Calculate property inference accuracy based on privacy and access// Lower privacy (higher slider value) = more accurate inferenceconst privacyPenalty = (11 - sliderValue) * 5; // High privacy reduces accuracyconst accessBonus = accessLevel * 8;const baseAccuracy = 50;const accuracy = Math.min(95, baseAccuracy + accessBonus + (sliderValue * 3));// Update uncertainty based on privacy (high privacy = high uncertainty)const uncertainty = Math.max(2, 20 - sliderValue * 1.5 - accessLevel * 2);document.getElementById('property-male').textContent = `${52}% ± ${Math.round(uncertainty)}%`;document.getElementById('property-female').textContent = `${48}% ± ${Math.round(uncertainty)}%`;// Update privacy barconst privacyLevels = ['Very High', 'Very High', 'High', 'High', 'Medium', 'Medium', 'Low', 'Low', 'Very Low', 'Very Low'];updatePropertyPrivacyBar(sliderValue, privacyLevels[sliderValue - 1]);// Update explanationconst explanation = document.getElementById('property-explanation');if (explanation) {if (sliderValue <= 3) {explanation.textContent = '✅ High privacy! The attacker cannot accurately infer dataset properties. Large confidence intervals show high uncertainty.';explanation.style.background = '#e8f5e9';explanation.style.borderLeft = '4px solid #4caf50';} else if (sliderValue <= 6) {explanation.textContent = '⚠️ Medium privacy. The attacker can infer properties with moderate accuracy. Consider increasing privacy for sensitive datasets.';explanation.style.background = '#fff3e0';explanation.style.borderLeft = '4px solid #ff9800';} else {explanation.textContent = '❌ Low privacy! The attacker can accurately infer sensitive dataset properties like demographic distributions. Privacy breach risk!';explanation.style.background = '#ffebee';explanation.style.borderLeft = '4px solid #f44336';}}// Add visual feedbackconst button = event.target;7 unmodified lines}, 2200);}function updatePropertyPrivacyBar(sliderValue, privacyText) {// Privacy bar has been removed - function kept for compatibility}function runLinkageAttack() {const simulator = window.attackSimulator;simulator.updateLinkageAttack();10 unmodified lines}, 2500);}// Draw reconstruction examples on canvasesfunction drawReconstructionExamples() {// Example data patternsconst examples = [{ // Face-likedraw: (ctx, noise) => {// Headctx.fillStyle = `rgba(139, 111, 71, ${1 - noise * 0.8})`;ctx.beginPath();ctx.ellipse(60, 45, 30, 35, 0, 0, Math.PI * 2);ctx.fill();// Eyesctx.fillStyle = `rgba(50, 50, 50, ${1 - noise * 0.9})`;ctx.fillRect(45 + Math.random() * noise * 5, 35, 8, 8);ctx.fillRect(67 + Math.random() * noise * 5, 35, 8, 8);// Nosectx.fillStyle = `rgba(100, 80, 60, ${1 - noise * 0.85})`;ctx.fillRect(57, 50, 6, 12);// Mouthctx.fillStyle = `rgba(80, 60, 50, ${1 - noise * 0.9})`;ctx.fillRect(48, 70, 24, 5);// Bodyctx.fillStyle = `rgba(107, 142, 107, ${1 - noise * 0.8})`;ctx.fillRect(35, 85, 50, 30);}},{ // Eye-like medical scandraw: (ctx, noise) => {// Dark backgroundctx.fillStyle = '#1a1a1a';ctx.fillRect(0, 0, 120, 120);// Eye socket (bright)ctx.fillStyle = `rgba(255, 200, 100, ${0.9 - noise * 0.7})`;ctx.beginPath();ctx.ellipse(60, 60, 35, 30, 0, 0, Math.PI * 2);ctx.fill();// Pupil (dark)ctx.fillStyle = `rgba(20, 20, 20, ${1 - noise * 0.8})`;ctx.beginPath();ctx.ellipse(60, 60, 15, 15, 0, 0, Math.PI * 2);ctx.fill();// Highlightctx.fillStyle = `rgba(255, 255, 255, ${0.8 - noise * 0.7})`;ctx.beginPath();ctx.arc(55, 52, 5, 0, Math.PI * 2);ctx.fill();}},{ // Medical scan with bright centerdraw: (ctx, noise) => {// Dark backgroundctx.fillStyle = '#0a0a0a';ctx.fillRect(0, 0, 120, 120);// Bright center (hot spot)const gradient = ctx.createRadialGradient(60, 60, 5, 60, 60, 40);gradient.addColorStop(0, `rgba(255, 100, 50, ${1 - noise * 0.6})`);gradient.addColorStop(0.5, `rgba(200, 80, 40, ${0.8 - noise * 0.6})`);gradient.addColorStop(1, `rgba(100, 40, 20, ${0.3 - noise * 0.3})`);ctx.fillStyle = gradient;ctx.fillRect(0, 0, 120, 120);// Green markersctx.fillStyle = `rgba(100, 255, 100, ${0.7 - noise * 0.6})`;ctx.fillRect(20, 20, 8, 8);ctx.fillRect(92, 20, 8, 8);ctx.fillRect(20, 92, 8, 8);ctx.fillRect(92, 92, 8, 8);}},{ // Computer/objectdraw: (ctx, noise) => {// Screenctx.fillStyle = `rgba(100, 150, 255, ${0.9 - noise * 0.7})`;ctx.fillRect(30, 20, 60, 45);// Screen contentctx.fillStyle = `rgba(200, 220, 255, ${0.8 - noise * 0.7})`;ctx.fillRect(35, 25, 50, 35);// Basectx.fillStyle = `rgba(80, 80, 80, ${1 - noise * 0.8})`;ctx.fillRect(40, 70, 40, 8);// Standctx.fillStyle = `rgba(100, 100, 100, ${1 - noise * 0.8})`;ctx.fillRect(55, 65, 10, 15);// Keyboardctx.fillStyle = `rgba(60, 60, 60, ${0.9 - noise * 0.7})`;ctx.fillRect(20, 85, 80, 25);}}];// Draw each example at different privacy levelsexamples.forEach((example, idx) => {const exampleNum = idx + 1;// Ground truth (original)const originalCanvas = document.getElementById(`original-${exampleNum}`);if (originalCanvas) {const ctx = originalCanvas.getContext('2d');ctx.clearRect(0, 0, 120, 120);example.draw(ctx, 0);}// No privacy (nearly perfect reconstruction - privacy breach!)const noPrivacyCanvas = document.getElementById(`no-privacy-${exampleNum}`);if (noPrivacyCanvas) {const ctx = noPrivacyCanvas.getContext('2d');ctx.clearRect(0, 0, 120, 120);example.draw(ctx, 0.02); // Almost no degradationaddNoise(ctx, 0.01, 120, 120); // Minimal noise}// High privacy (ε = 0.1) - complete noise/staticconst highPrivacyCanvas = document.getElementById(`high-privacy-${exampleNum}`);if (highPrivacyCanvas) {const ctx = highPrivacyCanvas.getContext('2d');ctx.clearRect(0, 0, 120, 120);// Draw pure random noise - no original features visibledrawCompleteNoise(ctx, 120, 120);}});// Update current setting examplesupdateCurrentReconstructionExamples();}function updateCurrentReconstructionExamples() {const clipping = parseFloat(document.getElementById('recon-clipping-slider')?.value || 1.0);const noise = parseFloat(document.getElementById('recon-noise-slider')?.value || 1.0);// Calculate quality/noise levelconst quality = Math.max(0.05, 0.95 - (5 - clipping) * 0.08 - noise * 0.22);const noiseLevel = 1 - quality;// Calculate epsilonconst epsilon = Math.max(0.5, 10 - (clipping * 0.5 + noise * 2));// Update epsilon displayconst epsilonDisplay = document.getElementById('current-epsilon');if (epsilonDisplay) {epsilonDisplay.textContent = `(ε = ${epsilon.toFixed(1)})`;}// Example patterns (same as above)const examples = [{ // Face-likedraw: (ctx, noise) => {ctx.fillStyle = `rgba(139, 111, 71, ${1 - noise * 0.8})`;ctx.beginPath();ctx.ellipse(60, 45, 30, 35, 0, 0, Math.PI * 2);ctx.fill();ctx.fillStyle = `rgba(50, 50, 50, ${1 - noise * 0.9})`;ctx.fillRect(45 + Math.random() * noise * 5, 35, 8, 8);ctx.fillRect(67 + Math.random() * noise * 5, 35, 8, 8);ctx.fillStyle = `rgba(100, 80, 60, ${1 - noise * 0.85})`;ctx.fillRect(57, 50, 6, 12);ctx.fillStyle = `rgba(80, 60, 50, ${1 - noise * 0.9})`;ctx.fillRect(48, 70, 24, 5);ctx.fillStyle = `rgba(107, 142, 107, ${1 - noise * 0.8})`;ctx.fillRect(35, 85, 50, 30);}},{ // Eye-likedraw: (ctx, noise) => {ctx.fillStyle = '#1a1a1a';ctx.fillRect(0, 0, 120, 120);ctx.fillStyle = `rgba(255, 200, 100, ${0.9 - noise * 0.7})`;ctx.beginPath();ctx.ellipse(60, 60, 35, 30, 0, 0, Math.PI * 2);ctx.fill();ctx.fillStyle = `rgba(20, 20, 20, ${1 - noise * 0.8})`;ctx.beginPath();ctx.ellipse(60, 60, 15, 15, 0, 0, Math.PI * 2);ctx.fill();ctx.fillStyle = `rgba(255, 255, 255, ${0.8 - noise * 0.7})`;ctx.beginPath();ctx.arc(55, 52, 5, 0, Math.PI * 2);ctx.fill();}},{ // Medical scandraw: (ctx, noise) => {ctx.fillStyle = '#0a0a0a';ctx.fillRect(0, 0, 120, 120);const gradient = ctx.createRadialGradient(60, 60, 5, 60, 60, 40);gradient.addColorStop(0, `rgba(255, 100, 50, ${1 - noise * 0.6})`);gradient.addColorStop(0.5, `rgba(200, 80, 40, ${0.8 - noise * 0.6})`);gradient.addColorStop(1, `rgba(100, 40, 20, ${0.3 - noise * 0.3})`);ctx.fillStyle = gradient;ctx.fillRect(0, 0, 120, 120);ctx.fillStyle = `rgba(100, 255, 100, ${0.7 - noise * 0.6})`;ctx.fillRect(20, 20, 8, 8);ctx.fillRect(92, 20, 8, 8);ctx.fillRect(20, 92, 8, 8);ctx.fillRect(92, 92, 8, 8);}},{ // Computerdraw: (ctx, noise) => {ctx.fillStyle = `rgba(100, 150, 255, ${0.9 - noise * 0.7})`;ctx.fillRect(30, 20, 60, 45);ctx.fillStyle = `rgba(200, 220, 255, ${0.8 - noise * 0.7})`;ctx.fillRect(35, 25, 50, 35);ctx.fillStyle = `rgba(80, 80, 80, ${1 - noise * 0.8})`;ctx.fillRect(40, 70, 40, 8);ctx.fillStyle = `rgba(100, 100, 100, ${1 - noise * 0.8})`;ctx.fillRect(55, 65, 10, 15);ctx.fillStyle = `rgba(60, 60, 60, ${0.9 - noise * 0.7})`;ctx.fillRect(20, 85, 80, 25);}}];// Draw current setting for each exampleexamples.forEach((example, idx) => {const currentCanvas = document.getElementById(`current-${idx + 1}`);if (currentCanvas) {const ctx = currentCanvas.getContext('2d');ctx.clearRect(0, 0, 120, 120);// If very high privacy (epsilon < 1.0), show mostly noiseif (epsilon < 1.0) {// Draw mostly random noise with tiny hint of originalexample.draw(ctx, 0.98);drawCompleteNoise(ctx, 120, 120);} else if (epsilon < 3.0) {// High privacy - heavy noiseexample.draw(ctx, noiseLevel);addNoise(ctx, Math.min(0.85, noiseLevel * 1.2), 120, 120);} else if (epsilon < 6.0) {// Medium privacy - moderate noiseexample.draw(ctx, noiseLevel * 0.7);addNoise(ctx, noiseLevel * 0.8, 120, 120);} else {// Low privacy - more visible noise (increased from 0.4 to 0.6)example.draw(ctx, noiseLevel * 0.4);addNoise(ctx, Math.max(0.3, noiseLevel * 0.6), 120, 120);}}});}function addNoise(ctx, intensity, width, height) {if (intensity < 0.05) return;const imageData = ctx.getImageData(0, 0, width, height);const data = imageData.data;// For high intensity, make it more aggressiveif (intensity > 0.7) {// Very high noise - almost complete randomizationfor (let i = 0; i < data.length; i += 4) {const randomness = intensity * 1.5;data[i] = Math.random() * 255 * randomness + data[i] * (1 - randomness); // Rdata[i + 1] = Math.random() * 255 * randomness + data[i + 1] * (1 - randomness); // Gdata[i + 2] = Math.random() * 255 * randomness + data[i + 2] * (1 - randomness); // B}} else {// Normal noise additionfor (let i = 0; i < data.length; i += 4) {const noise = (Math.random() - 0.5) * intensity * 300;data[i] += noise; // Rdata[i + 1] += noise; // Gdata[i + 2] += noise; // B}}ctx.putImageData(imageData, 0, 0);}function drawCompleteNoise(ctx, width, height) {// Draw pure random static - complete privacy protectionconst imageData = ctx.createImageData(width, height);const data = imageData.data;for (let i = 0; i < data.length; i += 4) {// Random RGB values - pure noisedata[i] = Math.random() * 255; // Rdata[i + 1] = Math.random() * 255; // Gdata[i + 2] = Math.random() * 255; // Bdata[i + 3] = 255; // A (fully opaque)}ctx.putImageData(imageData, 0, 0);}// Initialize when page loadsdocument.addEventListener('DOMContentLoaded', function() {window.attackSimulator = new AttackSimulator();2 unmodified lineswindow.attackSimulator.updateMembershipDemo();window.attackSimulator.updateReconstructionAttack();window.attackSimulator.updateLinkageAttack();// Draw reconstruction examplessetTimeout(() => {drawReconstructionExamples();}, 100);// Initialize inversion canvas and privacy bar with default valuessetTimeout(() => {drawInvertedFeatures('7', 6); // Default: digit 7, privacy level 6 (slider=5, inverted to 6)updateInversionPrivacyBar(5, 'Medium'); // Initialize privacy bar at slider position 5updatePropertyPrivacyBar(5, 'Medium'); // Initialize property privacy bar}, 100);// Add event listeners for inversion attack controlsconst inversionPrivacySlider = document.getElementById('inversion-privacy-slider');if (inversionPrivacySlider) {inversionPrivacySlider.addEventListener('input', function() {const sliderValue = parseInt(this.value);// Invert the slider: slider 1 = high privacy, slider 10 = low privacyconst privacyLevel = 11 - sliderValue;const privacyLevels = ['Very High', 'Very High', 'High', 'High', 'Medium', 'Medium', 'Low', 'Low', 'Very Low', 'Very Low'];document.getElementById('inversion-privacy').textContent = privacyLevels[sliderValue - 1];// Update visualization in real-timeconst classSelect = document.getElementById('inversion-class-select');const selectedClass = classSelect ? classSelect.value : '7';drawInvertedFeatures(selectedClass, privacyLevel);// Update privacy bar indicatorupdateInversionPrivacyBar(sliderValue, privacyLevels[sliderValue - 1]);// Update explanation based on slider value (1=high privacy, 10=low privacy)const explanation = document.getElementById('inversion-explanation');if (explanation) {if (sliderValue <= 3) {explanation.textContent = '✅ High privacy! The inverted features are very noisy and don\'t reveal clear class characteristics. Training data is well protected!';explanation.style.background = '#e8f5e9';explanation.style.borderLeft = '4px solid #4caf50';} else if (sliderValue <= 6) {explanation.textContent = '⚠️ Medium privacy. Some class features are visible but degraded. Consider increasing privacy for sensitive data.';explanation.style.background = '#fff3e0';explanation.style.borderLeft = '4px solid #ff9800';} else {explanation.textContent = '❌ Low privacy! The model reveals clear, detailed class features. An attacker can learn what the model associates with this class.';explanation.style.background = '#ffebee';explanation.style.borderLeft = '4px solid #f44336';}}});}// Add event listener for class selectionconst inversionClassSelect = document.getElementById('inversion-class-select');if (inversionClassSelect) {inversionClassSelect.addEventListener('change', function() {const privacySlider = document.getElementById('inversion-privacy-slider');const sliderValue = privacySlider ? parseInt(privacySlider.value) : 5;const privacyLevel = 11 - sliderValue; // Invert for drawingdrawInvertedFeatures(this.value, privacyLevel);document.getElementById('inversion-class').textContent = this.options[this.selectedIndex].text;});}// Add event listeners for property inference attack controlsconst propertyPrivacySlider = document.getElementById('property-privacy-slider');if (propertyPrivacySlider) {propertyPrivacySlider.addEventListener('input', function() {const sliderValue = parseInt(this.value);const privacyLevels = ['Very High', 'Very High', 'High', 'High', 'Medium', 'Medium', 'Low', 'Low', 'Very Low', 'Very Low'];document.getElementById('property-privacy').textContent = privacyLevels[sliderValue - 1];// Update privacy bar in real-timeupdatePropertyPrivacyBar(sliderValue, privacyLevels[sliderValue - 1]);// Update uncertainty display in real-timeconst accessLevel = parseInt(document.getElementById('property-access-slider').value);const uncertainty = Math.max(2, 20 - sliderValue * 1.5 - accessLevel * 2);document.getElementById('property-male').textContent = `${52}% ± ${Math.round(uncertainty)}%`;document.getElementById('property-female').textContent = `${48}% ± ${Math.round(uncertainty)}%`;// Update explanationconst explanation = document.getElementById('property-explanation');if (explanation) {if (sliderValue <= 3) {explanation.textContent = '✅ High privacy! The attacker cannot accurately infer dataset properties. Large confidence intervals show high uncertainty.';explanation.style.background = '#e8f5e9';explanation.style.borderLeft = '4px solid #4caf50';} else if (sliderValue <= 6) {explanation.textContent = '⚠️ Medium privacy. The attacker can infer properties with moderate accuracy. Consider increasing privacy for sensitive datasets.';explanation.style.background = '#fff3e0';explanation.style.borderLeft = '4px solid #ff9800';} else {explanation.textContent = '❌ Low privacy! The attacker can accurately infer sensitive dataset properties like demographic distributions. Privacy breach risk!';explanation.style.background = '#ffebee';explanation.style.borderLeft = '4px solid #f44336';}}});}// Add event listener for model access sliderconst propertyAccessSlider = document.getElementById('property-access-slider');if (propertyAccessSlider) {propertyAccessSlider.addEventListener('input', function() {const accessLevel = parseInt(this.value);const accessLevels = ['Black-box', 'Gray-box', 'White-box'];document.getElementById('property-access').textContent = accessLevels[accessLevel - 1];// Update uncertainty display when access changesconst privacySlider = document.getElementById('property-privacy-slider');const sliderValue = privacySlider ? parseInt(privacySlider.value) : 5;const uncertainty = Math.max(2, 20 - sliderValue * 1.5 - accessLevel * 2);document.getElementById('property-male').textContent = `${52}% ± ${Math.round(uncertainty)}%`;document.getElementById('property-female').textContent = `${48}% ± ${Math.round(uncertainty)}%`;});}});
16 unmodified lines17181920212223242526273 unmodified lines313233343536295 unmodified lines3323333343353363373383398 unmodified lines348349350351352353236 unmodified lines59059159259359459576 unmodified lines6726736746756766776783 unmodified lines6826836846856866876886896906916926936 unmodified lines7007017027037047057067077087097107111 unmodified line71371471571671771871972056 unmodified lines77777877978078178212 unmodified lines79579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483513 unmodified lines84985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588613 unmodified lines90090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294369 unmodified lines10131014101510161017101841 unmodified lines10601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108916 unmodified linespadding: 4px;margin-bottom: 2rem;overflow-x: auto;}.attack-tab {flex: 1;min-width: 150px;padding: 0.75rem 1rem;text-align: center;background: transparent;3 unmodified linesfont-weight: 500;transition: all 0.3s ease;white-space: nowrap;}.attack-tab:hover {295 unmodified linesflex-shrink: 0;}/* Mobile responsive */@media (max-width: 768px) {.story-flow {flex-direction: column;}8 unmodified lines}}.interactive-demo {background: #f8f9fa;padding: 2rem;236 unmodified linescolor: #666;line-height: 1.5;}</style>{% endblock %}76 unmodified lines<div class="demo-scenario"><div class="scenario-setup"><h4>The Setup</h4><p>We have a model trained to recognize handwritten digits. Let's see if we can tell which images were in the training set!</p></div><div class="confidence-comparison">3 unmodified lines<span class="sample-status training">✓ Was in training</span></div><div class="sample-image"><div class="digit-display">7</div></div><div class="confidence-bar"><div class="confidence-label">Model Confidence:</div><div class="confidence-meter"><div class="confidence-fill training-confidence" id="training-confidence" style="width: 92%;">92%</div></div></div></div>6 unmodified lines<span class="sample-status test">✗ Not in training</span></div><div class="sample-image"><div class="digit-display">7</div></div><div class="confidence-bar"><div class="confidence-label">Model Confidence:</div><div class="confidence-meter"><div class="confidence-fill test-confidence" id="test-confidence" style="width: 78%;">78%</div></div></div></div>1 unmodified line<div class="attack-insight"><div class="insight-box"><strong>🔍 The Attack Insight:</strong> The model is <span id="confidence-diff">14%</span> more confident on training data!An attacker can use this difference to guess membership.</div></div></div>56 unmodified lines<div class="chart-container"><canvas id="membership-chart"></canvas></div></div></div>12 unmodified lines<strong>Threat:</strong> Attackers with access to gradients can potentially reconstruct original training images, especially in federated learning scenarios.</div><div class="attack-demo"><div class="demo-panel"><h3>Gradient Privacy Settings</h3><div class="demo-controls"><label>Clipping Norm: <span id="recon-clipping">1.0</span></label><input type="range" class="demo-slider" id="recon-clipping-slider" min="0.1" max="5" step="0.1" value="1.0"><label>Noise Level: <span id="recon-noise-level">1.0</span></label><input type="range" class="demo-slider" id="recon-noise-slider" min="0" max="3" step="0.1" value="1.0"></div><button class="control-button" onclick="runReconstructionAttack()">Simulate Reconstruction</button></div><div class="demo-panel"><h3>Reconstruction Quality</h3><div class="visual-demo"><div class="visual-item"><div style="width: 120px; height: 120px; background: #f0f0f0; border-radius: 4px; margin: 0 auto 0.5rem; display: flex; align-items: center; justify-content: center;">Original Image</div><div>Ground Truth</div></div><div class="visual-item"><div style="width: 120px; height: 120px; background: #ffcccb; border-radius: 4px; margin: 0 auto 0.5rem; display: flex; align-items: center; justify-content: center;">Reconstructed</div><div class="reconstruction-quality quality-high" id="recon-quality">High Quality</div></div></div></div></div><div class="chart-container"><canvas id="reconstruction-chart"></canvas></div></div></div>13 unmodified lines</div><div class="attack-demo"><div class="demo-panel"><h3>Inversion Parameters</h3><div class="demo-controls"><label>Target Class: <span id="inversion-class">Digit 7</span></label><select id="inversion-class-select" class="parameter-select"><option value="0">Digit 0</option><option value="1">Digit 1</option><option value="7" selected>Digit 7</option><option value="9">Digit 9</option></select><label>Privacy Level: <span id="inversion-privacy">Medium</span></label><input type="range" class="demo-slider" id="inversion-privacy-slider" min="1" max="10" step="1" value="5"></div><button class="control-button" onclick="runInversionAttack()">Generate Class Representative</button></div><div class="demo-panel"><h3>Generated Features</h3><div class="visual-demo"><div class="visual-item"><div style="width: 120px; height: 120px; background: #e3f2fd; border-radius: 4px; margin: 0 auto 0.5rem; display: flex; align-items: center; justify-content: center; font-size: 3rem;">7</div><div>Inverted Features</div><div style="font-size: 0.8rem; color: #666; margin-top: 0.5rem;">Confidence: <span id="inversion-confidence">87%</span></div></div></div></div></div></div></div>13 unmodified lines</div><div class="attack-demo"><div class="demo-panel"><h3>Target Properties</h3><div class="demo-controls"><label>Property Type:</label><select id="property-type" class="parameter-select"><option value="gender">Gender Distribution</option><option value="age">Age Distribution</option><option value="location">Geographic Distribution</option></select><label>Model Access: <span id="property-access">Black-box</span></label><input type="range" class="demo-slider" id="property-access-slider" min="1" max="3" step="1" value="1"></div><button class="control-button" onclick="runPropertyAttack()">Infer Properties</button></div><div class="demo-panel"><h3>Inferred Properties</h3><div class="demo-result"><div>Inferred Distribution:</div><div style="margin: 1rem 0;"><div style="display: flex; justify-content: space-between; margin: 0.5rem 0;"><span>Male:</span> <span id="property-male">52% ± 8%</span></div><div style="display: flex; justify-content: space-between; margin: 0.5rem 0;"><span>Female:</span> <span id="property-female">48% ± 8%</span></div></div><div style="font-size: 0.8rem; color: #666;">Confidence intervals show attack uncertainty</div></div></div></div><div class="chart-container"><canvas id="property-chart"></canvas></div></div></div>69 unmodified lines<div class="chart-container"><canvas id="linkage-chart"></canvas></div></div></div>41 unmodified lines</div></div><!-- Defense Mechanisms --><div class="defense-section"><h2>🛡️ How DP-SGD Defends Against These Attacks</h2><p>Differential privacy provides mathematical guarantees against all these attack types</p><div class="defense-grid"><div class="defense-item"><h3>Gradient Noise</h3><p>Adds calibrated noise to gradients, making it impossible to perfectly reconstruct training data or infer membership with certainty.</p></div><div class="defense-item"><h3>Gradient Clipping</h3><p>Limits the influence of any single training example, preventing attackers from identifying outliers or high-influence samples.</p></div><div class="defense-item"><h3>Privacy Accounting</h3><p>Tracks cumulative privacy loss across training, ensuring mathematical bounds on what attackers can learn.</p></div><div class="defense-item"><h3>Composition Guarantees</h3><p>Provides formal bounds even when multiple attacks are combined, protecting against sophisticated adversaries.</p></div></div></div></div>{% endblock %}16 unmodified lines171819202122232425262728293 unmodified lines33343536373839295 unmodified lines3353363373383393403413423433443453463473483493503513523533543553563573583593603613628 unmodified lines371372373374375376377378379380381382383236 unmodified lines62062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299376 unmodified lines10701071107210731074107510763 unmodified lines10801081108210831084108510861087108810891090109110921093109410956 unmodified lines11021103110411051106110711081109111011111112111311141115111611171 unmodified line1119112011211122112311241125112656 unmodified lines118311841185118611871188118911901191119211931194119511961197119812 unmodified lines1211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313 unmodified lines139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146013 unmodified lines147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155569 unmodified lines162516261627162816291630163116321633163416351636163716381639164041 unmodified lines16821683168416851686168716 unmodified linespadding: 4px;margin-bottom: 2rem;overflow-x: auto;gap: 4px;flex-wrap: wrap;}.attack-tab {flex: 1 1 auto;min-width: 160px;padding: 0.75rem 1rem;text-align: center;background: transparent;3 unmodified linesfont-weight: 500;transition: all 0.3s ease;white-space: nowrap;font-size: 0.9rem;}.attack-tab:hover {295 unmodified linesflex-shrink: 0;}/* Responsive design */@media (max-width: 1024px) {.attack-tab {flex: 1 1 calc(33.333% - 4px);min-width: 150px;font-size: 0.88rem;}}@media (max-width: 768px) {.attack-tabs {gap: 4px;padding: 4px;}.attack-tab {flex: 1 1 calc(50% - 4px);min-width: 140px;font-size: 0.85rem;padding: 0.6rem 0.75rem;}.story-flow {flex-direction: column;}8 unmodified lines}}@media (max-width: 480px) {.attack-tab {flex: 1 1 100%;min-width: auto;}}.interactive-demo {background: #f8f9fa;padding: 2rem;236 unmodified linescolor: #666;line-height: 1.5;}/* Reconstruction Grid Styles */.reconstruction-visual-demo {background: white;padding: 2rem;border-radius: 12px;margin: 1.5rem 0;}.reconstruction-grid {display: grid;grid-template-columns: repeat(4, 1fr);gap: 1rem;margin: 0 auto;max-width: 800px;}.grid-header {background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);color: white;padding: 0.75rem 0.5rem;text-align: center;font-weight: bold;font-size: 0.9rem;border-radius: 8px 8px 0 0;line-height: 1.3;}.example-cell {background: #f8f9fa;border: 2px solid #dee2e6;border-radius: 8px;padding: 0.5rem;display: flex;align-items: center;justify-content: center;transition: all 0.3s ease;}.example-cell:hover {transform: scale(1.05);box-shadow: 0 4px 12px rgba(0,0,0,0.15);z-index: 10;}.example-cell canvas {display: block;border-radius: 4px;image-rendering: pixelated;image-rendering: -moz-crisp-edges;image-rendering: crisp-edges;}.example-cell.current-setting {border: 3px solid #ffc107;background: #fffbf0;box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.2);}.reconstruction-legend {display: grid;grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));gap: 1rem;margin-top: 2rem;padding: 1.5rem;background: #f8f9fa;border-radius: 8px;}.legend-item {display: flex;align-items: center;gap: 0.75rem;}.legend-box {width: 30px;height: 30px;border-radius: 4px;flex-shrink: 0;}.current-highlight {background: #fffbf0;border: 3px solid #ffc107;animation: pulse-border 2s infinite;}@keyframes pulse-border {0%, 100% { border-color: #ffc107; }50% { border-color: #ff9800; }}.legend-item span {font-size: 0.85rem;line-height: 1.4;}@media (max-width: 768px) {.reconstruction-grid {grid-template-columns: repeat(2, 1fr);gap: 0.5rem;}.grid-header {font-size: 0.75rem;padding: 0.5rem 0.25rem;}.example-cell canvas {width: 80px;height: 80px;}.reconstruction-legend {grid-template-columns: 1fr;gap: 0.75rem;}}.three-panel-container {display: grid;grid-template-columns: 1fr auto 1fr auto 1fr;gap: 1rem;align-items: stretch;max-width: 1400px;margin: 0 auto;}.privacy-panel {display: flex;flex-direction: column;border-radius: 12px;overflow: hidden;box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);transition: transform 0.3s ease;}.privacy-panel:hover {transform: translateY(-4px);}.panel-header {padding: 1.5rem 1rem;text-align: center;font-weight: bold;}.panel-header h3 {margin: 0;font-size: 1rem;line-height: 1.4;letter-spacing: 0.5px;}.private-panel {background: #f5e6d3;border: 4px solid #c89968;}.private-panel .panel-header {background: #f5e6d3;color: #8b4513;}.safe-panel {background: #e8f4f8;border: 4px solid #7fb3d5;}.safe-panel .panel-header {background: #e8f4f8;color: #2c5f2d;}.attack-panel {background: #fce4e4;border: 4px solid #d4a5a8;}.attack-panel .panel-header {background: #fce4e4;color: #c1272d;}.panel-image-wrapper {position: relative;flex: 1;display: flex;align-items: center;justify-content: center;overflow: hidden;background: #f8f9fa;}.panel-image {width: 100%;height: 100%;object-fit: cover;display: block;}.privacy-lock-overlay {position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);background: rgba(255, 255, 255, 0.95);padding: 0.75rem 1.5rem;border-radius: 30px;box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);}.lock-icon {font-size: 2rem;text-align: center;}.privacy-overlay {position: absolute;top: 0;left: 0;width: 100%;height: 100%;background: rgba(255, 255, 255, 0.95);backdrop-filter: blur(30px);display: flex;align-items: center;justify-content: center;font-size: 1.5rem;font-weight: bold;color: #28a745;transition: all 0.5s ease;flex-direction: column;gap: 1rem;}.panel-footer {padding: 1rem;text-align: center;font-size: 0.9rem;background: rgba(255, 255, 255, 0.5);}.safe-footer {display: flex;align-items: center;justify-content: center;gap: 0.75rem;background: rgba(255, 255, 255, 0.7);}.check-icon {font-size: 1.5rem;color: #28a745;background: white;width: 35px;height: 35px;border-radius: 50%;display: flex;align-items: center;justify-content: center;font-weight: bold;border: 2px solid #28a745;}.footer-metrics {text-align: left;font-size: 0.85rem;}.small-text {font-size: 0.75rem;color: #666;margin-top: 0.25rem;}.danger-footer {display: flex;align-items: center;justify-content: center;gap: 0.75rem;background: rgba(255, 255, 255, 0.7);padding: 1.25rem;}.alert-icon {font-size: 2rem;animation: pulse 2s infinite;}@keyframes pulse {0%, 100% { opacity: 1; transform: scale(1); }50% { opacity: 0.7; transform: scale(1.1); }}.danger-text {font-weight: bold;color: #c1272d;font-size: 1rem;line-height: 1.3;text-align: center;}.footer-text {color: #666;font-size: 0.9rem;}.flow-arrow {display: flex;flex-direction: column;align-items: center;justify-content: center;gap: 0.5rem;}.arrow-symbol {font-size: 2.5rem;color: #dc3545;font-weight: bold;}.attack-arrow .arrow-symbol {color: #c1272d;}.arrow-label {font-size: 0.85rem;color: #666;font-weight: 600;text-transform: uppercase;letter-spacing: 0.5px;}@media (max-width: 1200px) {.three-panel-container {grid-template-columns: 1fr;gap: 1.5rem;}.flow-arrow {flex-direction: row;gap: 1rem;}.arrow-symbol {transform: rotate(90deg);}.panel-header h3 {font-size: 0.95rem;}}@media (max-width: 768px) {.panel-header h3 {font-size: 0.85rem;}.arrow-symbol {font-size: 2rem;}.reconstruction-visual-demo {padding: 1rem;}}</style>{% endblock %}76 unmodified lines<div class="demo-scenario"><div class="scenario-setup"><h4>The Setup</h4><p>A hospital trained a model to predict heart disease risk. Let's see if an attacker can tell which patient records were in the training set!</p></div><div class="confidence-comparison">3 unmodified lines<span class="sample-status training">✓ Was in training</span></div><div class="sample-image"><div class="digit-display" style="font-size: 1rem; flex-direction: column; gap: 0.5rem; height: auto; padding: 1rem;"><div style="font-size: 2.5rem;">🏥</div><div style="font-size: 0.85rem; color: #666;">Patient #A2847</div><div style="font-size: 0.8rem; color: #999; line-height: 1.3;">Age: 58 | BP: 145/92<br/>Cholesterol: High</div></div></div><div class="confidence-bar"><div class="confidence-label">Model Confidence:</div><div class="confidence-meter"><div class="confidence-fill training-confidence" id="training-confidence" style="width: 96%;">96%</div></div></div></div>6 unmodified lines<span class="sample-status test">✗ Not in training</span></div><div class="sample-image"><div class="digit-display" style="font-size: 1rem; flex-direction: column; gap: 0.5rem; height: auto; padding: 1rem;"><div style="font-size: 2.5rem;">🏥</div><div style="font-size: 0.85rem; color: #666;">Patient #B3192</div><div style="font-size: 0.8rem; color: #999; line-height: 1.3;">Age: 56 | BP: 142/90<br/>Cholesterol: High</div></div></div><div class="confidence-bar"><div class="confidence-label">Model Confidence:</div><div class="confidence-meter"><div class="confidence-fill test-confidence" id="test-confidence" style="width: 68%;">68%</div></div></div></div>1 unmodified line<div class="attack-insight"><div class="insight-box"><strong>🔍 The Attack Insight:</strong> The model is <span id="confidence-diff">28%</span> more confident on training data!An attacker can use this difference to infer that Patient A2847 was treated at this hospital - a serious privacy breach.</div></div></div>56 unmodified lines<div class="chart-container"><canvas id="membership-chart"></canvas></div><!-- Defense against this attack --><div style="margin-top: 2rem; padding: 1.5rem; background: linear-gradient(135deg, #4caf50 0%, #45a049 100%); border-radius: 8px; color: white;"><h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"><span style="font-size: 1.5rem;">🛡️</span> How DP-SGD Defends Against This Attack</h3><p style="font-size: 1rem; line-height: 1.6; margin: 0;"><strong>Random noise addition:</strong> DP-SGD adds carefully calibrated noise to model outputs, making Alice's record indistinguishable from any other patient. The model gives similar confidence scores whether or not someone was in the training data - attackers can't tell the difference between training and test examples.</p></div></div></div>12 unmodified lines<strong>Threat:</strong> Attackers with access to gradients can potentially reconstruct original training images, especially in federated learning scenarios.</div><div class="attack-scenario-intro" style="background: #f8f9fa; padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem;"><h3>📋 Scenario: Federated Learning Attack</h3><p style="margin: 0.5rem 0 0 0; color: #666;">In federated learning, a company trains a model using images from users' devices. An attacker with access togradient updates attempts to reconstruct the original training images. Let's see how differential privacy protects against this!</p></div><div class="reconstruction-visual-demo"><h3 style="text-align: center; margin-bottom: 1.5rem;">🔍 Reconstruction Quality at Different Privacy Levels</h3><!-- Multi-example comparison grid --><div class="reconstruction-grid"><!-- Header Row --><div class="grid-header">Ground Truth</div><div class="grid-header">No Privacy<br/><span style="font-size: 0.85rem; font-weight: normal;">(ε = ∞)</span></div><div class="grid-header">Low Privacy<br/><span style="font-size: 0.85rem; font-weight: normal;" id="current-epsilon">(ε = 8.0)</span></div><div class="grid-header">High Privacy<br/><span style="font-size: 0.85rem; font-weight: normal;">(ε = 0.1)</span></div><!-- Example 1: Face-like --><div class="example-cell"><canvas id="original-1" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="no-privacy-1" width="120" height="120"></canvas></div><div class="example-cell current-setting"><canvas id="current-1" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="high-privacy-1" width="120" height="120"></canvas></div><!-- Example 2: Eye-like --><div class="example-cell"><canvas id="original-2" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="no-privacy-2" width="120" height="120"></canvas></div><div class="example-cell current-setting"><canvas id="current-2" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="high-privacy-2" width="120" height="120"></canvas></div><!-- Example 3: Medical scan-like --><div class="example-cell"><canvas id="original-3" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="no-privacy-3" width="120" height="120"></canvas></div><div class="example-cell current-setting"><canvas id="current-3" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="high-privacy-3" width="120" height="120"></canvas></div><!-- Example 4: Object-like --><div class="example-cell"><canvas id="original-4" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="no-privacy-4" width="120" height="120"></canvas></div><div class="example-cell current-setting"><canvas id="current-4" width="120" height="120"></canvas></div><div class="example-cell"><canvas id="high-privacy-4" width="120" height="120"></canvas></div></div><!-- Legend --><div class="reconstruction-legend"><div class="legend-item"><div class="legend-box" style="background: #e8f5e9; border: 2px solid #4caf50;"></div><span><strong>Ground Truth:</strong> Original private training images</span></div><div class="legend-item"><div class="legend-box" style="background: #ffebee; border: 2px solid #f44336;"></div><span><strong>No Privacy:</strong> Perfect reconstruction - privacy breach!</span></div><div class="legend-item"><div class="legend-box current-highlight"></div><span><strong>Your Settings:</strong> Adjust sliders below to see changes</span></div><div class="legend-item"><div class="legend-box" style="background: #e3f2fd; border: 2px solid #2196f3;"></div><span><strong>High Privacy:</strong> Reconstruction fails - data protected!</span></div></div><!-- Quality Badge Below --><div style="text-align: center; margin-top: 1.5rem;"><div class="reconstruction-quality quality-high" id="recon-quality" style="display: inline-block; padding: 0.75rem 1.5rem; font-size: 1.1rem;">⚠️ Medium Quality</div></div></div><div class="attack-demo" style="margin-top: 2rem;"><div class="demo-panel"><h3>🛡️ Differential Privacy Settings</h3><div class="demo-controls"><label>Gradient Clipping Norm: <span id="recon-clipping">1.0</span></label><input type="range" class="demo-slider" id="recon-clipping-slider" min="0.1" max="5" step="0.1" value="1.0"><div class="privacy-scale"><span style="font-size: 0.75rem;">🔒 Tight Clipping (More Private)</span><span style="font-size: 0.75rem;">🔓 Loose Clipping (Less Private)</span></div><label style="margin-top: 1rem;">Noise Multiplier (σ): <span id="recon-noise-level">1.0</span></label><input type="range" class="demo-slider" id="recon-noise-slider" min="0" max="3" step="0.1" value="1.0"><div class="privacy-scale"><span style="font-size: 0.75rem;">🔇 No Noise (Vulnerable)</span><span style="font-size: 0.75rem;">🔊 High Noise (Protected)</span></div></div><button class="control-button" onclick="runReconstructionAttack()">🔄 Update Reconstruction</button></div><div class="demo-panel"><h3>📊 Attack Analysis</h3><div class="demo-result"><div style="margin-bottom: 1rem;"><strong>Reconstruction SSIM Score:</strong><div style="font-size: 1.8rem; color: #dc3545; font-weight: bold; margin: 0.5rem 0;" id="ssim-score">0.85</div><div style="font-size: 0.85rem; color: #666;">(1.0 = perfect reconstruction, 0.0 = completely failed)</div></div><div style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #ddd;"><div style="display: flex; justify-content: space-between; margin: 0.5rem 0;"><span>Privacy Level:</span><span id="privacy-status" style="font-weight: bold; color: #dc3545;">❌ Low (ε ≈ 8.0)</span></div><div style="display: flex; justify-content: space-between; margin: 0.5rem 0;"><span>Attack Success:</span><span id="attack-success" style="font-weight: bold; color: #dc3545;">92%</span></div></div></div><div class="privacy-explanation" id="recon-explanation" style="margin-top: 1rem;">⚠️ Without sufficient privacy protection, attackers can reconstruct training images with high fidelity from gradient information alone!</div></div></div><div class="chart-container"><canvas id="reconstruction-chart"></canvas></div><!-- Defense against this attack --><div style="margin-top: 2rem; padding: 1.5rem; background: linear-gradient(135deg, #4caf50 0%, #45a049 100%); border-radius: 8px; color: white;"><h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"><span style="font-size: 1.5rem;">🛡️</span> How DP-SGD Defends Against This Attack</h3><p style="font-size: 1rem; line-height: 1.6; margin: 0;"><strong>Gradient clipping + noise:</strong> DP-SGD clips each person's influence on the model, then drowns it in noise - like taking a photo and adding so much blur that faces become unrecognizable blobs. Attackers cannot reverse-engineer the original training images from the model's outputs.</p></div></div></div>13 unmodified lines</div><div class="attack-demo"><div class="demo-panel" style="padding: 1.5rem;"><h3 style="margin-bottom: 1.5rem;">Inversion Parameters</h3><div class="demo-controls" style="gap: 1.5rem;"><div style="margin-bottom: 1.5rem;"><label style="display: block; margin-bottom: 0.75rem; font-weight: 500;">Target Class: <span id="inversion-class" style="color: #1976d2; font-weight: 600;">Digit 7</span></label><select id="inversion-class-select" class="parameter-select" style="width: 100%; padding: 0.5rem; font-size: 1rem; border-radius: 4px; border: 2px solid #e0e0e0;"><option value="0">Digit 0</option><option value="1">Digit 1</option><option value="7" selected>Digit 7</option><option value="9">Digit 9</option></select></div><div style="margin-bottom: 1.5rem;"><label style="display: block; margin-bottom: 0.75rem; font-weight: 500;">Privacy Level: <span id="inversion-privacy" style="color: #1976d2; font-weight: 600;">Medium</span></label><input type="range" class="demo-slider" id="inversion-privacy-slider" min="1" max="10" step="1" value="5" style="width: 100%; margin-top: 0.5rem;"><div style="display: flex; justify-content: space-between; font-size: 0.75rem; color: #999; margin-top: 0.5rem;"><span style="text-align: left;">🔒 High Privacy<br/>(ε = 1.0)</span><span style="text-align: right;">🔓 Low Privacy<br/>(ε = 10.0)</span></div></div></div><button class="control-button" onclick="runInversionAttack()" style="width: 100%; padding: 0.75rem; font-size: 1rem; margin-top: 1rem;">Generate Class Representative</button></div><div class="demo-panel" style="padding: 1.5rem;"><h3 style="margin-bottom: 1.5rem;">Generated Features</h3><div class="visual-demo"><div class="visual-item"><canvas id="inversion-canvas" width="160" height="160" style="border-radius: 8px; margin: 0 auto 1rem; display: block; border: 3px solid #2196f3; box-shadow: 0 2px 8px rgba(0,0,0,0.1);"></canvas><div style="font-size: 1rem; font-weight: 500; margin-bottom: 0.75rem;">Inverted Features</div><div style="font-size: 0.9rem; color: #666; margin-bottom: 0.5rem;">Confidence: <span id="inversion-confidence" style="font-weight: 600; color: #1976d2;">87%</span></div></div></div><div class="privacy-explanation" style="margin-top: 1.5rem; padding: 1.25rem; background: #fff3e0; border-radius: 6px; font-size: 0.9rem; line-height: 1.5; border-left: 4px solid #ff9800;"><div id="inversion-explanation">⚠️ Medium privacy. Some class features are visible but degraded. Move the slider left for higher privacy!</div></div></div></div><!-- Defense against this attack --><div style="margin-top: 2rem; padding: 1.5rem; background: linear-gradient(135deg, #4caf50 0%, #45a049 100%); border-radius: 8px; color: white;"><h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"><span style="font-size: 1.5rem;">🛡️</span> How DP-SGD Defends Against This Attack</h3><p style="font-size: 1rem; line-height: 1.6; margin: 0;"><strong>Feature scrambling:</strong> DP-SGD scrambles what the model "remembers" about each class. Instead of learning "digit 7 looks like this sharp image," it learns "7 is somewhere in this fuzzy cloud." Attackers cannot extract clear class representatives or features.</p></div></div></div>13 unmodified lines</div><div class="attack-demo"><div class="demo-panel" style="padding: 1.5rem;"><h3 style="margin-bottom: 1.5rem;">Target Properties</h3><div class="demo-controls" style="gap: 1.5rem;"><div style="margin-bottom: 1.5rem;"><label style="display: block; margin-bottom: 0.75rem; font-weight: 500;">Property Type:</label><select id="property-type" class="parameter-select" style="width: 100%; padding: 0.5rem; font-size: 1rem; border-radius: 4px; border: 2px solid #e0e0e0;"><option value="gender">Gender Distribution</option><option value="age">Age Distribution</option><option value="location">Geographic Distribution</option></select></div><div style="margin-bottom: 1.5rem;"><label style="display: block; margin-bottom: 0.75rem; font-weight: 500;">Privacy Level: <span id="property-privacy" style="color: #1976d2; font-weight: 600;">Medium</span></label><input type="range" class="demo-slider" id="property-privacy-slider" min="1" max="10" step="1" value="5" style="width: 100%; margin-top: 0.5rem;"><div style="display: flex; justify-content: space-between; font-size: 0.75rem; color: #999; margin-top: 0.5rem;"><span style="text-align: left;">🔒 High Privacy<br/>(ε = 1.0)</span><span style="text-align: right;">🔓 Low Privacy<br/>(ε = 10.0)</span></div></div><div style="margin-bottom: 1.5rem;"><label style="display: block; margin-bottom: 0.75rem; font-weight: 500;">Model Access: <span id="property-access" style="color: #1976d2; font-weight: 600;">Black-box</span></label><input type="range" class="demo-slider" id="property-access-slider" min="1" max="3" step="1" value="1" style="width: 100%; margin-top: 0.5rem;"><div style="display: flex; justify-content: space-between; font-size: 0.75rem; color: #999; margin-top: 0.5rem;"><span>Black-box</span><span>Gray-box</span><span>White-box</span></div></div></div><button class="control-button" onclick="runPropertyAttack()" style="width: 100%; padding: 0.75rem; font-size: 1rem; margin-top: 1rem;">Infer Properties</button></div><div class="demo-panel" style="padding: 1.5rem;"><h3 style="margin-bottom: 1.5rem;">Inferred Properties</h3><div class="demo-result"><div style="font-size: 1rem; font-weight: 500; margin-bottom: 1rem;">Inferred Distribution:</div><div style="margin: 1.5rem 0;"><div style="display: flex; justify-content: space-between; margin: 0.75rem 0; padding: 0.5rem; background: #f5f5f5; border-radius: 4px;"><span style="font-weight: 500;">Male:</span> <span id="property-male" style="font-weight: 600; color: #1976d2;">52% ± 8%</span></div><div style="display: flex; justify-content: space-between; margin: 0.75rem 0; padding: 0.5rem; background: #f5f5f5; border-radius: 4px;"><span style="font-weight: 500;">Female:</span> <span id="property-female" style="font-weight: 600; color: #1976d2;">48% ± 8%</span></div></div><div style="font-size: 0.85rem; color: #666; font-style: italic;">Confidence intervals show attack uncertainty</div></div><div class="privacy-explanation" style="margin-top: 1.5rem; padding: 1.25rem; background: #fff3e0; border-radius: 6px; font-size: 0.9rem; line-height: 1.5; border-left: 4px solid #ff9800;"><div id="property-explanation">⚠️ Medium privacy. The attacker can infer dataset properties with moderate accuracy. Move the slider left for higher privacy!</div></div></div></div><div class="chart-container"><canvas id="property-chart"></canvas></div><!-- Defense against this attack --><div style="margin-top: 2rem; padding: 1.5rem; background: linear-gradient(135deg, #4caf50 0%, #45a049 100%); border-radius: 8px; color: white;"><h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"><span style="font-size: 1.5rem;">🛡️</span> How DP-SGD Defends Against This Attack</h3><p style="font-size: 1rem; line-height: 1.6; margin: 0;"><strong>Privacy budget tracking:</strong> DP-SGD keeps a "privacy budget" (ε) - like a bank account that tracks how much information leaked. When the budget runs low, training stops to prevent dataset statistics (like gender distribution or age ranges) from being exposed.</p></div></div></div>69 unmodified lines<div class="chart-container"><canvas id="linkage-chart"></canvas></div><!-- Defense against this attack --><div style="margin-top: 2rem; padding: 1.5rem; background: linear-gradient(135deg, #4caf50 0%, #45a049 100%); border-radius: 8px; color: white;"><h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"><span style="font-size: 1.5rem;">🛡️</span> How DP-SGD Defends Against This Attack</h3><p style="font-size: 1rem; line-height: 1.6; margin: 0;"><strong>Output noise + bounded leakage:</strong> DP-SGD adds noise to model predictions AND tracks total privacy loss (ε). Even when attackers combine model outputs with external datasets (social media, public records), the mathematical privacy guarantee ensures they cannot reliably link individuals or infer sensitive attributes.</p></div></div></div>41 unmodified lines</div></div></div>{% endblock %}
app/static/js/attacks.js+697-30
app/templates/attacks.html+689-91