jminardi / syncnet

A decentralized browser
MIT License
411 stars 24 forks source link

Why not Namecoin for DNS? #1

Closed Ademan closed 10 years ago

Ademan commented 10 years ago

The Namecoin project already implements a robust (and flexible) DNS system based on a blockchain, and provides a Firefox browsing plugin. I invite you to consider using Namecoin in place of Colored Coins. Feel free to join us on irc.freenode.net #namecoin (slow) or our mailing list here: http://srv01.web-sweet-web.net/cgi-bin/mailman/listinfo/namecoin-dev-dot-bit.org

It's possible Namecoin isn't an appropriate solution for syncnet but at first glance it appears to be an excellent candidate, and would save you considerable reimplementation effort.

jminardi commented 10 years ago

I am not necessarily tied to colored coins. Do you have example code somewhere of integrating with namecoin?

ghost commented 10 years ago

The namecoin control util nmcontrol returns json info(to console) to a getValue command . You can easily scrape that.

Instructions : https://github.com/khalahan/nmcontrol/blob/master/doc/INSTALL.md

Ademan commented 10 years ago

Thanks for being open to the idea. In my opinion, the path of least resistance since you're already using python, is to depend on python-bitcoinlib (preferably from either my fork, which you probably shouldn't, or petertodd's pythonize branch) https://github.com/petertodd/python-bitcoinlib/tree/pythonize .

You can use the provided bitcoin.rpc.Proxy to talk to namecoin. I cranked out some proof-of-concept code on my BART ride home today, it looks more or less like this (assuming you have a local instance of namecoin running which accepts rpc messages):

import json
from bitcoin.rpc import Proxy

proxy = Proxy(service_url="http://user:password@localhost:8336") # interface for creating a proxy is negotiable, one of the things my branch does is change this
name = 'dot-bit'
dns_record = proxy._call('name_show', 'd/' + name) # throws if the name doesn't exist, iirc
try:
    name_info = json.loads(dns_record.get('value'))
except ValueError:
    pass # invalid json, or no 'value' field

secret = name_info['syncnet']['secret'] # of course this could throw a KeyError

# Use retrieved secret

I'd be happy to finish my PoC and submit a pull request if you'd like, otherwise I can provide more help. In addition since namecoin names are cheap, I can register a few secrets for you, but it's probably best if you communicate those to me in private so nobody decides to snatch up the names before you or I.

JeremyRand commented 10 years ago

@ippisl nmcontrol supports a JSON-RPC interface, which would be much cleaner than trying to scrape its console output. It's TCP rather than HTTP, so the Bitcoin RPC libs won't work as far as I know.

nmcontrol is quite a bit more flexible than talking directly to namecoind's RPC. For example, nmcontrol automatically caches data (saving around 60ms per lookup if I recall correctly), and I believe nmcontrol allows loading test data from a file rather than from the blockchain (makes debugging easier, although with names so cheap right now that hasn't been a concern for me when I'm developing).

That said, talking to namecoind should work fine if you don't expect to need any of nmcontrol's features. Also, nmcontrol isn't able to register/update names, it just reads them -- if you want to register names you need to use namecoind (as @Ademan's code does).

Hope this info is helpful.

jminardi commented 10 years ago

@Ademan I'd love it if you submitted a PR with your proposed updates. I've been thinking and I don't think there is a reason for me not to work with multiple decentralized name services. Namecoin seems to be the best one currently so I'd love to get it integrated.

jminardi commented 10 years ago

Closing this issue since @Ademan is working on a PR to demonstrate namecoin implementation.