diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 15dc88e5..2a6af5b7 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -228,6 +228,10 @@ class MyMesh : public BaseChatMesh { void loadMainIdentity() { if (!_identity_store->load("_main", self_id)) { self_id = radio_new_identity(); // create new random identity + int count = 0; + while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes + self_id = radio_new_identity(); count++; + } saveMainIdentity(self_id); } } diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 8ac1e8a7..1c76264e 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -643,6 +643,10 @@ void setup() { if (!store.load("_main", the_mesh.self_id)) { MESH_DEBUG_PRINTLN("Generating new keypair"); the_mesh.self_id = radio_new_identity(); // create new random identity + int count = 0; + while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes + the_mesh.self_id = radio_new_identity(); count++; + } store.save("_main", the_mesh.self_id); } diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 36938ef6..daf8b497 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -872,6 +872,10 @@ void setup() { #endif if (!store.load("_main", the_mesh.self_id)) { the_mesh.self_id = radio_new_identity(); // create new random identity + int count = 0; + while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes + the_mesh.self_id = radio_new_identity(); count++; + } store.save("_main", the_mesh.self_id); } diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 4b71811c..f5cbc743 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -300,6 +300,10 @@ public: ((StdRNG *)getRNG())->begin(millis()); self_id = mesh::LocalIdentity(getRNG()); // create new random identity + int count = 0; + while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes + self_id = mesh::LocalIdentity(getRNG()); count++; + } store.save("_main", self_id); }