DEV Community

Keith Ransom
Keith Ransom

Posted on

Privacy Engineering Patterns That Actually Work: Data Minimization, Consent, and ZK Architecture

Most privacy implementations I review have the same problem: they treat privacy as a compliance checkbox rather than an architectural property. Here are the patterns that actually work.

Data Minimization at the Schema Level

Don't collect what you don't need, and prove it in the schema. Every field should have a documented retention period and a deletion path. If you can't answer "what happens to this field in 2 years," you haven't designed it yet.

-- Every PII column gets a retention_until timestamp
ALTER TABLE users ADD COLUMN email_retention_until TIMESTAMP;
-- Scheduled job deletes or nulls past-retention PII
Enter fullscreen mode Exit fullscreen mode

Consent Architecture That Survives Audits

A consent record needs: who consented, to what, when, from where (IP + user agent), what version of the terms they agreed to, and a cryptographic proof that it hasn't been modified.

consent_record = {
    'user_id': user.id,
    'consent_type': 'marketing_email',
    'consented_at': datetime.utcnow().isoformat(),
    'terms_version': '2026-01',
    'ip_address': request.remote_addr,
    'signature': hmac.new(SECRET, json.dumps(record).encode(), 'sha256').hexdigest()
}
Enter fullscreen mode Exit fullscreen mode

Zero-Knowledge Architecture for Sensitive Data

For truly sensitive fields (SSN, medical, financial), consider whether your server needs to ever see the plaintext. Client-side encryption with the user's key means even a full database dump exposes nothing. The tradeoff: you lose searchability on encrypted fields. Use selective encryption — only the fields that are genuinely sensitive.

Data Broker Threat Modeling

If your app handles PII, your users' data will end up in data broker databases unless you explicitly prevent it. Data brokers scrape: public records, social media, app store data, advertising exchanges, and leaked/purchased datasets. Your privacy policy is not protection.

The Privacy Engineering Handbook covers these patterns with implementation examples, GDPR/CCPA compliance checklists, and a data broker threat model specifically for SaaS products.

$47 one-time: outset-solutions.com/products

Top comments (0)