示例#1
0
def verify64u(signature, message, verkey):
    """
    Returns True if signature is valid for message with respect to verification
    key verkey

    :param signature: base64 url-file safe encoded signature string
    :param message: json encoded unicode string of resource record
    :param verkey: base64 url-file safe encoded public key string
    :return: boolean True if valid False otherwise
    """
    sig = str64uToBytes(signature)
    vk = str64uToBytes(verkey)
    # msg = message.encode("utf-8")
    return verify(sig, message.encode(), vk)
示例#2
0
def testVerify():
    resource = b"message"
    vk, sk = ecdsa.generateByteKeys()
    vk = keys.VerifyingKey.from_string(vk, curves.SECP256k1)
    signature = str64uToBytes(ecdsa.signResource(resource, sk))

    assert ecdsa.verify(signature, resource, vk)
示例#3
0
def testSignResource64u():
    resource = "message"
    vk, sk = ecdsa.generate64uKeys()

    signature = ecdsa.signResource64u(resource, sk)

    assert str(signature) == signature
    assert len(signature) == 88
    assert len(str64uToBytes(signature)) == 64
示例#4
0
def signResource64u(resource, sk):
    """

    :param resource: string resource
    :param sk: base64 url-file safe private key
    :return: base64 url-file safe signature string
    """
    resource = resource.encode()
    sk = str64uToBytes(sk)

    return signResource(resource, sk)
示例#5
0
def testVerify():
    resource = b"message"
    vk, sk = eddsa.generateByteKeys()
    signature = str64uToBytes(eddsa.signResource(resource, sk))

    assert eddsa.verify(signature, resource, vk)