Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/routes/zk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ async function proveHandler(
`[prover] Proof generated in ${((Date.now() - start) / 1000).toFixed(1)}s`,
);

// ISP-053: Only return proof and nullifier; never return full profile PII
// in verification responses. Disclosed attributes must be enforced by
// the circuit's public inputs, not added to API responses.
res.json({
success: true,
proof: Buffer.from(proof).toString("hex"),
Expand Down
36 changes: 36 additions & 0 deletions src/lib/privacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,39 @@ export function violationFromVaultError(code: number): ZonePrivacyViolation | nu
return null
}
}

/**
* Redact PII from user profiles for public map display (ISP-053).
* Only disclosed attributes pass through; undisclosed fields are stripped.
*/
export function redactProfile<T extends Record<string, any>>(
profile: T,
disclosedFields: string[] = ['nickname', 'id']
): Partial<T> {
const redacted: Partial<T> = {}
for (const field of disclosedFields) {
if (field in profile) {
redacted[field as keyof T] = profile[field]
}
}
return redacted
}

/**
* Add positional jitter to coordinates for k-anonymity (ISP-053).
* Jitters coordinates by ±jitterMeters to prevent exact location tracking.
*/
export function jitterCoordinates(
lat: number,
lng: number,
jitterMeters: number = 200
): { lat: number; lng: number } {
// 1 degree latitude ≈ 111km
const latJitter = (Math.random() - 0.5) * 2 * (jitterMeters / 111000)
// Longitude degrees vary by latitude
const lngJitter = (Math.random() - 0.5) * 2 * (jitterMeters / (111000 * Math.cos((lat * Math.PI) / 180)))
return {
lat: lat + latJitter,
lng: lng + lngJitter,
}
}
1 change: 1 addition & 0 deletions src/pages/Help.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
generateEncryptionKeyPair,
importPrivateKeyJwk,
} from "../lib/crypto";
import { redactProfile, jitterCoordinates } from "../lib/privacy.ts";
import { api } from "../services/api";

const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN;
Expand Down