Beispiel #1
0
def testValidateSignedResource():
    resource = '{"1":"test"}'
    vk, sk = eddsa.generate64uKeys()
    signature = eddsa.signResource64u(resource, sk)

    # returns parsed json if signature is valid
    parsedResource = eddsa.validateSignedResource(signature, resource, vk)

    assert parsedResource == json.loads(resource)
Beispiel #2
0
def testValidateSignedResourceInvalidSignature():
    resource = '{"1":"test"}'
    vk, sk = eddsa.generate64uKeys()
    signature = eddsa.signResource64u(resource, sk)

    with pytest.raises(didering.ValidationError) as ex:
        eddsa.validateSignedResource(signature, b'{"1":"tes"}', vk)

        assert ex.value == "Unverifiable signature"
Beispiel #3
0
def testValidateSignedResourceInvalidJson():
    resource = "message"
    vk, sk = eddsa.generate64uKeys()
    signature = eddsa.signResource64u(resource, sk)

    with pytest.raises(didering.ValidationError) as ex:
        eddsa.validateSignedResource(signature, resource, vk)

        assert ex.value == "Invalid JSON"
Beispiel #4
0
def testSignResource64u():
    resource = "message"
    vk, sk = eddsa.generate64uKeys()

    signature = eddsa.signResource64u(resource, sk)

    assert str(signature) == signature
    assert len(signature) == 88
    assert len(str64uToBytes(signature)) == 64
Beispiel #5
0
def testVerify64u():
    resource = "message"
    vk, sk = eddsa.generate64uKeys()
    signature = eddsa.signResource64u(resource, sk)

    assert eddsa.verify64u(signature, resource, vk)