Privacy should be a first-class engineering primitive, not an afterthought bolted on at the end of a product roadmap. Composable privacy treats data minimization, selective disclosure, and purpose-bound handling as building blocks you can assemble into real features. This means product teams ship faster, security teams reduce blast radius, and compliance teams get clearer audit trails all without slowing innovation.
This post explains practical architecture and implementation patterns for composable privacy. You’ll get concrete guidance on data contracts, purpose-scoped microservices, selective disclosure (including practical notes on zero knowledge proofs), encryption in use options (TEEs vs MPC), privacy aware observability, and how to generate the artifacts auditors want.
Why composable privacy matters
Retrofitting privacy is costly. When you wait until late in the product cycle, you face expensive rewrites, complicated migrations, and lengthy audits. Composable privacy flips that model: rather than inventing bespoke protection for each feature, you provide a consistent set of primitives data contracts, purpose bound APIs, revocable attestations that teams reuse.
This approach reduces risk in three ways:
- Minimization - only the minimum data needed flows to each component.
- Containment - sensitive logic lives in isolated, audited services.
- Verifiability - actions and disclosures are logged and provable for audits.
Core principles
Before diving into patterns, keep these principles front and center:
- Least privilege by design: Services and users should see only the attributes they need; deny everything else by default.
- Purpose binding: Every dataset and API call is associated with a declared purpose; enforcement is automated.
- Consent as data: Treat user consent as first-class metadata versioned, auditable, revocable.
- Crypto-agility: Use pluggable cryptography so you can evolve algorithms without rewriting business code.
- Observable privacy: Collect operational metrics that show privacy posture without leaking PII.
Data contracts & purpose binding
A data contract defines what fields exist, their sensitivity level, allowed operations, and the business purpose(s) for which they may be used. Make contracts machine-readable and enforceable.
Key attributes of a good data contract:
- Schema + sensitivity labels (e.g.,
personal
,sensitive
,public
) - Allowed operations (read, aggregate, pseudonymize, delete)
- Purpose tags (billing, fraud-detection, analytics)
- Retention policy (TTL, archival rules)
- Access controls (roles allowed to read raw vs pseudonymized data)
Implement contracts as first class artifacts in your platform: register them in a metadata catalog, surface them in CI tests, and make them a gating condition in deployment pipelines. When a developer requests access to a dataset, automated checks compare the request’s purpose tag to allowed operations in the contract and either grant a scoped token or block the request.
Microservice patterns: purpose scoped services and ephemeral data flows
Rather than pushing privacy decisions into a monolith, design services with explicit purpose scopes.
Pattern: Purpose-Scoped Microservices
Each microservice is bounded to a specific purpose and only ingests attributes needed for that purpose. For example, a “payment-reconciliation” service might need transaction_id
, amount
, and a pseudonymous user_id
it should never receive raw personal contact details.
Implementation tips:
- API gateways enforce contracts by adding purpose headers (signed tokens proving intent).
- Transformation services (a.k.a. privacy middleware) sit between producers and consumers to implement pseudonymization, aggregation, or selective disclosure.
- Ephemeral pipelines: Prefer short-lived processing jobs that read encrypted raw data, produce minimized outputs, and discard the plaintext. Use strict TTLs so ephemeral artifacts expire automatically.
Pattern: Attribute Tokenization
Tokenize direct identifiers (email, SSN) into stable pseudonyms. The tokenization service holds the mapping and enforces access policies. Downstream services use tokens, not raw identifiers, and request de-tokenization only when strictly necessary (and auditable).
Selective disclosure: attribute-based proofs and ZK basics
Selective disclosure lets a user or service prove a fact without revealing the underlying data e.g., proving “over 18” without sharing a birthdate. There are multiple techniques to achieve this; choose the right one for your constraints.
Options:
- Attribute-based attestations Issuers (banks, government agencies) sign verifiable credentials that assert specific attributes. Holders present the credential; verifiers check the signature. Use decentralized identity standards (DID + VC) where interoperability matters.
- Zero-knowledge proofs (ZKPs) Useful when you need mathematical proofs about data without revealing inputs: range proofs (age > 18), set membership (address in whitelist), or more complex predicates. ZK libraries (zk-SNARKs, zk-STARKs) require careful engineering: circuit design, trusted setup considerations (for some schemes), and performance tuning.
- Range-limited tokens and buckets For simpler cases, pre compute flags (e.g.,
is_verified_age = true
) and store the flag as a limited-scope credential that expires and is auditable.
Practical guidance:
- Use verifiable credentials for cross-organization attestations (KYC, certifications). They are simpler to integrate and have mature tooling.
- Choose ZK when you must prove complex predicates about private data to untrusted verifiers and when performance budgets allow it. Pilot ZK on low-frequency, high privacy interactions first.
- Always include revocation mechanisms; credentials and proofs should be invalidatable if an issuer retracts them.
Encryption-in-use: TEEs vs MPC
When data must be processed without exposing raw values to infrastructure operators or third parties, you have two leading options: Trusted Execution Environments (TEEs) and Multi-Party Computation (MPC).
TEEs (e.g., Intel SGX, AMD SEV)
- Pros: Simpler programming model (run code inside the enclave), low latency for many tasks, good for workloads that fit enclave constraints.
- Cons: Relies on hardware vendor trust, historically subject to side-channel attacks, and attestation complexity across cloud providers.
MPC
- Pros: No single trusted execution environment; computation happens across multiple non-colluding parties. Stronger security model for some threat models.
- Cons: Higher latency and cost; more complex protocol engineering; best for specific cryptographic workloads (secure aggregation, private set intersection, joint model training).
When to use which:
- Use TEEs for latency-sensitive, relatively simple computations where you accept the hardware trust model and can manage attestations.
- Use MPC when you need strong, distributed trust guarantees (e.g., collaborative analytics between rival firms) and can tolerate more overhead.
- Consider hybrids: run MPC for the most sensitive operations and TEEs for pre-processing or performance-critical sections.
Privacy-aware observability
Observability is essential, but telemetry can leak PII if not carefully designed. Build monitoring and alerting that surfaces health and privacy posture without exposing raw personal data.
Techniques:
- Differential privacy for metrics: Add calibrated noise to aggregated telemetry where required so dashboards can’t be reverse-engineered into individual records.
- Event sampling with hashed context: Sample detailed traces and strip PII; retain full traces only in secure, short-lived investigation sandboxes.
- Metadata-only alerts: Alerts should include context-level descriptors (e.g.,
high-failure-rate: payment-reconciler
) and hashes referencing the affected object, but not emails or SSNs. - Privacy SLOs: Track metrics like “percentage of requests that requested de tokenization” and “time to revoke credential”, and use them as operational KPIs.
Integration with IAM, consent stores, and DPO workflows
Composable privacy works best when it’s integrated into the organization’s identity and governance fabric.
- Consent store: Centralize user consents as versioned records tied to user identifiers and purposes. Expose a query API so services can verify whether a requested operation is consented for that user and purpose.
- Attribute-based access control (ABAC): Use purpose, role, and contract tags in policy decisions rather than static RBAC alone. This allows dynamic, purpose-bound grants.
- DPO (Data Protection Officer) dashboard: Provide tools for DPOs to see consent status, request audit extracts, and initiate revocations. Feed DPO requests into automated flows that can flag affected data consumers and trigger re processing or deletion.
Testing, verification & audit artifacts
Auditors want evidence. Make it automatic.
- Automated end-to-end tests that validate privacy contracts: deploy a test that simulates a data flow and asserts that sensitive fields are removed or tokenized before reaching downstream systems.
- Attestation records: When a privacy service releases a pseudonymization token or issues a credential, emit an auditable, timestamped attestation signed by the service’s key. Store attestations in tamper-evident storage.
- Proof-of-processing logs: Keep metadata for each processing job inputs hashes, transformation version, operator, and purpose tag and retain them for the required audit window.
- Third-party verification: Periodically commission privacy-focused audits and publish an executive summary (redacted as needed) to build external trust.
Case study: KYC attribute verification without sharing full documents
Imagine a financial onboarding flow where the user must prove they are over 21 and have a valid KYC attestation, but you don’t want to store their passport or birthdate.
Composable flow:
- Issuance: A verified KYC provider issues a signed verifiable credential to the user containing attributes:
birthdate_hash
,citizenship
,issuer_signature
. The credential includes a purpose tagonboarding:kyc
. - Selective disclosure: The user’s wallet creates a selective disclosure proof: “age >= 21” computed via ZK or an attribute flag derived by the KYC issuer. The wallet only releases the proof and the issuer’s signature.
- Verification: Your onboarding service verifies the signature and the proof. It records an attestation (issuer, timestamp, purpose) and maps the user to a pseudonymous
user_id
. No raw birthdate or passport images are retained. - Consent & audit: The user’s consent is recorded in the consent store tied to
user_id
andonboarding:kyc
. The DPO can produce an audit trace showing the attestation and verification outcomes.
This flow minimizes retained data while still meeting compliance and verification needs.
Rollout checklist and practical tips
- Catalog data contracts and enforce them in CI/CD.
- Deploy a tokenization service with strict logging and short retention for lookups.
- Implement purpose-bound API tokens that encode the caller, purpose, and TTL; gate calls via an API gateway.
- Pilot selective disclosure on one high-value flow (e.g., KYC or proof-of-age) before broad rollout.
- Choose crypto tooling: start with verifiable credentials; pilot ZK for selected predicates.
- Plan for revocation: credentials, tokens, and attestations must be revocable; design workflows to react to revocations.
- Automate audit artifact generation so auditors can retrieve evidence without pulling raw PII.
- Train teams on privacy-aware design and include privacy reviews in sprint gates.
Closing thoughts
Composable privacy reduces friction between product velocity and regulatory/compliance requirements. By building a small set of reusable primitives data contracts, purpose-scoped services, tokenization, verifiable credentials, and secure computation options organizations can ship features quickly while keeping user data exposure minimal and auditable.
If you’d like a practical blueprint tailored to your stack (data contracts, tokenization service design, and a pilot for selective disclosure), Consensus Labs can help design and implement the architecture. Reach out at hello@consensuslabs.ch.