Skip to content

Commit 7532438

Browse files
luangucunzquestz
authored andcommitted
bchec: use slices.SortFunc for MuSig key ordering
1 parent f6e9de6 commit 7532438

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

bchec/musig.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"math/big"
11-
"sort"
11+
"slices"
1212
)
1313

1414
// AggregatePublicKeys aggregates the given public keys using
@@ -28,8 +28,8 @@ func SignMuSig(hash []byte, keys ...*PrivateKey) (*Signature, error) {
2828
}
2929

3030
// Sort the private keys by their corresponding public keys
31-
sort.Slice(keys, func(i, j int) bool {
32-
return keys[i].PubKey().X.Cmp(keys[j].PubKey().X) < 0
31+
slices.SortFunc(keys, func(a, b *PrivateKey) int {
32+
return a.PubKey().X.Cmp(b.PubKey().X)
3333
})
3434

3535
pubkeys := make([]*PublicKey, 0, len(keys))
@@ -268,7 +268,7 @@ func calculateAggregateSignature(aggregateNonce *PublicKey, svals ...*big.Int) *
268268
}
269269

270270
func sortPubkeys(keys []*PublicKey) {
271-
sort.Slice(keys, func(i, j int) bool {
272-
return keys[i].X.Cmp(keys[j].X) < 0
271+
slices.SortFunc(keys, func(a, b *PublicKey) int {
272+
return a.X.Cmp(b.X)
273273
})
274274
}

0 commit comments

Comments
 (0)