GDPR Compliance Implementation
Version: 2.0 Last Updated: 2026-10-10
Overview
This document describes how the Hello World DAO platform implements GDPR (General Data Protection Regulation) compliance for user PII (Personally Identifiable Information). The implementation covers both the encrypted canister storage and plaintext database storage in the hybrid architecture.
Regulatory Context
Applicability
GDPR applies when:
- ✅ Platform has users in the EU (European Union)
- ✅ Platform offers services to EU residents
- ✅ Platform processes PII of EU residents
Hello World DAO status: GDPR compliant architecture implemented.
Key GDPR Principles
- Lawfulness, Fairness, Transparency: User consent obtained during registration
- Purpose Limitation: PII used only for stated purposes (membership, marketing)
- Data Minimization: Only necessary PII collected (email, name)
- Accuracy: Users can update their information
- Storage Limitation: Retention policies defined
- Integrity and Confidentiality: Encryption and access controls
- Accountability: Audit logs and compliance procedures
User Rights Implementation
1. Right to Access (Article 15)
Requirement: Users must be able to obtain confirmation that their PII is being processed and access that data.
Implementation:
Canister Access (Encrypted PII)
// user-service/src/lib.rs
#[update]
fn get_individual_decryption_data(email_hash: String) -> Result<EncryptedIndividual, String> {
STATE.with(|state| {
let s = state.borrow();
s.individuals.get(&email_hash)
.cloned()
.ok_or_else(|| "Individual not found".to_string())
})
}User Flow:
- User logs in with password
- Frontend derives master key from password
- Frontend fetches encrypted PII from canister
- Frontend decrypts PII in browser
- User sees their data (email, first_name, last_name, recovery key)
Database Access (Plaintext PII)
-- Query user's plaintext PII
SELECT
id,
email,
first_name,
last_name,
verified,
verified_at,
submitted_at,
gdpr_marketing_consent,
gdpr_deleted,
created_at,
updated_at,
synced_at
FROM individuals
WHERE email = 'user@example.com'
AND gdpr_deleted = false;API Endpoint (planned):
GET /api/users/me/data
Authorization: Bearer <user_session_token>
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"first_name": "John",
"last_name": "Doe",
"verified": true,
"verified_at": "2025-11-01T10:30:00Z",
"marketing_consent": true
}2. Right to Rectification (Article 16)
Requirement: Users must be able to correct inaccurate PII.
Implementation:
Canister Update (Encrypted PII)
// user-service/src/lib.rs
#[update]
fn update_individual(
email_hash: String,
encrypted_email: String,
encrypted_first_name: String,
encrypted_last_name: String,
) -> Result<(), String> {
STATE.with(|state| {
let mut s = state.borrow_mut();
let record = s.individuals.get_mut(&email_hash)
.ok_or_else(|| "Individual not found".to_string())?;
// Update encrypted fields
record.email_encrypted = encrypted_email;
record.first_name_encrypted = encrypted_first_name;
record.last_name_encrypted = encrypted_last_name;
Ok(())
})?;
// Trigger database sync with updated plaintext PII
// (requires plaintext provided by frontend)
sync_individual_to_database(...).await?;
Ok(())
}User Flow:
- User updates PII in frontend
- Frontend encrypts new PII with master key
- Frontend sends encrypted PII to canister
- Canister updates encrypted record
- Canister syncs plaintext to database (if verification status unchanged)
3. Right to Erasure / "Right to be Forgotten" (Article 17)
Requirement: Users must be able to request deletion of their PII.
Implementation: Permanent deletion — on an erasure request, personal data is permanently removed, not merely marked deleted.
How erasure works
Two live mechanisms carry the right to erasure:
- ✅ Permanent deletion after a cancellable grace period: identifiers derived from identity-verification data are cleared immediately on request; a cancellable grace period runs (per Privacy Policy §10.4(a)), after which personal data is permanently deleted without undue delay.
- ✅ Crypto-erasure: deleting your user encryption key renders your encrypted personal data permanently unrecoverable (Privacy Policy §10.4(e)).
- ✅ Statutory retention: records under a legal retention obligation are kept for the periods stated in Privacy Policy §10.2, and only those records.
Canister Erasure Marker
The canister does not row-delete an erased member. Canister state is replicated and can be captured in snapshots, so a cleared field or a flag is not what makes the data unrecoverable. Unrecoverability comes from the crypto-erasure step above: once the member's encryption key is destroyed, the encrypted fields that remain (in state, replicas, and snapshots) can no longer be read or linked to the member. The gdpr_deleted flag below is an operational marker that keeps the record out of every live query; it is not the erasure itself. Records under a statutory retention obligation (for example the 7-year tax records, Privacy Policy §10.2) are retained for that period and only those.
// user-service/src/lib.rs
#[update]
fn delete_individual(email_hash: String) -> Result<(), String> {
let current_time = ic_cdk::api::time();
STATE.with(|state| {
let mut s = state.borrow_mut();
let record = s.individuals.get_mut(&email_hash)
.ok_or_else(|| "Individual not found".to_string())?;
// Operational erasure marker (excludes the record from live queries)
record.gdpr_deleted = true;
record.gdpr_deleted_at = Some(current_time);
// Clear the live encrypted PII fields; unrecoverability of any
// remaining copies comes from destroying the member key (crypto-erasure)
record.email_encrypted = String::new();
record.first_name_encrypted = String::new();
record.last_name_encrypted = String::new();
record.recovery_key_encrypted = String::new();
Ok(())
})?;
// Sync deletion status to database
sync_deletion_to_database(&email_hash).await?;
Ok(())
}Database Erasure Marker
Database sync propagates the gdpr_deleted = true marker (the personal data itself is then permanently deleted after the grace period, per above):
-- Sync deletion status
UPDATE individuals
SET
gdpr_deleted = true,
gdpr_deleted_at = NOW(),
gdpr_marketing_consent = false, -- Revoke marketing consent
updated_at = NOW()
WHERE email_hash = '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae';Marketing Exclusion
CRITICAL: Deleted users MUST be excluded from all marketing queries:
-- Marketing list (GDPR compliant)
SELECT email, first_name, last_name
FROM individuals
WHERE verified = true
AND gdpr_deleted = false -- Exclude deleted users
AND gdpr_marketing_consent = true; -- Exclude opt-outsAudit Query (verify no deleted users in marketing):
-- Should return 0
SELECT COUNT(*)
FROM individuals
WHERE gdpr_deleted = true
AND gdpr_marketing_consent = true;4. Right to Data Portability (Article 20)
Requirement: Users must be able to export their PII in a machine-readable format.
Implementation:
Export Endpoint (Planned)
// oracle-bridge/src/routes/users.ts
router.get('/export', requireAuth, async (req: Request, res: Response) => {
const userId = req.user.id;
// Fetch from database
const result = await pool.query(
`SELECT
id, email, first_name, last_name,
verified, verified_at, submitted_at,
gdpr_marketing_consent, gdpr_deleted
FROM individuals
WHERE id = $1 AND gdpr_deleted = false`,
[userId]
);
if (result.rows.length === 0) {
return res.status(404).json({ error: 'User not found' });
}
const user = result.rows[0];
// Return JSON export
res.json({
format: 'GDPR Data Export',
exported_at: new Date().toISOString(),
data: {
personal_information: {
email: user.email,
first_name: user.first_name,
last_name: user.last_name,
},
account_status: {
verified: user.verified,
verified_at: user.verified_at,
submitted_at: user.submitted_at,
marketing_consent: user.gdpr_marketing_consent,
},
},
});
});Export Format: JSON (machine-readable, GDPR compliant)
User Flow:
- User clicks "Export My Data" in dashboard
- Frontend requests export via authenticated API
- Oracle-bridge fetches plaintext PII from database
- User downloads JSON file
Marketing Consent Management
Consent Model
Opt-In by Default:
- Default:
gdpr_marketing_consent = true - Rationale: User registers to participate in DAO activities (legitimate interest)
- User can opt-out anytime
Alternative (Opt-Out by Default):
- Default:
gdpr_marketing_consent = false - Requires explicit consent checkbox during registration
- More conservative, lower marketing reach
Current Implementation: Opt-in (can be changed via config).
Consent Tracking
Canister Storage
pub struct IndividualRecord {
pub id: String,
pub email_encrypted: String,
pub first_name_encrypted: String,
pub last_name_encrypted: String,
pub email_hash: String,
pub verified: bool,
pub verified_at: Option<u64>,
pub submitted_at: u64,
pub recovery_key_encrypted: String,
pub encryption_key_id: String,
pub gdpr_marketing_consent: bool, // ✅ Tracked in canister
pub gdpr_deleted: bool,
pub gdpr_deleted_at: Option<u64>,
}Database Storage
-- individuals table
gdpr_marketing_consent BOOLEAN NOT NULL DEFAULT TRUE,
gdpr_deleted BOOLEAN NOT NULL DEFAULT FALSE,
gdpr_deleted_at TIMESTAMP NULLConsent Withdrawal
User Flow:
- User clicks "Unsubscribe from Marketing" in dashboard or email footer
- Frontend calls consent withdrawal endpoint
- Canister updates
gdpr_marketing_consent = false - Canister syncs to database
- User excluded from future marketing campaigns
Implementation:
#[update]
fn withdraw_marketing_consent(email_hash: String) -> Result<(), String> {
STATE.with(|state| {
let mut s = state.borrow_mut();
let record = s.individuals.get_mut(&email_hash)
.ok_or_else(|| "Individual not found".to_string())?;
record.gdpr_marketing_consent = false;
Ok(())
})?;
// Sync to database
sync_consent_to_database(&email_hash, false).await?;
Ok(())
}Marketing Query Pattern
Always filter by consent:
SELECT email, first_name, last_name
FROM individuals
WHERE verified = true
AND gdpr_deleted = false -- Exclude deleted
AND gdpr_marketing_consent = true -- Only consented users
ORDER BY created_at DESC;Data Retention Policies
Active Users
Policy: Retain data indefinitely while account is active.
Definition of Active:
- User has logged in within last 12 months
- OR user has active memberships
- OR user has pending governance votes
Inactive Users
Policy: Retain encrypted canister data, optionally purge database plaintext after 24 months of inactivity.
Rationale:
- Canister data is encrypted (low GDPR risk)
- Database plaintext can be purged (convenience copy)
- User can always re-verify to restore database PII
Implementation (planned):
-- Identify inactive users (no login in 24 months)
SELECT id, email, last_login_at
FROM individuals
WHERE last_login_at < NOW() - INTERVAL '24 months'
AND gdpr_deleted = false;
-- Mark inactive users as erased (marker only; permanent deletion follows the erasure process above)
UPDATE individuals
SET
gdpr_deleted = true,
gdpr_deleted_at = NOW(),
gdpr_marketing_consent = false
WHERE last_login_at < NOW() - INTERVAL '24 months'
AND gdpr_deleted = false;Deleted Users
Policy: Erasure requests result in permanent removal of personal data. Standard requests are cleared without undue delay after the cancellable grace period (Privacy Policy §10.4); records under a statutory obligation are retained for the periods stated in Privacy Policy §10.2, and only those records.
Audit Trail
Database Audit Log
Table: audit_log
Captures:
- All sync operations (SYNC, MANUAL_RESYNC)
- All deletions (DELETE)
- All consent changes (UPDATE)
- All data exports (EXPORT)
Schema:
CREATE TABLE audit_log (
id SERIAL PRIMARY KEY,
action VARCHAR(50) NOT NULL, -- 'SYNC', 'DELETE', 'EXPORT', etc.
table_name VARCHAR(50) NOT NULL, -- 'individuals', 'addresses', etc.
record_id UUID NULL, -- Affected record ID
user_role VARCHAR(50) NULL, -- 'canister', 'admin', 'user'
ip_address VARCHAR(45) NULL, -- IP address (if applicable)
details JSONB NULL, -- Additional context
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);Example Entries:
-- User deletion
INSERT INTO audit_log (action, table_name, record_id, user_role, details)
VALUES (
'DELETE',
'individuals',
'550e8400-e29b-41d4-a716-446655440000',
'user',
'{"reason": "User requested deletion via dashboard", "email_hash": "2c26b46b68ffc68f..."}'
);
-- Marketing consent withdrawal
INSERT INTO audit_log (action, table_name, record_id, user_role, details)
VALUES (
'UPDATE',
'individuals',
'550e8400-e29b-41d4-a716-446655440000',
'user',
'{"field": "gdpr_marketing_consent", "old_value": true, "new_value": false}'
);Canister Audit Log
Stored in canister stable memory:
pub struct AuditEntry {
pub timestamp: u64,
pub action: String, // "DELETE", "UPDATE", "ACCESS"
pub user_id: String,
pub email_hash: String,
pub ip_hash: Option<String>,
pub details: String,
}Example:
// Log deletion
let audit_entry = AuditEntry {
timestamp: ic_cdk::api::time(),
action: "DELETE".to_string(),
user_id: record.id.clone(),
email_hash: email_hash.clone(),
ip_hash: Some(ip_hash),
details: "User requested deletion via dashboard".to_string(),
};
STATE.with(|state| {
state.borrow_mut().audit_log.push(audit_entry);
});Audit Retention
Database: retention per Privacy Policy §10.2 Canister: 1 year minimum (limited by stable memory size)
Rationale: GDPR requires audit trails for compliance verification.
Compliance Procedures
Procedure 1: User Deletion Request
Trigger: User clicks "Delete My Account" in dashboard.
Steps:
- Confirm Identity: Require password re-entry
- Display Impact: Show user what data will be deleted
- Grace Period: A cancellable grace period runs before permanent deletion (per Privacy Policy §10.4(a))
- Immediate identifier clear: identifiers derived from verification data are cleared on request; encrypted PII is crypto-erased
- Database Sync: Propagate deletion to database
- Marketing Exclusion: Remove from all email lists
- Audit Log: Record deletion request
- Confirmation Email: Send deletion confirmation to user
Timeline: Identifiers cleared on request; after the cancellable grace period, personal data is permanently deleted without undue delay.
Procedure 2: Data Access Request
Trigger: User clicks "Export My Data" or sends email to privacy@helloworlddao.com.
Steps:
- Verify Identity: Require password or email verification
- Gather Data:
- Canister encrypted PII (user decrypts in browser)
- Database plaintext PII (via API endpoint)
- Audit log entries (related to user)
- Format Export: Generate JSON file
- Deliver: Provide download link (expires in 24 hours)
- Audit Log: Record data export
- Timeline: Within 30 days (GDPR requirement)
Procedure 3: Marketing Consent Withdrawal
Trigger: User clicks "Unsubscribe" in email footer or dashboard.
Steps:
- One-Click Unsubscribe: No password required (email link token)
- Canister Update: Set
gdpr_marketing_consent = false - Database Sync: Propagate to database
- List Removal: Remove from active marketing campaigns
- Confirmation: Show "You've been unsubscribed" page
- Audit Log: Record consent withdrawal
- Timeline: Immediate (within 1 hour)
Procedure 4: Data Breach Response
Trigger: Database breach detected (unauthorized access to plaintext PII).
Steps:
- Immediate: Disconnect database, revoke credentials
- Assess Impact: Identify affected users (audit log)
- Notify Users: Email notification within 72 hours (GDPR requirement)
- Notify Authorities: Report to supervisory authority within 72 hours
- Remediation: Patch vulnerability, rebuild database from canister
- Post-Mortem: Document incident, update security procedures
- Timeline: 72 hours for notification
Important: Canister breach has lower impact (data is encrypted).
Technical Safeguards
Encryption
Canister Storage:
- AES-256-GCM (Authenticated Encryption)
- User-controlled keys (zero-knowledge)
- Recovery keys encrypted with master key
Database Storage:
- Plaintext (by design, for operational use)
- Database credentials in environment variables (not in code)
- SSL/TLS for all connections (planned)
Access Controls
Canister:
- Only user with password can decrypt their PII
- Admin cannot access encrypted PII without user cooperation
Database:
- Role-based access (SELECT, INSERT, UPDATE only)
- DELETE is used for erasure requests and the post-grace purge; routine application paths have no DELETE
- Audit log for all access
Network Security
HTTP Outcalls:
- HTTPS only (TLS 1.3)
- Ed25519 signature authentication
- Timestamp validation (5-minute window)
Database:
- Firewall: Only oracle-bridge can connect
- No public access
- IP allowlist (planned)
Compliance Checklist
Pre-Launch
- [x] User consent obtained during registration
- [x] Privacy policy displayed and accepted
- [x] Right-to-erasure implemented — permanent deletion (immediate identifier clear + post-grace purge) and crypto-erasure
- [x] Marketing consent tracking implemented
- [x] Audit log tables created
- [ ] Self-serve data export endpoint implemented (export exists but is admin-operated, not member self-serve)
- [x] Deletion grace period implemented
- [ ] Legal review of privacy policy (pending)
Ongoing
- [ ] Annual GDPR compliance audit
- [ ] Privacy policy review (quarterly)
- [ ] Data retention policy enforcement (automated)
- [ ] Audit log review (monthly)
- [ ] User education (dashboard tooltips)
Post-Incident
- [ ] Breach notification procedures documented
- [ ] Supervisory authority contact information
- [ ] User notification templates
- [ ] Post-mortem report template
Known Gaps and Future Work
Gaps (Epic 2.5)
- No Self-Serve Data Export Endpoint: a GDPR export exists but is admin-operated; members cannot self-serve export yet
- No SSL/TLS Enforcement: Database connections use SSL but not enforced
- No Privacy Dashboard: User cannot view audit log of their data access
Future Enhancements (Epic 3)
- Differential Privacy: Add noise to analytics queries
- Federated Learning: ML models without raw PII access
- Homomorphic Encryption: Query encrypted database directly
- Multi-Party Computation: Admin access requires multiple approvals
Legal Disclaimer
This document is not legal advice. Consult with qualified legal counsel to ensure GDPR compliance for your specific jurisdiction and use case.
Last Review: 2025-11-25 Next Review: 2026-02-25 (Quarterly)
Related Documentation
Change Log
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0 | 2025-11-25 | System | Initial GDPR compliance documentation |