API-of-Me
Search…
⌃K

DID Create

How to create a DID KEY, WEB & INDY using client secret mode

Create DID KEY

Meeco API

Guide using the Meeco API

Generate Keypair for DID KEY

Create a new DID controller keypair (Ed25519) using openssl:
**NOTE: make sure you have openssl & GNU coreutils installed and avalible on command line (e.g. brew install coreutils)
openssl genpkey -algorithm ed25519 -outform DER >privkey
openssl pkey -in privkey -pubout -out pubkey -inform DER -outform DER
Convert DID controller public key to Base64URL:
cat pubkey| tail -c +13| basenc --base64url

API request

Call DID Create API with following payload to create new DID KEY
Request with above generated pubkey base64url string
curl -H "Authorization: Bearer TOKEN" \
-X POST "https://identity-network-dev.meeco.me/did/create?method=key" \
-H "Content-Type: application/json" \
-d '{
"options": {
"clientSecretMode": true
},
"secret": { },
"didDocument": {
"@context": ["https//www.w3.org/ns/did/v1"],
"verificationMethod": [{
"id": "#temp",
"type": "JsonWebKey2020",
"publicKeyJwk": {
"kty": "OKP",
"crv": "Ed25519",
"x": "{Replace_With_Above_Generated_Base64URL_String}"
}
}]
}
}'
Response with DID Identifier
{
....
....
"state": "finished",
"did": "{New_DID_KEY_Identifier}",
....
....
}
Resolve DID
curl -X 'GET' \
'https://identity-network-dev.meeco.me/did/{Replace_With_DID_KEY_Identifier}' \
-H 'accept: application/ld+json;profile="https://w3id.org/did-resolution"'

Meeco JS SDK

Guide using the Meeco JS SDK

For SDK installation & basic usage, visit SDK-Demo sample application SDK-JS-DEMO

Create a new DID controller keypair (Ed25519)
const array = new Uint8Array(32);
const secret = self.crypto.getRandomValues(array);
const keyPair = new Ed25519(secret);
console.log(`public key hex: ${keyPair.getPublicKeyHex()}`);
console.log(`private key hex: ${keyPair.keyPair.getSecret('hex')}`);
Create new DID KEY
let did: DIDBase = new DIDKey(keyPair);
const environment = new Environment({
vault: {
url: '',
subscription_key: '',
},
keystore: {
url: '',
subscription_key: '',
provider_api_key: '',
},
identityNetwork: {
url: '{identity-network-url}',
subscription_key: '{subsription-key}',
},
});
const api = new DIDManagementService(environment);
const generatedDID = await api.create({}, did);
console.log(generatedDID);
Resolve DID
const result = await api.resolve({}, identifier);
console.log(result);

Create DID WEB

Meeco API

Guide using the Meeco API

Generate Keypair for DID WEB

Create a new DID controller keypair (Ed25519) using openssl: **NOTE: make sure you have openssl & GNU coreutils installed and avalible on command line (e.g. brew install coreutils)
openssl genpkey -algorithm ed25519 -outform DER >privkey
openssl pkey -in privkey -pubout -out pubkey -inform DER -outform DER
Convert DID controller public key to base58:
cat pubkey| tail -c +13| base58

API request

Call DID Create API with following payload to create new DID WEB
Request with above generated pubkey base58 string
curl -H "Authorization: Bearer TOKEN" \
-X POST "https://identity-network-dev.meeco.me/did/create?method=web" \
-H "Content-Type: application/json" \
-d '{
"options": {
"clientSecretMode": false
},
"didDocument": {
"verificationMethod": [
{
"id": "did:web:did-web-meeco.me:{Replace_With_Above_Generated_Base58_String}#key-1",
"type": "Ed25519VerificationKey2018",
"publicKeyBase58": "{Replace_With_Above_Generated_Base58_String}"
}
],
"service": [
{
"type": "LinkedDomains",
"serviceEndpoint": "meeco.me"
}
],
"authentication": [
"did:web:did-web-meeco.me:{Replace_With_Above_Generated_Base58_String}#key-1"
],
"assertionMethod": [
"did:web:did-web-meeco.me:{Replace_With_Above_Generated_Base58_String}#key-1"
]
}
}'
Response with DID Identifier
{
....
....
{
"didState": {
"state": "finished",
"did": "{DID_WEB_Identifier}"
},
....
....
}
Resolve DID
curl -X 'GET' \
'https://identity-network-dev.meeco.me/did/{Replace_With_DID_WEB_Identifier}' \
-H 'accept: application/ld+json;profile="https://w3id.org/did-resolution"'

Meeco JS SDK

Guide using the Meeco JS SDK

For SDK installation & basic usage, visit SDK-Demo sample application SDK-JS-DEMO

Create a new DID controller keypair (Ed25519)
const array = new Uint8Array(32);
const secret = self.crypto.getRandomValues(array);
const keyPair = new Ed25519(secret);
console.log(`public key hex: ${keyPair.getPublicKeyHex()}`);
console.log(`private key hex: ${keyPair.keyPair.getSecret('hex')}`);
Create new DID KEY
const did: DIDWeb = new DIDWeb(keyPair);
const verificationMethodId = did.setVerificationMethod();
did
.setAssertionMethod(verificationMethodId)
.setAuthentication(verificationMethodId);
did.didDocument.service = [
{
type: 'LinkedDomains',
serviceEndpoint: 'meeco.me',
},
];
const environment = new Environment({
vault: {
url: '',
subscription_key: '',
},
keystore: {
url: '',
subscription_key: '',
provider_api_key: '',
},
identityNetwork: {
url: '{identity-network-url}',
subscription_key: '{subsription-key}',
},
});
const api = new DIDManagementService(environment);
const generatedDID = await api.create({}, did);
console.log(generatedDID);
Resolve DID
const result = await api.resolve({}, identifier);
console.log(result);

Create DID Indy

Meeco API

Guide using the Meeco API

Generate Keypair for DID Indy

Create a new DID controller keypair (Ed25519) using openssl:
openssl genpkey -algorithm ed25519 -outform DER >privkey
openssl pkey -in privkey -pubout -out pubkey -inform DER -outform DER
Convert DID controller public key to base58:
cat pubkey| tail -c +13| base58

API request

Call DID Create API with following payload to create new DID Indy

Step 1

Request with above generated pubkey base58 string & ledger network danube
curl -H "Authorization: Bearer TOKEN" \
-X POST "https://identity-network-dev.meeco.me/did/create?method=indy" \
-H "Content-Type: application/json" \
-d '{
"options": {
"clientSecretMode": true,
"network": "danube"
},
"secret": { },
"didDocument": {
"@context": ["https//www.w3.org/ns/did/v1"],
"verificationMethod": [{
"id": "#key-1",
"type": "Ed25519VerificationKey2018",
"publicKeyBase58": "{Replace_With_Above_Generated_Base58_String}"
}],
"service": [{
"id": "#testServiceId",
"type": "LinkedDomains",
"serviceEndpoint": "https://meeco.me/"
}]
}
}'
Response with action signPayload - signing Request Nym [Transaction on Ledger]
{
"jobId": "{JOB_ID}",
"didState": {
"state": "action",
"action": "signPayload",
"signingRequest": {
"signingRequestNym": {
"kid": "#key-1",
"alg": "EdDSA",
"purpose": "authentication",
"payload": { ... },
"serializedPayload": "<-- base 64 encoded -->"
}
}
},
"didRegistrationMetadata": { ... },
"didDocumentMetadata": { ... }
}

Step 2

decode base64 serializedPayload payload from above resonse
echo "<-- base64 encoded -->"|base64 -d >payload
sign payload with Transaction Endorser private key
openssl pkeyutl -sign -rawin -in payload -inkey privkey -keyform DER| base64| tr -d '\n' >signature
curl -H "Authorization: Bearer TOKEN" \
-X POST "https://identity-network-dev.meeco.me/did/create?method=indy" \
-H "Content-Type: application/json" \
-d '{
"jobId": "{JOB_ID_From_Previous_Response}",
"options": {
"clientSecretMode": true
},
"secret": {
"signingResponse": {
"signingRequestNym": {
"signature": "<-- base64 encoded signature-->"
}
}
},
"didDocument": { }
}'
Response with action signPayload - signing Request Attribute
{
"jobId": "{JOB_ID}",
"didState": {
"state": "action",
"action": "signPayload",
"signingRequest": {
"signingRequestAttrib": {
"kid": "#key-1",
"alg": "EdDSA",
"purpose": "authentication",
"payload": { ... },
"serializedPayload": "<-- base 64 encoded -->"
}
}
},
"didRegistrationMetadata": { ... },
"didDocumentMetadata": { ... }
}

Step 3

decode base64 serializedPayload payload from above resonse
echo "<-- base64 encoded -->"|base64 -d >payload
sign payload with DID controller private key
openssl pkeyutl -sign -rawin -in payload -inkey privkey -keyform DER| base64| tr -d '\n' >signature
curl -H "Authorization: Bearer TOKEN" \
-X POST "https://identity-network-dev.meeco.me/did/create?method=indy" \
-H "Content-Type: application/json" \
-d '{
"jobId": "{JOB_ID_From_Previous_Response}",
"options": {
"clientSecretMode": true
},
"secret": {
"signingResponse": {
"signingRequestAttrib": {
"signature": "<-- base64 encoded -->"
}
}
},
"didDocument": { }
}'
final response
....
"didState": {
"state": "finished",
"did": "{DID_WEB_Identifier}",
....
Resolve DID
curl -X 'GET' \
'https://identity-network-dev.meeco.me/did/{Replace_With_DID_WEB_Identifier}' \
-H 'accept: application/ld+json;profile="https://w3id.org/did-resolution"'

Meeco JS SDK

Guide using the Meeco JS SDK

For SDK installation & basic usage, visit SDK-Demo sample application SDK-JS-DEMO

Create a new DID controller keypair (Ed25519)
const array = new Uint8Array(32);
const secret = self.crypto.getRandomValues(array);
const keyPair = new Ed25519(secret);
console.log(`public key hex: ${keyPair.getPublicKeyHex()}`);
console.log(`private key hex: ${keyPair.keyPair.getSecret('hex')}`);
Create new DID KEY
const did = new DIDIndy(keyPair);
did.didDocument.service = [
{
type: 'LinkedDomains',
serviceEndpoint: 'meeco.me',
},
];
const environment = new Environment({
vault: {
url: '',
subscription_key: '',
},
keystore: {
url: '',
subscription_key: '',
provider_api_key: '',
},
identityNetwork: {
url: '{identity-network-url}',
subscription_key: '{subsription-key}',
},
});
const api = new DIDManagementService(environment);
const generatedDID = await api.create({}, did);
console.log(generatedDID);
Resolve DID
const result = await api.resolve({}, identifier);
console.log(result);