# Directly query the network

## Create your point from your input

### With mishtiwasm

Install:

```bash
npm i @holonym-foundation/mishtiwasm
```

Here is an example for a Human Key creation with oprf secp256k1

Import:

<pre class="language-javascript"><code class="lang-javascript">import init, { oprf_client_step1_secp256k1, unmask_secp256k1 } from "@holonym-foundation/mishtiwasm"
<strong>// important to call init -- wasm is initialized asynchronously.
</strong><strong>// without it, the other functions won't work
</strong><strong>await init();
</strong></code></pre>

To create a masked point from your input, use:

```rust
// Salt and secret input are arrays of uint8s
const { encoded_masked_point, secret_mask } = oprf_client_step1_secp256k1(salt, secret);
```

&#x20;`encoded_masked_point` can be the value for `point` in the RequestToNetwork

### Unmasking the point

After querying the network and receiving the point `response_from_network`, unmask the response via

```javascript
// Salt and secret input are arrays of uint8s
const result = unmask_secp256k1(response_from_network, secret_mask);
```

This is the output of the OPRF!

## Form a query to Human Network

Querying the epoch and their request number via the POST `/user-state/` endpoint to find the user&#x20;

```rust
pub struct StateRequest {
    pub user: ethereum_types::Address,
    pub method: Method,
}
```

Requests to the network are of the following format

```rust

pub struct RequestToNetwork {
    /// The method of the request
    pub method: Method,
    /// Encoded point to be multiplied
    pub point: Vec<u8>, 
    /// Which epoch this request is from
    pub epoch: u32,
    /// Which request number this is from this user in this epoch. Starts at 1 not 0 to ensure the first request is paid for.
    pub request_per_user: u32,
    /// Signature of the request, from an address with credits. 
    pub signature: Option<ethers_core::types::signature::Signature>,
    /// Extra optional data
    pub extra_data: Option<Vec<u8>>,
}

```

Use the point obtained above as `pub point: Vec<u8>`

Method is an enum with the following format

```rust
pub enum Method {
    OPRFSecp256k1,
    DecryptBabyJubJub,
    JWTPRFSecp256k1,
}
```

Here is an example request:

```json
{
  "method": "OPRFSecp256k1",
  "point": [2,58,211,253,26,34,132,83,157,111,80,144,179,1,88,82,243,119,99,104,156,248,158,115,87,30,114,39,90,142,78,236,28],
  "epoch": 123,
  "request_per_user": 69,
  "signature": {
    "r": "0xe3fbde1404800f5ac238b30f2118b69a1cdb604d0b4227056f18f87beb83abf2",
    "s": "0x9132d353ef806f526ef5e48cbee6872a11fcf688c2d92023a384d0f02082466",
    "v": 28
  },
  "extra_data": null
}
```

### How to find the epoch, request\_per\_user, and signature fields

To make a request to the network you need to know a few things

* `epoch`
* `request_per_user`  signifying how many requests the signer who signed off on the request has made
* `signature`   by the user who signed the request who you need to have credits at the address who signed the request.&#x20;

## Query the network

Run the following command:

```
curl 'http://44.217.242.218:8081' \
-H 'Content-Type: application/json'\
...
```


---

# 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.network.human.tech/for-developers/making-requests-to-human-network/directly-query-the-network.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.
