Issue a Self-proclaimed Credential

A self-pro-claimed credential is a credential issued by the users themselves for self-declaration of specific information. An example of creating self-pro-claimed credentials is as follows:

let store: DIDStore =... // an opened DIDStore instance
let storePasswd = "secret"
let did = try DID("did:elastos:iaurnSo71QStq2vXdJCWiqXYZWmR499pjn")
let doc = try store.loadDid(doc)
let selfIssuer = try VerifiableCredentialIssuer(doc)
// Create a credential builder for self-proclaimed credential
let cb = try selfIssuer.editingVerifiableCredentialFor(did: did)
// Create the credential
let vc = cb.withId("#profile")
    .withType("EmailCredential", "")
    .withType("SocialCredential", "")
    .withProperties("name", "John")
    .withProperties("gender", "Male")
    .withProperties("nationality", "Singapore")
    .withProperties("email", "")
    .withProperties("twitter", "@john")
    .seal(using: storePasswd)
// Save the credential to the store for later usage
try store.storeCredential(using: vc)

The credential issued by the customized DID is the same as that issued by the ordinary DID.

Last updated