Ejemplo n.º 1
0
    def verify(self, signature: Union[str, bytes], message: Union[str, bytes]) -> bool:
        """Verify signature with public key."""
        if isinstance(signature, str):
            signature = utils.hex_str_to_bytes(signature)

        message = utils.ensure_bytes(message)

        return schnorr.verify(message, signature, self.keypair_bytes.public)
Ejemplo n.º 2
0
    def sign(self, message: bytes) -> bytes:
        """Sign bytes message with private key, return bytes"""
        if not self._private_key:
            raise RuntimeError("missing private key")

        message = utils.ensure_bytes(message)

        return schnorr.sign(message, self.keypair_bytes.private)
Ejemplo n.º 3
0
 def sign_str(self, message: str) -> str:
     """Sign bytes message with private key, return hex string"""
     message = utils.ensure_bytes(message)
     return utils.bytes_to_hex_str(self.sign(message))