# Signed releases, stamped downloads and revocation

Every native download is made for one app: its libraries are stamped with the app and a build id, it carries a
licence file signed with 360sona's release key, and the library checks both before it opens. A build or an app can
be turned off later. This page says what is signed, what the library checks, and what your game sees when a build
is revoked.

## A download

`GET /sona/v1/apps/{id}/sdk?platform=<p>` (with the app's key) makes a new build, stamps every library in the zip
with the app id and the build id (once per binary and per Mach-O slice), and adds `sona-licence.json` listing that
download's platforms, signed with the release key. Pass the file's bytes to `sona_open`:

```c
sona_config_defaults(&cfg);
cfg.licence = licence;          /* the bytes of sona-licence.json */
cfg.licence_len = licence_len;
sona_result r = sona_open(&cfg, &ctx);
```

```cpp
sona::Config cfg;
cfg.licence_file("sona-licence.json");      // the bytes of sona-licence.json
sona::Context ctx(cfg);
```

```csharp
using var ctx = new SonaContext(new SonaOptions { Licence = File.ReadAllBytes("sona-licence.json") });   // the bytes of sona-licence.json
```

```rust
let cfg = Config::new().licence(std::fs::read("sona-licence.json").unwrap_or_default());   // the bytes of sona-licence.json
let ctx = Context::open(cfg)?;
```

```python
ctx = sona.Context(licence="sona-licence.json")
```

At `sona_open` the core checks the signature against the public key built into it, that the licence's app and build
are the ones stamped into the library, and that its own platform is listed.

| Result | Cause | Fix |
|---|---|---|
| `SONA_E_LICENCE` | The file is not the one from this download, or was changed | Use the `sona-licence.json` that came in the same zip as the library |
| `SONA_E_PLATFORM` | The library's platform is not in the licence | Download that platform for your app |
| `SONA_E_BUILD` (as a `SONA_EVENT_ERROR`) | This build was revoked | Download again: a new build of the same app works |
| `SONA_E_APP` (as a `SONA_EVENT_ERROR`) | The app was turned off | See your app's page |

## What is signed

One Ed25519 key signs everything. Its private half stays on 360sona's accounts server; every release library
embeds the public half. Each message starts with its own prefix, so one can never pass for another:

| What | Signed text |
|---|---|
| `sona-licence.json` in a download | `sona-licence|v1|<app>|<build>|<platform ids>|<version>|<issued>` |
| A native check answer | `sona-check|v1|<app>|<build>|<platform>|<nonce>` |
| A release's `SHA256SUMS` | `sona-release|v1|` and the file's bytes |

The package files of a release (the NuGet, PyPI, crates, npm, Unity, Godot and Fab packages) are listed in one
`SHA256SUMS`, signed the same way. A changed, missing or added file, or a signature that is not the release key's,
fails the check.

## The native check and revocation

A context with the gate as a source checks its build with 360sona in the background; gate reads wait for the
answer, and only a signed answer opens the gate.
The desktop downloads also carry `bin/sona` and `bin/sona-mcp` (`.exe` on Windows), stamped the same way. The
installed copies of the tools are the same for every developer and open no licence: they hand every command that
opens the SDK to the download's own ([Unattended agents](unattended.md)).

## A release's files: `SHA256SUMS`

- **A revoked build** answers `build` at its next check: the core raises `SONA_EVENT_ERROR` with `SONA_E_BUILD` and
  closes the gate source. A new download of the same app gets a new build that works; the revoked build's licence
  does not open it.
- **An app that was turned off** answers `app` (`SONA_E_APP`).
- A refusal closes the gate source at once. Local sources (a folder, a console) need only the licence file and keep
  working offline.
