ZKInput with L2Txs compatible with circom circuits

- Til
  - update Til users BJJ key generation for better js tests
    compatibility
- Common
  - PoolL2Tx to L2Tx use AuxToIdx in case that ToIdx is 0
  - Update ZKInputs parameter descriptions
- TxProcessor
  - Fix AccumulatedFees in case that there is no CoordIdx for that token
  - Fix zki.NewExit usage
  - Use same order for AccumulatedFees & FeeIdx & FeePlanTokens
  - Add Nonce usage to ExitLeafs
  - Update TestZKInput6 and check its compatibility with circom Hermez
circuits
This commit is contained in:
arnaucube
2021-01-07 18:32:09 +01:00
parent b0e925fd71
commit b59710a149
10 changed files with 247 additions and 73 deletions

View File

@@ -36,14 +36,16 @@ func BJJCompressedTo256BigInts(pkComp babyjub.PublicKeyComp) [256]*big.Int {
// formatAccumulatedFees returns an array of [nFeeAccounts]*big.Int containing
// the balance of each FeeAccount, taken from the 'collectedFees' map, in the
// order of the 'orderTokenIDs'
func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderTokenIDs []*big.Int) []*big.Int {
// func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderTokenIDs []*big.Int) []*big.Int {
func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderTokenIDs []*big.Int, coordIdxs []common.Idx) []*big.Int {
accFeeOut := make([]*big.Int, len(orderTokenIDs))
for i := 0; i < len(orderTokenIDs); i++ {
for i := 0; i < len(accFeeOut); i++ {
accFeeOut[i] = big.NewInt(0)
}
for i := 0; i < len(coordIdxs); i++ {
tokenID := common.TokenIDFromBigInt(orderTokenIDs[i])
if _, ok := collectedFees[tokenID]; ok {
accFeeOut[i] = new(big.Int).Set(collectedFees[tokenID])
} else {
accFeeOut[i] = big.NewInt(0)
}
}
return accFeeOut