def checkmultisig(self): outputHash = self.transaction.hashOutput(self.input, self.output) threshold = DataType.bytesToInt(self.output.extraData) match = 0 publicKeys = self.input.witness[::2] multiSigAddressBytes = bytearray() for publicKey in publicKeys: multiSigAddressBytes.extend(publicKey) multiSigAddress = Crypto.generateAddress(multiSigAddressBytes) if multiSigAddress == self.output.address: signatures = self.input.witness[1::2] for public, signature in zip(publicKeys, signatures): if Crypto.verify(public, signature, outputHash): match += 1 self.stack.append(match >= threshold)
def checksig(self): public = self.pop() signature = self.pop() outputHash = self.transaction.hashOutput(self.input, self.output) self.stack.append(Crypto.verify(public, signature, outputHash))
def verify(self, signature, message): return Crypto.verify(self.public, signature, message)