Skip to content

Commit

Permalink
Merge pull request #79 from Indicio-tech/feature/add-multikey
Browse files Browse the repository at this point in the history
feat: add multikey vm
  • Loading branch information
dbluhm authored Oct 29, 2023
2 parents 513d317 + 1eb9f15 commit fe23872
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
8 changes: 8 additions & 0 deletions pydid/verification_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ class EcdsaSecp256k1RecoveryMethod2020(VerificationMethod):
)


class Multikey(VerificationMethod):
"""Multikey VerificationMethod."""

type: Literal["Multikey"]
public_key_multibase: str


class UnsupportedVerificationMethod(VerificationMethod):
"""Model representing unsupported verification methods."""

Expand All @@ -280,4 +287,5 @@ class UnknownVerificationMethod(VerificationMethod):
X25519KeyAgreementKey2020,
SchnorrSecp256k1VerificationKey2019,
EcdsaSecp256k1RecoveryMethod2020,
Multikey,
]
28 changes: 19 additions & 9 deletions tests/test_verification_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pydid.did_url import DIDUrl
from pydid.verification_method import (
Ed25519VerificationKey2018,
UnknownVerificationMethod,
VerificationMaterialUnknown,
VerificationMethod,
)
Expand Down Expand Up @@ -35,23 +36,23 @@
},
}
VMETHOD3 = {
"id": "did:example:123#keys-1",
"type": "Ed25519Signature2018",
"controller": "did:example:123",
"something": "random",
}
VMETHOD4 = {
"id": "did:example:1234#z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3",
"type": "Ed25519VerificationKey2020",
"controller": "did:example:1234",
"publicKeyMultibase": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
}
VMETHOD5 = {
VMETHOD4 = {
"id": "did:example:123#keys-1",
"type": "X25519KeyAgreementKey2020",
"controller": "did:example:123",
"publicKeyMultibase": "z6LSeRSE5Em5oJpwdk3NBaLVERBS332ULC7EQq5EtMsmXhsM",
}
VMETHOD5 = {
"id": "did:example:123#keys-1",
"type": "Multikey",
"controller": "did:example:123",
"publicKeyMultibase": "z6LSeRSE5Em5oJpwdk3NBaLVERBS332ULC7EQq5EtMsmXhsM",
}


VMETHODS = [VMETHOD0, VMETHOD1, VMETHOD2, VMETHOD3, VMETHOD4, VMETHOD5]
Expand Down Expand Up @@ -81,9 +82,9 @@ def test_serialization(vmethod_raw):
assert vmethod.id == DIDUrl.parse(vmethod_raw["id"])
assert vmethod.type == vmethod_raw["type"]
assert vmethod.controller == DID(vmethod_raw["controller"])
if vmethod.type != "Ed25519Signature2018":
assert vmethod.material
assert vmethod.material
assert vmethod.serialize() == vmethod_raw
assert not isinstance(vmethod, UnknownVerificationMethod)


@pytest.mark.parametrize("invalid_vmethod_raw", INVALID_VMETHODS)
Expand Down Expand Up @@ -202,6 +203,15 @@ def test_infer_material():
}
vmethod = VerificationMethod.deserialize(vmethod_raw)
assert vmethod.material == vmethod_raw["blockchainAccountId"]
vmethod_unknown_raw = {
"id": "did:example:123#keys-1",
"type": "Ed25519Signature2018",
"controller": "did:example:123",
"something": "random",
}
vmethod = VerificationMethod.deserialize(vmethod_unknown_raw)
with pytest.raises(VerificationMaterialUnknown):
vmethod.material


def test_method_type():
Expand Down

0 comments on commit fe23872

Please sign in to comment.