Access the DID Document

Read the Document

DIDDocument mainly describes the key information of DID and the information it needs to disclose. In general, the content of DIDDocument is divided into the following categories:

  • Public Keys

    • Authentication keys

    • Authorization keys

  • Controllers

  • Multiple-Signature

  • VeriableCredentials

  • Services

  • Expiration date

  • Document proof

Different DIDs may use a subset of these attributes.VeriableCredentials is Elastos DID’s extension of W3C DID. In principle, the DID document should not contain any personal information because it's public and can be read all over the world once published. However, since some public entities hope to disclose specific entity information, verifiable credentials containing entity information can be embedded into the DID document for disclosure.

DIDDocument is read-only because it's a sealed object included by the signature of the controller. Swift’s DIDDocument implementation provides a series of methods to read the information included in DIDDocument.

Sign and Verify Data with DID

The DID object not only represents and verifies the identity, but also signs and verifies the application data.

Data about the Signature of the DID Controller

let store: DIDStore = ... // an opened DIDStore instance
let storePasswd = "secret";
let did = try DID("did:elastos:idFKwBpj3Buq3XbLAFqTy8LMAW8K7kp3Ab")
var data: Data  // the data to be sign and verify
// Get the existing DIDDocument
let doc = try store.loadDid(did)
let signature = try doc.sign(using: doc, for: data)

The controller can submit the data and digital signature generated by DID to a third party, and the third party can then verify whether the data matches the signature.

The Third Party Verifies the Data and Signature

let did = try DID("did:elastos:iXyYFboFAd2d9VmfqSvppqg1XQxBtX9ea2") // signer‘s DID
var data: Data // the data to be verify
let signature: String // the signature signed by signer
let doc = try did.resolve()
if try doc.isValid() {
let genuine = try doc.verify(signature: signature, onto: data)
} else {
// Signer's DID is invalid, should report error.

Last updated