# `Runic.Identity`
[🔗](https://github.com/zblanco/runic/blob/main/lib/identity.ex#L1)

A versioned, domain-separated content identity.

Identities contain the complete scheme and domain alongside the digest. Two
equal digest byte strings in different domains are therefore different keys.
Use `digest/2` for canonical identity documents and `derive/2` for identities
derived from ordered causal coordinates.

# `domain`

```elixir
@type domain() ::
  :component_definition
  | :node_occurrence
  | :connection_definition
  | :workflow_artifact
  | :payload
  | :fact_content
  | :fact_occurrence
  | :execution
  | :input_command
  | :activation
  | :attempt
  | :transaction
  | :event
  | :event_data
  | :snapshot
  | :segment
```

A registered identity domain.

# `t`

```elixir
@type t() :: %Runic.Identity{
  digest: &lt;&lt;_::256&gt;&gt;,
  domain: domain(),
  scheme: :sha256,
  version: 1
}
```

# `derive`

```elixir
@spec derive(domain(), term()) :: t()
```

Derives an identity from an ordered collection of identities and scalars.

# `digest`

```elixir
@spec digest(domain(), term()) :: t()
```

Builds a SHA-256 identity from a canonical identity document.

# `digest_bytes`

```elixir
@spec digest_bytes(domain(), binary()) :: t()
```

Builds an identity from bytes already encoded with the canonical codec.

# `domains`

```elixir
@spec domains() :: [domain()]
```

Returns the registered identity domains.

# `project`

```elixir
@spec project(domain(), term()) :: t()
```

Builds an identity from a value's explicit portable projection.

# `short_string`

```elixir
@spec short_string(t(), pos_integer()) :: String.t()
```

Returns a bounded display string. It must not be used for lookup.

# `to_binary`

```elixir
@spec to_binary(t()) :: binary()
```

Returns the compact binary form used inside canonical identity documents.

# `to_string`

```elixir
@spec to_string(t()) :: String.t()
```

Returns the full tagged text representation of an identity.

# `verify`

```elixir
@spec verify(t(), term()) :: :ok | {:error, Runic.Identity.IntegrityError.t()}
```

Verifies that an identity document reproduces the expected identity.

# `verify!`

```elixir
@spec verify!(t(), term()) :: :ok
```

Verifies an identity document, raising on mismatch.

---

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