# `BSV.Auth.Certificate`
[🔗](https://github.com/Bittoku/bsv_sdk_elixir/blob/main/lib/bsv/auth/certificate.ex#L1)

BRC-31 identity certificate.

A certificate binds a subject's public key to a set of encrypted fields,
signed by a certifier. Fields are encrypted with per-field symmetric keys.

Binary format:
`type (32 bytes) || serial (32 bytes) || subject (33 bytes) || certifier (33 bytes) ||
 revocation_outpoint (36 bytes) || field_count (varint) || fields... || [sig_len (varint) || signature]`

# `t`

```elixir
@type t() :: %BSV.Auth.Certificate{
  cert_type: String.t(),
  certifier: BSV.PublicKey.t(),
  fields: %{required(String.t()) =&gt; String.t()},
  revocation_outpoint: String.t(),
  serial_number: String.t(),
  signature: binary(),
  subject: BSV.PublicKey.t()
}
```

# `from_binary`

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

Deserialize a certificate from binary format.

# `get_encryption_details`

```elixir
@spec get_encryption_details(String.t(), String.t()) ::
  {BSV.Wallet.Types.Protocol.t(), String.t()}
```

Get the encryption protocol and key ID for a certificate field.

# `sign`

```elixir
@spec sign(t(), BSV.Wallet.ProtoWallet.t()) :: {:ok, t()} | {:error, String.t()}
```

Sign the certificate using the certifier's wallet (ProtoWallet).
Returns a new certificate with the signature set.

# `to_binary`

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

Serialize the certificate to binary format.

# `verify`

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

Verify the certificate signature.

---

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