gnosis / dex-zksnarks

Code to generate snark proofs for batch auction result validation of the Gnosis d.exchange
46 stars 7 forks source link

Modeling balances as single array instead of array as structs #29

Closed fleupold closed 5 years ago

fleupold commented 5 years ago

When running the main snark with real data (output from the solver), I noticed that the balances were not updated correctly.

This is most likely due to pepper not handling structs with arrays well. Balances were modelled as an array of

struct Balance {
  field254 tokens[TOKEN]
}

where each struct itself contained a subarray of token balances for this account.

This diff changes balances to being a single array of field elements, with account i's token balance for t being stored at index i*TOKENS + t.

I updated the unit tests and verified that state transitions are applied correctly when running the main snark with real data inside pepper (adding that functionality will come in a separate PR).