vm: dont use SetCheckedHash outside of vm package

This commit is contained in:
Evgenii Stratonikov 2020-04-17 17:03:07 +03:00
parent 941410a840
commit 4740d937aa
2 changed files with 7 additions and 8 deletions

View file

@ -43,8 +43,7 @@ func ECDSACheckMultisig(ic *interop.Context, v *vm.VM) error {
if len(pkeys) < len(sigs) { if len(pkeys) < len(sigs) {
return errors.New("more signatures than there are keys") return errors.New("more signatures than there are keys")
} }
v.SetCheckedHash(hashToCheck) sigok := vm.CheckMultisigPar(v, hashToCheck, pkeys, sigs)
sigok := vm.CheckMultisigPar(v, pkeys, sigs)
v.Estack().PushVal(sigok) v.Estack().PushVal(sigok)
return nil return nil
} }

View file

@ -1232,7 +1232,7 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
panic("VM is not set up properly for signature checks") panic("VM is not set up properly for signature checks")
} }
sigok := CheckMultisigPar(v, pkeys, sigs) sigok := CheckMultisigPar(v, v.checkhash, pkeys, sigs)
v.estack.PushVal(sigok) v.estack.PushVal(sigok)
case opcode.NEWMAP: case opcode.NEWMAP:
@ -1419,9 +1419,9 @@ func (v *VM) getJumpOffset(ctx *Context, parameter []byte, mod int) int {
} }
// CheckMultisigPar checks if sigs contains sufficient valid signatures. // CheckMultisigPar checks if sigs contains sufficient valid signatures.
func CheckMultisigPar(v *VM, pkeys [][]byte, sigs [][]byte) bool { func CheckMultisigPar(v *VM, h []byte, pkeys [][]byte, sigs [][]byte) bool {
if len(sigs) == 1 { if len(sigs) == 1 {
return checkMultisig1(v, pkeys, sigs[0]) return checkMultisig1(v, h, pkeys, sigs[0])
} }
k1, k2 := 0, len(pkeys)-1 k1, k2 := 0, len(pkeys)-1
@ -1446,7 +1446,7 @@ func CheckMultisigPar(v *VM, pkeys [][]byte, sigs [][]byte) bool {
result <- verify{ result <- verify{
signum: t.signum, signum: t.signum,
ok: t.pub.Verify(sigs[t.signum], v.checkhash), ok: t.pub.Verify(sigs[t.signum], h),
} }
} }
} }
@ -1511,10 +1511,10 @@ loop:
return sigok return sigok
} }
func checkMultisig1(v *VM, pkeys [][]byte, sig []byte) bool { func checkMultisig1(v *VM, h []byte, pkeys [][]byte, sig []byte) bool {
for i := range pkeys { for i := range pkeys {
pkey := v.bytesToPublicKey(pkeys[i]) pkey := v.bytesToPublicKey(pkeys[i])
if pkey.Verify(sig, v.checkhash) { if pkey.Verify(sig, h) {
return true return true
} }
} }