AntOS Library — data (reference)

The data library's design and native core — JSON, base64/hex, hashing, byte packing, and the disk-encoding codecs. The script-facing API is luau_data.

What it is

data is the glue between raw bytes (on the wire or on disk) and Lua values: JSON (data.json.*), base64 and hex (data.base64.* / data.hex.*), checksums and hashes (sha256, md5, crc32, crc16), and the magnetic-disk codecs (data.mfm.* / data.gcr.*) with their format checksums. Signing, HMAC, and the TLS CA store were split into crypto — data is byte-shuffling anyone reaches for freely; crypto is the security-critical surface.

Design notes

  • All of it is pure byte-in / byte-out C with no Luau dependency, so the same core is reused by net (response bodies), DBFS (catalogue checksums — crc32), firmware (image digests — sha256), and floppy (the disk codecs).
  • Plain hashing (sha256/crc32) stays here because it's used constantly and isn't secret; keyed MACs and signatures are in crypto.
  • For raw performance-critical binary work, scripts should prefer the VM's own buffer library.

Why the disk codecs are here — and where the line is

MFM and GCR bit-cell transforms are exactly what data is for: a function of their input and nothing else, with no device, no session and no state. They sit beside base64 for the same reason base64 sits beside hex.

What does not come with them is the rest of reading a disk. Clock recovery, sync-mark hunting, track segmentation, and weak-bit or unformatted-area detection each depend on a recovered clock and a tolerance policy as well as the input, so none of them is a pure function and none belongs here. Those live in floppy, which calls into this library for the pure half.

The test is purity, and it matters practically: net, DBFS and firmware all link data, and a device-shaped API here would follow them in. data.crc16 is the illustration of the line working — it already existed for other callers and is already the CRC-16/CCITT that IBM MFM sectors use, so the disk work reuses it rather than adding anything.

If the codec family keeps growing, the precedent is to split rather than to stretch the definition — crypto left data on exactly this reasoning. A handful of functions does not justify it yet.

Native core — libantos_data

libantos_data holds the JSON parser/serialiser, the codecs, the hash implementations, and the MFM/GCR tables. The binding converts between Lua values and the core's byte buffers.

Related

Important: The Ant64 family of home computers are at early design/prototype stage, everything you see here is subject to change.