# `ExWapp.Noise.Handshake`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/noise/handshake.ex#L1)

Implements the Noise_XX handshake primitives used by WhatsApp Web.

The state mirrors the Go implementation bundled with whatsmeow. It keeps
track of the running hash, the current AEAD key and the handshake counters.

# `t`

```elixir
@type t() :: %ExWapp.Noise.Handshake{
  counter: non_neg_integer(),
  hash: binary(),
  key: binary(),
  salt: binary()
}
```

# `authenticate`

```elixir
@spec authenticate(t(), binary()) :: t()
```

Mixes additional authenticated data into the running handshake hash.

# `decrypt`

```elixir
@spec decrypt(t(), binary()) :: {:ok, t(), binary()} | {:error, term()}
```

Decrypts a handshake payload and updates hash/counter on success.

# `derive_transport_keys`

```elixir
@spec derive_transport_keys(t()) :: {binary(), binary()}
```

Derives transport write/read keys from the current handshake salt.

# `encrypt`

```elixir
@spec encrypt(t(), binary()) :: {t(), binary()}
```

Encrypts a handshake payload using the current key and updates hash/counter.

# `mix_into_key`

```elixir
@spec mix_into_key(t(), binary()) :: t()
```

Derives a new handshake key/salt pair from input key material.

# `mix_shared_secret`

```elixir
@spec mix_shared_secret(t(), binary(), binary()) :: {:ok, t()} | {:error, term()}
```

Mixes a Curve25519 shared secret into the handshake key schedule.

# `new`

```elixir
@spec new(binary(), binary()) :: t()
```

Initializes a Noise handshake state with the provided protocol pattern and header.

---

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