Add UI for setting repeater identity keys

This adds a simple UI in repeater management settings for remotely
setting a repeater's private key. A key can be pasted from an external
key generator, or a random one can be generated here, optionally with a
specified prefix.

If a prefix is specified, searching is done in 30ms batches in order
to keep the UI responsive and show the progress indicator animation
smoothly. Searches can be interrupted. An estimation of search length is
given as expected number of generated key pairs. (A future improvement
would be to observe keys per second performance and give time estimates
based on that.)

When it generates a new private key on your behalf, it can tell you
what the corresponding public key will be. Unfortunately, if you paste
one in from another source, it can't compute the corresponding public
key. This is because the standard Dart crypto library doesn't provide
that capability, nor does it give access to the elliptic curve functions
it implements so we could do it ourselves. Our only recourse would be to
copy the source for all those things, and I didn't think it was worth
it.

This will not check the validity of a pasted key, but the remote
repeater will. It does limit it to the correct length and hexadecimal
charset.

Prefixes are limited to 4 characters. There's no technical reason for
this, but users are unlikely to want more, and I think it would just be
a bad experience to allow more and spin for a very long time. If someone
really wants a longer one, they can use an external generator like they
do now.

Possible TODO: rewrite background processing using isolates.

Closes #142.
This commit is contained in:
Seth Golub
2026-05-28 10:57:50 -07:00
parent 5670ab0067
commit e1a4900dc0
29 changed files with 1169 additions and 44 deletions
+61 -1
View File
@@ -4748,6 +4748,66 @@ abstract class AppLocalizations {
/// **'Bytes used to encode this repeater\'s ID in flood path/loop-detect tags. 0=1 byte (256 IDs, up to 64 hops), 1=2 bytes (65K IDs, up to 32 hops), 2=3 bytes (16M IDs, up to 21 hops). v1.13 and older firmware drops multi-byte paths — only raise once your network is on v1.14+.'**
String get repeater_pathHashModeHelper;
/// No description provided for @repeater_keySettings.
///
/// In en, this message translates to:
/// **'Change Identity Keys'**
String get repeater_keySettings;
/// No description provided for @repeater_keySettingsSubtitle.
///
/// In en, this message translates to:
/// **'Change the public/private keypair'**
String get repeater_keySettingsSubtitle;
/// No description provided for @repeater_prvKey.
///
/// In en, this message translates to:
/// **'Private key'**
String get repeater_prvKey;
/// No description provided for @repeater_prvKeyHelper.
///
/// In en, this message translates to:
/// **'A new private key for the repeater, a 128-character hex string.'**
String get repeater_prvKeyHelper;
/// No description provided for @repeater_generatePrvKey.
///
/// In en, this message translates to:
/// **'Generate a random keypair'**
String get repeater_generatePrvKey;
/// No description provided for @repeater_stopGeneratingPrvKey.
///
/// In en, this message translates to:
/// **'Interrupt search for keypair'**
String get repeater_stopGeneratingPrvKey;
/// No description provided for @repeater_pubKey.
///
/// In en, this message translates to:
/// **'Public key'**
String get repeater_pubKey;
/// No description provided for @repeater_pubKeyHelper.
///
/// In en, this message translates to:
/// **'This is the public key that goes with the generated private key. You can\'t set this directly.'**
String get repeater_pubKeyHelper;
/// No description provided for @repeater_pubKeyPrefix.
///
/// In en, this message translates to:
/// **'Desired prefix'**
String get repeater_pubKeyPrefix;
/// No description provided for @repeater_pubKeyPrefixHelper.
///
/// In en, this message translates to:
/// **'Find a public key that starts with these hex digits. Expected tries needed: {tries}.'**
String repeater_pubKeyPrefixHelper(int tries);
/// No description provided for @repeater_txDelay.
///
/// In en, this message translates to:
@@ -5519,7 +5579,7 @@ abstract class AppLocalizations {
/// No description provided for @repeater_cliHelpSetPrvKey.
///
/// In en, this message translates to:
/// **'(Serial only) Replaces the device identity private key. Reboot required to apply. Generates a new public key.'**
/// **'Replaces the device identity private key. Reboot required to apply. Generates a new public key.'**
String get repeater_cliHelpSetPrvKey;
/// No description provided for @repeater_cliHelpSetRadioRxGain.