> For the complete documentation index, see [llms.txt](https://esper.gitbook.io/esperchain-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://esper.gitbook.io/esperchain-docs/architecture/proof-of-ai-consensus/zkllm-and-native-llm.md).

# zkLLM and native LLM

Esperchain has native LLM model from its Proof-of-AI consensus and hence also an MCP for agents to interact with.

### zkLLM: Zero-Knowledge Proofs for Language-Model Inference

Esperchain treats *every* forward-pass of its canonical model **Mᵗ** as on-chain data that must be:

1. **Correct** – the logits come from an *exact* deterministic execution of Mᵗ on a given prompt.
2. **Private-as-needed** – user prompts can remain undisclosed.
3. **Cheap to verify** – full-nodes must check blocks in milliseconds.

`zkLLM` is the proof specification that makes those three goals coexist.

| Layer                    | Design Choice                                                                      | Why                                                               |
| ------------------------ | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| **Field & Proof System** | STARKs over a 64-bit friendly prime, batched with Halo2 recursion                  | Transparent setup, fast GPU provers, \~2 kB proof after recursion |
| **Circuit Layout**       | *Tensor-arithmetic kernel* + *lookup ranges* for softmax & GELU                    | Keeps constraints per token \~25× smaller than naïve mat-mul      |
| **Model Commitment**     | \`Poseidon-512(ROOT(weights)                                                       |                                                                   |
| **Prompt Privacy**       | Optional masking of `user_tokens` → proof only reveals Poseidon hash of the prompt | Lets enterprises run private prompts while still posting proofs   |
| **Determinism**          | Temperature = 0, greedy decode, `max_tokens = 128`                                 | Removes sampling nondeterminism ∴ provable                        |

#### Proof Generation Pipeline (per micro-batch Bₖ)

```
Tokenise → Quantise (int8) → Pad/Chunk → 
   ┌──────────────────────────────────┐
   │  Transformer-Block Circuits      │   n × L
   └──────────────────────────────────┘
LayerNorm → Linear → Top-K → Poseidon hash r
↓
STARK π  (≈ 180 ms for 16-prompt batch on 1×RTX 5090)
```

*Provers* can amortise cost by **re-using commitment openings** for every layer’s weight matrix, so only activations flow through the trace.

#### Verification

A full-node runs:

```go
if poseidon512(B || y) ≥ Target { invalid }
if !stark.Verify(π, public_inputs) { invalid }
```

Runtime: **< 10 ms on Apple M3**.\
This keeps block validation lightweight—even for mobile light clients.

***

### Native LLM Execution Path (“LLMCall” Transaction)

{% @mermaid/diagram content="sequenceDiagram
participant User/Agent
participant Esper\_L1
participant PoAI\_Miner
participant zkLLM\_Verifier

User/Agent->>Esper\_L1: LLMCall{prompt, max=64}
Esper\_L1-->>User/Agent: tx-hash
Esper\_L1-)PoAI\_Miner: picked into batch Bₖ
PoAI\_Miner->>PoAI\_Miner: run Mᵗ(prompt) → answer y
PoAI\_Miner->>PoAI\_Miner: generate zkLLM proof π
PoAI\_Miner-->>Esper\_L1: Block{k, π, y\_commit}
Esper\_L1->>zkLLM\_Verifier: Verify(π)
Esper\_L1-->>User/Agent: receipt + y (or ref if encrypted)" %}

*Gas* for `LLMCall` is **zero**; instead the caller burns *Compute Credits* (CC) that it accrues by staking ESP.

***

### Putting It All Together

* **zkLLM** turns “LLM answers” into *cryptographic work* you can audit in 10 ms.
* **Native LLM** interface (`LLMCall`) exposes that work *directly* to end-users with no RPC detour and no gas.

This triad—zkLLM + LLM-native transactions —makes Esperchain the first **self-securing AI compute commons**: every joule spent defending the chain *simultaneously* answers real user prompts and feeds the agentic economy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://esper.gitbook.io/esperchain-docs/architecture/proof-of-ai-consensus/zkllm-and-native-llm.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.
