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:
- 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:
Which can be further converted to
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:
For example, the hash of public key of IPFS peer's running in your browser is something like:
So, if you are hosting a website from your device, and want a permanent link, then it will look like this:
And if you want, you can change this to a human-friendly 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.