Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Uf6H3-0001Nw-W3 for bitcoin-development@lists.sourceforge.net; Wed, 22 May 2013 10:28:02 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; envelope-from=melvincarvalho@gmail.com; helo=mail-lb0-f182.google.com; Received: from mail-lb0-f182.google.com ([209.85.217.182]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Uf6H2-0003an-Da for bitcoin-development@lists.sourceforge.net; Wed, 22 May 2013 10:28:01 +0000 Received: by mail-lb0-f182.google.com with SMTP id z5so1881989lbh.27 for ; Wed, 22 May 2013 03:27:53 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.121.9 with SMTP id lg9mr3534266lab.39.1369218473655; Wed, 22 May 2013 03:27:53 -0700 (PDT) Received: by 10.112.143.38 with HTTP; Wed, 22 May 2013 03:27:53 -0700 (PDT) In-Reply-To: <519AB8EB.5000103@monetize.io> References: <519AB8EB.5000103@monetize.io> Date: Wed, 22 May 2013 12:27:53 +0200 Message-ID: From: Melvin Carvalho To: Mark Friedenbach Content-Type: multipart/alternative; boundary=089e0117749dbe041a04dd4c0415 X-Spam-Score: -0.6 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (melvincarvalho[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Uf6H2-0003an-Da Cc: Bitcoin Dev Subject: Re: [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: Wed, 22 May 2013 10:28:02 -0000 --089e0117749dbe041a04dd4c0415 Content-Type: text/plain; charset=ISO-8859-1 On 21 May 2013 01:59, Mark Friedenbach wrote: > 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. > This is essentially name spacing. As registries grow namespaces become more important. In bitcoin's quest for decentrality there's also the question of who maintains the registry. Some out of band algo/hash could work so long as there was a one to one relationship between the described object and the UUID. In this case the gensis block may not uniquely identify a coin. The normal way to namespace a registry on the internet is to allow it to be a URI. In this case an http style uri has the added bonus side effect that it can be dereferencable and both human and machine readable. So yes something like org.bitcoin.* is good, just simply growing things to http style uris is cleaner, imho > > Kind regards, > Mark Friedenbach > > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may > _______________________________________________ > Bitcoin-development mailing list > Bitcoin-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bitcoin-development > --089e0117749dbe041a04dd4c0415 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On 21 May 2013 01:59, Mark Friedenbach <mark@monetize.io> wrote:
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.<= br> 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:

=A0 =A0 =A0from hashlib import sha256
=A0 =A0 =A0from uuid import UUID
=A0 =A0 =A0def chain_uuid(serialized_genesis_block):
=A0 =A0 =A0 =A0 =A0h =3D sha256(serialized_genesis_block).digest()
=A0 =A0 =A0 =A0 =A0h =3D sha256(h).digest()
=A0 =A0 =A0 =A0 =A0h =3D h[:16]
=A0 =A0 =A0 =A0 =A0h =3D ''.join([
=A0 =A0 =A0 =A0 =A0 =A0 =A0h[:6],
=A0 =A0 =A0 =A0 =A0 =A0 =A0chr(0x40 | ord(h[6]) & 0x0f),
=A0 =A0 =A0 =A0 =A0 =A0 =A0h[7],
=A0 =A0 =A0 =A0 =A0 =A0 =A0chr(0x80 | ord(h[8]) & 0x3f),
=A0 =A0 =A0 =A0 =A0 =A0 =A0h[9:]
=A0 =A0 =A0 =A0 =A0])
=A0 =A0 =A0 =A0 =A0return UUID(bytes=3Dh)

And some example chain identifiers:

=A0 =A0 =A0mainnet: =A0UUID('6fe28c0a-b6f1-4372-81a6-a246ae63f74f')=
=A0 =A0 =A0testnet3: UUID('43497fd7-f826-4571-88f4-a30fd9cec3ae') =A0 =A0 =A0namecoin: 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&q= uot; 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.

This is es= sentially name spacing.=A0 As registries grow namespaces become more import= ant.=A0 In bitcoin's quest for decentrality there's also the questi= on of who maintains the registry.

Some out of band algo/hash could work so long as there was a= one to one relationship between the described object and the UUID.=A0 In t= his case the gensis block may not uniquely identify a coin.

The normal way to namespace a registry on the internet is to allow it = to be a URI.=A0 In this case an http style uri has the added bonus side eff= ect that it can be dereferencable and both human and machine readable.=A0 S= o yes something like org.bitcoin.* is good, just simply growing things to h= ttp style uris is cleaner, imho
=A0

Kind regards,
Mark Friedenbach

---------------------------------------------------------------------------= ---
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service=
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Bitcoin-development mailing list
Bitcoin-develo= pment@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-de= velopment

--089e0117749dbe041a04dd4c0415--