# Signing plugins

A signature tells you who published a package and that it is the exact
archive they released. It does not tell you the code is safe: that is
still a matter of trusting the publisher (see [Security](./security)).

## Installing a signed plugin

A signed plugin comes with two files: the package (`my-plugin.zip`) and
its signature (`my-plugin.zip.sig`). In **Settings › Plugins**, choose
**Install plugin** and select both files together.

The plugin is marked **Signed by** a publisher only when the signature
verifies against a key you trust. A signature that matches none of your
keys, or that was made for different bytes, is refused rather than
installed as unsigned.

## Trusting a publisher

Under **Trusted publishers**, add the publisher's name and the public
key they announced (base64). Phantom shows each key's fingerprint, the
first 16 hex characters of its SHA-256; compare it with the one the
publisher shows before you trust it.

Once a plugin is installed signed, its updates must be signed by the
same publisher. An unsigned update, or one signed by any other key, is
refused, so a package that only reuses the plugin's ID cannot replace
it. Removing a publisher does not stop plugins already installed; their
next update needs a key you trust.

**Require signatures** refuses every unsigned package. Turn it on when
you install plugins only from publishers you know.

## Signing your own plugin

Make a key once and keep its private half secret:

```bash
python -m scripts.plugin_sign keygen publisher.key
```

It prints the public key and its fingerprint to publish next to your
plugin. Sign each release after building the zip:

```bash
python -m scripts.plugin_sign sign my-plugin.zip publisher.key
```

This writes `my-plugin.zip.sig`. Ship both files. The signature is
Ed25519 over the archive's SHA-256 with a fixed Phantom context, so
rebuilding the zip, even with the same files, needs a new signature.

## Dependencies

A plugin runs with the Python standard library, the SDK and the files in
its own package, nothing else: the process starts without site packages,
so libraries installed for Phantom are not importable. Put any helper
code the plugin needs into the package itself and review it as part of
the plugin.
