Update ZKInputs for empty batches

- Add TestZKInputsEmpty circom test vectors
- Fix ZKInputsHash OldLastIdx bytearray
This commit is contained in:
arnaucube
2020-12-23 11:01:20 +01:00
parent a50bda3f59
commit 2583d35adf
3 changed files with 33 additions and 20 deletions

View File

@@ -431,8 +431,9 @@ func (z ZKInputs) ToHashGlobalData() ([]byte, error) {
// [MAX_NLEVELS bits] oldLastIdx
oldLastIdx := make([]byte, bytesMaxLevels)
copy(oldLastIdx, z.OldLastIdx.Bytes())
b = append(b, SwapEndianness(oldLastIdx)...)
oldLastIdxBytes := z.OldLastIdx.Bytes()
copy(oldLastIdx[len(oldLastIdx)-len(oldLastIdxBytes):], oldLastIdxBytes)
b = append(b, oldLastIdx...)
// [MAX_NLEVELS bits] newLastIdx
newLastIdx := make([]byte, bytesMaxLevels)