Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UeaU7-0003Ot-AF for bitcoin-development@lists.sourceforge.net; Tue, 21 May 2013 00:31:23 +0000 Received: from mail-oa0-f43.google.com ([209.85.219.43]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1UeaU4-0008OV-0C for bitcoin-development@lists.sourceforge.net; Tue, 21 May 2013 00:31:23 +0000 Received: by mail-oa0-f43.google.com with SMTP id o6so56053oag.30 for ; Mon, 20 May 2013 17:31:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=bTKXYi6oHKpI2XmL+t8Q/EjrxCiNGu3WPYY8AOiMPZU=; b=ejQtVufwaCMLP+zPEAIhNvBHLQJHKdbCKTbkskcOKm09te1SSR8cl/Shjwjsm/Ia+q h1XF6C6f3LWT40heKIG4TyTPUCGQ8sA10sDfEDwQJK5IIuo9xM9MRXhTS65r1D5UUdSS 20sxUehMoBxx9hPS8hp7c9rARxJYjVzI1OdW20YyfGC4Fx5TGSrsmtBtguG74cY3hmkH WQ9sOqNrL74aaLdk4QgmpFSQM7YeJk5Jcrqfyezgu8EUyJWlZvJE+xe6borSe+HBqg7c RbeoeQo4hAeWeWMxjHkoDGlFtrgh8ZR7ywJIZeUM37UnycS+0zFTnzpCnV1x/fgoni1U 78AQ== X-Received: by 10.60.99.10 with SMTP id em10mr5855100oeb.58.1369094380511; Mon, 20 May 2013 16:59:40 -0700 (PDT) Received: from [192.168.1.118] (adsl-71-131-176-204.dsl.sntc01.pacbell.net. [71.131.176.204]) by mx.google.com with ESMTPSA id c20sm108422oez.4.2013.05.20.16.59.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 May 2013 16:59:39 -0700 (PDT) Message-ID: <519AB8EB.5000103@monetize.io> Date: Mon, 20 May 2013 16:59:39 -0700 From: Mark Friedenbach Organization: Monetize.io Inc. User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: bitcoin-development@lists.sourceforge.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn9Vx2Jty7f0H7+1w+ScJlBEEdX/s6dUUmurzzKJ0YtSlmos3Y1A07sJM/mZqTnQ9XllhGl X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. X-Headers-End: 1UeaU4-0008OV-0C Subject: [Bitcoin-development] UUID to identify chains (payment protocol and elsewhere) X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 00:31:23 -0000 At the developer round-table it was asked if the payment protocol would alt-chains, and Gavin noted that it has a UTF-8 encoded string identifying the network ("main" or "test"). As someone with two proposals in the works which also require chain/coin identification (one for merged mining, one for colored coins), I am opinionated on this. I believe that we need a standard mechanism for identifying chains, and one which avoids the trap of maintaining a standard registry of string-to-chain mappings. Any chain can be uniquely identified by its genesis block, 122 random bits is more than sufficient for uniquely tagging chains/colored assets, and the low-order 16-bytes of the block's hash are effectively random. With these facts in mind, I propose that we identify chains by UUID. So as to remain reasonably compliant with RFC 4122, I recommend that we use Version 4 (random) UUIDs, with the random bits extracted from the double-SHA256 hash of the genesis block of the chain. (For colored coins, the colored coin definition transaction would be used instead, but I will address that in a separate proposal and will say just one thing about it: adopting this method for identifying chains/coins will greatly assist in adopting the payment protocol to colored coins.) The following Python code illustrates how to construct the chain identifier from the serialized genesis block: from hashlib import sha256 from uuid import UUID def chain_uuid(serialized_genesis_block): h = sha256(serialized_genesis_block).digest() h = sha256(h).digest() h = h[:16] h = ''.join([ h[:6], chr(0x40 | ord(h[6]) & 0x0f), h[7], chr(0x80 | ord(h[8]) & 0x3f), h[9:] ]) return UUID(bytes=h) And some example chain identifiers: mainnet: UUID('6fe28c0a-b6f1-4372-81a6-a246ae63f74f') testnet3: UUID('43497fd7-f826-4571-88f4-a30fd9cec3ae') namecoin: UUID('70c7a9f0-a2fb-4d48-a635-a70d5b157c80') As for encoding the chain identifier, the simplest method is to give "network" the "bytes" type, but defining a "UUID" message type is also possible. In either case bitcoin mainnet would be the default, so the extra 12 bytes (vs: "main" or "test") would only be an issue for alt-chains or colored coins. Kind regards, Mark Friedenbach