"""
    密码标签生成与验证功能
"""
from watermark_verify.tools import sign_verify


def generate_secret_label(raw_data: str):
    """
    生成密码标签
    :param raw_data: 模型版权信息
    :return: 指定格式密码标签字符串
    """
    sign_data, public_key = sign_verify.get_sign(raw_data)
    secret_label = f"{raw_data}.{sign_data}"
    return secret_label, public_key


def verify_secret_label(secret_label: str, public_key: str) -> bool:
    """
    验证密码标签
    :param secret_label: 生成的密码标签
    :param public_key: 签名公钥
    :return: 密码标签验证结果
    """
    parts = secret_label.split('.')
    if len(parts) != 2:
        return False
    raw_data = parts[0]
    sign_data = parts[1]
    verify_result = sign_verify.verify_sign(raw_data, sign_data, public_key)
    return verify_result
