remoteid 0.2.0

Drone Remote ID (ASTM F3411-22a, EN 4709-002) in pure no_std Rust: decode, encode, track, and judge trust (spoof and plausibility verdicts, DRIP RFC 9575 Ed25519 verification)
Documentation
# Python

```text
pip install remoteid
```

abi3 wheels for CPython 3.10 and later on Linux (x86_64, aarch64), macOS
(x86_64, arm64) and Windows (x86_64). The source is `python/` in this
repository.

## decode

```python
remoteid.decode(data: bytes, transport: str = "auto") -> dict
```

`transport` names what `data` is:

| Value | `data` |
|---|---|
| `payload` | a Remote ID message (25 bytes) or message pack, header byte first |
| `wifi_frame` | an 802.11 management frame; a radiotap header in front is stripped |
| `radiotap` | radiotap header plus 802.11 frame |
| `wifi_vendor_ie` | the body of the vendor element, as scapy's `Dot11Elt.info` gives it: OUI `FA:0B:BC`, type `0x0D`, counter, pack |
| `wifi_ies` | an 802.11 element list |
| `nan` | the body of a NAN service discovery action frame |
| `ble_adv` | Bluetooth advertising data (AD structures) |
| `ble_service_data` | service data for UUID 0xFFFA (application code first; a leading `FA FF` is accepted) |
| `auto` | try the above |

Returns `{"transport", "counter", "source", "is_pack", "messages"}`.
Each message is a dict with a `type` of `basic_id`, `location`, `auth`,
`self_id`, `system` or `operator_id`. Location fields are SI units
(`latitude`, `longitude`, `altitude_geo`, `altitude_baro`, `height` in
meters, `speed_horizontal` and `speed_vertical` in m/s, `direction` in
degrees, `timestamp` in seconds after the hour); unknown values are `None`.
Anything that is not Remote ID raises `ValueError`.

With scapy:

```python
from scapy.all import Dot11Elt
import remoteid

def on_packet(pkt):
    elt = pkt.getlayer(Dot11Elt)
    while elt is not None:
        if elt.ID == 221 and elt.info[:4] == b"\xfa\x0b\xbc\x0d":
            frame = remoteid.decode(bytes(elt.info), "wifi_vendor_ie")
            ...
        elt = elt.payload.getlayer(Dot11Elt)
```

## Tracker and verdicts

```python
tracker = remoteid.Tracker(
    max_speed_mps=100.0,
    fingerprints=True,
    accept_self_certified=False,
    trusted_keys=None,          # {DET text or 16 bytes: Ed25519 public key (32 bytes)}
    timeout_ms=10_000,
    use_system_clock=True,
)
v = tracker.ingest(data, transport="auto", address=None, now_ms=None, unix_ms=None, rssi=None)
```

`ingest` returns a `Verdict` with `verdict` (`authenticated`, `plausible`,
`suspicious`, `spoofed`), `score`, `reasons`, `spoofer`, `auth`,
`address`, `transport`, `uas_id`, `latitude`, `longitude`, `altitude_m`,
`frames`, `is_alert` and `to_dict()`. The reasons are explained in
`trust.md`.

Times: by default a frame is stamped with a monotonic clock and, with
`use_system_clock`, the machine's UTC clock (which enables the absolute
timestamp checks; leave it on only if the clock is NTP or GNSS synced).
When replaying a capture, pass `now_ms` (and `unix_ms` if the capture
clock was right) from the packet timestamps.

`address` identifies Bluetooth transmitters and element-only Wi-Fi input;
whole Wi-Fi frames carry their own source address.

Other methods: `verdicts()`, `get(address)`, `aircraft_json(...)` (see
`aircraft-json.md`), `ingest_ridf(bytes)`, `expire(now_ms=None)`, `len()`.

## RIDF

`remoteid.write_ridf(payload, transport, rx_time_ns, counter=None, rssi=None,
address=None, receiver_id=0, receiver=None, utc=False, header=False)`
returns one record (with the file header if `header`), and
`remoteid.read_ridf(data)` returns a list of dicts. See `ridf.md`.