# Sum proof

Maru volume sum proof via zk-STARKs enables efficient verification of any volume trades from a remote pools.

To prove volume of pool trades we need to add each value of sold token volume in receipts and prove that counted volume is correct. For this purpose we create SumStark using constraints and cross table lookups tables from SumStark and ArithmeticStark to prove correctness of each arithmetic addition of 256 bits elements.

### Circuit

**Private inputs** include data fields about each value of acummulated sum.

In execution trace we use such fields:&#x20;

* `IS_INPUT`  indicates where in row the initial value of accumulated sum.
* `IS_OUTPUT` indicates where in row the output of accumulated sum from previous operation will be as the operand in current row.&#x20;
* `IS_RESULT`  indicates the last value of accumulated sum of ChainResult operations&#x20;
* `ACUM_SUM` consists of 16 limbs that represent each 16 bit per column.
* `IS_PUBLIC` indicates where in row the public value of accumulated sum.
* `NOT_INIT` indicates where the first zero init value.
* `VALUE` indicates initial volume to be multiplied.
* `MULTIPLIER` is used to multiply the value to a consistent format, specifically, 18 digits after the decimal point.&#x20;
* `MULT_RESULT` indicates result of multiplication.
* `TOKEN_ID` indicates the ID of the token with the specified volume value.
* `CALCULATION_ID` indicates the ID of volume summation. &#x20;

### Constraints

The Sum Stark aims at constraining the following aspects: &#x20;

* `IS_INPUT` and `IS_OUTPUT` can be in range of {0, 1}&#x20;

The main idea of proving relies on CTL, where we build two function for CTL:&#x20;

* `ctl_previous_sum_equal_op1()` prove that previous accumulated sum used as second operand in arithmetic operation.&#x20;
* `ctl_acum_equals_result()` guarantees that acum sum columns have the exact values as result columns in arithmetic table.
* `ctl_mult_value()` ensures that `VALUE`, `MULTIPLIER`, `MULT_RESULT` columns contain the exact values in the Arithmetic STARK, where we prove the multiplication.
* `ctl_volume_value()` ensures that `VALUE` and `CALCULATION_ID` columns contain the exact values in the Data Stark.
* `ctl_token_id()` ensures that `TOKEN_ID` and `CALCULATION_ID` columns contain the exact values in the Data Stark.


---

# 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://maru-2.gitbook.io/maru/zk-implementation/schema/sum-proof.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.
