forked from TrueCloudLab/neoneo-go
emit: introduce CheckSig function
Which allows to create verification scripts without keys.PublicKey which is convenient in some cases where we already have serialized key and don't want to waste time decompressing it.
This commit is contained in:
parent
8983d25f7f
commit
bf3415e2bc
2 changed files with 9 additions and 3 deletions
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
|
@ -319,8 +318,7 @@ func (p *PublicKey) GetVerificationScript() []byte {
|
|||
buf.WriteB(0xAC) // CHECKSIG
|
||||
return buf.Bytes()
|
||||
}
|
||||
emit.Bytes(buf.BinWriter, b)
|
||||
emit.Syscall(buf.BinWriter, interopnames.SystemCryptoCheckSig)
|
||||
emit.CheckSig(buf.BinWriter, b)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
|
|
@ -219,6 +219,14 @@ func AppCall(w *io.BinWriter, scriptHash util.Uint160, operation string, f callf
|
|||
AppCallNoArgs(w, scriptHash, operation, f)
|
||||
}
|
||||
|
||||
// CheckSig emits a single-key verification script using given []bytes as a key.
|
||||
// It does not check for key correctness, so you can get an invalid script if the
|
||||
// data passed is not really a public key.
|
||||
func CheckSig(w *io.BinWriter, key []byte) {
|
||||
Bytes(w, key)
|
||||
Syscall(w, interopnames.SystemCryptoCheckSig)
|
||||
}
|
||||
|
||||
func isInstructionJmp(op opcode.Opcode) bool {
|
||||
return opcode.JMP <= op && op <= opcode.CALLL || op == opcode.ENDTRYL
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue