Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching strategy handles change poorly #2

Open
GalenReich opened this issue Jan 23, 2025 · 4 comments
Open

Caching strategy handles change poorly #2

GalenReich opened this issue Jan 23, 2025 · 4 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@GalenReich
Copy link
Contributor

Currently, it is difficult to update a puzzle if a mistake is identified. This is because of the caching strategy in run_on_mount_and_update .

At the moment, the unencrypted content of a puzzle that is unlocked by a user persists in thewir browser, even if the encrypted content was updated.

This could be addressed by using the previous puzzle's solution to unencrypt the updated (encrypted) puzzle

How to handle the decryption of a locked puzzle when the answer to a previous puzzle changes to the answer of challenges remains a mystery to me.

There is probably a better way of implementing the logic, so overhauls are welcome.

@GalenReich GalenReich added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Jan 23, 2025
@GalenReich
Copy link
Contributor Author

Ideally, any changes would allow existing users to preserve their current progress.

@franklindyer
Copy link
Contributor

What do you think of this?

  1. Each puzzle is assigned a long random string (e.g. in uuid format) which is never changed. Call it the puzzle's "secret".
  2. Clients receive an encrypted copy of each puzzle's secret, encrypted using the puzzle's solution string as the key. When the solution changes, so does the encrypted secret (but the unencrypted secret does not).
  3. Each non-initial puzzle is encrypted using the random string assigned to the previous puzzle.

This would avoid erasing a user's progress if the solution to one of the solved puzzles changes.

@franklindyer
Copy link
Contributor

franklindyer commented Jan 24, 2025

I went ahead and implemented the above in PR #7 - let me know what you think :-)

This does not do anything with your caching issue - but it should prevent the decryption from breaking in the case when answers need to be changed retroactively, so long as the uuid-style "secret" of each puzzle is not.

@GalenReich
Copy link
Contributor Author

This is a great idea, thank you! I'll have chance to review the PR properly next week, but this looks like a good first step! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants