Skip to content

Implement BLE MAC Address Randomization - #1

Merged
BigNathan1 merged 16 commits into
BigNathan1:mainfrom
StellarConduit:main
Jun 29, 2026
Merged

Implement BLE MAC Address Randomization#1
BigNathan1 merged 16 commits into
BigNathan1:mainfrom
StellarConduit:main

Conversation

@BigNathan1

Copy link
Copy Markdown
Owner

Summary

Implements MAC address randomization for the simulated BLE Central to close the
passive-tracking privacy gap: a static device address let an observer correlate a
device across Bluetooth scans over time. This defines the rotation interface and
policy so both the simulation and a future Android JNI binding implement the same
contract.

Changes

  • MacAddressProvider trait + RandomMacProvider (ble_transport.rs):
    injectable MAC generation. RandomMacProvider::generate() produces a 6-byte
    address with the locally-administered bit set and the multicast bit cleared.
  • BleCentral rotation state (ble_transport.rs): adds current_mac,
    mac_provider, last_rotation, and rotation_interval (default 15 minutes),
    plus rotate_mac_if_due(), which rotates only once per elapsed interval and
    returns Some(new_mac) on rotation, None otherwise.
  • TopologyFlag::MacRotated (types.rs): variant is now defined and emitted.
  • TransportManager (unified.rs): power_tick_at() calls
    rotate_mac_if_due() and, on rotation, appends TopologyFlag::MacRotated to
    PowerTickOutcome::topology_flags so the gossip loop can broadcast the new MAC.
  • notify_mac_rotated() (unified.rs): drops all BLE connections (they
    reference the stale MAC) while leaving WiFi-Direct connections intact, and keeps
    peer_count consistent.

Testing

  • RandomMacProvider::generate() sets the locally-administered bit and clears the
    multicast bit over 1000 samples.
  • rotate_mac_if_due() returns None before the interval and Some(_) after;
    a second immediate call returns None (no double rotation).
  • TopologyFlag::MacRotated is present in power_tick output on the rotation round
    and absent before the interval elapses.
  • BLE connections are dropped after notify_mac_rotated; WiFi-Direct survives.
  • All transport::ble_transport tests pass.

Closes StellarConduit#38

Wetshakat and others added 16 commits June 18, 2026 12:00
Remove trailing blank line at end of ble_transport.rs and trailing
whitespace on an empty doc-comment line in unified.rs. Both are
normalized by `cargo fmt --check`, which was failing the CI step.
Sort the ble_transport import group in unified.rs and wrap two
over-length send_with_timeout calls in the gossip integration test,
matching cargo fmt output. The test-file lines were pre-existing
formatting violations on main.
- Avoid use-after-move of ble_peers in notify_mac_rotated by iterating
  over a reference so the subsequent len() read stays valid.
- Drop unused mut bindings in two BleCentral rotation tests.

These were masked by the earlier formatting failure and surface once
cargo clippy --all-targets --all-features -- -D warnings runs.
The 'outer loop only ever exits via `break 'outer`, so it never iterates
a second time, tripping clippy::never_loop (deny-by-default). Convert it
to a labeled block, preserving the advertise-once-then-accept behavior
and the two `break 'outer` exit paths.
Implement BLE MAC address randomization for privacy
Fix: Remove Incorrect soroban-sdk Dependency from Core
@BigNathan1
BigNathan1 merged commit 51f3a37 into BigNathan1:main Jun 29, 2026
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.

3 participants