Skip to content

Fix privacy atomicity, encryption, retry loop, and integrity verification#787

Merged
orbitlumen-hue merged 2 commits into
DogStark:mainfrom
Jambox11:feature/privacy-stellar-fixes
Jul 24, 2026
Merged

Fix privacy atomicity, encryption, retry loop, and integrity verification#787
orbitlumen-hue merged 2 commits into
DogStark:mainfrom
Jambox11:feature/privacy-stellar-fixes

Conversation

@Jambox11

Copy link
Copy Markdown
Contributor

Summary

Four critical security and correctness fixes: real AES-256-GCM encryption for medical records, proper SHA-256 integrity hashing, enforced retry limits with exponential backoff, and atomic privacy settings saves.

Changes

#697 — Implement AES-256-GCM encryption for medical records

  • Replaced Base64 encoding with authenticated encryption using Web Crypto API
  • Properly consumes encryptionKey parameter in PBKDF2 key derivation
  • IV generated per-encryption and stored with ciphertext for decryption
  • Prevents exposure of plaintext medical data on IPFS

#698 — Use SHA-256 hash for on-chain integrity verification

  • Replaced substring(0, 64) payload prefix with computeChecksum() (SHA-256 hex digest)
  • Updated verifyRecord() to actually compare current data against stored hash
  • Enables tamper detection for synced records

#699 — Fix retry loop to enforce maxRetries and add exponential backoff

  • Thread result.attempts through recursive calls by passing existingResult to syncRecord()
  • Permanently-failing records now stop after exactly 3 retries and reach status: 'failed'
  • Exponential backoff: 2s, 4s, 6s delays across retry attempts

#696 — Make privacy settings save atomic with per-endpoint error reporting

  • Update local state immediately after each successful API call (not after both succeed)
  • Distinguish partial failures: "Visibility settings saved, but profile preferences failed"
  • Prevents user mental model mismatch when one endpoint succeeds and the other fails

Testing notes

  • Encryption: output not recoverable via atob() or Base64 decode
  • Retry: simulate permanent failure and verify exactly 3 attempts, then terminal failed status
  • Integrity: verify verifyRecord() detects tampering with off-chain data
  • Privacy: test failure of 2nd API call and confirm 1st result is reflected in UI

Closes #696, Closes #697, Closes #698, Closes #699

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

@Jambox11 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@orbitlumen-hue
orbitlumen-hue merged commit 5531081 into DogStark:main Jul 24, 2026
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment