Esempio n. 1
0
def execute_zero_compare(prim: str, stack: MichelsonStack, stdout: List[str],
                         compare: Callable[[int], bool]):
    a = cast(IntType, stack.pop1())
    a.assert_type_equal(IntType)
    res = BoolType(compare(int(a)))
    stack.push(res)
    stdout.append(format_stdout(prim, [a], [res]))
Esempio n. 2
0
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     pk, sig, msg = cast(Tuple[KeyType, SignatureType, BytesType],
                         stack.pop3())
     pk.assert_type_equal(KeyType)
     sig.assert_type_equal(SignatureType)
     msg.assert_type_equal(BytesType)
     key = Key.from_encoded_key(str(pk))
     try:
         key.verify(signature=str(sig), message=bytes(msg))
     except ValueError:
         res = BoolType(False)
     else:
         res = BoolType(True)
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [pk, sig, msg], [res]))
     return cls()