The .orixmap region package — format 1.0
Status: implemented in Packages/ORIXMapPackage (reader, writer, verifier, installer) and
Infrastructure/package-builder (orix-package). This document is the reference; the code follows it and the tests
in Packages/ORIXMapPackage/Tests check every rule stated here.
1. What it is
A .orixmap file is one region of the map, ready to be used offline: a signed container of ordinary files. It is
not a codec and it defines no new data encoding. After installation each component is a normal file that its consumer
opens by path.
| Component id | File name in an installed region | Content | Media type recorded by the builder |
|---|---|---|---|
map |
map.pmtiles |
PMTiles v3 archive of Mapbox Vector Tiles | application/vnd.pmtiles |
search |
search.sqlite |
SQLite database (FTS5 + R-tree search index) | application/vnd.sqlite3 |
routing |
routing.orixgraph |
memory-mapped routing graph | application/vnd.orix.graph |
terrain |
terrain.pmtiles |
PMTiles v3 archive of elevation tiles (optional; no producer yet) | application/vnd.pmtiles |
The file extension is .orixmap, the media type application/vnd.orix.map.
File names never come from the package. A package only carries component identifiers; the installer maps the four
identifiers above to the four fixed file names above and writes nothing else. An identifier it does not know is verified
and skipped. There is no path, no directory and no file name anywhere in the format, so path traversal is impossible by
construction — and identifiers are additionally restricted to [a-z0-9-]{1,32} (see 4.3), which the tests exercise with
hostile values (../map, /etc/passwd, map.pmtiles, NUL bytes, look-alike Unicode…).
2. File layout
All integers are little-endian. Offsets are from the start of the file.
offset 0 ┌──────────────────────────────┐
│ header (64 bytes in 1.0) │ fixed prefix: enough to know the size of the preamble
headerLength ├──────────────────────────────┤
│ manifest (UTF-8 JSON) │ manifestLength bytes — the signed bytes
├──────────────────────────────┤
│ signature (Ed25519, 64 B) │ over the exact manifest bytes
preambleLength ├──────────────────────────────┤
│ zero padding │ up to the next multiple of 4096
├──────────────────────────────┤
│ component 1 │ at manifest.components[0].offset
├──────────────────────────────┤
│ zero padding │ up to the next multiple of 4096
├──────────────────────────────┤
│ component 2 … │
totalLength └──────────────────────────────┘ the file ends with the last byte of the last componentpreambleLength = headerLength + manifestLength + signatureLength. A client learns it from the first 64 bytes, so it
can fetch the preamble alone with one or two HTTP Range requests, verify the signature and show the exact content,
sizes, licences and compatibility of a package before downloading it; the rest is then downloaded, and resumed, by
byte range.
2.1 Header
| Offset | Size | Type | Field | Value / rule |
|---|---|---|---|---|
| 0 | 8 | bytes | magic | 4F 52 49 58 4D 41 50 1A (ORIXMAP + 0x1A) |
| 8 | 2 | u16 | format major | 1. Any other value: reject |
| 10 | 2 | u16 | format minor | 0. Any value is accepted (see 6) |
| 12 | 4 | u32 | header length | 64 in 1.0. Accepted range 64…4096; bytes beyond 64 are skipped |
| 16 | 4 | u32 | manifest length | 1…1 048 576 |
| 20 | 4 | u32 | signature length | 64 |
| 24 | 2 | u16 | signature algorithm | 1 = Ed25519. Any other value: reject |
| 26 | 2 | — | reserved | written as zero, ignored |
| 28 | 4 | u32 | flags | none defined in 1.0; written as zero, ignored |
| 32 | 8 | bytes | signing key identifier | the 8 raw bytes whose hexadecimal form is the 16-digit key id |
| 40 | 8 | u64 | total length | length of the whole file |
| 48 | 16 | — | reserved | written as zero, ignored |
The header itself is not signed, and does not need to be: every field that matters is bound to the signed manifest.
- manifest length, header length, signature length: any wrong value makes the signature check read other bytes and fail.
- signing key identifier: must equal
signingKeyIdof the manifest (signingKeyMismatchotherwise), and the signature must verify under that key. - total length: must equal
downloadSizeof the manifest and the real size of the file. - minor version, flags, reserved bytes: carry no meaning in 1.0 and are ignored. They are the only bytes of a file that can change without invalidating it.
2.2 Manifest
manifestLength bytes of UTF-8 JSON (no BOM; UTF-16/32 are refused), one object. See section 4.
2.3 Signature
64 bytes: the Ed25519 signature (RFC 8032, as produced by CryptoKit Curve25519.Signing) of exactly the
manifestLength manifest bytes as stored — no canonicalisation, no re-encoding. A reader verifies the signature on the
raw bytes first and only then parses them: nothing in the manifest is interpreted before it is authenticated.
The manifest contains the length and the SHA-256 of every component and the total length of the file, so the signature authenticates the whole file.
CryptoKit's Ed25519 signatures are randomised: building the same package twice gives two files that differ in these 64 bytes and nowhere else.
2.4 Components and padding (canonical layout)
- Components appear in the file in the order of
manifest.components. - Every component starts at a multiple of 4096.
- The first component starts at the first multiple of 4096 that is ≥
preambleLength; each following component starts at the first multiple of 4096 that is ≥ the end of the previous one. No other gap is allowed. - The file ends with the last byte of the last component:
totalLength = offset + lengthof the last component. - Padding bytes are zero. A reader checks them.
With these rules a package has exactly one valid byte sequence for a given manifest, signature and set of components (up to the ignored header fields of 2.1): there is no slack space in which unauthenticated data could travel.
Container overhead is therefore preamble + padding: at most 4096 × (number of components) bytes plus the size of a
manifest larger than one page (measured: 4 185 bytes for a 236 MB three-component package).
3. Limits
A reader rejects a package beyond any of these limits before using it (PackageLimits.standard; an application may
lower them).
| What | Limit |
|---|---|
| Manifest size | 1 MiB (1 048 576 bytes) |
| Header length | 64…4096 bytes |
| Number of components (known + unknown) | 16 |
| Size of one component | 1 byte … 32 GiB |
| Total file size | 64 GiB |
| Short strings (names, sources, licence names, URLs) | 512 UTF-8 bytes, not empty, no control character |
| Attribution text | 4096 UTF-8 bytes |
| Media type, builder names and versions | 128 / 64 / 64 UTF-8 bytes |
| Number of licences | 1…32 |
| Number of languages, of localized names | 32 |
| Number of builder entries | 32 |
| Zoom levels | 0 ≤ minZoom ≤ maxZoom ≤ 24 |
| Region id | [a-z0-9-]{1,64} |
| Component id | [a-z0-9-]{1,32}, unique in a package |
| Version strings | 1 to 4 groups of 1 to 9 decimal digits separated by . |
Arithmetic: every offset + length, every sum of lengths and every alignment is computed with overflow detection; an
overflow is an error (invalidLayout(.offsetOverflow)), never a wrapped value. JSON numbers that do not fit an unsigned
64-bit integer (negative, fractional, too large, quoted) make the manifest undecodable.
Placement checks, in this order for each component: offset multiple of 4096; offset ≥ preambleLength; no overlap with
the previous component; offset + length ≤ totalLength; offset equal to the canonical one. Then totalLength equals
the end of the last component, the header value, downloadSize and the size of the file on disk. Then, while the
component is streamed: exactly length bytes are read (truncated otherwise) and their SHA-256 equals the manifest
value (componentChecksumMismatch otherwise).
4. Manifest
4.1 Example
The manifest of the Greater Montréal development package built on 2026-11-25 from real components (pretty-printed here; stored on one line with sorted keys):
{
"bbox": { "maxLat": 45.95, "maxLon": -73.15, "minLat": 45.15, "minLon": -74.35 },
"buildDate": "2026-11-25T08:33:51Z",
"builder": { "orix-package": "1.0.0" },
"capabilities": ["map", "search", "routing"],
"components": [
{ "formatVersion": 3, "id": "map", "length": 96370599, "mediaType": "application/vnd.pmtiles",
"offset": 4096, "sha256": "2a9051192b6e6b12ebca351ba0f71c8d1ce5b57b7015a28ca9a8e2f7c87ea807" },
{ "formatVersion": 1, "id": "search", "length": 40460288, "mediaType": "application/vnd.sqlite3",
"offset": 96374784, "sha256": "ad542b9daacbdb9ad418ef518976a4e4c2c9335338015a58f37793a4e740bd01" },
{ "formatVersion": 1, "id": "routing", "length": 99315712, "mediaType": "application/vnd.orix.graph",
"offset": 136835072, "sha256": "aaa26d20a0f2f942f76a9b4a0566b4d873bea22872f371f6f33dd12267c30486" }
],
"dataTimestamp": "2026-11-24T00:00:00Z",
"dataVersion": "2026.11.24",
"downloadSize": 236150784,
"format": "orixmap",
"installedSize": 236146599,
"languages": ["en", "fr"],
"licences": [
{ "attribution": "© OpenStreetMap contributors", "licence": "ODbL-1.0", "source": "OpenStreetMap",
"url": "https://www.openstreetmap.org/copyright" },
{ "attribution": "Made with Natural Earth", "licence": "Public domain", "source": "Natural Earth",
"url": "https://www.naturalearthdata.com/about/terms-of-use/" }
],
"mapZoom": { "maxZoom": 15, "minZoom": 0 },
"names": { "en": "Greater Montréal", "fr": "Grand Montréal" },
"regionId": "ca-qc-montreal",
"schemaVersion": 1,
"signingKeyId": "92853604e9033917"
}4.2 Members
| Member | Type | Required | Rule |
|---|---|---|---|
format |
string | yes | "orixmap" |
schemaVersion |
integer | yes | 1. A greater value is refused before any other member is read (unsupportedSchemaVersion) |
regionId |
string | yes | [a-z0-9-]{1,64}. Identifies the region across versions; used as a directory name by the store |
names |
object | yes | language tag → display name; en and fr mandatory |
bbox |
object | yes | minLat, minLon, maxLat, maxLon in WGS 84 degrees; finite, inside ±90 / ±180, minLat < maxLat, minLon ≠ maxLon (minLon > maxLon means the box crosses the antimeridian) |
dataVersion |
string | yes | dotted decimal version (2026.11.24, 7), compared numerically group by group; strictly increasing from one publication of a region to the next |
dataTimestamp |
string | yes | timestamp of the OpenStreetMap data, YYYY-MM-DDTHH:MM:SSZ exactly |
buildDate |
string | yes | when the package was assembled and signed, same syntax |
mapZoom |
object | if map is present |
minZoom, maxZoom of the map component |
languages |
array of strings | yes | language tags for which the data carries localized names |
licences |
array | yes, ≥ 1 | objects {source, licence, attribution, url}; url is http(s) |
capabilities |
array of strings | yes | exactly the known component ids present (map, search, routing, terrain), no duplicate; unknown values are tolerated |
downloadSize |
integer | yes | length of the whole file in bytes |
installedSize |
integer | yes | sum of the lengths of all components |
components |
array | yes, ≥ 1 | see 4.3; at least one known component |
signingKeyId |
string | yes | 16 lowercase hexadecimal digits; equals the header key id |
builder |
object | yes | tool name → version ("orix-package": "1.0.0", "tile-builder": "…") |
minAppVersion |
string | no | oldest application version able to use the package (dotted decimal) |
Language tags: [a-z]{2,3} followed by up to three -[A-Za-z0-9]{2,8} subtags.
Unknown members, at any level, are ignored. They are covered by the signature like everything else.
4.3 Components
| Member | Type | Rule |
|---|---|---|
id |
string | [a-z0-9-]{1,32}, unique. Known: map, search, routing, terrain |
offset |
integer | first byte of the payload (see 2.4) |
length |
integer | 1 … 32 GiB |
sha256 |
string | 64 lowercase hexadecimal digits, SHA-256 of the length bytes at offset |
mediaType |
string | informative |
formatVersion |
integer | 1…65535: version of the component's own format (PMTiles: 3; search index and routing graph: their schema version). The application declares the range it supports per component and refuses a package outside it |
A component with an unknown (but well-formed) identifier is an optional extension: it is verified like the others
(placement, length, SHA-256) and not installed. A component that an older application must understand cannot be added
without bumping schemaVersion or minAppVersion.
5. Signature, keys and trust
- Algorithm: Ed25519 (
Curve25519.Signingin CryptoKit). Public key: 32 bytes. Signature: 64 bytes. - Key identifier: the first 16 hexadecimal digits of the SHA-256 of the 32 raw public key bytes. Always computed
from the key; a trust store entry whose declared
keyIddoes not match its key is refused. - Trust store (
TrustStore): a list ofTrustedKey {keyId, publicKey, label?, notBefore?, notAfter?}and a listrevokedKeyIds. It is compiled into the application; it is never downloaded. - Verification order: key revoked →
revokedSigningKey; key unknown →unknownSigningKey; signature wrong →invalidSignature; then the manifest is decoded; header key id ≠ manifest key id →signingKeyMismatch;buildDateafternotAfter→expiredSigningKey;buildDatebeforenotBefore→signingKeyNotYetValid.
notAfter / notBefore are compared with the signed build date of the package, not with the clock of the phone
(which is unreliable and would make installed maps expire). They express an orderly retirement: "this key signed nothing
after that date". They do not protect against a stolen key (the thief can write any build date): that is what
revokedKeyIds is for.
Private keys never enter the repository or the application. The builder reads the key from a file given with --key or
named by the environment variable ORIX_PACKAGE_SIGNING_KEY_FILE; the file must be a regular file (not a symbolic
link), owned by the current user, with no permission for group or others (mode 600 or 400). Expected location on the
build machine: ~/.config/orix-maps/signing/.
5.1 Key rotation procedure
- On the build machine:
orix-package keygen --out ~/.config/orix-maps/signing --label "production 2027". Keep the.keyfile there (mode 600) and in the owner's offline backup; copy the printed Swift snippet. - Application release N: add the new public key to the trust store next to the old one. Packages are still signed with the old key, so every application version keeps working.
- When release N is widely installed, switch the builder to the new key and set
--min-app-version Non the packages it signs. An older application cannot verify them (unknownSigningKey); the catalog repeatssigningKeyIdandminAppVersionso that the application can say "update the app" before downloading anything (trustStore.key(withId:) == nil). - Application release N+1: give the old key a
notAfterequal to the date of the switch. Packages it signed before stay valid; nothing built later is accepted under it. - Later: remove the old key from the trust store once no published package uses it.
Compromised key: put its identifier in revokedKeyIds in an application release, re-sign and republish every
package with a new key under a new dataVersion. Installed regions signed by the revoked key keep working until
RegionStore.verifyInstalled is run on them (it fails with revokedSigningKey); the application then offers to download
them again. A revocation only reaches users who update the application — this is the price of a trust store that no
server can modify.
6. Versioning and compatibility
| Change | How it is expressed | Old reader |
|---|---|---|
| New optional component | new id |
verifies it, does not install it |
| New optional manifest member | — | ignores it |
| New header field | headerLength > 64, minor version bumped |
skips the extra bytes |
| New flag, use of reserved bytes | minor version bumped | ignores them |
| Incompatible manifest (member renamed, semantics changed) | schemaVersion 2 |
refuses: unsupportedSchemaVersion |
| Incompatible component format | formatVersion of that component |
refuses: unsupportedComponentFormat (store) |
| Feature that needs a newer application | minAppVersion |
refuses: appTooOld (store) |
| Incompatible container (other signature placement, other alignment…) | format major 2 | refuses: unsupportedFormatVersion |
Rules for writers: a minor version may only add things an old reader can ignore safely. Anything an old reader must not
ignore requires a new major, a new schemaVersion, a new formatVersion or a minAppVersion.
7. Reading a package safely (normative summary)
- Read 64 bytes. Check magic, major, header length, manifest length (against the limit, before allocating),
signature algorithm and length, total length (against the limit and ≥
preambleLength). - Read the manifest and the signature. Verify the signature under the trusted, non-revoked key named by the header.
- Decode the manifest (UTF-8 only); refuse an unknown
schemaVersion; validate every member against section 3 and 4. - Check that the header key id equals
signingKeyId, then the validity window of the key againstbuildDate. - Check the layout (2.4, 3) against the header and the size of the file.
- Stream every component through a bounded buffer: zero padding before it, exact length, SHA-256.
- Only then make anything visible to the rest of the application (see the installer in
Packages/ORIXMapPackage/README.md).
Errors are values of PackageError; each rule above has its own case, and none of them carries text for the user.
8. What the format deliberately does not do
- No compression. PMTiles tiles are already compressed; the search index and the routing graph are opened in place
(SQLite,
mmap) and must not be compressed. Transport compression is the server's business and is disabled for artefacts (Range requests). - No encryption. Map data is public; confidentiality is not a goal.
- No delta updates. An update is a whole new package. The catalog schema leaves room for it (unknown members are ignored).
- No in-place use. Components are extracted to their own files at installation: PMTiles, SQLite and the routing
graph are then ordinary files for their libraries. The 4096 alignment keeps a future in-place or
clonefile-based design possible but nothing relies on it today. - No timestamp authority.
buildDateis asserted by the signer.