Skip to content

I think this nonce calculator works but is technically incorrect #9

Description

@wz2b

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:

meshtastic/firmware#6424

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions