InterPlanetary Naming System (IPNS)

InterPlanetary Naming System (IPNS)

In the last section, we learned how we can create a more resilient, censorship-resistant and faster internet using content addressing.

But there are 2 problems here:

  • We don't want the links to our photos, websites turned into a lengthy and non-human friendly sequence of letter like this:
    QmPAwR5un1YPJEF6iB7KvErDmAhiXxwL5J5qjA3Z9ceKqv
  • We know that for each unique input data we have a unique CID. So, this means that if I update anything on my website, then the resulting CID will change and hence the link to simpleaswater.com will change. This means the links on IPFS are permanent.

To solve these problems we use the Inter-Planetary Naming System or IPNS.

For those who are familiar with Domain Name System or DNS, IPNS is a decentralized version of DNS.

In short, IPNS does 2 things:

  • It allows you to generate a link(mutable address) which always points to the latest version of the content. So, even if I update the website, it will still have the same link.
  • It allows you to replace the non-human friendly CID with a human-friendly label.

This is how an IPNS link looks like:

/ipns/QmSrPmbaUKA3ZodhzPWZnpFgcPMFWF4QsxXbkWfEptTBJd

Which can be further converted to

/ipns/simpleaswater.com

Voila, you have a pretty link :)

But, How does it Work?

As every human has a name, IPFS peers also have names which are called public keys. Each IPFS peer has its own unique public key. So, the public keys almost never clash.

The problem with public keys is that they are long. I mean really long… Below is an IPFS public key:

MIIBITANBgkqhkiG9w0BAQEFAAOCAQ4AMIIBCQKCAQB9UeL9CjQnYktgPxl3cpfQ At/iI+QK4/bUVO4HcbcDtdLLK8iorsrduBXbZ+PYdLnTBuYL3NNnyGDvHri5moaf C+WxClvBDTo+wzjqEF1PCgou8XXgCsbCOcdEh3BfSN9YAI7gb0sT70/C2RDVLaFa lo0kjA7csnKKoWS4iD70QZJIlo8vbD02B7HHsXcLQy3L02vCMcbGaSjZ1oeDXpNE CHo+3MNC34JFl3e6XLC7hduv9TubdCu6ZutbaqSkftBxE8AI7pYDsu/AeOMcFeAV KUjlAoC2nxw5tx1mdVQIOgJ9Mu5e3SjGzwpbzaSKznQecFZ0ca20gC+xYcVSEBDP
AgMBAAE=

So, we use the power of hashes again. When we hash the above public key, we get a small CID:

QmVD2YQF96S6Em8zhgNNDKVc7jKUqTyFRaL6ejwKXUUCju

For example, the hash of public key of IPFS peer's running in your browser is something like:

QmY25ni7FSUJyRkNQ8HXxW7Ers3xJ41sBzgTCbUSEBLYtd

So, if you are hosting a website from your device, and want a permanent link, then it will look like this:

/ipns/QmY25ni7FSUJyRkNQ8HXxW7Ers3xJ41sBzgTCbUSEBLYtd

And if you want, you can change this to a human-friendly name:

/ipns/your_website_name

IPNS is not the only way to create mutable addresses on IPFS. You can also use DNSLink (which is currently much faster than IPNS and also uses more readable names). Other community members are exploring ways to use blockchains to store common name records.

If you want to see how this all is done, head over to the tutorials section, where you will learn to host your website on IPFS using IPNS and DNSLink.

Subscribe to SimpleAsWater

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe