# `EEVM.MPT.HexPrefix`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/mpt/hex_prefix.ex#L1)

Hex-prefix (aka compact) encoding used by Ethereum's Merkle Patricia Trie.

Trie leaf and extension nodes encode their nibble path as a compact byte
string. The first nibble carries node kind and parity flags:

- `0x0` = extension, even path length
- `0x1` = extension, odd path length
- `0x2` = leaf, even path length
- `0x3` = leaf, odd path length

Paths are represented as nibble lists (`[0..15]`).

# `nibble`

```elixir
@type nibble() :: 0..15
```

Nibble values used in hex-prefix paths.

# `decode`

```elixir
@spec decode(binary()) :: {[nibble()], boolean()}
```

Decodes Ethereum hex-prefix bytes into `{nibbles, is_leaf}`.

# `encode`

```elixir
@spec encode([nibble()], boolean()) :: binary()
```

Encodes a nibble path using Ethereum hex-prefix rules.

---

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