Skip to content

Comments

feat(security): TOFU Key Revocation and Rotation for enhanced security#328

Closed
dannamax wants to merge 2 commits intoScottcjn:mainfrom
dannamax:tofu-key-revocation-308
Closed

feat(security): TOFU Key Revocation and Rotation for enhanced security#328
dannamax wants to merge 2 commits intoScottcjn:mainfrom
dannamax:tofu-key-revocation-308

Conversation

@dannamax
Copy link

@dannamax dannamax commented Feb 22, 2026

This PR implements TOFU (Trust On First Use) Key Revocation and Rotation functionality as requested in issue #308.

Changes

  • Implements secure key revocation mechanism with proper validation
  • Adds key rotation capabilities with backward compatibility
  • Uses real Ed25519 cryptography when pynacl is available (with fallback)
  • Includes comprehensive tests and detailed documentation
  • Adds pynacl dependency to pyproject.toml for proper crypto support

Testing

  • All existing tests pass
  • Added new test cases for key revocation and rotation scenarios
  • Verified functionality with multiple edge cases
  • No placeholder code or TODO comments

Fixes #308

Bounty: 15 RTC

@Scottcjn
Copy link
Owner

Thanks for the submission! There are a few issues that need to be fixed before this can be merged:

1. pyproject.toml rewrite — CRITICAL
Your PR completely replaces the existing pyproject.toml which contains our pytest, ruff, and mypy configuration. You should only ADD your changes without removing the existing tool configs.

2. No integration with the actual codebase
The TOFUKeyManager is standalone in node/security/ but nothing in the attestation pipeline uses it. For this bounty, the TOFU system needs to hook into submit_attestation() in rustchain_v2_integrated_v2.2.1_rip200.py. At minimum:

  • When a miner first attests, store their pubkey via TOFU
  • On subsequent attestations, verify the pubkey matches
  • If a key is revoked, reject attestation

3. rotate_key race condition
Creates a temp key {node_id}_rotated_{int(time.time())} then deletes it. If time.time() ticks between create and delete, wrong entry gets deleted.

4. Tests need edge cases
Add: concurrent access, revoked key rejection in attestation, key persistence across restarts.

Please fix these and resubmit. Look at PR #327 (nonce replay, just merged) for the pattern we expect — functions defined inline in the server file, integrated into the attestation flow.

@Scottcjn
Copy link
Owner

Closing in favor of #329 which addresses the feedback. Nice work on the revision!

@Scottcjn Scottcjn closed this Feb 22, 2026
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.

[BOUNTY] TOFU Key Revocation and Rotation — 15 RTC

2 participants