Skip to content

Key backup and cryptography

Mesh-Client stores different kinds of keys in different places. Meshtastic and MeshCore each back up a full key pair (public + private) per node, indexed by node number (Meshtastic nodeNum, MeshCore nodeId). The private key restores mesh identity after factory reset; public key alone is not enough, but every backup payload includes both keys.

Per-node archives are created only when you click Backup Keys on that protocol’s Admin tab (Key Backup / Restore). Opening Admin or Security, connecting a radio, or importing Radio JSON updates the MeshCore MQTT active cache only — it does not create a per-node backup.

UI split: Security keeps DM key display / regenerate (Meshtastic) and MeshCore sign / export / import private key. Admin holds Admin Keys, Administration Settings, Key Backup / Restore, and Full device backup (collapsed sections).

See also Meshtastic vs MeshCore feature parity, the README Security section, and Database at-rest encryption decision (why mesh-client.db stays plaintext while credentials use safeStorage).

What a backup contains (both protocols)

Every encrypted backup stores:

Field Meshtastic MeshCore
Public key 32 bytes (Curve25519) 32 bytes
Private key 32 bytes 32- or 64-byte orlp export
Index nodeNum (unsigned 32-bit) nodeId (numeric self id)

Keys are not interchangeable across Meshtastic and MeshCore firmware.

Encryption: Electron safeStorage (OS keychain). Each archive and its index is a secure secret (backup:meshtastic:<nodeNum>, backup:meshcore:<nodeId>, backup-index:meshtastic, backup-index:meshcore). Backup succeeds only when OS key storage is available. Room and repeater passwords use the same store (meshcore:room:<nodeId>, meshcore:repeater:<nodeId>); when OS key storage is unavailable, those remembered passwords keep a local compatibility copy and key backups do not.

Not included in backup: channels, NodeDB, messages, MeshCore contacts DB, Meshtastic remote admin keys (meshtasticRemoteAdminKey:<nodeNum> in SQLite), device name/owner (optional nodeLabel in the index is display-only).

Restore lists prefix entries with Meshtastic · or MeshCore · so archives are distinguishable when nodeNum and nodeId share the same numeric display.


Meshtastic: DM key backup / restore

Where: Admin tab → Key Backup / Restore (local radio only; hidden for remote configure targets). DM key fields and Regenerate Keys remain on Security.

What it backs up: The connected local radio’s DM public and private keys from device security config.

Storage:

Item Secure secret
Per-node archive backup:meshtastic:<nodeNum>
Index (labels and dates) backup-index:meshtastic

Index privacy: The index is a secure secret, same as the per-node archive. Each entry stores nodeLabel, backedUpAt, and publicKeyB64 (the restore UI shows only an 8-character hex prefix).

Scope: per node, Meshtastic only

  • Each Meshtastic nodeNum has its own backup slot on this computer.
  • Backing up radio A does not overwrite radio B’s archive or any MeshCore archive.
  • Restore Keys applies the archive for the currently connected nodeNum when one exists.
  • Restore from backup… lists Meshtastic archived backups only.

Restore pipeline

  1. Decrypt and validate both keys.
  2. applyConfig merges only publicKey / privateKey (admin keys and toggles on the device are preserved).
  3. Commit so keys persist to firmware.
  4. Post-restore verification compares device public key to backup; success or actionable failure toast.

Implementation: meshtasticDmKeyBackupStorage.ts, KeyBackupRestoreSection.tsx, AdminPanelDeviceSecuritySections.tsx.


MeshCore: key backup / restore and MQTT identity

Where: Admin → Key Backup / Restore for archives; Security for sign / export / import private key (no Meshtastic PKI/admin sections on MeshCore).

What it backs up: Device public key plus private key from exportPrivateKey() (normalized orlp bytes) — only when you click Backup Keys.

Storage:

Item Secure secret
Per-node archive backup:meshcore:<nodeId>
Index backup-index:meshcore
Active MQTT cache (last connected/restored device) mesh-client:meshcoreIdentity in localStorage (public key); meshcore:identity in the secure store (private key)

Index privacy: Same as Meshtastic — the index is a secure secret and stores nodeLabel, backedUpAt, and publicKeyB64 (UI shows an 8-character hex prefix only).

The active MQTT cache is separate from per-node archives: device-signing MeshCore MQTT (JWT) signing — LetsMesh, MeshMapper, Colorado Mesh, Waev, Meshat.se, MeshCore.CA, EastMesh — uses whichever identity was last connected or restored. Per-node archives retain full pairs without overwriting each other.

How keys get into the active cache (not a per-node backup)

  1. Connect a MeshCore radio — session export via tryPersistMeshcoreIdentityFromRadioExport.
  2. Admin → Restore or Restore from backup… — syncMeshcoreActiveIdentityFromBackup writes the full pair and dispatches meshclient:meshcoreIdentityUpdated.
  3. Radio → Import config JSON — updates MQTT cache only (RadioPanel.tsx); use Admin → Backup Keys to create a per-node archive.

Restore pipeline

  1. Decrypt and validate both keys.
  2. importPrivateKey(privateKeyBytes) on the connected radio.
  3. Sync active MQTT cache with full pair; identity-updated event refreshes the Connection tab MeshCore MQTT username.
  4. Best-effort verification after reconnect delay.

