fix: persist context key locally and remove dead node re-encryption#90
Merged
Conversation
- Add ContextKey field to NetworkState (base64-encoded X25519 private key) - cmdNetworkJoin: persist fetched context key to network.json - cmdUp: load context key from cache first, fall back to DWN fetch; persist newly fetched keys for subsequent startups - cmdACLShow: same cached-first pattern for context key loading - Remove dead node re-encryption block in cmdUp — node records are already written with context encryption by 'peer add' and 'network create', and DWN rejects updates from non-authors anyway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
network.jsonso non-anchor nodes survive DWN outages at startup. Previously, the context key was fetched from the anchor's DWN on everymeshd up— if the DWN was unreachable, the node couldn't encrypt/decrypt records.cmdUp— this code attempted to re-register the node with Protocol Context encryption on every startup, but it was dead code after PR fix: use Protocol Context encryption for all records so peers can decrypt (#87, #88) #89: anchor nodes already write with context encryption innetwork create, and non-anchor nodes' records are created bypeer add(also with context encryption). Additionally, the DWN rejects updates from non-authors, so the non-anchor path always failed silently.acl show— same optimization: try cached context key before fetching from DWN.Changes
internal/state/state.goContextKey stringfield toNetworkState(base64-encoded X25519 private key)cmd/meshd/main.gocmdNetworkJoin: persist fetched context key tonetwork.jsoncmd/meshd/main.gocmdUp: load context key from cache first, fall back to DWN fetch; persist newly fetched keyscmd/meshd/main.gocmdUp: remove 35-line dead node re-encryption blockcmd/meshd/main.gocmdACLShow: cached-first context key loading (skip anchor, which derives via HKDF)Verification
go build ./...— zero errorsgo vet ./...— zero warningsgo test ./... -count=1 -race— all tests pass, no data races