Skip to content

fix: add resolve_token to TokenStore for E2E handshake - #103

Merged
blaspat merged 1 commit into
mainfrom
fix/e2e-resolve-token
Aug 4, 2026
Merged

fix: add resolve_token to TokenStore for E2E handshake#103
blaspat merged 1 commit into
mainfrom
fix/e2e-resolve-token

Conversation

@blaspat

@blaspat blaspat commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the 'TokenStore' object has no attribute 'resolve_token' crash that prevented E2E handshakes from completing. Node connections now work again.

Root cause

The E2E handshake needs the raw pairing token to derive the HKDF handshake key, but TokenStore only stored SHA-256 hashes. Two bugs:

  1. server.py:510 called token_store.resolve_token() — a method that didn't exist
  2. E2E proof verification result was overwritten by a legacy token_store.validate() call (which fails because auth.token is empty in E2E mode)

Changes

  • tokens.py: Add token field to _StoredRecord (Fernet-encrypted at rest). Add resolve_token(name) method. Backward-compatible — old token stores without the field load fine.
  • wsserver/server.py: Call resolve_token to get the raw token for HKDF. Graceful fallback to legacy auth when token isn't available (nodes paired before this fix). Fix auth logic so E2E proof verification correctly skips the legacy token_store.validate() call.

Behavior

Scenario Result
New node paired after fix Full E2E encryption (AES-256-GCM)
Old node paired before fix Falls back to legacy plaintext auth — re-pair to enable E2E
Wrong token / revoked node e2e_keypair_failed → connection closed

The E2E handshake needs the raw pairing token to derive the HKDF
handshake key, but TokenStore only stored SHA-256 hashes. This adds:

- token field to _StoredRecord (Fernet-encrypted at rest)
- resolve_token(name) method to retrieve raw token
- Graceful fallback to legacy auth when token not available
  (nodes paired before this fix get plaintext auth until re-paired)

Also fixes auth logic: E2E proof verification now correctly skips
the legacy token_store.validate() call instead of overwriting
is_valid=True with the (empty) auth.token.

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
@blaspat
blaspat merged commit a02a7c9 into main Aug 4, 2026
2 checks passed
@blaspat
blaspat deleted the fix/e2e-resolve-token branch August 4, 2026 06:46
@blaspat
blaspat restored the fix/e2e-resolve-token branch August 5, 2026 02:16
@blaspat
blaspat deleted the fix/e2e-resolve-token branch August 5, 2026 02:18
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.

1 participant