# 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](/subnet-template/dht.md#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](/build-a-subnet/requirements.md)). For testing without a blockchain, a [signature authorizer](/subnet-template/authorizers/signature-authorizer.md) 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](/build-a-subnet/protocols.md) 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
)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/subnet-template/authorizers/how-to-use.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
