# sign_identity

> Generate legacy identity verification headers signed with an Algorand private key.

```python
from ai_economy_sdk import sign_identity
```

```python
def sign_identity(private_key: str, now: int | None = None) -> dict[str, str]
```

Generate legacy identity verification headers signed with an Algorand private key.

Signs the ASCII message `x402-identity:<sender_address>:<timestamp>` using Ed25519
and returns the three legacy headers `x-sender-address`, `x-sender-timestamp`,
and `x-sender-signature`.

**Notes**

.. deprecated:: 0.5.0
Use `sign_identity_txn`, whose proof is bound to one network's genesis
hash. `sign_identity` keeps working and servers keep accepting its headers;
it emits a `DeprecationWarning` and will be removed in a future major release.

## Parameters

- `private_key` (`str`, required):
Base64-encoded 32-byte Algorand private key.

- `now` (`int | None`, default `None`):
Unix timestamp in seconds. If None, defaults to `int(time.time())`.

## Returns

- `returns` (`dict[str, str]`):
Dictionary with keys `x-sender-address`, `x-sender-timestamp`,
and `x-sender-signature` (base64-encoded signature).

## Examples

```python
>>> import warnings
>>> from algosdk import account
>>> from ai_economy_sdk.identity import sign_identity
>>> sk, addr = account.generate_account()
>>> with warnings.catch_warnings():
...     warnings.simplefilter("ignore", DeprecationWarning)
...     hdrs = sign_identity(sk, now=1700000000)
>>> hdrs["x-sender-address"] == addr
True
>>> hdrs["x-sender-timestamp"]
'1700000000'
>>> bool(hdrs["x-sender-signature"])
True
```

## See also

- `sign_identity_txn`: Preferred modern transaction-based proof.
- `verify_identity`: Validates both modern and legacy identity headers.

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

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