# How To Use

Authorizers can be used for a wide variety of use cases, not only for signature authentication. Signature authentication should be the base of all authorizers, but you can build other authentication requirements for different use cases.

The main [DHTProtocol](https://docs.hypertensor.org/dht#dhtprotocol) takes in an authorizer as a parameter that will `verify` all communication between requests and responses.

The main **DHTProtoco**l is created by the DHT class, and the `authorizer` parameter is sent in as a `kwargs`:

## DHT

The DHT should always be initialized with a PoS authorizer (see [requirements](https://docs.hypertensor.org/build-a-subnet/requirements)). For testing without a blockchain, a [signature authorizer](https://docs.hypertensor.org/subnet-template/authorizers/signature-authorizer) should be used.

```python
identity_path = "alith.id"
pk = get_private_key(identity_path)

signature_authorizer = SignatureAuthorizer(pk)

pos = ProofOfStake(
    subnet_id,
    Hypertensor(),
    min_class=1,
)
pos_authorizer = ProofOfStakeAuthorizer(signature_authorizer, pos)

dht = DHT(
    initial_peers=initial_peers,
    start=True,
    num_workers=DEFAULT_NUM_WORKERS,
    use_relay=use_relay,
    use_auto_relay=use_auto_relay,
    client_mode=reachable_via_relay,
    record_validators=[MockRecordValidator()],
    **dict(kwargs, authorizer=pos_authorizer)
)
```

#### Signature Authorizer

When building application logic protocols, always use an authorizer (see the [Protocols](https://docs.hypertensor.org/build-a-subnet/protocols) example).

If the protocols built for the subnet require peer-to-peer communication, you can initialize or create the protocol with an authorizer, such as:

```python
identity_path = "alith.id"
pk = get_private_key(identity_path)

signature_authorizer = SignatureAuthorizer(pk)

mock_protocol = MockProtocol(
    dht=dht,
    subnet_id=subnet_id,
    hypertensor=Hypertensor(),
    authorizer=signature_authorizer,
    start=True
)
```
