Skip to content
chrisballinger edited this page Oct 14, 2014 · 13 revisions

Bluetooth LE Mesh Chat Spec

All text fields are UTF-8 and padded with " " if shorter than the max length. All protocol data is always versioned, timestamped and signed in its entirety by your private key. For version 1, all data after the version byte is compressed with zlib before being sent over the wire.

All data packets follow this format:

[key=#bytes]
[[version=1][timestamp=8][sender_public_key=32][data=n]][signature=64]
signature = sign(version + timestamp + sender_public_key + data, sender_private_key)

There is a constant 105-byte overhead for each data packet comprised of version, timestamp, sender_public_key and signature.

Definitions

Global

  • version: Spec version, 1 byte
  • timestamp: Current 64-bit Unix timestamp, 8 bytes
  • signature: 512-bit Ed25519 signature, 64 bytes
  • sender_public_key: Your 256-bit Ed25519 public key, 32 bytes
  • sender_private_key: Your 512-bit Ed25519 private key, 64 bytes

Identity

  • display_name: desired nickname, 35 bytes

Messaging

  • message: UTF-8 message body, 140 bytes
  • reply_signature: signature of message you're replying to, 64 bytes

Direct Messaging

  • mac: message authentication code (crypto_box_MACBYTES in libsodium), 32 bytes

Identity

Your identity is revealed on the first read to the identity characteristic. Your public key is your unique identifier, and the display name can be anything. Subsequent reads give other people's identities signed by your own.

Your Identity (140-bytes):

data: [display_name=35]
full: [[version=1][timestamp=8][sender_public_key=32][display_name=35]][signature=64]

Propagated Identities (245-bytes):

data: [others_identity=140]
full: [[version=1][timestamp=8][sender_public_key=32][others_identity=140]][signature=64]

Public Messages

All public messages flowing over the network will have the following format. They are uniquely identified by their signature.

data: [message=140][reply_signature=64]]
full: [[version=1][timestamp=8][sender_public_key=32][message=140][reply_signature=64]][signature=64]

Broadcast

Messages with valid message but empty reply_signature are considered general broadcast.

Replies

Messages with both message and reply_signature are considered replies to the original message.

Upvote/Repost

Messages with an empty message but still containing a valid reply_signature are considered upvotes/reposts.

Direct Messages

Convert Ed25519 keys to Curve25519 for authenticated asymmetric encryption.

{} denotes ciphertext encrypted to destination_public_key
data: [destination_public_key=32][mac=32]{[message=140][reply_signature=64]}
full: [[version=1][timestamp=8][sender_public_key=32][destination_public_key=32][mac=32]{[message=140][reply_signature=64]}][signature=64]

This example doesn't yet provide forward secrecy. The performance characteristics of a BLE-only mesh may prevent PFS from working reliably.

Clone this wiki locally