# `Tezex.Michelson.Base58`
[🔗](https://github.com/objkt-com/tezex/blob/v6.0.0/lib/michelson/base58.ex#L1)

Validates the base58 literals of Michelson's address-like types and decodes
them into the binary forms the protocol compares them by.

Prefixes are Octez's: src/lib_crypto/base58.ml, plus contract_hash.ml (KT1)
and zk_rollup_repr.ml (epx1) in the protocol.

# `address`

```elixir
@spec address(String.t()) :: {:ok, {binary(), String.t()}} | :error
```

An address is compared by destination, then by entrypoint name, where no
entrypoint means `"default"` (script_comparable.ml, `compare_address`).
Destinations are tagged like their binary encoding (destination_repr.ml), so
their byte order is the protocol's: implicit (tz1 < tz2 < tz3 < tz4) < KT1 <
sr1 < epx1.

# `chain_id`

```elixir
@spec chain_id(String.t()) :: {:ok, binary()} | :error
```

# `decode`

```elixir
@spec decode(String.t(), String.t()) :: {:ok, term()} | :error
```

# `key`

```elixir
@spec key(String.t()) :: {:ok, {0..3, binary()}} | :error
```

A key is compared by curve (ed25519 < secp256k1 < p256 < bls), then by key
bytes (signature_v1.ml). The bytes here are the encoded ones; p256 keys need
decompressing before they're compared, see `Tezex.Michelson.Comparable`.

# `key_hash`

```elixir
@spec key_hash(String.t()) :: {:ok, binary()} | :error
```

# `signature`

```elixir
@spec signature(String.t()) :: {:ok, binary()} | :error
```

A signature is compared by its raw bytes, whatever its prefix
(signature_v1.ml), so `edsig…` and `sig…` with the same bytes are equal.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
