bigchaindb/org

Idea for eating our own dog food: Persist shorted links on IPDB

TimDaub opened this issue · 2 comments

Persist shorted links on IPDB

Cool URIs don't change

Since I'm in lack of time, this is a super quick write down of an idea I had.

TL;DR: URL shortening is breaking the web. I'm sure someone said that before. There ya go. Build [your favorite browser] plugin that crawls your current page looking for href=bit.ly|.... Resolve link, generate an BigchainDB transaction output where PublicKey(b'[bit.ly link you just crawled]') and asset data being the link resolved from the short link. Submit transaction to IPDB. If e.g. bit.ly ever goes down, IPDB is backup. You can query by link, just search for: PublicKey(b"[bit.ly link you're looking for]") using the outputs endpoint. Thx @r-marques for public key indexing idea.

Problems

From @vrde:

how do you make sure that the data is true?
the only source of trust should be bitly

vrde commented

Snippet to go from a bit.ly hash to a public key:

import base58
import nacl.encoding
import nacl.signing
import nacl.hash

def get_address(target):
    key = nacl.hash.sha256(target.encode('utf8'), encoder=nacl.encoding.RawEncoder)
    verify_key = nacl.signing.VerifyKey(key)
    return base58.b58encode(verify_key.encode())

print(get_address('2mXv2sB'))
# -> 8gHaecA38pscZqhBCoKSni5ZqNwamXVf4VvdnB6ivF2X

Snippet to go from a bit.ly hash to a public key:

Awesome! 🎉

You'd want to encode bit.ly (meaning: the full link) into the public key as well though, as there are a lot of other frequently used link shorteners: fb.com, t.co, ...