-
Notifications
You must be signed in to change notification settings - Fork 669
/
input.go
44 lines (36 loc) · 1.01 KB
/
input.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
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package secp256k1fx
import (
"errors"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/math"
)
const (
CostPerSignature uint64 = 1000
)
var (
errNilInput = errors.New("nil input")
errNotSortedUnique = errors.New("signatures not sorted and unique")
)
type Input struct {
// This input consumes an output, which has an owner list.
// This input will be spent with a list of signatures.
// SignatureList[i] is the signature of OwnerList[i]
SigIndices []uint32 `serialize:"true" json:"signatureIndices"`
}
func (in *Input) Cost() (uint64, error) {
numSigs := uint64(len(in.SigIndices))
return math.Mul64(numSigs, CostPerSignature)
}
// Verify this input is syntactically valid
func (in *Input) Verify() error {
switch {
case in == nil:
return errNilInput
case !utils.IsSortedAndUniqueUint32(in.SigIndices):
return errNotSortedUnique
default:
return nil
}
}