Skip to content

Comments

feat(puzzles): implement puzzle solution submission and verification …#171

Open
Robinsonchiziterem wants to merge 1 commit intoMindFlowInteractive:mainfrom
Robinsonchiziterem:feature/puzzle-submission-api-141
Open

feat(puzzles): implement puzzle solution submission and verification …#171
Robinsonchiziterem wants to merge 1 commit intoMindFlowInteractive:mainfrom
Robinsonchiziterem:feature/puzzle-submission-api-141

Conversation

@Robinsonchiziterem
Copy link

PR: Implement Puzzle Solution Submission and Verification API
This pull request implements the core infrastructure for submitting and verifying puzzle solutions, as outlined in GitHub issue #141.

Summary of Changes
🧩 Core Infrastructure
New Entity: Added
PuzzleSolutionAttempt
to track every submission attempt with:
SHA-256 hashed answer storage for security.
Nonce-based anti-replay protection.
Detailed timing, reward, and fraud metadata.
Service Layer: Implemented
SolutionSubmissionService
to orchestrate:
Rate limiting (max 5 submissions / 60s).
Answer verification with normalisation (case-insensitivity, object key ordering).
Server-side timing validation against puzzle time limits.
Fraud detection for "impossibly fast" completions.
Atomic reward and aggregate statistic updates.
🛡️ Anti-Cheat & Security
Integrated with
AntiCheatService
to report suspicious completion times.
Implemented SHA-256 hashing for all answer comparisons.
Added strict nonce uniqueness enforcement to prevent replay attacks.
🚀 API Endpoints
POST /puzzles/:id/submit: Submit a solution for verification.
GET /puzzles/:id/submissions: Retrieve current user's history for a specific puzzle.
GET /puzzles/submissions/history: Retrieve full submission history for the authenticated user.
✅ Verification
Added a comprehensive test suite in
src/puzzles/tests/solution-submission.service.spec.ts
(35+ test cases).
Covered edge cases including:
Correct/incorrect answers.
Answer normalization.
Time limit expiration.
Replay attacks.
Fraudulent timing.
Rate limit exhaustion.
Closes #141

@Mkalbani
Copy link
Contributor

@Robinsonchiziterem Not starting. Please resolve
Screenshot 2026-02-21 at 09 58 47

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.

Puzzle Solution Submission and Verification API

2 participants