dyne / restroom-mw

🛠 Easy REST API builder executing Zencode
https://restroom.dyne.org
GNU Affero General Public License v3.0
3 stars 11 forks source link

Statement to retrieve DID Documents #261

Closed andrea-dintino closed 8 months ago

andrea-dintino commented 1 year ago

Since the W3C-DID method are (kinda) standardize, it should be easy to have a statement that resolves a DID (or at least just for did:dyne DIDs), this can come in handy in plenty of situations. Something like:

Given I resolve the did named 'myDid' and store into 'didDocument'

Input:

{
"myDid": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB"
}

Output:

{
    "didDocument": {
        "@context": "https://w3id.org/did-resolution/v1",
        "didDocument": {
            "@context": [
                "https://www.w3.org/ns/did/v1",
                "https://w3id.org/security/suites/ed25519-2018/v1",
                "https://w3id.org/security/suites/secp256k1-2019/v1",
                "https://w3id.org/security/suites/secp256k1-2020/v1",
                "https://dyne.github.io/W3C-DID/specs/ReflowBLS12381.json",
                {
                    "description": "https://schema.org/description",
                    "url": "https://schema.org/url"
                }
            ],
            "description": "test_oracle_5",
            "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
            "proof": {
                "created": "1686927477135",
                "jws": "eyJhbGciOiJFUzI1NksiLCJiNjQiOnRydWUsImNyaXQiOiJiNjQifQ..Ocxj61LEnM23RO7rHw-owtJ9_cSeDtWf733AfCwMO9zFJyIl5DIjmanrAvb9DnHns8oxEeFT5wGWEwB-QfYgAA",
                "proofPurpose": "assertionMethod",
                "type": "EcdsaSecp256k1Signature2019",
                "verificationMethod": "did:dyne:sandbox.zenswarm_A:DZmuSi2WgdsN8Usbbw4ZF4cZfF31ecqzPRHwP6GnxNE4#ecdh_public_key"
            },
            "url": "https://oracle5.zenswarm.forkbomb.eu/",
            "verificationMethod": [
                {
                    "controller": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB#ecdh_public_key",
                    "publicKeyBase58": "R6fNF9TUiVts3hgTZ2rMvz7sYLrt9XHwiV588jmya5n37vD2S2HyrvDwxANJu8C3AMvZFzmoc5vhoA9Yh3Rf5rJD",
                    "type": "EcdsaSecp256k1VerificationKey2019"
                },
                {
                    "controller": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB#reflow_public_key",
                    "publicKeyBase58": "2kdSPmjEqCKYNNATdj9Qk8r13obceX5QdRbk4BEY9cWat8aDC4Qa63er5TRwQkeKYX79aUY4Hexz9jcWWqTEmpug6dmrAAF5xH8ueg46yA46a72riZm7nq93JZcx9oxu8KnrXBHEVP1zjBAijf3FbpefNqBYfqobwEj7gP9C5fdJipiFWZKmLFzguPzzbuStNSTWQSXoZgWSCQJCf2wsDJ5onG8wWgQat3T9vnUXiYdhjAc1mRoDGCrX97dpdwuAGuQDaG",
                    "type": "ReflowBLS12381VerificationKey"
                },
                {
                    "controller": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB#bitcoin_public_key",
                    "publicKeyBase58": "dsxu7c6YzFvqi4TgnXtiKmtwiXHebncCCxcXFFU2HAMD",
                    "type": "EcdsaSecp256k1VerificationKey2019"
                },
                {
                    "controller": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB#eddsa_public_key",
                    "publicKeyBase58": "HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "type": "Ed25519VerificationKey2018"
                },
                {
                    "blockchainAccountId": "eip155:1:0x0af5d8fd63f94b3faa8af0e0d028c1f7a5ae2544",
                    "controller": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB",
                    "id": "did:dyne:sandbox.zenswarm:HwSjX94eXVmVpqGnN6L5HD3rjSBwxJeNc9xByJKB83wB#ethereum_address",
                    "type": "EcdsaSecp256k1RecoveryMethod2020"
                }
            ]
        },
        "didDocumentMetadata": {
            "created": "1686927477135",
            "deactivated": "false"
        }
    }
}
matteo-cristino commented 1 year ago

This can be done by using the universal resolver, it is not working at the moment but it seems a simply GET to

https://dev.uniresolver.io/1.0/identifiers/*did*
andrea-dintino commented 1 year ago

For now I think it's enough that we resolve did:dyne What you mention, it's something we should look at in the near future :-)

matteo-cristino commented 1 year ago

We can perform a GET from https://dev.uniresolver.io/1.0/identifiers/*did* and in case of failure, if the did starts with did:dyne: then we can perform a GET from https://did.dyne.org/dids/*did* in this way it can work with all DIDs and even if the universarl resolver is down we can still resolve our DIDs

matteo-cristino commented 11 months ago

Statement:

Given I resolve the did 'my_did' from 'my_url' and save the output into 'my_variable'