-
Notifications
You must be signed in to change notification settings - Fork 5
Description
meshtastic-python-scripts/mqtt-script.py
Line 22 in 63f53ea
| nonce = getattr(mp, "id").to_bytes(8, "little") + getattr(mp, "from").to_bytes(8, "little") |
I think this code:
nonce = getattr(mp, "id").to_bytes(8, "little") + getattr(mp, "from").to_bytes(8, "little")
should actually be:
nonce = getattr(mp, "id").to_bytes(8, "little") + getattr(mp, "from").to_bytes(4, "little") + (0).to_bytes(4, "little")
It's a subtle issue, and in a practical sense it makes no difference because the firmware always sets extraNonce to zero and because it's little endien. But I was referred to this code as a reference ("this is how you do it") so I think if this is serving as an example that it should reflect the correct reading of the nonce calculation, which I believe is:
[ 64 bits of packet id ] [ 32 bits of from ] [ 32 bits of extra nonce which is by default all zeros ]
This is related to my squawk in the firmware, which I also think has an issue: