<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Bluish Coder: namecoin</title>
 <link href="http://bluishcoder.co.nz/tag/namecoin/atom.xml" rel="self"/>
 <link href="http://bluishcoder.co.nz/"/>
 <updated>2020-07-10T16:25:05+12:00</updated>
 <id>http://bluishcoder.co.nz/</id>
 <author>
   <name>Bluishcoder</name>
   <email>admin@bluishcoder.co.nz</email>
 </author>

 
 <entry>
   <title>Namecoin - A DNS alternative based on Bitcoin</title>
   <link href="http://bluishcoder.co.nz/2011/05/12/namecoin-a-dns-alternative-based-on-bitcoin.html"/>
   <updated>2011-05-12T18:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/05/12/namecoin-a-dns-alternative-based-on-bitcoin</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;https://github.com/vinced/namecoin&quot;&gt;Namecoin&lt;/a&gt; is a domain name system based on &lt;a href=&quot;http://www.bitcoin.org&quot;&gt;Bitcoin&lt;/a&gt;. It extends Bitcoin to add transactions for registering, updating and transferring names. The idea behind this is to provide an alternative to the existing DNS system where names can be taken from their owners by groups that control the DNS servers.&lt;/p&gt;

&lt;p&gt;The project was originally &lt;a href=&quot;http://www.bitcoin.org/smf/index.php?topic=6017.0&quot;&gt;announced in the bitcoin forums&lt;/a&gt; and has seen some uptake. The namecoin author, &lt;a href=&quot;https://github.com/vinced&quot;&gt;vinced&lt;/a&gt;, states in the post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is a new blockchain, separate from the main Bitcoin chain&lt;/li&gt;
&lt;li&gt;Name/value pairs are stored in the blockchain attached to coins&lt;/li&gt;
&lt;li&gt;Names are acquired through new transaction types - new, first-update and update&lt;/li&gt;
&lt;li&gt;Names expire after 12000 blocks unless renewed with an update&lt;/li&gt;
&lt;li&gt;No two unexpired names can be identical&lt;/li&gt;
&lt;li&gt;Block validation is extended to reject transactions that do not follow the above rules&lt;/li&gt;
&lt;li&gt;The code is here: &lt;a href=&quot;https://github.com/namecoin/namecoin&quot;&gt;https://github.com/vinced/namecoin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;A number of projects have been created around this to provide a mapping from namecoin names to standard DNS. This allows resolving namecoin names to a &#39;.bit&#39; suffixed domain. I&#39;ll go through building the namecoin software, registering and updating names, then the software to use these names.&lt;/p&gt;

&lt;h2&gt;Building Namecoin&lt;/h2&gt;

&lt;p&gt;Namecoin needs to be built from source. The following steps on a Linux based system will build without UPNP support:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/namecoin/namecoin.git
$ cd namecoin
namecoin $ make -f makefile.unix USE_UPNP=
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once built you&#39;ll need to create a &lt;code&gt;~/.namecoin/bitcoin.conf&lt;/code&gt; file that contains entries for a username and password used for the JSON-RPC server that &lt;code&gt;namecoind&lt;/code&gt; runs. Notice the name of the .conf file is &lt;code&gt;bitcoin.conf&lt;/code&gt; even though this is &lt;code&gt;namecoind&lt;/code&gt;. It won&#39;t clash with an existing &lt;code&gt;bitcoin&lt;/code&gt; installation as it is in a &lt;code&gt;~/.namecoin&lt;/code&gt; directory. To prevent conflict with an existing &lt;code&gt;bitcoin&lt;/code&gt; install I suggest running &lt;code&gt;namecoind&lt;/code&gt; on a different port. An example &lt;code&gt;~/.namecoin/bitcoin.conf&lt;/code&gt; is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rpcuser=me
rpcpassword=password
rpcport=9332
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Running &lt;code&gt;namecoind&lt;/code&gt; will start the daemon and you can then use &lt;code&gt;namecoind&lt;/code&gt; to execute commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind
bitcoin server starting
$ ./namecoind getblockcount
2167
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Yes, it prints out &#39;bitcoin server starting&#39;. There are still &lt;code&gt;bitcoin&lt;/code&gt; references in the code that need to be changed apparently.&lt;/p&gt;

&lt;h2&gt;Getting Namecoins&lt;/h2&gt;

&lt;p&gt;To register a name you need to have some namecoins. These can be obtained via mining, just like bitcoins. Or you can buy them. To mine namecoins you can run any of the &lt;a href=&quot;http://www.weusecoins.com/mining-guide.php&quot;&gt;standard bitcoin miners&lt;/a&gt; and point them to the server and port that is running &lt;code&gt;namecoind&lt;/code&gt;. The difficulty level for namecoin mining is currently very low (about 290 at the time of writing) so even CPU miners have a chance. Generating a block gets you 50 namecoins.&lt;/p&gt;

&lt;p&gt;You can also buy namecoins as &lt;a href=&quot;http://dot-bit.org/HowToBuyNamecoins&quot;&gt;described here&lt;/a&gt;. The going rate seems to be about 1BTC for 50 namecoins.&lt;/p&gt;

&lt;h2&gt;Registering a name&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;name_new&lt;/code&gt; command will register a name. An example invocation is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_new d/myname
[
    &quot;1234567890123456789012345678901234567890&quot;,
    &quot;0987654321&quot;
]   
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will start the registration process for the name &lt;code&gt;myname&lt;/code&gt;. Note the two hash values returned. Once this is done you need to wait for 12 blocks to be generated by the namecoin network. You then need to run a &lt;code&gt;name_firstupdate&lt;/code&gt; command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_firstupdate d/myname 0987654321 &#39;{&quot;map&quot;:{&quot;&quot;:&quot;1.2.3.4&quot;}}&#39;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We pass to &lt;code&gt;name_firstupdate&lt;/code&gt; the domain name we are updating, the shorter hash that we got from &lt;code&gt;name_new&lt;/code&gt; and a JSON value that defines how that name is mapped to an IP address.&lt;/p&gt;

&lt;p&gt;In this case the name is mapped to the IP address 1.2.3.4. Using the existing systems for mapping names this would make &lt;code&gt;myname.bit&lt;/code&gt; resolve to &lt;code&gt;1.2.3.4&lt;/code&gt;. You can also do subdomains (See the update example later).&lt;/p&gt;

&lt;p&gt;The cost to do a &lt;code&gt;name_new&lt;/code&gt;, followed by a &lt;code&gt;name_firstupdate&lt;/code&gt;, varies depending on how many blocks there are in the namecoin block chain. It started at 50 namecoins and slowly reduces. The formula is defined in the &lt;a href=&quot;https://github.com/namecoin/namecoin/blob/master/DESIGN-namecoin.md&quot;&gt;namecoin design document&lt;/a&gt; as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network fees start out at 50 NC per operation at the genesis block&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every block, the network fees decreases based on this algorithm, in 1e-8 NC:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  res = 500000000 &amp;gt;&amp;gt; floor(nBlock / 8192)
  res = res - (res &amp;gt;&amp;gt; 14)*(nBlock % 8192)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nBlock is zero at the genesis block&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;This is a decrease of 50% every 8192 blocks (about two months)&lt;/li&gt;
&lt;li&gt;As 50 NC are generated per block, the maximum number of registrations in the first 8192 blocks is therefore 2/3 of 8192, which is 5461&lt;/li&gt;
&lt;li&gt;Difficulty starts at 512&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Updating a name&lt;/h2&gt;

&lt;p&gt;To update the domain mapping you use &lt;code&gt;name_update&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_update d/myname &#39;{&quot;map&quot;:{&quot;&quot;:&quot;1.2.3.4&quot;,&quot;www&quot;:&quot;5.6.7.8&quot;}}&#39;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This example updates the value of &lt;code&gt;myname&lt;/code&gt; so it includes a &lt;code&gt;www&lt;/code&gt; subdomain. The name &lt;code&gt;www.myname.bit&lt;/code&gt; will now map to &lt;code&gt;5.6.7.8&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are other possibilities for the JSON mapping. See the &lt;a href=&quot;https://github.com/namecoin/namecoin/blob/master/README.md&quot;&gt;namecoin README&lt;/a&gt; for details. Note that the JSON code must be valid JSON (ie. use double quotes, unlike the examples currently shown in the README unfortunately).&lt;/p&gt;

&lt;h2&gt;Transferring a name&lt;/h2&gt;

&lt;p&gt;To transfer a name to another person you need to get their namecoin address and do an update passing that address:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_update d/myname &#39;{&quot;map&quot;:{&quot;&quot;:&quot;1.2.3.4&quot;}}&#39; NGZs7UndoWgpfTstoxryYEW8b1GtDLPwMa
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Addresses can be generated with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind getnewaddress
N9jzzaptnQ28uiLgWm19WZAqrGqRVVGkFX
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Transferring namecoins&lt;/h2&gt;

&lt;p&gt;You can transfer namecoins to other people by sending coins to their address just like bitcoin:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind sendtoaddress N9jzzaptnQ28uiLgWm19WZAqrGqRVVGkFX 50
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will send 50 namecoins to &lt;code&gt;N9jzzaptnQ28uiLgWm19WZAqrGqRVVGkFX&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Listing registered names&lt;/h2&gt;

&lt;p&gt;You can list all registered namecoin names using &lt;code&gt;name_scan&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_scan
{
    &quot;name&quot; : &quot;d/bluishcoder&quot;,
    &quot;value&quot; : &quot;{\&quot;map\&quot;:{\&quot;\&quot;:\&quot;69.164.206.88\&quot;}}&quot;,
    &quot;txid&quot; : &quot;....&quot;,
    &quot;expires_in&quot; : 10874
},
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can also list only the names you&#39;ve registered using &lt;code&gt;name_list&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./namecoind name_list
{
    &quot;name&quot; : &quot;d/bluishcoder&quot;,
    &quot;value&quot; : &quot;{\&quot;map\&quot;:{\&quot;\&quot;:\&quot;69.164.206.88\&quot;}}&quot;,
    &quot;expires_in&quot; : 10874
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Using namecoin names&lt;/h2&gt;

&lt;p&gt;Software needs to be modified to use &lt;code&gt;namecoind&lt;/code&gt; to lookup the name, or you can run DNS software that connects to namecoin to do lookups. To be able to try out &lt;code&gt;namecoin&lt;/code&gt; I modified an HTTP proxy and later tried using DNS software.&lt;/p&gt;

&lt;h3&gt;HTTP Proxy&lt;/h3&gt;

&lt;p&gt;I modified the &lt;a href=&quot;http://www.pps.jussieu.fr/~jch/software/polipo/&quot;&gt;Polipo web proxy&lt;/a&gt; to use &lt;code&gt;namecoin&lt;/code&gt; for lookups. The modified source is available at &lt;a href=&quot;https://github.com/doublec/namecoin-polipo&quot;&gt;https://github.com/doublec/namecoin-polipo&lt;/a&gt;. This can be built and run with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone https://github.com/doublec/namecoin-polipo
$ cd namecoin-polipo
$ make
$ ./polipo namecoindServer=&quot;127.0.0.1:9332&quot; namecoindUsername=rpcuser namecoindPassword=rpcpassword
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Changing your browser to point to the proxy on &lt;code&gt;localhost&lt;/code&gt;, port &lt;code&gt;8123&lt;/code&gt;, will allow &lt;code&gt;.bit&lt;/code&gt; domains to be used. See &lt;a href=&quot;http://www.bitcoin.org/smf/index.php?topic=6017.msg96826#msg96826&quot;&gt;my forum post&lt;/a&gt; about it for more details.&lt;/p&gt;

&lt;h3&gt;dnsmasq&lt;/h3&gt;

&lt;p&gt;Another approach I tried was to write a program that generates a &#39;host file&#39; from &lt;code&gt;namecoind&lt;/code&gt; and uses &lt;a href=&quot;http://www.thekelleys.org.uk/dnsmasq/doc.html&quot;&gt;dnsmasq&lt;/a&gt; to run a local DNS server that serves domains from this host file, falling back to the standard DNS server. The &#39;quick and dirty&#39; code to generate the hosts file is in &lt;a href=&quot;https://gist.github.com/967992&quot;&gt;namecoin-hosts.c&lt;/a&gt; and uses &lt;a href=&quot;http://curl.haxx.se/libcurl/&quot;&gt;libcurl&lt;/a&gt; and &lt;a href=&quot;http://www.digip.org/jansson/&quot;&gt;libjansson&lt;/a&gt; to build:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gcc -o namecoin-hosts namecoin-hosts.c -lcurl -ljansson
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I added the following to my &lt;code&gt;dnsmasq.conf&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;local=/.bit/
local-ttl=300
addn-hosts=/tmp/hosts.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And created a shell script to update &lt;code&gt;/tmp/hosts.txt&lt;/code&gt; with the namecoin related data:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;while true; do
  ./namecoin-hosts 127.0.0.1:9332 rpcuser rpcpassword &amp;gt;/tmp/hosts.txt
  kill -HUP `cat /var/run/dnsmasq/dnsmasq.pid`
  echo `date`
  sleep 300
done
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Pointing my OS DNS resolver to the &lt;code&gt;dnsmasq&lt;/code&gt; IP address and port allowed &lt;code&gt;.bit&lt;/code&gt; names to resolve.&lt;/p&gt;

&lt;h2&gt;Public .bit DNS servers&lt;/h2&gt;

&lt;p&gt;Details of a public .bit DNS server that doesn&#39;t require you to run &lt;code&gt;namecoin&lt;/code&gt; are available at &lt;a href=&quot;http://namecoin.bitcoin-contact.org/&quot;&gt;namecoin.bitcoin-contact.org&lt;/a&gt;. That site also provides details on using &lt;code&gt;namecoin&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;More Information&lt;/h2&gt;

&lt;p&gt;Namecoin seems to be very much an experiment in having an alternative DNS like system. The developer has taken the approach of &#39;release early&#39; and iterate towards a solution. As such it may fizzle out and go nowhere. Or it may prove a useful test-bed for ideas that make it into a successful DNS alternative.&lt;/p&gt;

&lt;p&gt;More details about Namecoin can be obtained from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://mmpool.org&quot;&gt;Merge Mining Pool&lt;/a&gt; for mining Namecoins and Bitcoins concurrently.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vircurex.com/register?referral_id=350-195&quot;&gt;Vircurex Exchange&lt;/a&gt;. Buy and Sell namecoins using bitcoins.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://dot-bit.org/Main_Page&quot;&gt;dot-bit.org&lt;/a&gt;. Contains setup information, binaries to download, forums and other pointers.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.bitcoin.org/smf/index.php?topic=6017.0&quot;&gt;Original Namecoin announcement thread&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.bitcoin.org/smf/index.php?topic=7412.0&quot;&gt;Dot-BIT Project announcement thread&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/namecoin/namecoin&quot;&gt;Namecoin github repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.reddit.com/r/namecoin&quot;&gt;Namecoin subreddit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#namecoin&lt;/code&gt; channel on &lt;code&gt;irc.freenode.net&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Are there any other alternatives to DNS around with similar ideas?&lt;/p&gt;
</content>
 </entry>
 
 
</feed>
