# `MetamorphicLog.Commitment`
[🔗](https://github.com/moss-piglet/metamorphic_log/blob/main/lib/metamorphic_log/commitment.ex#L1)

SHA3-512 commitment verification (CONIKS value commitments).

A commitment is `SHA3-512_with_context(context, opening(32 bytes) || value)`.
Given the public `context` label, the 64-byte `commitment`, the committed
`value`, and the 32-byte `opening`, `verify/4` recomputes and constant-time
compares.

All binary arguments are **base64-encoded**.

# `valid?`

```elixir
@spec valid?(String.t(), String.t(), String.t(), String.t()) :: boolean()
```

Boolean form of `verify/4`. Returns `true` only on a valid opening.

# `verify`

```elixir
@spec verify(
  context :: String.t(),
  commitment_b64 :: String.t(),
  value_b64 :: String.t(),
  opening_b64 :: String.t()
) :: :ok | {:error, String.t()}
```

Verify that `commitment` opens to `value` under `opening` and `context`.

Returns `:ok` or `{:error, reason}`.

## Example

    :ok = MetamorphicLog.Commitment.verify(context, commitment, value, opening)

---

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