github.com/algorand/go-algorand-sdk@v1.24.0/types/signature.go (about) 1 package types 2 3 import ( 4 "golang.org/x/crypto/ed25519" 5 ) 6 7 // Signature is an ed25519 signature 8 type Signature [ed25519.SignatureSize]byte 9 10 // MultisigSubsig contains a single public key and, optionally, a signature 11 type MultisigSubsig struct { 12 _struct struct{} `codec:",omitempty,omitemptyarray"` 13 14 Key ed25519.PublicKey `codec:"pk"` 15 Sig Signature `codec:"s"` 16 } 17 18 // MultisigSig holds multiple Subsigs, as well as threshold and version info 19 type MultisigSig struct { 20 _struct struct{} `codec:",omitempty,omitemptyarray"` 21 22 Version uint8 `codec:"v"` 23 Threshold uint8 `codec:"thr"` 24 Subsigs []MultisigSubsig `codec:"subsig"` 25 } 26 27 // Blank returns true iff the msig is empty. We need this instead of just 28 // comparing with == MultisigSig{}, because Subsigs is a slice. 29 func (msig MultisigSig) Blank() bool { 30 if msig.Version != 0 { 31 return false 32 } 33 if msig.Threshold != 0 { 34 return false 35 } 36 if msig.Subsigs != nil { 37 return false 38 } 39 return true 40 } 41 42 // LogicSig contains logic for validating a transaction. 43 // LogicSig is signed by an account, allowing delegation of operations. 44 // OR 45 // LogicSig defines a contract account. 46 type LogicSig struct { 47 _struct struct{} `codec:",omitempty,omitemptyarray"` 48 49 // Logic signed by Sig or Msig 50 // OR hashed to be the Address of an account. 51 Logic []byte `codec:"l"` 52 53 // The signature of the account that has delegated to this LogicSig, if any 54 Sig Signature `codec:"sig"` 55 56 // The signature of the multisig account that has delegated to this LogicSig, if any 57 Msig MultisigSig `codec:"msig"` 58 59 // Args are not signed, but checked by Logic 60 Args [][]byte `codec:"arg"` 61 } 62 63 // Blank returns true iff the lsig is empty. We need this instead of just 64 // comparing with == LogicSig{}, because it contains slices. 65 func (lsig LogicSig) Blank() bool { 66 if lsig.Args != nil { 67 return false 68 } 69 if len(lsig.Logic) != 0 { 70 return false 71 } 72 if !lsig.Msig.Blank() { 73 return false 74 } 75 if lsig.Sig != (Signature{}) { 76 return false 77 } 78 return true 79 }