<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JohnTobey253</id>
	<title>Bitcoin Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JohnTobey253"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/JohnTobey253"/>
	<updated>2026-04-17T11:31:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=45460</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=45460"/>
		<updated>2014-03-27T15:07:32Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Update link.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://bitcointalk.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/bitcoin-abe/bitcoin-abe/master/README.md&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://bcv.coinwallet.pl/ Demonstration site]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=22785.0 Project announcement]&lt;br /&gt;
* [https://github.com/bitcoin-abe/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=45459</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=45459"/>
		<updated>2014-03-27T15:06:41Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Updated links.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://bitcointalk.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/bitcoin-abe/bitcoin-abe/master/README.md&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://bcv.coinwallet.pl/ Demonstration site]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=22785.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37602</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37602"/>
		<updated>2013-05-06T18:19:27Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ more simulation and discussion of difficulty adjustments&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the original client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.  The new formula yields practically the same result in the absence of 51% attacks and network partitions.  Each new block adds weight in proportion to its difficulty.  The fee component usually affects only contests between blocks of equal height, in which case it rewards transaction inclusion.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In simulated attacks, the time is less; my calculations are rough.  If the checkpoint is far in the past, it takes longer, but the eventual result is the same: the honest network creates ever-longer side chains.  Indeed, if the checkpoint is well placed and&lt;br /&gt;
&lt;br /&gt;
 A*I &amp;lt; H * (I+E)&lt;br /&gt;
&lt;br /&gt;
the attacker&#039;s advantage is nullified, and the honest network wins without intervention.  Otherwise, the lead keeps going back and forth, with ever longer honest branches, until the honest participants agree on a checkpoint that decides the contest in their favour.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to 50 in the first 2200.  Of course, 90% is a pretty strong operation, and 60% compliance with the Gum Mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, it would satisfy the constraint mentioned above, namely:&lt;br /&gt;
&lt;br /&gt;
 A   * I   &amp;lt; H   * (I+E)&lt;br /&gt;
 0.7 * 0.2 &amp;lt; 0.3 * 1&lt;br /&gt;
&lt;br /&gt;
After just 100 blocks, it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 ./wfscp 70 20 100 0 100 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 100&lt;br /&gt;
 1000 run avg: 0.898 reorgs, honest lead 27.927, max lead 28.004, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Note here that the theoretical maxium (average) honest lead is 30 (30% power over 100 blocks) and so 27.9 indicates very few honest blocks lost in the attack.  On the other hand, if we start with a month-old (4400-block) checkpoint, recovery is slower, but still well in hand by 10 thousand blocks:&lt;br /&gt;
&lt;br /&gt;
 ./wfscp 70 20 100 4400 10000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 4400&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 67.015 reorgs, honest lead 1026.510, max lead 1205.691, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Until now, I have ignored difficulty adjustments.  To the extent that changing difficulty affects these scenarios, it will permit relatively faster extension of honest branches, since the honest network has less hashing power than the attacker.  This benefit is limited, but not entirely negated, by the weighting of difficulty in the chain-selection formula.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37598</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37598"/>
		<updated>2013-05-06T18:01:08Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ simulation results: clarification&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the original client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.  The new formula yields practically the same result in the absence of 51% attacks and network partitions.  Each new block adds weight in proportion to its difficulty.  The fee component usually affects only contests between blocks of equal height, in which case it rewards transaction inclusion.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In simulated attacks, the time is less; my calculations are rough.  If the checkpoint is far in the past, it takes longer, but the eventual result is the same: the honest network creates ever-longer side chains.  Indeed, if the checkpoint is well placed and&lt;br /&gt;
&lt;br /&gt;
 A*I &amp;lt; H * (I+E)&lt;br /&gt;
&lt;br /&gt;
the attacker&#039;s advantage is nullified, and the honest network wins without intervention.  Otherwise, the lead keeps going back and forth, with ever longer honest branches, until the honest participants agree on a checkpoint that decides the contest in their favour.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to 50 in the first 2200.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, it would satisfy the constraint mentioned above, namely:&lt;br /&gt;
&lt;br /&gt;
 A   * I   &amp;lt; H   * (I+E)&lt;br /&gt;
 0.7 * 0.2 &amp;lt; 0.3 * 1&lt;br /&gt;
&lt;br /&gt;
After just 100 blocks, it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 ./wfscp 70 20 100 0 100 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 100&lt;br /&gt;
 1000 run avg: 0.898 reorgs, honest lead 27.927, max lead 28.004, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Note here that the theoretical maxium (average) honest lead is 30 (30% power over 100 blocks) and so 27.9 indicates very few honest blocks lost in the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37597</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37597"/>
		<updated>2013-05-06T17:57:04Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ more discussion of simulation result&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the original client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.  The new formula yields practically the same result in the absence of 51% attacks and network partitions.  Each new block adds weight in proportion to its difficulty.  The fee component usually affects only contests between blocks of equal height, in which case it rewards transaction inclusion.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In simulated attacks, the time is less; my calculations are rough.  If the checkpoint is far in the past, it takes longer, but the eventual result is the same: the honest network creates ever-longer side chains.  Indeed, if the checkpoint is well placed and&lt;br /&gt;
&lt;br /&gt;
 A*I &amp;lt; H * (I+E)&lt;br /&gt;
&lt;br /&gt;
the attacker&#039;s advantage is nullified, and the honest network wins without intervention.  Otherwise, the lead keeps going back and forth, with ever longer honest branches, until the honest participants agree on a checkpoint that decides the contest in their favour.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to 50 in the first 2200.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, it would satisfy the constraint mentioned above, namely:&lt;br /&gt;
&lt;br /&gt;
 A   * I   &amp;lt; H   * (I+E)&lt;br /&gt;
 0.7 * 0.2 &amp;lt; 0.3 * 1&lt;br /&gt;
&lt;br /&gt;
After just 100 blocks, it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 ./wfscp 70 20 100 0 100 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 100&lt;br /&gt;
 1000 run avg: 0.898 reorgs, honest lead 27.927, max lead 28.004, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Note here that the theoretical maxium honest lead is 30 (30% power over 100 blocks) and so 27.9 indicates very few honest blocks lost in the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37596</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37596"/>
		<updated>2013-05-06T17:31:30Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ details about attack resolution; comparison to original chain-work formula&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the original client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.  The new formula yields practically the same result in the absence of 51% attacks and network partitions.  Each new block adds weight in proportion to its difficulty.  The fee component usually affects only contests between blocks of equal height, in which case it rewards transaction inclusion.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In simulated attacks, the time is less; my calculations are rough.  If the checkpoint is far in the past, it takes longer, but the eventual result is the same: the honest network creates ever-longer side chains.  Indeed, if the checkpoint is well placed and&lt;br /&gt;
&lt;br /&gt;
 A*I &amp;lt; H * (I+E)&lt;br /&gt;
&lt;br /&gt;
the attacker&#039;s advantage is nullified, and the honest network wins without intervention.  Otherwise, the lead keeps going back and forth, with ever longer honest branches, until the honest participants agree on a checkpoint that decides the contest in their favour.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37491</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37491"/>
		<updated>2013-05-03T06:30:12Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ reordered sections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is far in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37488</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37488"/>
		<updated>2013-05-03T02:54:02Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ clarity tweaks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and varying knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume that we have abolished the block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each such first block will outweigh nine (or any number) of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint freshness and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available new transaction fees &#039;&#039;excluded&#039;&#039; (foregone) by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is far in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37487</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37487"/>
		<updated>2013-05-03T02:34:27Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweaked wording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all disapproved transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37485</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37485"/>
		<updated>2013-05-03T01:24:42Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ prettier C&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0]) attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0) return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0]) inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0]) avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0]) checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0]) blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0]) iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0]) srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all honest transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37484</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37484"/>
		<updated>2013-05-03T01:20:34Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ minor rewording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0])&lt;br /&gt;
    attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0)&lt;br /&gt;
    return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0])&lt;br /&gt;
    inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0])&lt;br /&gt;
    avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0])&lt;br /&gt;
    checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0])&lt;br /&gt;
    blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0])&lt;br /&gt;
    iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0])&lt;br /&gt;
    srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all honest transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  Thus, block-generation rewards still encourage miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37481</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37481"/>
		<updated>2013-05-03T01:08:53Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ simulation: bug fixes, more examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of fee-bearing transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry a fee of 1 unit.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  unsigned int count_honest_ahead = 0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average fee-bearing transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double excluded_weight = 0.0;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iter &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\r%u run avg: %.3f reorgs, honest lead %.3f, max lead %.3f, honest %.1f%%   &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter, count_honest_ahead * 100.0 / iter);&lt;br /&gt;
          fflush (stdout);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus one for each time an excluded fee has occurred in&lt;br /&gt;
                  // an orphaned, honest block (excluded_weight),&lt;br /&gt;
                  // plus the sum of current fees (included_tx + excluded_tx).&lt;br /&gt;
                  honest_weight = attacker_weight + excluded_weight&lt;br /&gt;
                    + included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              excluded_weight += excluded_tx;&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      count_honest_ahead += (honest_lead &amp;gt; 0 ? 1 : 0);&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 200.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0])&lt;br /&gt;
    attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0)&lt;br /&gt;
    return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0])&lt;br /&gt;
    inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0])&lt;br /&gt;
    avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0])&lt;br /&gt;
    checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0])&lt;br /&gt;
    blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0])&lt;br /&gt;
    iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0])&lt;br /&gt;
    srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions (inclusion rate 60%).  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 1000 run avg: 49.980 reorgs, honest lead 5.608, max lead 15.016, honest 89.6%&lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending all honest transactions back to the memory pool) on average 50 times in 2200 blocks.  At the end of those 2200 blocks, on average there were 5.6 honest blocks at the end of the longest chain.  In 89.6% of the runs, the 2200th block was honest.  Based on the simulation, one expects to see a longest string of 15.0 honest blocks somewhere among the 2200 blocks.  Running to 10 thousand blocks, we get:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 10000 1000 0&lt;br /&gt;
 ...same as above...&lt;br /&gt;
 blocks per run: 10000&lt;br /&gt;
 1000 run avg: 82.755 reorgs, honest lead 21.567, max lead 50.008, honest 97.3%&lt;br /&gt;
&lt;br /&gt;
Here, our 90% attacker has to wait up to 50 blocks between times when it has the lead.  The last 7800 blocks see only about 33 reorgs, compared to the first 2200&#039;s 50.  Of course, 90% is a pretty strong operation, and 60% compliance with the gum mint&#039;s registration requirement seems rather high.  If the attack had only 70% power and 20% compliance, already after 1000 blocks it would be essentially over:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 70 20 100 0 1000 1000 0&lt;br /&gt;
 attacker share: 70.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 20.000000%&lt;br /&gt;
 average fee-bearing transactions per block: 100.000000&lt;br /&gt;
 checkpoint age in blocks: 0&lt;br /&gt;
 blocks per run: 1000&lt;br /&gt;
 1000 run avg: 0.903 reorgs, honest lead 298.030, max lead 298.030, honest 100.0%&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  This encourages miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37477</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37477"/>
		<updated>2013-05-02T23:43:09Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweak input description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry an equal fee.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age in blocks: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iters &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\rAvg after %u runs: %.4f reorgs, honest lead %.4f, max lead %.4f  &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus excluded fees times the number of orphan blocks,&lt;br /&gt;
                  // plus sum of current fees.&lt;br /&gt;
                  honest_weight = attacker_weight +&lt;br /&gt;
                    (excluded_tx * honest_blocks) + included_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 300.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0])&lt;br /&gt;
    attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0)&lt;br /&gt;
    return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0])&lt;br /&gt;
    inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0])&lt;br /&gt;
    avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0])&lt;br /&gt;
    checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0])&lt;br /&gt;
    blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0])&lt;br /&gt;
    iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0])&lt;br /&gt;
    srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions.  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average transactions per block: 100.000000&lt;br /&gt;
 checkpoint age: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 Avg after 1000 runs: 33.2040 reorgs, honest lead 9.7170, max lead 22.0240  &lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending the honest transactions back to the memory pool) on average 33.2 times in 2200 blocks.  Over those 2200 blocks, on average there were 9.7 honest blocks at the end of the longest chain.  Based on the simulation, one expects to see a longest string of 22.0 honest blocks somewhere during the same period.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  This encourages miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37476</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37476"/>
		<updated>2013-05-02T23:38:35Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ simulation program and result&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are rough.  Simulation confirms that after the calculated number of blocks, an honest block is usually in the lead.  However, if the checkpoint is further in the past, it takes longer.  Here is the C program I used to simluate attacks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;// Public domain.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static int&lt;br /&gt;
