Skip to content

fix: certificate course_id integrity and revocation challenge period (#141, #146) - #273

Open
victor-2017 wants to merge 1 commit into
Hamplard-Hub:mainfrom
victor-2017:fix/141-146-certificate-integrity-revocation
Open

fix: certificate course_id integrity and revocation challenge period (#141, #146)#273
victor-2017 wants to merge 1 commit into
Hamplard-Hub:mainfrom
victor-2017:fix/141-146-certificate-integrity-revocation

Conversation

@victor-2017

@victor-2017 victor-2017 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

Closes #141
Closes #146

Changes

#141 — Certificate course_id integrity:

  • Removed course_id parameter from issue_certificate(); the caller no longer supplies the course_id
  • Added enrollment_ref: String field to Enrollment struct and DataKey::EnrollmentByRef(String) mapping
  • issue_certificate() now derives course_id from the enrollment reference stored in DataKey::EnrollmentByRef, preventing caller-supplied spoofing
  • Added counter_to_string() and generate_enrollment_ref() helpers for deterministic enrollment ref generation
  • init() now accepts revocation_challenge_period: u32 parameter

#146 — Revocation challenge period:

  • Added revocation_deadline: Option<u32> field to Certificate struct
  • revoke_certificate() now sets a pending revocation with a configurable challenge window (default: 17,280 ledger sequences ~ 24 hours)
  • During the challenge period, verify_certificate() returns true (certificate remains valid)
  • Added challenge_revocation(student, certificate_id) — allows the certificate holder to dispute within the challenge window, restoring the certificate
  • Added set_revocation_challenge_period() and get_revocation_challenge_period() for admin configuration
  • After the challenge period expires, revocation becomes permanent

Tests

  • All 219 tests pass (13 new tests for both issues)
  • Existing tests updated to account for pending revocation behavior
  • New tests cover: enrollment ref integrity, invalid ref rejection, challenge lifecycle, boundary conditions, unauthorized challenges, configurable periods

- Hamplard-Hub#141: Remove course_id parameter from issue_certificate; derive it from
  enrollment_reference lookup, preventing caller-supplied spoofing
- Hamplard-Hub#146: Add configurable challenge period to revocation; revoked
  certificates remain valid during the challenge window, giving holders
  time to dispute via challenge_revocation()
- Init now accepts revocation_challenge_period parameter
- Admin can configure challenge period via set_revocation_challenge_period
- Add enrollment_ref tracking and counter for enrollment references
- 13 new tests covering both issues, all 219 tests passing
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@victor-2017 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant