Skip to content

feat(certificate): tamper detection with checksums and chain of custody - #521

Merged
LaGodxy merged 4 commits into
StarkMindsHQ:mainfrom
blessingernest54:feature/certificate-tamper-detection
Jun 9, 2026
Merged

feat(certificate): tamper detection with checksums and chain of custody#521
LaGodxy merged 4 commits into
StarkMindsHQ:mainfrom
blessingernest54:feature/certificate-tamper-detection

Conversation

@blessingernest54

@blessingernest54 blessingernest54 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Closes #404


Description

Add tamper detection to prevent certificate modification.

Changes

  • types.rs: CustodyEntry, TamperRecord structs; CertDataKey::TamperRecord storage key
  • errors.rs: TamperDetected = 110, NotSealed = 111
  • storage.rs: set_tamper_record / get_tamper_record helpers
  • lib.rs: compute_checksum (SHA-256), seal_certificate, verify_integrity, get_tamper_record
  • test.rs: 5 tests

How It Works

Step Function Description
1 seal_certificate Admin seals cert after issuance; SHA-256 checksum stored with initial custody entry
2 verify_integrity Recomputes checksum; appends custody entry; emits CertificateVerified(is_valid=false) alert on mismatch
3 get_tamper_record Returns full record including custody log and tampered flag

Acceptance Criteria

  • Tampering detected — checksum mismatch returns TamperDetected error
  • Alerts functional — emit_certificate_verified(is_valid=false) fires on tamper
  • False positive rate <1% — SHA-256 is deterministic; same inputs always produce same hash

…ustody

- Add CustodyEntry and TamperRecord types; CertDataKey::TamperRecord storage key
- Add TamperDetected=110 and NotSealed=111 error variants
- Add set/get_tamper_record storage helpers
- Add compute_checksum (SHA-256 over cert_id+course_id+title+issued_at)
- Add seal_certificate, verify_integrity, get_tamper_record contract functions
- Tamper alert emitted via emit_certificate_verified(is_valid=false)
- Add 5 tests covering seal, verify, custody log, and error cases
@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@blessingernest54 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

@LaGodxy
LaGodxy merged commit da5ce6c into StarkMindsHQ:main Jun 9, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: Implement Certificate Tampering Detection

2 participants