# Gas Cost Analysis

## Aggregation Cost

The cost of verifying aggregated user proofs in a Gnark Groth16 super-proof system can be broken down as follows:

1. Base cost: `~380,000 Gas` for verifying the super-proof on-chain.
2. Per-proof cost: `0 Gas` for processing and state updates per individual proof aggregated.

The gas cost formula for aggregation per proof turns out to be:

$$
C\_{agg\_per\_proof} = \~(380,000)/n
$$

## Verification Access Cost

Users can verify that a certain zk-proof, corresponding to specific public inputs, is included in the superproof. This verification is done through a cross-contract call, as described in the integration docs. The gas cost for this verification process is approximately `16,000 Gas` per call.

## Total Cost Per Proof

The total cost of verifying each proof in an aggregated system consists of two components:

1. Fixed Cost: `16,000 Gas` This cost remains constant per proof, regardless of the number of proofs aggregated.
2. Diminishing Cost: `(380,000 / n) Gas`  Where n is the number of proofs aggregated in a single superproof. This cost decreases as the number of aggregated proofs increases.

$$
total\_ cost\_ per\_proof = fixed\_cost + diminishing\_cost = 16,000 + (380,000/ n) Gas
$$

{% hint style="info" %}
Key Point: The Diminishing Cost represents an economy of scale – the more proofs aggregated into a single superproof, the lower the per-proof cost for this component.
{% endhint %}


---

# 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.electron.dev/quantum-proof-aggregation-for-ethereum/gas-cost-analysis.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.
