<li><codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> is an on-chain public key hash (e.g. a Bitcoin address).</li>
<li><codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> refers to the <codeclass="highlighter-rouge">nth</code> name this address created.</li>
</ul>
<p>For example, the DID for <codeclass="highlighter-rouge">personal.id</code> is
<codeclass="highlighter-rouge">did:stack:v0:1dARRtzHPAFRNE7Yup2Md9w18XEQAtLiV-0</code>, because the name
<codeclass="highlighter-rouge">personal.id</code> was the first-ever name created by
<p>As another example, the DID for <codeclass="highlighter-rouge">jude.id</code> is <codeclass="highlighter-rouge">did:stack:v0:16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg-1</code>.
Here, the address <codeclass="highlighter-rouge">16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg</code> had created one earlier
name in history prior to this one (which happens to be <codeclass="highlighter-rouge">abcdefgh123456.id</code>).</p>
<p>The purpose of a DID is to provide an eternal identifier for a public key.
The public key may change, but the DID will not.</p>
<p>Blockstack Core implements a DID method of its own
in order to be compatible with other systems that use DIDs for public key resolution.
In order for a DID to be resolvable, all of the following must be true for a
name:</p>
<ul>
<li>The name must exist</li>
<li>The name’s zone file hash must be the hash of a well-formed DNS zone file</li>
<li>The DNS zone file must be present in the BNS <ahref="atlas_network.md">Atlas Network</a></li>
<li>The DNS zone file must contain a <codeclass="highlighter-rouge">URI</code> resource record that points to a signed
JSON Web Token</li>
<li>The public key that signed the JSON Web Token (and is included with it) must
hash to the address that owns the name</li>
</ul>
<p>Not all names will have DIDs that resolve to public keys. However, names created by the <ahref="https://github.com/blockstack/blockstack-browser">Blockstack
Browser</a> will have DIDs that
do.</p>
<p>Developers can programmatically resolve DIDs via the Python API:</p>
<p>Every name and subdomain in BNS has a DID. The encoding is slightly different
for subdomains, so the software can determine which code-path to take.</p>
<ul>
<li>
<p>For on-chain BNS names, the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> is the same as the Bitcoin address
that owns the name. Currently, both version byte 0 and version byte 5
addresses are supported (i.e. addresses starting with <codeclass="highlighter-rouge">1</code> or <codeclass="highlighter-rouge">3</code>, meaning <codeclass="highlighter-rouge">p2pkh</code> and
<p>For off-chain BNS subdomains, the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> has version byte 63 for
subdomains owned by a single private key, and version byte 50 for subdomains
owned by a m-of-n set of private keys. That is, subdomain DID addresses start
with <codeclass="highlighter-rouge">S</code> or <codeclass="highlighter-rouge">M</code>, respectively.</p>
</li>
</ul>
<p>The <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> field for a subdomain’s DID is distinct from the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> field
for a BNS name’s DID, even if the same created both names and subdomains.
For example, the name <codeclass="highlighter-rouge">abcdefgh123456.id</code> has the DID <codeclass="highlighter-rouge">did:stack:v0:16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg-0</code>,
because it was the first name created by <codeclass="highlighter-rouge">16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg</code>.
However, <codeclass="highlighter-rouge">16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg</code><em>also</em> created <codeclass="highlighter-rouge">jude.statism.id</code>
as its first subdomain name. The DID for <codeclass="highlighter-rouge">jude.statism.id</code> is
<codeclass="highlighter-rouge">did:stack:v0:SSXMcDiCZ7yFSQSUj7mWzmDcdwYhq97p2i-0</code>. Note that the address
<codeclass="highlighter-rouge">SSXMcDiCZ7yFSQSUj7mWzmDcdwYhq97p2i</code> encodes the same public key hash as the address
<codeclass="highlighter-rouge">16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg</code> (the only difference between these two
strings is that the first is base58check-encoded with version byte 0, and the
second is encoded with version byte 63).</p>
<p>You can see this play out in practice with the following code snippit:</p>