StateDB ZKInputs generation compatible with circom

- Add SignatureConstant to L1Tx.TxCompressedData
- ZKInputs generation works initial version working and compatible with circom Hermez circuit
    - Lots of small updates for circuits compatibility
- Update version (with new changes) of `go-iden3-crypto` & `go-merkletree`
This commit is contained in:
arnaucube
2020-12-01 22:15:19 +01:00
parent d306f4890a
commit 80cbac24f9
13 changed files with 187 additions and 105 deletions

View File

@@ -107,12 +107,6 @@ func NewPoolL2Tx(poolL2Tx *PoolL2Tx) (*PoolL2Tx, error) {
// [ 32 bits ] signatureConstant // 4 bytes
// Total bits compressed data: 241 bits // 31 bytes in *big.Int representation
func (tx *PoolL2Tx) TxCompressedData() (*big.Int, error) {
// sigconstant
sc, ok := new(big.Int).SetString("3322668559", 10)
if !ok {
return nil, tracerr.Wrap(fmt.Errorf("error parsing SignatureConstant"))
}
amountFloat16, err := NewFloat16(tx.Amount)
if err != nil {
return nil, tracerr.Wrap(err)
@@ -141,8 +135,8 @@ func (tx *PoolL2Tx) TxCompressedData() (*big.Int, error) {
return nil, tracerr.Wrap(err)
}
copy(b[19:25], fromIdxBytes[:])
copy(b[25:27], []byte{0, 1}) // TODO this will be generated by the ChainID config parameter
copy(b[27:31], sc.Bytes())
copy(b[25:27], []byte{0, 0}) // TODO this will be generated by the ChainID config parameter
copy(b[27:31], SignatureConstantBytes[:])
bi := new(big.Int).SetBytes(b[:])
return bi, nil