Exemple #1
0
    def get_vk(self, output_type, dbg) -> str:
        """
        Get public key (as hex, code or pem)
        """
        if self.sk is None:
            raise IllegalStateException("Can't get key. No key created/loaded")

        if output_type is None:
            raise InvalidArgumentException("Invalid output type for public key.")
        elif output_type == 'hex':
            return self.get_vk_hex()
        elif output_type == 'code':
            return self.get_vk_code(dbg)
        elif output_type == 'pem':
            return self.get_vk_pem()
        else:
            raise InvalidArgumentException("Invalid argument. Can't get key")
Exemple #2
0
    def get_sk(self, output_type, dbg):
        """
        Get private key (as hex, code or pem)
        """
        if self.sk is None:
            raise IllegalStateException("Can't get key. No key created/loaded")

        if output_type is None:
            raise InvalidArgumentException("Invalid output type for private key.")
        elif output_type == 'hex':
            return self.get_sk_hex()
        elif output_type == 'code':
            raise InvalidArgumentException("Private key cannot be shown as code")
        elif output_type == 'pem':
            return self.sk.to_pem()
        else:
            raise InvalidArgumentException("Invalid argument. Can't get key")