import json
from base64 import b64decode

from . import public_key

encoding = "utf-8"


def verify(payload: str, signature: str):
    public_key.verify(b64decode(signature), bytes(payload, encoding))
    payload = json.loads(str(b64decode(bytes(payload, encoding)), encoding))
    return payload
