# `PublicKey`

An Ed25519 public key (RFC 8032), its 32 bytes as unpadded Base64url, `11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo`: not secret, so it may be read, stored and sent.

[Security](types.md#security); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its text, `PublicKey("11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo")`, which checks it: text that isn't one breaks `format`.

`text.parse(raw, as: PublicKey)` reads one from its text; text that isn't one at all fails `malformed`, such as `""`.

This operation gives one: `crypto.public_key`.

## Text, JSON and storage

`text.from` writes its canonical text, the one form `text.parse` reads back. JSON sends its canonical text as a string.

| Text | JSON |
|---|---|
| `11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo` | `"11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo"` |
| `PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw` | `"PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw"` |

It is stored in one column named for the field, of type `text`. `PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw` is stored as `'PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw'`.

## Shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo` | `11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo` |
| `PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw` | `PUAXw-hDiVqStwqnTRt-vJyYLM8uxJaMwM1V8Sr0Zgw` |

## Operations

- `crypto.public_key(key: PrivateKey) -> PublicKey`: The Ed25519 public key of the `PrivateKey` setting, which isn't secret: published, others check what the app signs with it.
- `crypto.verify_signature(value: T, signature: Bytes, key: PublicKey) -> Bool`: Whether `signature` is `value`'s Ed25519 signature under `key`, which is not secret and may be read.

Like every standard type, it also has the contract's own operations: `text.parse`, `text.from`, `text.format`, `json.read`, `json.write` and `==`. It isn't ordered, so `<` and sorting don't take it. [Every standard type meets one contract](../topics/every-standard-type-meets-one-contract.md) says how they work.
