# `ExWapp.Pairing.ADV`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/pairing/adv.ex#L1)

Helpers for parsing and validating WhatsApp ADV (Account Device Verification) payloads.

Pair-success `device-identity` arrives as an `ADVSignedDeviceIdentityHMAC`
container in both Baileys and whatsmeow. The inner payload is an
`ADVSignedDeviceIdentity`.

Outbound message `device-identity` nodes and pair-success ACK payloads use the
direct `ADVSignedDeviceIdentity` bytes instead.

The methods below verify the pair-success HMAC using the stored ADV secret,
validate the server account signature, and prepare the client device
signature that must be echoed back to WhatsApp once pairing completes.

# `parsed_identity`

```elixir
@type parsed_identity() :: %{
  container: struct() | nil,
  signed: struct(),
  details: struct() | map(),
  hosted?: boolean(),
  device_signature: binary(),
  self_signed: binary(),
  details_binary: binary()
}
```

Result returned by `parse_signed_device_identity/3`.

# `encode_signed_device_identity`

```elixir
@spec encode_signed_device_identity(struct(), keyword()) ::
  {:ok, binary()} | {:error, term()}
```

Encodes an `ADVSignedDeviceIdentity` payload.

By default it includes `accountSignatureKey` (required for outgoing messages).
Pass `include_signature_key: false` for pair-device-sign payloads.

# `parse_signed_device_identity`

```elixir
@spec parse_signed_device_identity(binary() | nil, binary(), identity_input()) ::
  {:ok, parsed_identity() | nil} | {:error, term()}
```

Parses and validates a signed ADV device identity blob.

The returned map exposes both the decoded structs and the serialized payload
that must be echoed back to the server (under `:self_signed`).

---

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