Implementation: meshcoreKeyBackupStorage.ts.

Details: MeshCore MQTT authentication.


Meshtastic keys vs MeshCore keys

Meshtastic DM backup MeshCore key backup
Protocol Meshtastic PKC / DM MeshCore orlp keys
UI Admin → Backup Keys Admin → Backup Keys
Storage pattern backup:meshtastic:<nodeNum> backup:meshcore:<nodeId>
Per node? Yes — indexed by nodeNum Yes — indexed by nodeId
Created by opening Admin? No (legacy MT slot migrates once) No
Portable across protocols? No No

Flashing MeshCore firmware on hardware that previously ran Meshtastic replaces on-device key material. Meshtastic archives preserve your old Meshtastic identity for restore if you return to Meshtastic; they do not carry that identity onto the MeshCore mesh.


Use case: backing up keys before moving MT nodes to MC

Before you flash (Meshtastic)

  1. Switch to Meshtastic and connect each radio one at a time.
  2. Open Admin → Key Backup / Restore.
  3. For each node: click Backup Keys (requires safeStorage). Each node gets its own indexed slot — no overwrite when you connect the next radio.
  4. Optional: use Copy / export private key for an off-device copy (Security crypto / DM sections as applicable).
  5. Remote admin keys remain in SQLite per node; no extra Security step.

Flash and first MeshCore setup

  1. Flash MeshCore firmware.
  2. Switch to MeshCore and connect — new MeshCore identity on the mesh.
  3. Admin → Backup Keys archives the new pair under that nodeId (required; connect/import alone is not enough).
  4. Optional: Radio → Import config JSON for MQTT cache before RF connect; then Admin → Backup Keys for a per-node archive.

If you return a radio to Meshtastic later

  1. Reflash Meshtastic firmware and connect locally.
  2. Restore Keys if a backup exists for the current nodeNum, or Restore from backup… to pick an archive from before a factory reset / node-num change.

What this does not do

  • Does not migrate Meshtastic identity into MeshCore contacts — peers see a new public key after flash.
  • Does not replace MeshCore companion full JSON backup tools; use Admin Backup Keys for Mesh-Client per-node archives.

Full device backup (MeshCore + Meshtastic)

Where: Admin → Full device backup (local radio only).

The backup file holds channel secrets (MeshCore channel secrets, Meshtastic PSKs) in plain text. Mesh-client writes it readable by the owner only (mode 0600 where the volume supports it); keep it somewhere private.

MeshCore export includes companion-shaped JSON: channels (with secrets), contacts, the node name, and the public key only. It does not include radio settings or the advert position. Private keys stay in Admin → Key Backup / Restore (backup:meshcore:<nodeId>); the export may include a secureBackupRef pointer to that archive, not plaintext key bytes.

MeshCore import accepts mesh-client .mesh-backup.json envelopes or legacy companion JSON. The whole file is read and checked before anything is written to the radio.

  • Merge fills empty channel slots and adds or updates contacts. It keeps the node name, the radio settings and each existing contact's flags. Entries that are not valid are skipped and counted.
  • Replace overwrites the channel table only when the file holds channels, and the contact list only when the file holds contacts (an empty list counts as none), so a partial legacy file cannot empty the radio. It applies the file's node name and radio settings (all five radio_settings values must be present). A file with any entry that is not valid is refused and nothing changes.

The result toast reports how many channels and contacts were written and how many entries were skipped. Radio → Import config JSON still applies radio/name/key-cache fields from companion files, including ones that also hold channel and contact lists (those lists go through Merge).

Meshtastic export is a JSON pack beyond ChannelSet URLs: enabled channels (with PSKs), the owner (long/short name, licensed flag), the LoRa config, and public key metadata via the same secure-backup reference pattern (backup:meshtastic:<nodeNum>). It does not include the Device config.

Meshtastic import applies the channel pack through the same pipeline as pasted ChannelSet links. Merge adds the channels to free slots and keeps the owner and LoRa config; Replace overwrites the channel table and applies the file's owner and LoRa config. Channels, PSK sizes and owner names are checked before anything is written. A device slice in a file is ignored: it is never sent to the radio. Replace keeps each channel's slot index from the file (a sparse layout stays sparse), requires slot 0 (PRIMARY), and clears the slots the file does not name. An index outside 0–7 falls back to the channel's position in the file (the first entry is slot 0, the second slot 1, and so on).

Implementation: deviceBackupTypes.ts, src/renderer/lib/deviceBackup/, DeviceBackupSection.tsx, main file dialogs device-backup-file.ts.


Quick reference

Goal Action
Save Meshtastic DM keys for this node Meshtastic → connect local radio → Admin → Backup Keys
Save keys for multiple Meshtastic nodes Backup each node while connected; each nodeNum keeps its slot
Restore Meshtastic DM keys (same node) Admin → Restore Keys
Restore after factory reset / different node num Admin → Restore from backup… → confirm
Save MeshCore keys for this node MeshCore → connect → Admin → Backup Keys
Restore MeshCore archive to connected radio Restore Keys or Restore from backup…
Cache MeshCore keys for MQTT only Connect radio, restore backup, or Radio JSON import (no per-node archive)
Administer a remote Meshtastic node meshtasticRemoteAdminKey:<nodeNum> via node detail (separate from DM backup)