Skip to content

Commit 07ceb38

Browse files
committed
Sort identity preimages in messages
1 parent ee9d7a6 commit 07ceb38

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

rolling-shutter/keyperimpl/gnosis/newslot.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"math"
88
"math/big"
9+
"sort"
910

1011
"github.com/ethereum/go-ethereum/common"
1112
"github.com/jackc/pgx/v4"
@@ -297,7 +298,10 @@ func (kpr *Keyper) getDecryptionIdentityPreimages(
297298
}
298299
identityPreimages = append(identityPreimages, identityPreimage)
299300
}
300-
return identityPreimages, nil
301+
302+
sortedIdentityPreimages := sortIdentityPreimages(identityPreimages)
303+
304+
return sortedIdentityPreimages, nil
301305
}
302306

303307
func transactionSubmittedEventToIdentityPreimage(
@@ -325,3 +329,12 @@ func makeSlotIdentityPreimage(slot uint64) identitypreimage.IdentityPreimage {
325329

326330
return identitypreimage.IdentityPreimage(buf.Bytes())
327331
}
332+
333+
func sortIdentityPreimages(identityPreimages []identitypreimage.IdentityPreimage) []identitypreimage.IdentityPreimage {
334+
sorted := make([]identitypreimage.IdentityPreimage, len(identityPreimages))
335+
copy(sorted, identityPreimages)
336+
sort.Slice(sorted, func(i, j int) bool {
337+
return bytes.Compare(sorted[i], sorted[j]) < 0
338+
})
339+
return sorted
340+
}

0 commit comments

Comments
 (0)