Skip to content

bridge: the seed is parsed whole, and is 64 bits wide - #21

Merged
A13xB0 merged 1 commit into
mainfrom
seed-is-sixty-four-bits
Sep 8, 2026
Merged

A13xB0 merged 1 commit into
mainfrom
seed-is-sixty-four-bits

Conversation

@A13xB0

@A13xB0 A13xB0 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

--seed was parsed with strtoul into a uint32_t. Where a long is 64 bits the cast keeps the low word and every node differs. Where a long is 32 bits, every Windows target, strtoul saturates at ULONG_MAX on overflow, so every node whose seed was above 2^32 was seeded 0xFFFFFFFF and booted with one identity, private key included. That is MeshBench/meshbench#712: 57 of 58 nodes byte-identical, node 0 (whose seed is the bare run seed, which fits) the one apart.

strtoull into a uint64_t, which HostRNG already takes. MeshBench masks what it sends to 32 bits on its side (so the published binaries are right without a rebuild, and no identity changes on Linux or macOS); this makes the parser honest for anyone running the binary by hand with a wide seed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6

strtoul saturates at ULONG_MAX where a long is 32 bits, which is every
Windows target, so a seed above 2^32 came in as 0xFFFFFFFF and every node
of a run but the first booted with one identity, private key included.
strtoull, into a uint64_t, so the number the simulator sends means the same
thing on every platform. The simulator sends a value that fits in 32 bits
either way, so no identity changes where the mesh already worked.

MeshBench/meshbench#712

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6
A13xB0 added a commit to MeshBench/meshbench that referenced this pull request Sep 8, 2026
57 of 58 native nodes on Windows booted with one identity, private key
included. The bridge parses --seed with strtoul into a uint32_t; where a
long is 64 bits the cast keeps the low word, and where it is 32 bits, every
Windows target, strtoul saturates at ULONG_MAX, so every node whose seed
was above 2^32 was seeded 0xFFFFFFFF. Node 0's seed is the run seed, which
fits, and was the one node apart.

The seed now goes down as its low 32 bits, which is all the firmware ever
read: no identity changes on Linux or macOS, and the published binaries
are right without a rebuild. MeshBench/meshcore-native#21 widens the
parser for anyone running the binary by hand.

Closes #712


Claude-Session: https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6

Co-authored-by: R0ck <random@email.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
@A13xB0
A13xB0 merged commit d1e00f4 into main Sep 8, 2026
1 check passed
@A13xB0
A13xB0 deleted the seed-is-sixty-four-bits branch September 8, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants