Exemplo n.º 1
0
 def verify_by_hash(self, msg_hash: bytes, signature: bytes) -> int:
     if len(msg_hash) != 64:
         raise ValueError("the length of SHA512 Hash(Bytes) must be 64")
     if len(signature) != 64:
         raise ValueError("the length of signature(Bytes) must be 64")
     return funcs.CDLL_WalletVerifyByHash(self._handler_num, 0,
                                          GoBytes.frombytes(signature),
                                          GoBytes.frombytes(msg_hash))
Exemplo n.º 2
0
 def verify_by_raw(self, msg: bytes, signature: bytes) -> int:
     if len(signature) != 64:
         raise ValueError("the length of signature(Bytes) must be 64")
     print(msg, len(msg),
           GoBytes.convert(GoBytes.frombytes(signature), 64).hex())
     return funcs.CDLL_WalletVerifyByRaw(self._handler_num, 0,
                                         GoBytes.frombytes(signature),
                                         GoBytes.frombytes(msg), len(msg))
Exemplo n.º 3
0
 def sign_hash(self, msg_hash: bytes) -> bytes or None:
     if len(msg_hash) != 64:
         raise ValueError("the length of SHA512 Hash(Bytes) must be 64")
     ptr = funcs.CDLL_WalletSign(self._handler_num, 0,
                                 GoBytes.frombytes(msg_hash))
     if ptr is None:
         return
     return GoBytes.convert(ptr, 64)
Exemplo n.º 4
0
 def sign(self, msg: bytes) -> bytes or None:
     ptr = funcs.CDLL_WalletSign(self._handler_num, 0,
                                 GoBytes.frombytes(msg), len(msg))
     if ptr is None:
         return
     return GoBytes.convert(ptr, 64)
Exemplo n.º 5
0
 def address(self, idx=0):
     ptr = funcs.CDLL_WalletAddress(self._handler_num, idx)
     if ptr is None:
         return
     return GoBytes.convert(ptr, 32)