-
Notifications
You must be signed in to change notification settings - Fork 643
/
signature.go
33 lines (25 loc) · 921 Bytes
/
signature.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package spdagvm
import (
"sort"
"github.com/ava-labs/gecko/utils"
"github.com/ava-labs/gecko/utils/crypto"
)
// Sig is a signature on a transaction
type Sig struct {
index uint32
sig []byte
parsedPubKey []byte
}
// InputSigner stores the keys used to sign an input
type InputSigner struct {
Keys []*crypto.PrivateKeySECP256K1R
}
type sortTxSig []*Sig
func (tsp sortTxSig) Less(i, j int) bool { return tsp[i].index < tsp[j].index }
func (tsp sortTxSig) Len() int { return len(tsp) }
func (tsp sortTxSig) Swap(i, j int) { tsp[j], tsp[i] = tsp[i], tsp[j] }
// SortTxSig sorts the tx signature list by index
func SortTxSig(sigs []*Sig) { sort.Sort(sortTxSig(sigs)) }
func isSortedAndUniqueTxSig(sig []*Sig) bool { return utils.IsSortedAndUnique(sortTxSig(sig)) }