# 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:

`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.`IS_RESULT`

indicates the last value of accumulated sum of ChainResult operations`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.`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.

### Constraints

The Sum Stark aims at constraining the following aspects:

`IS_INPUT`

and`IS_OUTPUT`

can be in range of {0, 1}

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

`ctl_previous_sum_equal_op1()`

prove that previous accumulated sum used as second operand in arithmetic operation.`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.

Last updated