Esempio n. 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)
Esempio n. 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"
Esempio n. 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"
Esempio n. 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
Esempio n. 5
0
def testVerify64u():
    resource = "message"
    vk, sk = eddsa.generate64uKeys()
    signature = eddsa.signResource64u(resource, sk)

    assert eddsa.verify64u(signature, resource, vk)