TBD54566975 / web5-go

Apache License 2.0
10 stars 6 forks source link

Add JWA to the JWK when it's created or parsed from bytes #34

Closed mihai-chiorean closed 6 months ago

mihai-chiorean commented 6 months ago

taking the following DID doc as an example:

{
        "id": "did:dht:cwxob5rbhhu3z9x3gfqy6cthqgm6ngrh4k8s615n7pw11czoq4fy",
        "verificationMethod": [
        {
            "id": "did:dht:cwxob5rbhhu3z9x3gfqy6cthqgm6ngrh4k8s615n7pw11czoq4fy#0",
            "type": "JsonWebKey2020",
            "controller": "did:dht:cwxob5rbhhu3z9x3gfqy6cthqgm6ngrh4k8s615n7pw11czoq4fy",
            "publicKeyJwk": {
            "crv": "Ed25519",
            "kty": "OKP",
            "alg": "EdDSA",
            "kid": "0",
            "x": "ZR8A7IHnJ5v9-TFcDzI8cZfhGJzSj29LYutpKTLwdoo"
            }
        }
        ],
        "authentication": [
        "#0"
        ],
        "assertionMethod": [
        "#0"
        ],
        "capabilityInvocation": [
        "#0"
        ],
        "capabilityDelegation": [
        "#0"
        ]
    }

if we do PublicKeyToBytes and then BytesToPublicKey the result for the verification method would be missing the alg key. it would look like

{
    ...
    "publicKeyJwk": {
    "crv": "Ed25519",
    "kty": "OKP",
    "kid": "0",
    "x": "ZR8A7IHnJ5v9-TFcDzI8cZfhGJzSj29LYutpKTLwdoo"
    }
        ...
}