# verify_identity_txn

> Verify an X-Identity-Txn header value against timestamp skew and Algorand signature.

```python
from ai_economy_sdk import verify_identity_txn
```

```python
def verify_identity_txn(
    header_value: str,
    expected_genesis_hash_b64: str,
    max_skew: float | int = 120,
    now: float | int | None = None,
) -> str | None
```

Verify an X-Identity-Txn header value against timestamp skew and Algorand signature.

Decodes the signed transaction, checks that it is a self-payment of 0 amount with
0 fee and no rekeying or close-to fields, verifies network genesis hash matching,
validates round validity window <= 1000, checks timestamp within `max_skew` seconds,
and cryptographically verifies the Ed25519 signature against the sender address.

**Notes**

Rejects multisig, logic signatures, and rekeyed accounts. This proof cannot
be executed on chain because fee is 0 and rounds 1..1000 are long past on live nets.

## Parameters

- `header_value` (`str`, required):
Value of the `X-Identity-Txn` HTTP request header (base64 msgpack).

- `expected_genesis_hash_b64` (`str`, required):
Base64-encoded genesis hash of the expected Algorand network.

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

- `now` (`float | int | None`, default `None`):
Current unix timestamp. If None, defaults to `time.time()`.

## Returns

- `returns` (`str or None`):
The verified Algorand sender address if all security checks pass,
or None if verification fails. Never raises exceptions.

## Examples

```python
>>> from algosdk import account
>>> from ai_economy_sdk.identity import sign_identity_txn, verify_identity_txn
>>> sk, addr = account.generate_account()
>>> gh = "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8="
>>> hdrs = sign_identity_txn(sk, gh)
>>> verify_identity_txn(hdrs["X-Identity-Txn"], gh) == addr
True
>>> verify_identity_txn(hdrs["X-Identity-Txn"], "wrong_genesis_hash=") is None
True
```

## See also

- `sign_identity_txn`: Client-side proof creation.
- `verify_identity`: High-level verification supporting both proof formats.

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

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