title: Safe encryption of names of devices
body: <p>Let's have N devices each has a unique name DEVICE_1, DEVICE_2, .. , DEVICE_N</p>
  
  <p>Devices broadcast their names so that other devices can start communication with another device from the same group (according to the format of the name).</p>
  
  <p>The device name is encrypted so that nobody else who is not in the group can see the name and thus can't fake the name.
  There's one key for symmetric encryption used by all devices to encrypt their names and decrypt names of other devices.</p>
  
  <p>The problem is that the key for symmetric enctyption is stored in the device. So if somebody hack into the device, reads the key, decrypt the name, change its name to existing name
  of other device and ecrypt it, everybody else think that it's somebody else.</p>
  
  <p><strong>EDIT the idea below is wrong since the device must be able to decrypt the name offline</strong></p>
  
  <p>I came with a solution of storing the key in database on server so the name is encrypted on server once the device has registered to the service. This will work even when the name of the device has
  changed since the change of name is always uploaded to server so we can do the encryption on the server again.</p>
  
  <p>The only vulnerability left is if somebody breaks into the database and reads the key...</p>
  
  <p><strong>EDIT END</strong></p>
  
  <p>Any idea how to solve this?</p>
  
  <p>Oh, I forgot, the devices can't communicate before they know each other's name so assymetric cryptography wouldn't help because I even don't know there's some device from my group out there.</p>