# verify_identity

> Verify identity headers against timestamp skew and Algorand signature.

```python
from ai_economy_sdk import verify_identity
```

```python
def verify_identity(
    headers: Mapping[str, Any],
    max_skew: int = 120,
    now: int | None = None,
    genesis_hash_b64: str | None = None,
) -> str | None
```

Verify identity headers against timestamp skew and Algorand signature.

First checks for the presence of the modern `X-Identity-Txn` header (if
`genesis_hash_b64` is provided). If absent or verification fails, falls back
to inspecting the legacy `x-sender-address`, `x-sender-timestamp`, and
`x-sender-signature` headers.

## Parameters

- `headers` (`Mapping[str, Any]`, required):
HTTP request headers mapping (case-insensitive inspection).

- `max_skew` (`int`, default `120`):
Maximum allowable clock skew in seconds between the timestamp and `now`.

- `now` (`int | None`, default `None`):
Current unix timestamp in seconds. Defaults to `int(time.time())`.

- `genesis_hash_b64` (`str | None`, default `None`):
Base64-encoded network genesis hash. Required to verify `X-Identity-Txn`.

## Returns

- `returns` (`str or None`):
The verified Algorand sender address if signature and skew checks pass,
or None if invalid or missing headers. Never raises exceptions.

## Examples

```python
>>> from algosdk import account
>>> from ai_economy_sdk.identity import sign_identity_txn, verify_identity
>>> sk, addr = account.generate_account()
>>> gh = "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8="
>>> hdrs = sign_identity_txn(sk, gh)
>>> verify_identity(hdrs, genesis_hash_b64=gh) == addr
True
>>> verify_identity({}) is None
True
```

## See also

- `verify_identity_txn`: Specific verification for the X-Identity-Txn format.
- `sign_identity`: Client-side helper for legacy identity headers.

Source: [ai_economy_sdk/identity.py](https://github.com/x402-avm/ai-economy-sdk/blob/main/ai_economy_sdk/identity.py#L391)

Source: https://x402-avm.github.io/reference/python/ai-economy-sdk/verify-identity