usage ()&lt;br /&gt;
{&lt;br /&gt;
  printf (&amp;quot;Usage: wfscp [ATTACKER_SHARE [INCLUSION_RATE [TX_PER_BLOCK [CP_AGE [BLOCKS_PER_ITER [ITERS [RANDOM_SEED]]]]]]]\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Simulate work-fee-since-checkpoint under attack by an entity\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;controlling ATTACKER_SHARE%% (between 0 and 100) of hash power\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;and seeking to include only INCLUSION_RATE%% (0 to 100) of\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;transactions (weighted by fee).\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;Run ITERS simulations, each lasting BLOCKS_PER_ITER blocks.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;TX_PER_BLOCK is the rate of transactions per block, pre-attack.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;CP_AGE is the difference in height between the last pre-attack\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;block and the last checkpoint.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;The integer RANDOM_SEED initializes the random number stream.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, all transactions are assumed to carry an equal fee.\n&amp;quot;);&lt;br /&gt;
  printf (&amp;quot;For simplicity, difficulty is assumed constant.\n&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void&lt;br /&gt;
wfscp (double attacker_share, double inclusion_rate, double avg_tx_per_block,&lt;br /&gt;
       unsigned int checkpoint_age, unsigned int blocks_per_iter,&lt;br /&gt;
       unsigned int iters)&lt;br /&gt;
{&lt;br /&gt;
  unsigned int iter = 0;&lt;br /&gt;
  double sum_reorgs = 0.0;&lt;br /&gt;
  double sum_honest_lead = 0.0;&lt;br /&gt;
  double sum_max_lead = 0.0;&lt;br /&gt;
&lt;br /&gt;
  printf (&amp;quot;attacker share: %f%%\n&amp;quot;, 100.0 * attacker_share);&lt;br /&gt;
  printf (&amp;quot;attacker transaction inclusion rate: %f%%\n&amp;quot;, 100.0 * inclusion_rate);&lt;br /&gt;
  printf (&amp;quot;average transactions per block: %f\n&amp;quot;, avg_tx_per_block);&lt;br /&gt;
  printf (&amp;quot;checkpoint age: %u\n&amp;quot;, checkpoint_age);&lt;br /&gt;
  printf (&amp;quot;blocks per run: %u\n&amp;quot;, blocks_per_iter);&lt;br /&gt;
&lt;br /&gt;
  for (;; iter++)&lt;br /&gt;
    {&lt;br /&gt;
      unsigned int attacker_blocks = 0, honest_blocks = 0;&lt;br /&gt;
      double attacker_weight = checkpoint_age * (checkpoint_age + 1) * avg_tx_per_block / 2;&lt;br /&gt;
      double honest_weight = attacker_weight;&lt;br /&gt;
      double included_tx = checkpoint_age * avg_tx_per_block, excluded_tx = 0.0;&lt;br /&gt;
      unsigned int honest_lead = 0;&lt;br /&gt;
      unsigned int max_lead = 0;&lt;br /&gt;
      unsigned int reorgs = 0;&lt;br /&gt;
&lt;br /&gt;
      if (iters &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          printf (&amp;quot;\rAvg after %u runs: %.4f reorgs, honest lead %.4f, max lead %.4f  &amp;quot;,&lt;br /&gt;
                  iter, sum_reorgs / iter, sum_honest_lead / iter,&lt;br /&gt;
                  sum_max_lead / iter);&lt;br /&gt;
        }&lt;br /&gt;
      if (iter &amp;gt;= iters)&lt;br /&gt;
        {&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
      for (; attacker_blocks + honest_blocks &amp;lt; blocks_per_iter;)&lt;br /&gt;
        {&lt;br /&gt;
          double r = drand48 () * (avg_tx_per_block + 1.0);&lt;br /&gt;
&lt;br /&gt;
          if (r &amp;lt; attacker_share)&lt;br /&gt;
            {&lt;br /&gt;
              // Attacker extends the last attacker block.&lt;br /&gt;
              attacker_blocks++;&lt;br /&gt;
&lt;br /&gt;
              // New weight is the parent block&#039;s weight&lt;br /&gt;
              // (attacker_weight) plus SUM(fee[j]) over included&lt;br /&gt;
              // transactions.  Difficulty assumed constant 1.0.&lt;br /&gt;
              attacker_weight += included_tx;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead &amp;gt; 0 &amp;amp;&amp;amp; attacker_weight &amp;gt; honest_weight)&lt;br /&gt;
                {&lt;br /&gt;
                  reorgs++;&lt;br /&gt;
                  honest_lead = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              // Honest miner extends the best block.&lt;br /&gt;
              honest_blocks++;&lt;br /&gt;
&lt;br /&gt;
              if (honest_lead == 0)&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending attacker&#039;s block.&lt;br /&gt;
                  // New weight is the parent block&#039;s value (attacker_weight)&lt;br /&gt;
                  // plus excluded fees times the number of orphan blocks,&lt;br /&gt;
                  // plus sum of current fees.&lt;br /&gt;
                  honest_weight = attacker_weight +&lt;br /&gt;
                    (excluded_tx * honest_blocks) + included_tx;&lt;br /&gt;
                }&lt;br /&gt;
              else&lt;br /&gt;
                {&lt;br /&gt;
                  // Extending an honest block.&lt;br /&gt;
                  // Weight adds just current fees.&lt;br /&gt;
                  honest_weight += included_tx + excluded_tx;&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
              honest_lead += 1;&lt;br /&gt;
              if (honest_lead &amp;gt; max_lead)&lt;br /&gt;
                {&lt;br /&gt;
                  max_lead = honest_lead;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
          else if (r &amp;lt; inclusion_rate * avg_tx_per_block + 1.0)&lt;br /&gt;
            {&lt;br /&gt;
              included_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
          else&lt;br /&gt;
            {&lt;br /&gt;
              excluded_tx += 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
      sum_reorgs += reorgs;&lt;br /&gt;
      sum_honest_lead += honest_lead;&lt;br /&gt;
      sum_max_lead += max_lead;&lt;br /&gt;
    }&lt;br /&gt;
  printf (&amp;quot;\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int&lt;br /&gt;
main (int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
  double attacker_share = 0.7;&lt;br /&gt;
  double inclusion_rate = 0.5;&lt;br /&gt;
  double avg_tx_per_block = 300.0;&lt;br /&gt;
  unsigned int checkpoint_age = 0;&lt;br /&gt;
  unsigned int blocks_per_iter = 1000;&lt;br /&gt;
  unsigned int iters = 1000;&lt;br /&gt;
&lt;br /&gt;
  if (argc &amp;gt; 1 &amp;amp;&amp;amp; argv[1][0])&lt;br /&gt;
    attacker_share = atof (argv[1]) / 100.0;&lt;br /&gt;
  if (attacker_share == 0.0)&lt;br /&gt;
    return usage ();&lt;br /&gt;
  if (argc &amp;gt; 2 &amp;amp;&amp;amp; argv[2][0])&lt;br /&gt;
    inclusion_rate = atof (argv[2]) / 100.0;&lt;br /&gt;
  if (argc &amp;gt; 3 &amp;amp;&amp;amp; argv[3][0])&lt;br /&gt;
    avg_tx_per_block = atof (argv[3]);&lt;br /&gt;
  if (argc &amp;gt; 4 &amp;amp;&amp;amp; argv[4][0])&lt;br /&gt;
    checkpoint_age = atoi (argv[4]);&lt;br /&gt;
  if (argc &amp;gt; 5 &amp;amp;&amp;amp; argv[5][0])&lt;br /&gt;
    blocks_per_iter = atoi (argv[5]);&lt;br /&gt;
  if (argc &amp;gt; 6 &amp;amp;&amp;amp; argv[6][0])&lt;br /&gt;
    iters = atoi (argv[6]);&lt;br /&gt;
  if (argc &amp;gt; 7 &amp;amp;&amp;amp; argv[7][0])&lt;br /&gt;
    srand48 (atol (argv[7]));&lt;br /&gt;
&lt;br /&gt;
  wfscp (attacker_share, inclusion_rate, avg_tx_per_block, checkpoint_age,&lt;br /&gt;
         blocks_per_iter, iters);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example run where the attacker generates 90% of blocks and seeks to exclude 40% of transactions.  A checkpoint occurs (or is placed during the attack) at the start of the attack.  The simulation lasts 2200 blocks and repeats 1000 times:&lt;br /&gt;
&lt;br /&gt;
 $ ./wfscp 90 60 100 0 2200 1000 0&lt;br /&gt;
 attacker share: 90.000000%&lt;br /&gt;
 attacker transaction inclusion rate: 60.000000%&lt;br /&gt;
 average transactions per block: 100.000000&lt;br /&gt;
 checkpoint age: 0&lt;br /&gt;
 blocks per run: 2200&lt;br /&gt;
 Avg after 1000 runs: 33.2040 reorgs, honest lead 9.7170, max lead 22.0240  &lt;br /&gt;
&lt;br /&gt;
The result: The attacker caused a reorg (sending the honest transactions back to the memory pool) on average 33.2 times in 2200 blocks.  Over those 2200 blocks, on average there were 9.7 honest blocks at the end of the longest chain.  Based on the simulation, one expects to see a longest string of 22.0 honest blocks somewhere during the same period.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  This encourages miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 23:38, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37469</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37469"/>
		<updated>2013-05-02T20:49:30Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ comment regarding block-generation rewards&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
* This formula works best when transaction fees dominate block-generation rewards.  The attacker keeps its generated coins even after giving up.  This encourages miners to join the attack.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37468</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37468"/>
		<updated>2013-05-02T20:42:20Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ added a few details&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*difficulty[i])&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).  Note that even the existing client allows a some ambiguity in best-chain selection: when blocks of equal chain-work compete, it prefers the first received.&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.  Excluded transactions will have multiple confirmations with increasing frequency.  Only during periods of high attacker luck will they revert to unconfirmed, and such events will occur with decreasing frequency over time.  Merchants might reasonably begin to count orphaned blocks as contributing something to the number of transaction confirmations.&lt;br /&gt;
&lt;br /&gt;
How soon will one honest block weigh the same as nine of the attacker&#039;s blocks?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
The more draconian the attacker, the shorter the attack.  An attacker with 90% who tries to exclude 90% of transaction fees will fail after&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.1/0.9) =~ 162 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or a mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37467</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37467"/>
		<updated>2013-05-02T19:55:04Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ minor tweak&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37462</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37462"/>
		<updated>2013-05-02T18:44:00Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweak&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or through an ancestor, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37461</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37461"/>
		<updated>2013-05-02T18:38:15Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweak&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh nine of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37460</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37460"/>
		<updated>2013-05-02T18:25:45Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Undo revision 37459 by JohnTobey253 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37459</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37459"/>
		<updated>2013-05-02T18:18:52Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ no need to &amp;quot;disregard questionable checkpoints&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37458</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37458"/>
		<updated>2013-05-02T18:02:37Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweaks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37457</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37457"/>
		<updated>2013-05-02T17:59:52Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Work-fee-since-checkpoint as chain weight metric */ tweaks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can disregard questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement over checkpoints and knowledge of orphaned blocks seen will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the (eventually victorious) honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37456</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37456"/>
		<updated>2013-05-02T17:55:06Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: add section heading&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Work-fee-since-checkpoint as chain weight metric ==&lt;br /&gt;
&lt;br /&gt;
How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can prevent questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement regarding checkpoints and orphaned blocks seen will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the victorious honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37455</id>
		<title>Talk:Proof of blockchain fair sharing</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Proof_of_blockchain_fair_sharing&amp;diff=37455"/>
		<updated>2013-05-02T17:52:48Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Work-fees-since-checkpoint as chain-height metric&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How about the following implementation.  Everything stays the same as current Bitcoin except the definition of best chain.  Instead of total chain work as defined by&lt;br /&gt;
&lt;br /&gt;
 SUM(difficulty[i])&lt;br /&gt;
&lt;br /&gt;
over all blocks &#039;&#039;i&#039;&#039; in the chain, we define chain weight as &#039;&#039;chain work-fee since checkpoint&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 SUM(fee[j]*SUM(difficulty[i]))&lt;br /&gt;
&lt;br /&gt;
Here, &#039;&#039;j&#039;&#039; ranges over all fee-bearing transactions in a given branch &#039;&#039;&#039;since the last checkpoint,&#039;&#039;&#039; and &#039;&#039;i&#039;&#039; ranges over all valid blocks that contain transaction &#039;&#039;j,&#039;&#039; directly or indirectly, &#039;&#039;&#039;including orphaned blocks.&#039;&#039;&#039;  Checkpoints may be specified by administrative fiat, by a central authority (as currently), or by one of the proposed proof-of-stake checkpointing schemes, so long as one can prevent questionable checkpoints when one notices an attack in progress.&lt;br /&gt;
&lt;br /&gt;
Network disagreement regarding checkpoints and orphaned blocks seen will eventually work itself out, I think, faster and more automatically than under current conditions (which rely on manual intervention to develop and patch the block-acceptance algorithm in reaction to attacks).&lt;br /&gt;
&lt;br /&gt;
For simplicity, assume there is no block-size limit.  A typical chain under 90% attack will have a side chain about every ninth block.  Side chains occasionally grow longer than one block, but typically, the &#039;&#039;first&#039;&#039; block in a side chain contains all the excluded transactions from previous side chains since the attack began.  Eventually, each side-chain-initial block will outweigh several of the attacker&#039;s blocks.&lt;br /&gt;
&lt;br /&gt;
How soon?  It depends on the checkpoint age and the proportion of transaction fees excluded by the attacker.  In the happy case where the last checkpoint immediately precedes the attack, my calculations show an approximate upper bound of&lt;br /&gt;
&lt;br /&gt;
 2 * (A/H)^3 * (I/E)&lt;br /&gt;
&lt;br /&gt;
blocks, where &#039;&#039;A&#039;&#039; is the attacker strength, &#039;&#039;H&#039;&#039; is the honest network strength, &#039;&#039;I&#039;&#039; is the average fees &#039;&#039;included&#039;&#039; by the attacker, per block, and &#039;&#039;E&#039;&#039; is the average available fees foregone by the attacker, per block.  For example, an attacker with 90% trying to exclude 40% of transactions (weighted by fee) can succeed for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.9/0.1)^3 * (0.6/0.4) =~ 2200 blocks&lt;br /&gt;
&lt;br /&gt;
A 70% attacker can exclude 10% of transaction fees for&lt;br /&gt;
&lt;br /&gt;
 2 * (0.7/0.3)^3 * (0.9/0.1) =~ 230 blocks&lt;br /&gt;
&lt;br /&gt;
In practice, I suspect the time would be less; my calculations are still rough.  However, if the checkpoint is further in the past, it takes longer.&lt;br /&gt;
&lt;br /&gt;
Corollaries:&lt;br /&gt;
&lt;br /&gt;
* Orphaned block hashes are no longer wasted but protect the network.&lt;br /&gt;
* Transaction fees protect the network in a new, more direct way.&lt;br /&gt;
* Good citizens may be able to fight an attack by submitting fee-bearing transactions that the attacker would exclude, increasing &#039;&#039;E.&#039;&#039;&lt;br /&gt;
* Conversely, an attacker submitting self-transactions to increase &#039;&#039;I&#039;&#039; would put those fees at risk of capture by the victorious honest network.&lt;br /&gt;
* Keeping up-to-date on checkpoints protects users by speeding up the resolution of this kind of attack.&lt;br /&gt;
* Intuitively, the chain weight formula rewards &#039;&#039;&#039;confirmation of fee-bearing transactions&#039;&#039;&#039; as opposed to simply &amp;quot;work&amp;quot;.&lt;br /&gt;
* This change does not affect block acceptance criteria, so it is arguably not a hard fork or mandatory upgrade.  However, it works best with unlimited block size, at least as regards fee-bearing transactions.&lt;br /&gt;
&lt;br /&gt;
[[User:JohnTobey253|JohnTobey253]] ([[User talk:JohnTobey253|talk]]) 17:52, 2 May 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=36251</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=36251"/>
		<updated>2013-03-20T18:34:31Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: update: abe.john-edwin-tobey.org not offline currently&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://bitcointalk.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.md&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://abe.bitcoinstats.org:2750 Demonstration site]&lt;br /&gt;
* [http://abe.john-edwin-tobey.org/ Original demonstration site]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=22785.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Firstbits&amp;diff=27794</id>
		<title>Firstbits</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Firstbits&amp;diff=27794"/>
		<updated>2012-06-13T02:23:27Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Flagged statement needing citation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Firstbits&#039;&#039;&#039; refers to the practice of abbreviating a [[Bitcoin address]] such that only enough of the initial characters of the address are given so that the full address can be identified from the [[block chain]].  It also refers to the website http://www.Firstbits.com.&lt;br /&gt;
&lt;br /&gt;
The term Firstbits was popularized by the Firstbits website, which was provided with the intent of a &amp;quot;Bitcoin address shortener&amp;quot;, working similar to a URL shortener.  Firstbits.com performs a lookup service, giving the full address from the block chain from the initial portion of an address.  Anyone with access to a complete copy of the block chain can independently perform the same lookup done by Firstbits.com.&lt;br /&gt;
&lt;br /&gt;
Any time a Bitcoin address is used for transactional purposes and appears in the block chain, its firstbits - or the prefix that uniquely identifies that address within the block chain - are considered assigned at that time.  If another address is created and used with the same prefix at a later time, the firstbits of that new address will be at least one character longer, as the shorter prefix remains reserved for the address that used it first.  No action on the part of any user is required for firstbits to be assigned - any transaction activity (receiving or sending) for an address for the first time results in firstbits becoming automatically assigned.&lt;br /&gt;
&lt;br /&gt;
Unlike Bitcoin addresses, firstbits are deemed assigned in a &#039;&#039;&#039;case-insensitive&#039;&#039;&#039; manner.&lt;br /&gt;
&lt;br /&gt;
The firstbits of the very first address to be used by [[Satoshi]] in the [[genesis block]] of the [[block chain]] will have been &#039;&#039;&#039;&amp;quot;1&amp;quot;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Criticism==&lt;br /&gt;
Firstbits is generally considered to be a bad idea because it encourages transaction spam.&lt;br /&gt;
This position is held by most, if not all, of Bitcoin developers.{{Citation needed}}&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=22609</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=22609"/>
		<updated>2012-01-22T19:08:16Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Updated link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://bitcointalk.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.md&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://abe.john-edwin-tobey.org/ Demonstration site]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=22785.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18125</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18125"/>
		<updated>2011-10-16T04:42:59Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Protecting against double proof */ minor tweaks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic. Alternative chains may share miners with a &#039;&#039;&#039;parent&#039;&#039;&#039; network such as Bitcoin&#039;s; this is called &#039;&#039;&#039;merged mining&#039;&#039;&#039;. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that [[Satoshi Nakamoto|Satoshi]] was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
== Sharing work ==&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Independent node software ==&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
== Handling your new block chain ==&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
== Paying for resources on alternative chains with Bitcoins ==&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
== Incentivising non-resource based chains ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
== Mining on the alt-chain but not Bitcoin ==&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
== Scaling up ==&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Protecting against double proof ===&lt;br /&gt;
&lt;br /&gt;
The merkle tree approach to scalability comes with a caveat.  If naïvely implemented, a miner could cheat the proof-of-work system by putting more than one alt-chain block header into one Bitcoin block.  This &amp;quot;cheating&amp;quot; would not cause a problem if the alt-chain blocks all had the same previous-block hash: one or another would win the race, as happens when competing blocks enter the network.  The problem would arise if a linked series of alt-chain blocks all existed in one Bitcoin block&#039;s auxiliary merkle trees.  The miner could work on them all at once, getting more from his hashes than difficulty warrants.&lt;br /&gt;
&lt;br /&gt;
Namecoin&#039;s [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269&amp;amp;start=11 solution] is to constrain the paths by which alt-chain blocks may be embedded in Bitcoin blocks.  This works, but it complicates the picture for miners and chain designers in a future with many alternative chains.&lt;br /&gt;
&lt;br /&gt;
Perhaps a better solution for new chains is to prevent the existence of linked series of alt-chain blocks which lack proof of work.  For example, one could require each alt-chain block to refer (perhaps via its own coinbase or a new header field) to the &amp;quot;solution&amp;quot; (target-meeting hash of parent chain block) as well as the hash of the previous block in the alt chain.  (In Bitcoin, these two hashes are the same.)  This would force blocks to refer not just to the previous block in the chain but to the proof of work on that block.  A series of alt-chain blocks all being worked on would not make sense, because the second block in the series would refer to the first block&#039;s solution, so the first block would have been solved already.&lt;br /&gt;
&lt;br /&gt;
== Generalized proof of work ==&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script simply appends the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=6197.0 BitDNS in the words of Satoshi]&lt;br /&gt;
* [http://dot-bit.org/Merged_Mining Merged Mining] in Namecoin&lt;br /&gt;
* [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269 Namecoin forum discussion]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=46927.msg572981#msg572981 Forum thread about double proof]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Merged_mining&amp;diff=18124</id>
		<title>Merged mining</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Merged_mining&amp;diff=18124"/>
		<updated>2011-10-16T04:17:57Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Redirect to Alternative Chains&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Alternative Chains]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18123</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18123"/>
		<updated>2011-10-16T04:17:00Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Introduce term &amp;#039;merged mining&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic. Alternative chains may share miners with a &#039;&#039;&#039;parent&#039;&#039;&#039; network such as Bitcoin&#039;s; this is called &#039;&#039;&#039;merged mining&#039;&#039;&#039;. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that [[Satoshi Nakamoto|Satoshi]] was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
== Sharing work ==&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Independent node software ==&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
== Handling your new block chain ==&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
== Paying for resources on alternative chains with Bitcoins ==&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
== Incentivising non-resource based chains ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
== Mining on the alt-chain but not Bitcoin ==&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
== Scaling up ==&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Protecting against double proof ===&lt;br /&gt;
&lt;br /&gt;
The merkle tree approach to scalability comes with a caveat.  If naïvely implemented, a miner could cheat the proof-of-work system by putting more than one alt-chain block header into one Bitcoin block.  This &amp;quot;cheating&amp;quot; would not cause a problem if the alt-chain blocks all had the same previous-block hash: one or another would win the race, as happens when competing blocks enter the network.  The problem would arise if a linked series of alt-chain blocks all existed in one Bitcoin block&#039;s auxiliary merkle trees.  The miner could work on them all at once, getting more from his hashes than difficulty warrants.&lt;br /&gt;
&lt;br /&gt;
Namecoin&#039;s [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269&amp;amp;start=11 solution] is to constrain the paths by which alt-chain blocks may be embedded in Bitcoin blocks.  This works, but it complicates the picture for miners and chain designers in a future with many alternative chains.&lt;br /&gt;
&lt;br /&gt;
Perhaps a better solution for new chains is to prevent the existence of linked series of alt-chain blocks which lack proof of work.  For example, one could require each aux chain block to refer (perhaps via its own coinbase or a new header field) to the &amp;quot;solution&amp;quot; (target-meeting hash of parent chain block) as well as the hash of the previous block in the alt chain.  (In Bitcoin, these two hashes are the same.)  This would force blocks to refer not just to the previous block in the chain but to the proof of work on that block.  A series of alt-chain blocks all being worked on would not make sense, because the second block in the series would have to reference the first block&#039;s solution, so the first block would have to have been solved.&lt;br /&gt;
&lt;br /&gt;
== Generalized proof of work ==&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script simply appends the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=6197.0 BitDNS in the words of Satoshi]&lt;br /&gt;
* [http://dot-bit.org/Merged_Mining Merged Mining] in Namecoin&lt;br /&gt;
* [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269 Namecoin forum discussion]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=46927.msg572981#msg572981 Forum thread about double proof]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18122</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=18122"/>
		<updated>2011-10-16T04:09:51Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Added section: Protecting against double proof&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that [[Satoshi Nakamoto|Satoshi]] was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
== Sharing work ==&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Independent node software ==&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
== Handling your new block chain ==&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
== Paying for resources on alternative chains with Bitcoins ==&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
== Incentivising non-resource based chains ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
== Mining on the alt-chain but not Bitcoin ==&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
== Scaling up ==&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Protecting against double proof ===&lt;br /&gt;
&lt;br /&gt;
The merkle tree approach to scalability comes with a caveat.  If naïvely implemented, a miner could cheat the proof-of-work system by putting more than one alt-chain block header into one Bitcoin block.  This &amp;quot;cheating&amp;quot; would not cause a problem if the alt-chain blocks all had the same previous-block hash: one or another would win the race, as happens when competing blocks enter the network.  The problem would arise if a linked series of alt-chain blocks all existed in one Bitcoin block&#039;s auxiliary merkle trees.  The miner could work on them all at once, getting more from his hashes than difficulty warrants.&lt;br /&gt;
&lt;br /&gt;
Namecoin&#039;s [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269&amp;amp;start=11 solution] is to constrain the paths by which alt-chain blocks may be embedded in Bitcoin blocks.  This works, but it complicates the picture for miners and chain designers in a future with many alternative chains.&lt;br /&gt;
&lt;br /&gt;
Perhaps a better solution for new chains is to prevent the existence of linked series of alt-chain blocks which lack proof of work.  For example, one could require each aux chain block to refer (perhaps via its own coinbase or a new header field) to the &amp;quot;solution&amp;quot; (target-meeting hash of parent chain block) as well as the hash of the previous block in the alt chain.  (In Bitcoin, these two hashes are the same.)  This would force blocks to refer not just to the previous block in the chain but to the proof of work on that block.  A series of alt-chain blocks all being worked on would not make sense, because the second block in the series would have to reference the first block&#039;s solution, so the first block would have to have been solved.&lt;br /&gt;
&lt;br /&gt;
== Generalized proof of work ==&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script simply appends the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=6197.0 BitDNS in the words of Satoshi]&lt;br /&gt;
* [http://dot-bit.org/Merged_Mining Merged Mining] in Namecoin&lt;br /&gt;
* [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269 Namecoin forum discussion]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=46927.msg572981#msg572981 Forum thread about double proof]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=18119</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=18119"/>
		<updated>2011-10-16T02:59:34Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Updated links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://forum.bitcoin.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.md&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://abe.john-edwin-tobey.org/ Demonstration site]&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=16549</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=16549"/>
		<updated>2011-09-13T04:56:24Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: External links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that [[Satoshi Nakamoto|Satoshi]] was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
== Sharing work ==&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Independent node software ==&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
== Handling your new block chain ==&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
== Paying for resources on alternative chains with Bitcoins ==&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
== Incentivising non-resource based chains ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
== Mining on the alt-chain but not Bitcoin ==&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
=== Scaling up ===&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
== Generalized proof of work ==&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script simply appends the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=6197.0 BitDNS in the words of Satoshi]&lt;br /&gt;
* [http://dot-bit.org/Merged_Mining Merged Mining] in Namecoin&lt;br /&gt;
* [http://dot-bit.org/forum/viewtopic.php?f=5&amp;amp;t=269 Namecoin forum discussion]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Software&amp;diff=16307</id>
		<title>Software</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Software&amp;diff=16307"/>
		<updated>2011-09-08T01:53:00Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Added Abe under &amp;quot;Web apps (opensource)&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of Bitcoin-related software. See also [[:Category:Software|Category:Software]].&lt;br /&gt;
&lt;br /&gt;
==Bitcoin clients==&lt;br /&gt;
===Bitcoin clients===&lt;br /&gt;
*[[Original Bitcoin client|Bitcoin client]] - standard Bitcoin client, recommended for installation&lt;br /&gt;
*[[bitcoind]] - GUI-less version of the standard Bitcoin client, providing [[API reference (JSON-RPC)|JSON-RPC]] interface (see also -server option of the standard client)&lt;br /&gt;
&lt;br /&gt;
===Frontends to bitcoind===&lt;br /&gt;
*[[BitcoinApp]] - RPC client for iOS devices (iPhone, iPad, iPodTouch)&lt;br /&gt;
*[[Bitcoiner]] - Java RPC client (Android)&lt;br /&gt;
*[[Bitcoin-js-remote]] - JavaScript RPC client, support for QR codes&lt;br /&gt;
*[[Bitcoin-qt]] - C++/Qt based tabbed UI for Bitcoin, Linux/MacOSX/Windows, full-featured&lt;br /&gt;
*[[Python Bitcoinclient]] - Python RPC client&lt;br /&gt;
*[[Spesmilo]] - Python/PySide RPC client&lt;br /&gt;
*[[Bitcoin-python]] - Python API&lt;br /&gt;
*[[Java Bitcoin Client]] - Java API&lt;br /&gt;
*[[Wallet.Net]] - Windows (soon to be cross platform) Full Featured, secure RPC client&lt;br /&gt;
*[[FastCat BRPC]] - Fast low memory footprint Windows client!&lt;br /&gt;
Alternative, experimental implementations:&lt;br /&gt;
*[[BitDroid]] - Java client&lt;br /&gt;
*[[Bitdollar]] - C++/Qt client, unstable beta version&lt;br /&gt;
*[[BitCoinJ]] - Java client by Google, early development stage&lt;br /&gt;
*[[Freecoin]] - C++ client, supports alternative currencies like [[Beertoken]]&lt;br /&gt;
*[[Pycoin]] - Python client&lt;br /&gt;
*[[QBitcoin]] - C++/Qt client, unfinished&lt;br /&gt;
*[[BCCAPI]] (Bitcoin Client API) - a java library designed for making secure light-weight bitcoin clients. &lt;br /&gt;
&lt;br /&gt;
===Frontends to eWallet===&lt;br /&gt;
*[[BitPay]] - Android application&lt;br /&gt;
&lt;br /&gt;
==Bitcoin Trade Data==&lt;br /&gt;
*[[Bitcoin Charts]] – Html website that has trading data for virtual all the bitcoin markets.&lt;br /&gt;
*[[MtGox Live]] - Html website that shows a live fee of [[MtGox]] trade data in an innovative chart form.  (Must Use Chrome)&lt;br /&gt;
*[[BitcoinNotify]] - Realtime Bitcoin price alerts (via SMS, Jabber, e-mail or HTTP call) on major exchanges&lt;br /&gt;
*[[Bitcoinity]] - Html Ajax website that shows a live feed of [[MtGox]], [[TradeHill]], and [[BitMarket]].&lt;br /&gt;
*[[Bitcoin Sentiment Index]] - A financial index that collects and disseminates sentiment data about bitcoin.&lt;br /&gt;
*[[Preev]] - Bitcoin converter with live exchange rates.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin software==&lt;br /&gt;
&lt;br /&gt;
===Web interfaces for merchants===&lt;br /&gt;
*[[MyBitcoin]] - Buy Now button to insert on websites&lt;br /&gt;
*[[Bitcoin Evolution]] - Non wallet-based Buy Now button to insert into websites (handles sales tracking; client must be used for actual transaction)&lt;br /&gt;
*[[Btceconomy]] - a JavaScript widget listing items for sale&lt;br /&gt;
*[[Javascript Bitcoin Converter]] - currency conversion&lt;br /&gt;
&lt;br /&gt;
===Web apps (opensource)===&lt;br /&gt;
*[[Bitcoin Central]] - currency exchange&lt;br /&gt;
*[[Bitcoin Poker Room]] - poker site&lt;br /&gt;
*[[Abe]] - block chain viewer&lt;br /&gt;
&lt;br /&gt;
===Browser extensions===&lt;br /&gt;
*[[Bitcoin Extension]] - check balance and send bitcoins (Chrome)&lt;br /&gt;
*[[Bitcoin Ticker]] - monitoring price (Chrome)&lt;br /&gt;
*[[Bitcoin Prices (extension)]] - monitoring price (Firefox)&lt;br /&gt;
*[[Bitcoin Tool]] - recognizes Bitcoin addresses on websites (Firefox, Chrome, IE)&lt;br /&gt;
&lt;br /&gt;
===PC apps===&lt;br /&gt;
*[[BTConvert]] - currency conversion&lt;br /&gt;
*[[Sierra Chart MtGox Bridge]] - real-time charting&lt;br /&gt;
*[[BTC Trader]] - live charting and tech-analysis&lt;br /&gt;
*[[BitTicker]] - monitoring price (Mac OS X)&lt;br /&gt;
*[[ToyTrader]] - a command line trading tool for [[MtGox]]&lt;br /&gt;
*[[goxsh]] - a command-line frontend to the [[MtGox|Mt. Gox Bitcoin Exchange]] (Python)&lt;br /&gt;
&lt;br /&gt;
===Mobile apps===&lt;br /&gt;
==== iPhone / iPad ====&lt;br /&gt;
*[[Bitcoin Ticker (iPhone)]] - monitoring price w/push notifications&lt;br /&gt;
*[[BitCoins Mobile]] - First iPad native app! Live market data, news feeds, mining pool statistics, full screen exchange price charts, bitcoin network statistical charts. (iPad only, iPhone/iPod Touch coming soon!)&lt;br /&gt;
*[https://github.com/teeman/BitcoinTrader BitcoinTrader] - Spend/receive BTC via QR codes, trade, deposit/withdraw, etc. Supports Mt. Gox, TradeHill, ExchB, CampBX, and InstaWallet.&lt;br /&gt;
==== Android ====&lt;br /&gt;
* Direct link to Android Market bitcoin apps. https://market.android.com/search?q=bitcoin&lt;br /&gt;
*[[Bitcoin Wallet]] - This is the most functional android bitcoin wallet application. https://market.android.com/details?id=de.schildbach.wallet&lt;br /&gt;
*[[Bitcoin Android]] - Does not appear to be being maitained anymore. https://market.android.com/details?id=com.bitcoinandroid&lt;br /&gt;
*[[Bitpay]] - Is not related to the bit-pay.com online payment processor. Does not appear to be being maintained. https://market.android.com/details?id=com.bitcoin.bitpay&lt;br /&gt;
&lt;br /&gt;
*[[Bitcoin Alert]] - monitoring price (Android)&lt;br /&gt;
*[[BitcoinX]] - monitoring price (Android)&lt;br /&gt;
*[[BtcMobile]] - monitoring price and mining pool statistics (iPhone/iPad, Android)&lt;br /&gt;
*[[Miner Status]] - monitoring miner status (Android)&lt;br /&gt;
*[[SMS Bitcoins]] - transactions by SMS&lt;br /&gt;
*[[Bitcoin Wallet Balance]] - view your balance in real time on your android phone&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Other device apps===&lt;br /&gt;
*[[Zen Cart Bitcoin Payment Module]] - a payment module that interacts with bitcoind for the Zen Cart eCommerce shopping chart&lt;br /&gt;
&lt;br /&gt;
===Operating systems===&lt;br /&gt;
*[[LinuxCoin]] - a lightweight Debian-based OS, with the Bitcoin client and GPU mining software&lt;br /&gt;
&lt;br /&gt;
===Mining apps===&lt;br /&gt;
*[[Poclbm]] - Python/OpenCL GPU miner ([[Poclbm-gui|GUI]])&lt;br /&gt;
*[[Poclbm-mod]] - more efficient version of [[Poclbm]] ([[Poclbm-mod-gui|GUI]])&lt;br /&gt;
*[[DiabloMiner]] - Java/OpenCL GPU miner ([[DiabloMiner.app|MAC OS X GUI]])&lt;br /&gt;
*[[RPC Miner]] - remote RPC miner ([[RPCminer.app|MAC OS X GUI]])&lt;br /&gt;
*[[Phoenix miner]] - miner&lt;br /&gt;
*[[Cpu Miner]] - miner&lt;br /&gt;
*[[Ufasoft miner]] - miner&lt;br /&gt;
*[[Pyminer]] - Python miner, reference implementation&lt;br /&gt;
*[[Remote miner]] - mining pool software&lt;br /&gt;
*[[Open Source FGPA Bitcoin Miner]] - a miner that makes use of an FPGA Board&lt;br /&gt;
&lt;br /&gt;
===Mining Pool Servers (backend)===&lt;br /&gt;
*[[Pushpoold]] - The original mining pool server&lt;br /&gt;
*[[Poold]] - Python mining pool server&lt;br /&gt;
*[[PoolServerJ]] - Java mining pool server&lt;br /&gt;
&lt;br /&gt;
===Utilities, libraries, and interfaces:===&lt;br /&gt;
*[[Bitcointools]] - a set of Python tools accessing the transaction database and the wallet&lt;br /&gt;
*[[Finance::MtGox]] - a Perl module which interfaces with the Mt. Gox API&lt;br /&gt;
*[[BitcoinCrypto]] - a lightweight Bitcoin crypto library for Java/Android&lt;br /&gt;
*[[Bitcoin Dissector]] - a wireshark dissector for the bitcoin protocol&lt;br /&gt;
&lt;br /&gt;
===Lists of software===&lt;br /&gt;
*[[BitGit]] - list of Bitcoin-related opensource projects hosted at Git&lt;br /&gt;
&lt;br /&gt;
===Developer resources===&lt;br /&gt;
*[[:Category:Developer|Category:Developer]]&lt;br /&gt;
*[[:Category:Technical|Category:Technical]]&lt;br /&gt;
*[[Original Bitcoin client/API calls list]]&lt;br /&gt;
*[[API reference (JSON-RPC)]]&lt;br /&gt;
&lt;br /&gt;
===Other===&lt;br /&gt;
*[[Namecoin]] - a distributed naming system based on Bitcoin technology&lt;br /&gt;
*[[Bitcoin Consultancy]] - an organization providing open source software and Bitcoin-related consulting&lt;br /&gt;
*[[Open Transactions]] - a financial crypto and digital cash software library, complementary to Bitcoin&lt;br /&gt;
*[[Moneychanger]] - Java-based GUI for [[Open Transactions]]&lt;br /&gt;
*[http://btcnames.org/ BTCnames] - a webbased aliasing service which allows to handle unlimited names for your BTC deposit hashes&lt;br /&gt;
*[[Devcoin]] - the open source developer coin&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=12942</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=12942"/>
		<updated>2011-07-14T20:27:14Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* External Links */ updated demo site URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://forum.bitcoin.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.txt&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://abe.john-edwin-tobey.org/ Demonstration site]&lt;br /&gt;
* [https://forum.bitcoin.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Nonce&amp;diff=12138</id>
		<title>Nonce</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Nonce&amp;diff=12138"/>
		<updated>2011-06-30T13:05:34Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Soften &amp;quot;impossible&amp;quot; wrt breaking the hash function.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;quot;nonce&amp;quot; in a bitcoin [[block]] is a 32-bit (4-byte) field whose value is set so that the [[hash]] of the block will contain a run of zeros. The rest of the fields may not be changed, as they have a defined meaning.&lt;br /&gt;
&lt;br /&gt;
Any change to the the block data (such as the nonce) will make the block hash completely different. Since it is [[wikipedia:Cryptographic hash function|believed infeasible]] to predict which combination of bits will result in the right hash, many different nonce values are tried, and the hash is recomputed for each value until a hash containing the required number of zero bits is found. As this iterative calculation requires time and resources, the presentation of the block with the correct nonce value constitutes [[proof of work]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12053</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12053"/>
		<updated>2011-06-29T15:32:29Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Generalized proof of work */ tense agreement.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Objective ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that Satoshi was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
=== Sharing work ===&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Independent node software ===&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
=== Handling your new block chain ===&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
=== Paying for resources on alternative chains with Bitcoins ===&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
=== Incentivising non-resource based chains ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
=== Mining on the alt-chain but not Bitcoin ===&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
=== Scaling up ===&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Generalized proof of work ===&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script simply appends the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12052</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12052"/>
		<updated>2011-06-29T15:30:21Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Generalized proof of work */ tweaks.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Objective ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that Satoshi was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
=== Sharing work ===&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Independent node software ===&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
=== Handling your new block chain ===&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
=== Paying for resources on alternative chains with Bitcoins ===&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
=== Incentivising non-resource based chains ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
=== Mining on the alt-chain but not Bitcoin ===&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
=== Scaling up ===&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Generalized proof of work ===&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions and headers, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to satisfy the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script would simply append the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12050</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12050"/>
		<updated>2011-06-29T15:26:58Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: /* Generalized proof of work */ minor correction.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Objective ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that Satoshi was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
=== Sharing work ===&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Independent node software ===&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
=== Handling your new block chain ===&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
=== Paying for resources on alternative chains with Bitcoins ===&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
=== Incentivising non-resource based chains ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
=== Mining on the alt-chain but not Bitcoin ===&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
=== Scaling up ===&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Generalized proof of work ===&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all three as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block header, and the hash of its output would have to match the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script would simply append the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12049</id>
		<title>Alternative chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Alternative_chain&amp;diff=12049"/>
		<updated>2011-06-29T15:20:17Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Generalized proof of work&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An &#039;&#039;&#039;alternative chain&#039;&#039;&#039; is a system using the block chain algorithm to achieve distributed consensus on a particular topic, whilst sharing miners with the Bitcoin network. Alternative chains have been suggested as ways to implement DNS, SSL certificate authorities, timestamping, file storage and voting systems.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Objective ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses the [[block chain]] algorithm to achieve distributed consensus on who owns what coins. Block chains were invented specifically for the Bitcoin project but they can be applied anywhere a distributed consensus needs to be established in the presence of malicious or untrustworthy actors.&lt;br /&gt;
&lt;br /&gt;
Whilst it&#039;s possible to abuse the Bitcoin financial block chain for other purposes, it&#039;s better to set up an alternative network and chain which share the same miners. There are several reasons to do this.&lt;br /&gt;
&lt;br /&gt;
* The block chain is a large, complex data structure shared between many people. Verifying its integrity requires many slow (and thus expensive) operations like ECDSA verifications and disk seeks. Everyone who takes part in Bitcoin today runs a node and thus maintains the whole thing. Whilst in future end-users will probably use more efficient but slightly less secure modes (SPV), merchants and miners will probably always pay the full costs for the upkeep of this shared data structure. All these people today are united by a common interest in a new form of payments. They may or may not also be interested in other schemes. So one reason to keep the Bitcoin chain for finance is it&#039;s unfair to externalize the costs of unrelated schemes onto people who are interested only in payments - the canonical example being merchants. Increasing the cost of accepting Bitcoins for goods and services hurts everyone who uses the system by reducing the number of merchants or increasing their costs.&lt;br /&gt;
&lt;br /&gt;
* Another reason is that it&#039;s just bad engineering to cram every possible distributed quorum into the design constraints of Bitcoin. The transaction format Bitcoin uses is flexible but ultimately designed for finance. You cannot leave out the &amp;quot;value&amp;quot; field. It&#039;s always there, even if it&#039;d make no sense for your particular application. Building non-financial applications on top of a financial system results in bizarre protocols and code that are difficult to understand, leading to maintainability problems.&lt;br /&gt;
&lt;br /&gt;
* One final reason is that Satoshi was opposed to putting non-Bitcoin related data into the main chain. As creator of the system, his opinion should carry a lot of weight with anyone serious about extending it.&lt;br /&gt;
&lt;br /&gt;
=== Designing a new network ===&lt;br /&gt;
&lt;br /&gt;
To create a new network that uses Nakamoto block chains, you need to start by defining what a transaction in your new network means. Bitcoin transactions split and combine value using scripts, but yours don&#039;t have to do that. They could be anything. Here&#039;s an example of a simple DNS style &amp;quot;transaction&amp;quot; described using [http://code.google.com/p/protobuf/ Google protocol buffers] syntax.&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
This is very different to a Bitcoin style transaction. There&#039;s no concept of inputs, outputs, addresses, values or scripts. It&#039;s got what you need for a very simple DNS style scheme (that lacks abuse controls etc) and nothing more. There&#039;s also no concept of a &amp;quot;coinbase&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
The block definition is also up to you. It does not have to be formatted in the same way as Satoshi chose, but you need most of the same conceptual parts. You also need to store something else, some data from Bitcoin. Here&#039;s a minimal example of what&#039;s needed:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to observe what we don&#039;t have as well as what we do. We don&#039;t have the following fields from Satoshis format:&lt;br /&gt;
&lt;br /&gt;
# version: protobufs handles the versioning of binary data formats for us&lt;br /&gt;
# merkle root: you can choose to arrange your transactions into a merkle root if you like, so you can use the same disk space reclamation trick Satoshi did. But it&#039;s strictly optional. If you want to simplify things down you can skip it.&lt;br /&gt;
# nonce&lt;br /&gt;
&lt;br /&gt;
=== Sharing work ===&lt;br /&gt;
&lt;br /&gt;
The bitcoin_data field is how you share work with miners today (assuming they opt in by installing your software alongside their bitcoin node). It&#039;s defined like this:&lt;br /&gt;
&lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The coinbase scriptSig contains bits of data in order. Which one is our hash?&lt;br /&gt;
   required int coinbase_tx_index = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
All you need to share work is the above four things.&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Merkle tree]] is a data structure in which each node in the tree is a hash. The leaf nodes are hashes of the things you want to include in the tree. The interior nodes are hashes of the concatenations of the child nodes. A merkle branch is a part of a merkle tree which allows you to cryptographically prove that something you&#039;re given was in the tree, without needing everything that was in the tree. They are calculated by the CBlock::GetMerkleBranch() function in the Bitcoin code.&lt;br /&gt;
&lt;br /&gt;
We store a merkle branch here for efficiency. It means no matter how large the current Bitcoin block is, your alternative network only needs to handle a small amount of data. You could just store the entire Bitcoin block - that would be simpler but inefficient.&lt;br /&gt;
&lt;br /&gt;
The merkle branch links the coinbase transaction to the block header, so you can prove it was in that block. The coinbase TX is a regular Bitcoin coinbase (that makes new coins and claims fees), except the scriptSig on its input contains an extra entry that todays scriptSigs don&#039;t. That extra entry is a hash of your block structure. The coinbase scriptSig today is formatted like this:&lt;br /&gt;
&lt;br /&gt;
 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&amp;amp; nExtraNonce, int64&amp;amp; nPrevTime)&lt;br /&gt;
 {&lt;br /&gt;
     .....&lt;br /&gt;
     pblock-&amp;gt;vtx[0].vin[0].scriptSig = CScript() &amp;lt;&amp;lt; pblock-&amp;gt;nBits &amp;lt;&amp;lt; CBigNum(nExtraNonce);&lt;br /&gt;
     .....&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Just the difficulty bits and the &amp;quot;extra nonce&amp;quot;. But it&#039;s actually allowed to contain anything, as long as it&#039;s not too big. So in your new blocks it&#039;d be:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the MyBlock hash into Bitcoin requires a presently unimplemented RPC command, &amp;quot;setextrahashes&amp;quot;. It&#039;d update a global list and the IncrementExtraNonce function would include the extra hashes when the scriptSig is built. This is a very simple change to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
In the scriptSig above the coinbase_tx_index would be zero. It&#039;s possible to work on an arbitrary number of alternative chains simultaneously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MyBlock hash&amp;gt; &amp;lt;SomeOtherChainBlock hash&amp;gt; &amp;lt;nBits&amp;gt; &amp;lt;nExtraNonce&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in which case the BitcoinData message for SomeOtherChain would be 1 rather than zero.&lt;br /&gt;
&lt;br /&gt;
A more complex change is the other new RPC. Because you have your own chain, it has its own difficulty. Most likely it&#039;ll be different to Bitcoins own. So you need a way to tell Bitcoin &amp;quot;when you find a block that matches an extradifficulty, please let me know&amp;quot;. To mine on multiple difficulties at once, the node vends work (via getwork) matching the easiest difficulty. When a miner reports finding a solution the difficulty is checked to see which chains it is sufficiently difficult for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Important note: Your chain has its &amp;lt;i&amp;gt;own difficulty&amp;lt;/i&amp;gt; and as such the block creation rate is independent of how much mining takes place.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Independent node software ===&lt;br /&gt;
&lt;br /&gt;
Your new network has its own codebase. It can be written in whatever language you like, use whatever P2P protocol you like, store its data however you like and so on.&lt;br /&gt;
&lt;br /&gt;
When a node on your network receives a message informing it about a new transaction, it verifies that transaction follows the rules of your network. To use our simple DNS example it would verify that if you&#039;re claiming a new name, it doesn&#039;t already exist and if you&#039;re transferring a name that the signatures are correct.&lt;br /&gt;
&lt;br /&gt;
If the transaction is valid, it&#039;s added to your current MyBlock message. That message is serialized to binary (protobufs does this for you), hashed and then your node makes an RPC to Bitcoin telling it what the current extra hash is. When Bitcoin finds a Bitcoin-format block of the right difficulty for your network, it informs your software and passes the block header, coinbase transaction and merkle branch to it. Your node combines them together into a BitcoinData message, which is then glued together with your alternative chains block. This &amp;quot;superblock&amp;quot; is then broadcast via your independent P2P network.&lt;br /&gt;
&lt;br /&gt;
When a node on your new network receives a superblock it does the following things:&lt;br /&gt;
&lt;br /&gt;
# Verifies the MyBlock contents are correct, ie, that the transactions follow the rules.&lt;br /&gt;
# Verifies that the MyBlock prev hash makes it fit somewhere in the chain and that the difficulty is correct.&lt;br /&gt;
# Hashes the MyBlock structure and then verifies that this hash appears in the BitcoinData coinbase scriptSig, in the right place.&lt;br /&gt;
# Extracts the merkle root of the Bitcoin format block from the header and then verifies that the coinbase tx provided did, in fact, exist in that block (using the branch, root, tx and header together).&lt;br /&gt;
# Verifies that the hash of the Bitcoin format block header is below the difficulty found in the MyBlock structure.&lt;br /&gt;
&lt;br /&gt;
You&#039;ve now verified that a sufficiently hard proof of work was done over the contents of the MyBlock structure, so your node can relay the newly found block (or if you don&#039;t use a P2P network make it available on your server, etc).&lt;br /&gt;
&lt;br /&gt;
On the other side when Bitcoin finds a block that is correct for the Bitcoin network and chain, it broadcasts it and obviously the hash of your MyBlock is included. Fortunately this is only an additional 33 bytes overhead so nobody cares about it - the pollution of the financial chain is both trivial and constant. Note that regular Bitcoin nodes just ignore this extra hash, it doesn&#039;t mean anything to them.&lt;br /&gt;
&lt;br /&gt;
=== Handling your new block chain ===&lt;br /&gt;
&lt;br /&gt;
You have to handle re-organizations. This is a standard part of the block chain algorithm. When a re-org occurs you have to verify that the state of your world still makes sense. For example in the new chain maybe somebody else now owns a resource you thought you owned. It&#039;s up to you how to inform your users of these events and what app specific logic is appropriate here.&lt;br /&gt;
&lt;br /&gt;
You can choose your own parameters for the new chain. As an example, Satoshi chose to target one new block every ten minutes as a tradeoff between latency and wasted work. You could choose something much larger (hours, days) or much faster if you&#039;re willing to tolerate more splits due to blocks being found simultaneously. Bitcoin retargets the difficulty roughly every two weeks. You could choose some other length of time.&lt;br /&gt;
&lt;br /&gt;
To store the block chain, Satoshi chose to use Berkeley DB as a way to index from transactions to the blocks they appeared in (amongst other things). You could use any database you liked.&lt;br /&gt;
&lt;br /&gt;
=== Paying for resources on alternative chains with Bitcoins ===&lt;br /&gt;
&lt;br /&gt;
A commonly cited reason for putting DNS related data into the financial chain is the desire to pay for names with Bitcoins. You can do this with an independent chain too, because you make the rules and can link the two chains together as you see fit.&lt;br /&gt;
&lt;br /&gt;
To start, decide on the purpose of your payments and who will receive the coins - if anyone. In the case of a DNS system, there are two reasons you might want to pay for names:&lt;br /&gt;
&lt;br /&gt;
# To prevent abuse by people claiming all interesting names via a dictionary attack.&lt;br /&gt;
# To incentivise people to run your software and mine on your alternative chain.&lt;br /&gt;
&lt;br /&gt;
In the first case really nobody should receive the payment. The money is being put up as a collateral and has no other use, so as long as it&#039;s sitting around unspent that is good enough. In the second case the payment should go to the miner working on the DNS chain.&lt;br /&gt;
&lt;br /&gt;
To implement this we extend our hypothetical DNS transaction message like this:&lt;br /&gt;
&lt;br /&gt;
 message NameTx {&lt;br /&gt;
   required string name = 1;&lt;br /&gt;
   repeated bytes ip_addresses = 2;&lt;br /&gt;
   required bytes pubkey = 3;&lt;br /&gt;
   enum ClaimType {&lt;br /&gt;
     NEW_NAME,&lt;br /&gt;
     TRANSFER&lt;br /&gt;
   }&lt;br /&gt;
   required ClaimType type = 4;&lt;br /&gt;
   &lt;br /&gt;
   // Only used if type == TRANSFER. The new owner of the name and signature proving current ownership.&lt;br /&gt;
   optional bytes dest_pubkey = 5;&lt;br /&gt;
   optional bytes signature = 6;&lt;br /&gt;
 &lt;br /&gt;
   // Only used if type == NEW_NAME.&lt;br /&gt;
   optional bytes collateral_signature = 7;&lt;br /&gt;
   optional string miner_address = 8;&lt;br /&gt;
   optional uint64 miner_fee = 9;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The collateral_signature field contains an ECDSA signature generated from a public key that holds some Bitcoins. The miner address is blank when the name purchaser creates the transaction and is filled out after a miner receives it, but before they begin working on it.&lt;br /&gt;
&lt;br /&gt;
To buy a name that costs 10 BTC with a miner fee of 2 BTC, a user presses the &amp;quot;buy name&amp;quot; button in their DNS software. It talks to their local Bitcoin node via RPC and does the following:&lt;br /&gt;
&lt;br /&gt;
# Creates a new Bitcoin address (key).&lt;br /&gt;
# Sends 10 BTC to the new address (a send-to-self transaction).&lt;br /&gt;
# Extracts the key from Bitcoin, meaning it&#039;s no longer available to spend in your wallet.&lt;br /&gt;
# Stores the key in a local DNS data file (&amp;quot;wallet&amp;quot;) somewhere.&lt;br /&gt;
# Sets the miner_fee field to the pre-agreed value of 2 BTC.&lt;br /&gt;
# Takes the public key part and uses it to sign a version of the NameTx that lacks collateral_signature (a signature can&#039;t sign itself) and miner_address.&lt;br /&gt;
# The signature is placed in collateral_signature field.&lt;br /&gt;
# The transaction is sent to a miner who charges 2 BTC.&lt;br /&gt;
&lt;br /&gt;
When the miner receives the transaction, it verifies that the 10 BTC is not spent:&lt;br /&gt;
&lt;br /&gt;
# The ECDSA public key recovery algorithm is run on the collateral_signature. It can yield several possible keys.&lt;br /&gt;
# The public keys recovered are used to verify the signature is correct. This step also figures out which of the possible keys is the right one.&lt;br /&gt;
# The correct public key is turned into a Bitcoin address (by hashing it)&lt;br /&gt;
# The DNS node software queries Bitcoin to discover whether that address has 10 BTC associated with it, or whether the balance of that address is lower. Note that todays software does not index the balance of every address in the system, but it can be added (the Block Explorer does this).&lt;br /&gt;
# If the address does indeed have 10 unspent Bitcoins then the collateral is present and it&#039;s OK to serve the name&lt;br /&gt;
&lt;br /&gt;
The miner then creates a new Bitcoin address for themselves and sets miner_address to contain it, then includes it into the current block being worked on. After a block matching the DNS chains difficulty is found, it is broadcast. Other nodes do the following:&lt;br /&gt;
&lt;br /&gt;
# For each transaction, repeat the verification steps to ensure the collateral is not spent.&lt;br /&gt;
# Check the balance of the miners own address.&lt;br /&gt;
# If the balance is not yet equal to miner_fee, the name is put into a &amp;quot;pending&amp;quot; state in which it is owned but not served in response to DNS queries.&lt;br /&gt;
&lt;br /&gt;
The user observes the broadcast and sees that their name is now pending payment, so they send 2 BTC to the address they find in their transaction. As nodes notice the payment becoming confirmed they start responding to DNS queries for that name (ie, the ownership process is complete).&lt;br /&gt;
&lt;br /&gt;
When the user gets tired of owning the name, he can simply re-import the collateral key into his wallet and spend the coins. The DNS network will soon observe that the coins are spent and make the name available for purchasing by somebody else.&lt;br /&gt;
&lt;br /&gt;
=== Incentivising non-resource based chains ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to incentivise mining on an alt-chain even if that chain does not have any concept of ownership, ie, if the act of finding a block itself is what is being paid for. An example of this is a timestamping chain in which presence in a block alone is sufficient to satisfy the user.&lt;br /&gt;
&lt;br /&gt;
To implement this, set up a new chain as normal. Blocks in this new chain arrange transactions into a merkle tree in the same manner as Bitcoin does. A client that wants something incorporated into a block connects directly to some miners and submits their transaction. The miners add their address to the transaction as normal. Once a miner finds a block, it immediately sends the block to connected clients whose transactions made it in, but does not broadcast the new block to other miners. The clients respond with a valid Bitcoin transaction which pays for block inclusion. Once all clients have paid up the transaction is broadcast. &lt;br /&gt;
&lt;br /&gt;
If a client has disconnected or does not pay quickly enough, their transaction can be replaced inside the block with its hash. In this way the blocks validity is preserved because the merkle tree is still valid. The newly found alt-block is broadcast, minus the transaction of the delinquent customer. As long as clients are still connected the payment process for all found transactions can be completed quickly: it would only take a few seconds to gather the payments and broadcast those on the Bitcoin network, minimizing the chance of a race that would require you to trust the miner to reinclude your transactions in the next block despite having already been paid.&lt;br /&gt;
&lt;br /&gt;
=== Mining on the alt-chain but not Bitcoin ===&lt;br /&gt;
&lt;br /&gt;
So far we&#039;ve considered a scheme in which all alt-chain miners simultaneously mine on Bitcoin. It&#039;s possible some people may wish to mine on your chain but not Bitcoin, perhaps because the cost of keeping up with the Bitcoin transaction rate has become too high for them to bother.&lt;br /&gt;
&lt;br /&gt;
To mine without an attached Bitcoin node, your software can simply implement the same getwork protocol Bitcoin itself does. When a mining tool requests work your program would generate a correctly formatted but ultimately bogus Bitcoin block. The contents of this block don&#039;t need to be correct because it will never be broadcast on the Bitcoin network, for example, the prevBlockHash field can be all zeros. It exists purely for backwards compatibility. Whilst the block needs a valid merkle root and a coinbase transaction, no other transactions are required and the only part of the coinbase tx that matters is the part holding the hash.&lt;br /&gt;
&lt;br /&gt;
=== Scaling up ===&lt;br /&gt;
&lt;br /&gt;
In the simple scheme each alt-chain being worked on needs 33 bytes in the Bitcoin coinbase transaction (1 for the length and 32 for the hash). Note that if there are two independent miners working on two different alt-chains, you still only need 1 hash in the coinbase scriptSig because the hash isn&#039;t meaningful to anyone else on the Bitcoin network. If miners only want to work a handful of chains this overhead is trivially dwarfed by the rest of the data in a Bitcoin block. &lt;br /&gt;
&lt;br /&gt;
But if a miner wishes to work on hundreds, thousands or millions of alternative chains the size of the coinbase scriptSig would balloon and become unworkable. To solve this, the hash stored in the scriptSig can be the root of yet another merkle tree, this time a tree over the hashes of all blocks being worked on. The BitcoinData message is extended like this:&lt;br /&gt;
&lt;br /&gt;
 message MyBlock {&lt;br /&gt;
   required bytes prev_block_hash = 1;&lt;br /&gt;
   required uint32 difficulty = 2;&lt;br /&gt;
   required uint32 time = 3; &lt;br /&gt;
 &lt;br /&gt;
   repeated MyTx transactions = 4;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message SuperBlock {&lt;br /&gt;
   required MyBlock my_data = 1;&lt;br /&gt;
   required BitcoinData bitcoin_data = 2;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 message BitcoinData {&lt;br /&gt;
   // A Bitcoin format block header. Because it&#039;s in Satoshis custom format we represent this as a byte array.&lt;br /&gt;
   required bytes header = 1;&lt;br /&gt;
 &lt;br /&gt;
   // The first transaction from the block.&lt;br /&gt;
   required bytes coinbase_tx = 2;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking the coinbase transaction to the header.&lt;br /&gt;
   required bytes coinbase_merkle_branch = 3;&lt;br /&gt;
 &lt;br /&gt;
   // The merkle branch linking MyBlock to the merkle root in the coinbase_tx.&lt;br /&gt;
   required bytes altblock_merkle_branch = 4;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The verification step becomes a bit more complex:&lt;br /&gt;
&lt;br /&gt;
# Verify the header is of sufficient difficulty for the alt-chain&lt;br /&gt;
# Verify coinbase_tx was a part of that block by checking the coinbase_merkle_branch is linked to the merkle root in the header.&lt;br /&gt;
# Extract the root of the second merkle tree from the coinbase_tx (call it 2MR).&lt;br /&gt;
# Hash the alt-chain block (my_data), verify that altblock_merkle_branch links the my_data hash to 2MR.&lt;br /&gt;
&lt;br /&gt;
You have now proven that the MyBlock instance was worked on, along with perhaps thousands of other chains you don&#039;t have to know anything about.&lt;br /&gt;
&lt;br /&gt;
This is an advanced technique which is probably not worth implementing unless the additional scalability is required. It can be introduced in a backwards compatible manner for new chains without impacting older networks.&lt;br /&gt;
&lt;br /&gt;
=== Generalized proof of work ===&lt;br /&gt;
&lt;br /&gt;
Hashes embedded in transactions, merkle branches, and [[Nonce|nonces]] all contribute to the goal of [[Proof of work|proving work]] on a block header.  One can express all three as sequences of these basic operations:&lt;br /&gt;
&lt;br /&gt;
* prepend a byte string to the current data&lt;br /&gt;
* append a byte string to the current data&lt;br /&gt;
* hash the current data&lt;br /&gt;
&lt;br /&gt;
For maximum flexibility, a work-sharing chain&#039;s block acceptance algorithm might accept proof in the form of a script using just these operations.  The script would receive as input an alternative chain block, and the hash of its output would have to match the chain&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
This design would even support plain Bitcoin proof of work, where the &amp;quot;header&amp;quot; consists of all [[Protocol Specification#block|Bitcoin block header fields]] except the nonce, and the proof-of-work script would simply append the nonce.  Thus, one can think of the work-sharing rules as an extension of the original Bitcoin rules.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Bitcoin_Days_Destroyed&amp;diff=12046</id>
		<title>Bitcoin Days Destroyed</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Bitcoin_Days_Destroyed&amp;diff=12046"/>
		<updated>2011-06-29T14:43:29Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Lowercase &amp;quot;Abe&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin Days Destroyed is a measure of the transaction volume of Bitcoin. &amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=6172.msg90789#msg90789 ByteCoin&#039;s Proposal to use Bitcoin Days Destroyed as a measure of transaction volume]&amp;lt;/ref&amp;gt; A bounty for a  script to compute the Bitcoin Days Destroyed by the transactions in a block has been awarded. &amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=9300.0 Bounty Award to develop a script to compute the BitcoinDays Destroyed by the transactions in a block.]&amp;lt;/ref&amp;gt; [[Abe]] is a [[block chain browser]] that computes this statistic in real time.&lt;br /&gt;
&lt;br /&gt;
==Calculation==&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
If someone has 100BTC that they received a week ago and they spend it then 700 bitcoin days have been destroyed. If they take those 100BTC and send them to several addresses and then spend them then although the total transaction volume could be arbitrarily large the number of bitcoindays destroyed is still 700.&lt;br /&gt;
&lt;br /&gt;
==Graph of Bitcoin Days Destroyed==&lt;br /&gt;
&lt;br /&gt;
Percentage of Bitcoin Days destroyed vs block number, as of June 17th 2011.&lt;br /&gt;
[[File:June-17th-days-destroyed.png]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Economics]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=12045</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=12045"/>
		<updated>2011-06-29T14:42:22Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Use special syntax for Wikipedia links.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [[wikipedia:Affero General Public License|Affero General Public License]].&lt;br /&gt;
&lt;br /&gt;
Written in [[wikipedia:Python (programming language)|Python]] and portable [[wikipedia:SQL|SQL]],&amp;lt;ref&amp;gt;https://forum.bitcoin.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.txt&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://john-edwin-tobey.org:2750/ Demonstration site]&lt;br /&gt;
* [https://forum.bitcoin.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=11948</id>
		<title>Abe</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Abe&amp;diff=11948"/>
		<updated>2011-06-28T16:12:58Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Renamed &amp;quot;ABE&amp;quot; to &amp;quot;Abe&amp;quot;, added a redirect.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|Abe]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Abe&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [http://en.wikipedia.org/wiki/Affero_General_Public_License Affero General Public License].&lt;br /&gt;
&lt;br /&gt;
Written in [http://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] and portable [http://en.wikipedia.org/wiki/SQL SQL],&amp;lt;ref&amp;gt;https://forum.bitcoin.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; Abe draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.txt&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://john-edwin-tobey.org:2750/ Demonstration site]&lt;br /&gt;
* [https://forum.bitcoin.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11947</id>
		<title>ABE</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11947"/>
		<updated>2011-06-28T16:12:26Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Renamed &amp;quot;ABE&amp;quot; to &amp;quot;Abe&amp;quot;, added a redirect.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT[[Abe]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Block_chain_browser&amp;diff=11789</id>
		<title>Block chain browser</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Block_chain_browser&amp;diff=11789"/>
		<updated>2011-06-26T20:44:51Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Replace individual links with category link.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;&#039;block chain browser&#039;&#039;&#039; such as [[Bitcoin Block Explorer]] [http://blockexplorer.com/] is a program or web site that lets users search and navigate a [[block chain]].  Uses include:&lt;br /&gt;
&lt;br /&gt;
* checking [[address]] balances&lt;br /&gt;
* tracking coin transfer histories&lt;br /&gt;
* watching for [[transaction]] acceptance&lt;br /&gt;
* monitoring the [[Difficulty|network hash rate]] and other statistics&lt;br /&gt;
&lt;br /&gt;
Block chain browsers typically offer:&lt;br /&gt;
&lt;br /&gt;
* a list of a chain&#039;s recent [[blocks]] [http://blockexplorer.com/]&lt;br /&gt;
* transactions in a given block [http://blockexplorer.com/b/133310]&lt;br /&gt;
* links to the previous and next transaction involving each input and output [http://blockexplorer.com/t/2oajkZh1uz]&lt;br /&gt;
* a list of all transactions involving a given address [http://blockexplorer.com/a/7Djn6doKaa]&lt;br /&gt;
* current and historical address balances&lt;br /&gt;
* a way to search for blocks, transactions, and addresses&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Block chain browsers]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Namecoin_block_explorer&amp;diff=11788</id>
		<title>Namecoin block explorer</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Namecoin_block_explorer&amp;diff=11788"/>
		<updated>2011-06-26T20:44:17Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Very basic info.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Namecoin block explorer&#039;&#039;&#039; [http://explorer.dot-bit.org/] is an online [[block chain browser]] for [[Namecoin]].&lt;br /&gt;
&lt;br /&gt;
In addition to block, transaction, and address details, the Namecoin block explorer displays name operations and the effect of network fees on the number of coins outstanding.&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11778</id>
		<title>ABE</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11778"/>
		<updated>2011-06-26T18:19:20Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Show URL in references section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|ABE]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ABE&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [http://en.wikipedia.org/wiki/Affero_General_Public_License Affero General Public License].&lt;br /&gt;
&lt;br /&gt;
Written in [http://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] and portable [http://en.wikipedia.org/wiki/SQL SQL],&amp;lt;ref&amp;gt;https://forum.bitcoin.org/index.php?topic=16141.0&amp;lt;/ref&amp;gt; ABE draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.txt&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://john-edwin-tobey.org:2750/ Demonstration site]&lt;br /&gt;
* [https://forum.bitcoin.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11775</id>
		<title>ABE</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=ABE&amp;diff=11775"/>
		<updated>2011-06-26T14:51:29Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: Logo, more details&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:penny-abe-160.png|thumb|160px|ABE]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ABE&#039;&#039;&#039; is a free, open-source [[block chain browser]] released by [[User:JohnTobey253|John Tobey]] under the [http://en.wikipedia.org/wiki/Affero_General_Public_License Affero General Public License].&lt;br /&gt;
&lt;br /&gt;
Written in [http://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] and portable [http://en.wikipedia.org/wiki/SQL SQL],&amp;lt;ref&amp;gt;[https://forum.bitcoin.org/index.php?topic=16141.0]&amp;lt;/ref&amp;gt; ABE draws inspiration from [[Bitcoin Block Explorer]] and seeks some level of compatibility with it but uses a completely new implementation.&amp;lt;ref&amp;gt;https://raw.github.com/jtobey/bitcoin-abe/master/README.txt&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Block chain browser]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
* [http://john-edwin-tobey.org:2750/ Demonstration site]&lt;br /&gt;
* [https://forum.bitcoin.org/index.php?topic=16141.0 Project announcement]&lt;br /&gt;
* [https://github.com/jtobey/bitcoin-abe Project on Github]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Block chain browsers]]&lt;br /&gt;
[[Category:Free Software]]&lt;br /&gt;
[[Category:Open Source]]&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=File:Penny-abe-160.png&amp;diff=11774</id>
		<title>File:Penny-abe-160.png</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=File:Penny-abe-160.png&amp;diff=11774"/>
		<updated>2011-06-26T14:39:52Z</updated>

		<summary type="html">&lt;p&gt;JohnTobey253: ABE logo, 160x160 PNG&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
ABE logo, 160x160 PNG&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{self|GFDL|cc-by-sa-all|migration=redundant}}&lt;/div&gt;</summary>
		<author><name>JohnTobey253</name></author>
	</entry>
</feed>