# 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 %}
