File tree Expand file tree Collapse file tree 4 files changed +16
-0
lines changed Expand file tree Collapse file tree 4 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ class MyMesh : public BaseChatMesh {
228228 void loadMainIdentity () {
229229 if (!_identity_store->load (" _main" , self_id)) {
230230 self_id = radio_new_identity (); // create new random identity
231+ int count = 0 ;
232+ while (count < 10 && (self_id.pub_key [0 ] == 0x00 || self_id.pub_key [0 ] == 0xFF )) { // reserved id hashes
233+ self_id = radio_new_identity (); count++;
234+ }
231235 saveMainIdentity (self_id);
232236 }
233237 }
Original file line number Diff line number Diff line change @@ -643,6 +643,10 @@ void setup() {
643643 if (!store.load (" _main" , the_mesh.self_id )) {
644644 MESH_DEBUG_PRINTLN (" Generating new keypair" );
645645 the_mesh.self_id = radio_new_identity (); // create new random identity
646+ int count = 0 ;
647+ while (count < 10 && (the_mesh.self_id .pub_key [0 ] == 0x00 || the_mesh.self_id .pub_key [0 ] == 0xFF )) { // reserved id hashes
648+ the_mesh.self_id = radio_new_identity (); count++;
649+ }
646650 store.save (" _main" , the_mesh.self_id );
647651 }
648652
Original file line number Diff line number Diff line change @@ -872,6 +872,10 @@ void setup() {
872872#endif
873873 if (!store.load (" _main" , the_mesh.self_id )) {
874874 the_mesh.self_id = radio_new_identity (); // create new random identity
875+ int count = 0 ;
876+ while (count < 10 && (the_mesh.self_id .pub_key [0 ] == 0x00 || the_mesh.self_id .pub_key [0 ] == 0xFF )) { // reserved id hashes
877+ the_mesh.self_id = radio_new_identity (); count++;
878+ }
875879 store.save (" _main" , the_mesh.self_id );
876880 }
877881
Original file line number Diff line number Diff line change @@ -300,6 +300,10 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
300300 ((StdRNG *)getRNG ())->begin (millis ());
301301
302302 self_id = mesh::LocalIdentity (getRNG ()); // create new random identity
303+ int count = 0 ;
304+ while (count < 10 && (self_id.pub_key [0 ] == 0x00 || self_id.pub_key [0 ] == 0xFF )) { // reserved id hashes
305+ self_id = mesh::LocalIdentity (getRNG ()); count++;
306+ }
303307 store.save (" _main" , self_id);
304308 }
305309
You can’t perform that action at this time.
0 commit comments