xNoise: Differential Privacy on Threshold Shares
XorIDA splits data across parties first, then each party adds calibrated differential privacy noise to their share. No trusted curator needed. Information-theoretic data protection meets mathematical privacy guarantees. Zero npm dependencies.
Executive Summary
xNoise eliminates the trusted curator problem in differential privacy. Data is first split into K-of-N XorIDA threshold shares across independent parties. Each party then adds calibrated DP noise to their share independently. The aggregate result after reconstruction provides (ε,δ)-differential privacy guarantees without any party ever seeing the raw data.
The standard differential privacy model requires a trusted server that sees all raw data, adds noise to outputs, and never leaks anything. But that server is a single point of failure. Equifax, OPM, Anthem — every major breach was a "trusted curator" that got compromised.
xNoise flips the architecture: XorIDA provides information-theoretic protection of the raw data (no single party sees it), while DP provides mathematical privacy guarantees on the aggregate output (the result itself resists inference attacks). Together: no trusted curator, no raw data exposure, mathematically provable privacy.
Three functions cover 80% of use cases: createPerturbationEngine() initializes a privacy budget tracker. engine.perturbResult() adds Laplace or Gaussian noise to a query result and consumes budget. engine.getBudget() returns epsilon/delta remaining. All noise generation uses crypto.getRandomValues() — no Math.random().
Developer Experience
xNoise provides real-time progress tracking and 30+ structured error codes to help developers build reliable, privacy-preserving systems.
Progress Callbacks
All perturbation operations support onProgress callbacks for tracking noise generation, budget validation, and batch operations.
const result = await engine.perturbResult( { value: 42, context: 'user-count' }, { distribution: 'laplace', sensitivity: 1.0, epsilon: 1.0 }, onProgress: async (event) => { switch (event.stage) { case 'validating': console.log('Checking budget...'); break; case 'generating': console.log('Generating noise...'); break; case 'complete': console.log(`Remaining: ${event.remaining}ε`); break; } } );
Structured Error Handling
xNoise uses a Result<T, E> pattern with detailed error structures. Every error includes a machine-readable code, human-readable message, actionable hint, and documentation URL.
interface ErrorDetail { code: string; // e.g., 'EPSILON_EXHAUSTED' message: string; // Human-readable description hint?: string; // Actionable suggestion field?: string; // Field that caused the error docs?: string; // Documentation URL }
Error Categories
xNoise organizes 30+ error codes across 6 categories:
| Category | Example Codes | When |
|---|---|---|
| Budget | EPSILON_EXHAUSTED, DELTA_EXHAUSTED | Privacy budget overflow, negative budget |
| Noise Generation | INVALID_DISTRIBUTION, SCALE_NOT_POSITIVE | Distribution config validation, RNG failures |
| Injection | VALUE_NOT_FINITE, SENSITIVITY_INVALID | Input validation, arithmetic errors |
| Verification | HMAC_MISMATCH, ARITHMETIC_INVALID | HMAC integrity checks, perturbation validation |
| Trust Boundaries | TRUST_BREACH, UNAUTHORIZED_CATEGORY | Cross-domain access violations |
| Batch | BATCH_PARTIAL_FAILURE, BATCH_EMPTY | Batch operations, aggregation errors |
The Problem
Differential privacy alone adds noise to query results but does not protect data at rest. The standard DP model requires a trusted curator who sees all raw data. The curator IS the single point of failure that DP was supposed to eliminate.
Central DP assumes a trusted server that holds everyone's data, adds noise to outputs, and never leaks the raw data. But that server is a breach target. Equifax, OPM, Anthem — every major data breach was a "trusted curator" that got compromised.
Local DP (where each user adds noise before sending data) avoids the central curator but at a steep accuracy cost. The noise required for meaningful privacy at the individual level degrades aggregate statistics to the point of uselessness for many applications.
Central DP: Trusted Curator Problem
Use Cases
xNoise applies anywhere you need both data-at-rest protection and output privacy guarantees. No trusted curator. No single point of failure.
EU AI Act compliant. Split population data across agencies, add DP noise per agency. Publish statistics without any agency holding complete records.
EU AI ActHIPAA + DP. Split patient records across hospitals, compute aggregate health statistics with DP noise. No hospital exposes individual patient data.
HIPAACCPA/GDPR compliant. Split conversion data across measurement providers, add DP noise. Measure campaign effectiveness without user-level tracking.
GDPRSplit gradient updates and add DP noise per participant. Protect both individual training data and model convergence signals.
FLArchitecture
xNoise operates in two phases. Phase 1: XorIDA splits data across parties (information-theoretic protection). Phase 2: Each party adds calibrated Laplace or Gaussian noise to their share (differential privacy guarantee). The combination provides both data-at-rest security and output privacy.
Noise Distributions
xNoise supports two standard DP noise distributions. Laplace noise for (ε,0)-DP (pure DP), Gaussian noise for (ε,δ)-DP (approximate DP).
Budget Tracking
The PrivacyBudgetTracker enforces total epsilon and delta limits across all queries. Every perturbation consumes budget. When exhausted, subsequent queries fail with EPSILON_EXHAUSTED or DELTA_EXHAUSTED.
const engine = createPerturbationEngine({ totalEpsilon: 10.0, totalDelta: 0.01, }); // Each query consumes budget await engine.perturbResult(query1, { epsilon: 2.0, /*...*/ }); // 8.0 remaining await engine.perturbResult(query2, { epsilon: 5.0, /*...*/ }); // 3.0 remaining await engine.perturbResult(query3, { epsilon: 4.0, /*...*/ }); // EPSILON_EXHAUSTED // Check budget before consuming const check = engine.getBudget(); if (check.epsilonRemaining < 1.0) { // Stop querying }
HMAC Verification
Every XorIDA share can be HMAC-verified before reconstruction. This prevents tampered shares from being aggregated. The verifyComputationIntegrity() function computes HMAC-SHA256 over both shares and compares to the expected tag.
Integration
Three functions cover most use cases. Install from the monorepo, import the engine, perturb results, track budget. Zero npm dependencies.
import { createPerturbationEngine } from '@private.me/xnoise'; // Create engine with privacy budget const engine = createPerturbationEngine({ totalEpsilon: 10.0, totalDelta: 0.01, }); // Perturb query results with Laplace or Gaussian noise const result = await engine.perturbResult( { value: 42, context: 'user-count' }, { distribution: 'laplace', // or 'gaussian' sensitivity: 1.0, epsilon: 1.0 } ); if (result.ok) { console.log(`Perturbed: ${result.value.perturbed}`); console.log(`Budget remaining: ${engine.getBudget().epsilonRemaining}`); } // Batch operations const batch = await engine.perturbBatch(results, noiseConfig); // Stops on first error (fails-safe)
Core APIs
Complete Flow
End-to-end example: split data with XorIDA, add DP noise per party, verify HMAC, reconstruct DP-protected aggregate.
import { createPerturbationEngine, verifyComputationIntegrity } from '@private.me/xnoise'; import { split, reconstruct } from '@private.me/crypto'; // 1. Split data via XorIDA (2-of-3) const data = new TextEncoder().encode('sensitive records'); const shares = await split(data, 2, 3); // 2. Each party creates DP engine and perturbs their share const engine1 = createPerturbationEngine({ totalEpsilon: 5.0, totalDelta: 0.01 }); const engine2 = createPerturbationEngine({ totalEpsilon: 5.0, totalDelta: 0.01 }); const perturbed1 = await engine1.perturbResult( { value: shares[0].share[0], context: 'party-1' }, { distribution: 'laplace', sensitivity: 1.0, epsilon: 1.0 } ); const perturbed2 = await engine2.perturbResult( { value: shares[1].share[0], context: 'party-2' }, { distribution: 'laplace', sensitivity: 1.0, epsilon: 1.0 } ); // 3. HMAC verification (prevents tampering) const hmacKey = new Uint8Array(32); crypto.getRandomValues(hmacKey); const verified = await verifyComputationIntegrity({ share1: shares[0].share, share2: shares[1].share, hmacKey, hmac: /* expected HMAC */ }); if (!verified.ok) { throw new Error('HMAC mismatch'); } // 4. Reconstruct DP-protected aggregate const reconstructed = await reconstruct([shares[0], shares[1]]); console.log('DP-protected result:', reconstructed);
Security Properties
xNoise provides both data-at-rest protection and output privacy guarantees. No trusted curator. No single point of failure.
| Property | Mechanism | Guarantee |
|---|---|---|
| Data Protection | XorIDA threshold shares | ✓ Information-theoretic |
| Output Privacy | Differential privacy | ✓ (ε,δ)-DP guarantee |
| Curator-Free | Distributed noise addition | ✓ No single trusted party |
| Composition | Per-share noise calibration | ✓ Favorable privacy budget |
| Quantum Resistance | GF(2) + information theory | ✓ Unconditional security |
| Integrity | HMAC-SHA256 per share | ✓ Tamper detection |
Benchmarks
Noise generation is fast. Budget tracking is constant-time. HMAC verification adds ~1ms per share.
| Operation | Latency | Notes |
|---|---|---|
| Laplace noise generation | <100µs | crypto.getRandomValues() + log transform |
| Gaussian noise generation | <150µs | Box-Muller transform, two randoms |
| Budget validation | <10µs | O(1) arithmetic check |
| HMAC-SHA256 (per share) | ~1ms | Web Crypto API, variable by payload |
| Batch 100 queries | ~10ms | Serial processing, fails-safe |
Honest Limitations
xNoise is not a silver bullet. Here are the trade-offs you accept when you deploy it.
What xNoise Does NOT Do
- Not a drop-in DP library. Requires XorIDA splitting infrastructure. You cannot just add DP noise to a central database without splitting first.
- Budget tracking is not a security guarantee. The engine enforces limits but does not prevent side-channel leakage if you log noisy results elsewhere.
- No automatic sensitivity calculation. You must manually specify sensitivity for each query. Misconfigured sensitivity breaks the DP guarantee.
- Not a full DP platform. No query planner, no auto-composition, no privacy accounting dashboard. Just noise generation + budget tracking.
- HMAC verification is not proof of correctness. HMAC only detects tampering. It does not prove the noise was calibrated correctly.
When NOT to Use xNoise
- You trust a central server. If you already have a trusted curator, central DP is simpler and more accurate.
- You need interactive queries with adaptive composition. xNoise does not automatically track composition across multiple query rounds.
- You need local DP. xNoise assumes data is split across parties BEFORE noise is added. It does not support individual users adding noise to their own data.
- You need public verifiability. HMAC is symmetric-key verification. For public audit, use xProve with ZK proofs.
sensitivity too low, the DP guarantee fails. If you set it too high, accuracy degrades unnecessarily. There is no automatic sensitivity analysis. You are responsible for calculating the correct sensitivity for your query.
Implementation Details
Deep dive into error handling, trust boundaries, API surface, and codebase structure. For developers integrating xNoise into production systems.
Error Hierarchy
xNoise uses a structured Result pattern with detailed error codes. Every error includes a machine-readable code, human-readable message, actionable hint, and documentation URL.
Error Structure
interface ErrorDetail { code: string; // Machine-readable (e.g., 'EPSILON_EXHAUSTED') message: string; // Human-readable description hint?: string; // Actionable fix suggestion field?: string; // Field that caused the error docs?: string; // Documentation URL }
Error Categories (30+ codes)
- Budget Errors — EPSILON_EXHAUSTED, DELTA_EXHAUSTED, BUDGET_NEGATIVE, INVALID_BUDGET_CONFIG
- Noise Generation — INVALID_DISTRIBUTION, SCALE_NOT_POSITIVE, SIGMA_NOT_POSITIVE, RNG_FAILED
- Injection Errors — VALUE_NOT_FINITE, SENSITIVITY_INVALID, EPSILON_INVALID, DELTA_INVALID
- Verification Errors — HMAC_MISMATCH, ARITHMETIC_INVALID, EPSILON_COST_INVALID
- Trust Boundary Errors — TRUST_BREACH, UNAUTHORIZED_CATEGORY, INVALID_DID
- Batch Errors — BATCH_PARTIAL_FAILURE, BATCH_EMPTY, BUDGET_INSUFFICIENT_FOR_BATCH
Trust Boundaries
Trust boundaries enforce data category access control. Three levels: consumer (public data), enterprise (corporate compliance), government (classified/sensitive).
Boundary Types
| Category | Access Level | Example |
|---|---|---|
| Consumer | Public data only | Census statistics, survey results |
| Enterprise | Corporate compliance data | HR records, financial reporting |
| Government | Classified / sensitive data | Defense, law enforcement, intel |
import { createConsumerBoundary, verifyTrustBoundary } from '@private.me/xnoise'; // Create consumer-only boundary const boundary = createConsumerBoundary(operatorDid); // Verify operator is authorized for data category const allowed = verifyTrustBoundary( boundary, operatorDid, 'consumer' // or 'enterprise' or 'government' ); if (!allowed.ok) { // TRUST_BREACH — operator not authorized throw new Error(allowed.error.message); }
Full ACI Surface
Complete API reference. All exported functions, types, and interfaces.
Engine Creation
Perturbation Operations
Budget Management
Noise Generation
Verification
Trust Boundaries
Error Taxonomy
Complete list of all 30+ error codes with descriptions and hints.
| Code | Category | Description |
|---|---|---|
| EPSILON_EXHAUSTED | Budget | Epsilon budget fully consumed |
| DELTA_EXHAUSTED | Budget | Delta budget fully consumed |
| BUDGET_NEGATIVE | Budget | Negative epsilon or delta in config |
| INVALID_BUDGET_CONFIG | Budget | Malformed budget configuration |
| INVALID_DISTRIBUTION | Noise | Distribution must be 'laplace' or 'gaussian' |
| SCALE_NOT_POSITIVE | Noise | Laplace scale must be > 0 |
| SIGMA_NOT_POSITIVE | Noise | Gaussian sigma must be > 0 |
| RNG_FAILED | Noise | crypto.getRandomValues() failed |
| VALUE_NOT_FINITE | Injection | Input value is NaN or Infinity |
| SENSITIVITY_INVALID | Injection | Sensitivity must be > 0 and finite |
| EPSILON_INVALID | Injection | Epsilon must be > 0 and finite |
| DELTA_INVALID | Injection | Delta must be in (0,1) |
| HMAC_MISMATCH | Verification | HMAC integrity check failed |
| ARITHMETIC_INVALID | Verification | Perturbed ≠ original + noise |
| EPSILON_COST_INVALID | Verification | Epsilon cost out of range (0,100] |
| TRUST_BREACH | Trust | Operator not authorized for category |
| UNAUTHORIZED_CATEGORY | Trust | Data category access denied |
| INVALID_DID | Trust | Operator DID malformed |
| BATCH_PARTIAL_FAILURE | Batch | Batch stopped after first error |
| BATCH_EMPTY | Batch | Empty result array provided |
| BUDGET_INSUFFICIENT_FOR_BATCH | Batch | Not enough budget for entire batch |
Codebase Statistics
xNoise is production-ready. 108 tests (all passing), 7 source files, 4 test files, ~1,750 source lines, ~1,470 test lines.
Module Structure
index.ts— Barrel exports, public API surfacetypes.ts— TypeScript interfaces and typeserrors.ts— Error codes and error detail structuresbudget.ts— PrivacyBudgetTracker implementationinjection.ts— Noise generation (Laplace/Gaussian) + injectionperturbation.ts— PerturbationEngine main logicverification.ts— HMAC verification + trust boundaries
Test Coverage
budget.test.ts— Budget tracking, consumption, exhaustioninjection.test.ts— Noise generation, Laplace/Gaussian distributionsperturbation.test.ts— Engine creation, perturbation, batch operationsabuse.test.ts— Out-of-range values, negative budgets, invalid configs
Verifiable Data Protection
Every operation in this ACI produces a verifiable audit trail via xProve. HMAC-chained integrity proofs let auditors confirm that data was split, perturbed, and reconstructed correctly — without accessing the data itself.
Read the xProve white paper →
Deployment Options
SaaS Recommended
Fully managed infrastructure. Call our REST API, we handle scaling, updates, and operations.
- Zero infrastructure setup
- Automatic updates
- 99.9% uptime SLA
- Enterprise SLA available
SDK Integration
Embed directly in your application. Runs in your codebase with full programmatic control.
npm install @private.me/xnoise- TypeScript/JavaScript SDK
- Full source access
- Enterprise support available
On-Premise Upon Request
Enterprise CLI for compliance, air-gap, or data residency requirements.
- Complete data sovereignty
- Air-gap capable deployment
- Custom SLA + dedicated support
- Professional services included
Enterprise On-Premise Deployment
While xNoise is primarily delivered as SaaS or SDK, we build dedicated on-premise infrastructure for customers with:
- Regulatory mandates — HIPAA, SOX, FedRAMP, CMMC requiring self-hosted processing
- Air-gapped environments — SCIF, classified networks, offline operations
- Data residency requirements — EU GDPR, China data laws, government mandates
- Custom integration needs — Embed in proprietary platforms, specialized workflows
Includes: Enterprise CLI, Docker/Kubernetes orchestration, RBAC, audit logging, and dedicated support.