github.com/MetalBlockchain/metalgo@v1.11.9/vms/secp256k1fx/input.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package secp256k1fx 5 6 import ( 7 "errors" 8 9 "github.com/MetalBlockchain/metalgo/utils" 10 "github.com/MetalBlockchain/metalgo/utils/math" 11 ) 12 13 const ( 14 CostPerSignature uint64 = 1000 15 ) 16 17 var ( 18 ErrNilInput = errors.New("nil input") 19 ErrInputIndicesNotSortedUnique = errors.New("address indices not sorted and unique") 20 ) 21 22 type Input struct { 23 // This input consumes an output, which has an owner list. 24 // This input will be spent with a list of signatures. 25 // SignatureList[i] is the signature of OwnerList[i] 26 SigIndices []uint32 `serialize:"true" json:"signatureIndices"` 27 } 28 29 func (in *Input) Cost() (uint64, error) { 30 numSigs := uint64(len(in.SigIndices)) 31 return math.Mul64(numSigs, CostPerSignature) 32 } 33 34 // Verify this input is syntactically valid 35 func (in *Input) Verify() error { 36 switch { 37 case in == nil: 38 return ErrNilInput 39 case !utils.IsSortedAndUniqueOrdered(in.SigIndices): 40 return ErrInputIndicesNotSortedUnique 41 default: 42 return nil 43 } 44 }