The Truth behind BIP 16 and 17

January 29, 2012
By Amir Taaki (genjix)

A huge change to the underlying fundamentals of the bitcoin system are in the pipeline. I strongly recommend everyone to understand the issues before voting in any direction. Do not vote based on personalities but ideas.

Voting is based on mining power.

Doing nothing is voting for the current existing system.

Upgrading to the newest bitcoind or Bitcoin-Qt from git is voting for the BIP 0016 P2SH system.

Merging Luke’s branch or applying one of his patches is voting for BIP 0017 CHV.

Two proposals debated over are up for inclusion into bitcoin; P2SH (Pay To Script Hash) and CHV (CHECKHASHVERIFY). Neither are for transactions owned by multiple people (m-of-n transactions), which are already possible in the current bitcoin system and simply requires re-enabling.

Bitcoin (the word) simultaneously refers to the system, a protocol and one program written by Satoshi. The discussion is over a change to the bitcoin system and is highly fundamental, ergo the most important in the bitcoin system’s development history. It is a mistake that if it goes wrong could be destructive. A serious problem would need a network-wide upgrade of all nodes and would cause a blockchain fork. Bitcoin successfully survived one blockchain fork in its early history (August 2010) due to a serious bug. And it is claimed bitcoin could survive another.

Making a payment is in actuality specifying how that money can be spent. Your program creates a script which specifies how another user can spend those funds. We can group payments that use similar script code for specifying how they are spent into broad categories of payment types. The most common payment type is pubkey-hash which first appeared in block 728. The message of the script says “only the owner of the address <12higDjoCCNXSA95xZMWUdPvXNmkAduhWv> can spend these bitcoins I sent.” – replacing the address with the recipient of your payment.

Sara wants to pay Ash 10 BTC. Her bitcoin program takes 10 BTC from her address 12higDjoCCNXSA95xZMWUdPvXNmkAduhWv, creates a script saying “only the owner of 1PEsXxy7kVSPL3Sqw9q4HPkbM368tGTYcx can spend this 10 BTC.” and sends it to the bitcoin network. When Ash wishes to repeat the process, he can take those 10 BTC (because he owns that address) and specify new script code to tie up those bitcoins with a new address- the address of the recipient.

Script overview

Script consists of a series of operations and data.

enum class opcode
{
    raw_data = 0,
    special = 1,
    pushdata1 = 76,
    pushdata2 = 77,
    pushdata4 = 78,
    nop = 97,
    drop = 117,
    dup = 118,
    sha256 = 168,
    hash160 = 169,
    equal = 135,
    equalverify = 136,
    checksig = 172,
    codeseparator,
    bad_operation
    // There are other operations, but these are the most used
};

struct operation
{
    opcode code;
    data_chunk data;
};

typedef std::vector operation_stack;
typedef std::vector data_stack;

struct script
{
    operation_stack operations;
    data_stack stack;
};

The script is a mini programming language that theoretically allows creative payment types. It is deliberately Turing incomplete to restrict the dangerous properties such as an attacker consuming resources looping forever.

The most common payment type (pubkey-hash) follows the same scheme of operations as:

DUP HASH160 <hash of public key> EQUALVERIFY CHECKSIG

“hash of public key” is what a bitcoin address represents. An address is the human readable form, whereas pubkey-hash is the computer readable form.

For the programmers:

bool is_pubkey_hash_type(const operation_stack& ops)
{
    return ops.size() == 5 &&
        ops[0].code == opcode::dup &&
        ops[1].code == opcode::hash160 &&
        ops[2].code == opcode::special &&
        ops[3].code == opcode::equalverify &&
        ops[4].code == opcode::checksig;
}

This means that in order to spent the money sent to me, I have to satisfy the demands- that I own the key to unlock the funds.

The output script (archaic name scriptPubKey) specifies the requisites for how funds will be unlocked:

DUP HASH160 <hash of public key> EQUALVERIFY CHECKSIG

The input script (archaically called scriptSig) actually unlocks those funds:

<signature> <public key>

When a transaction attempts to spend an output by pulling in the transaction’s new input, the scripting engine inside the bitcoin program will join the input script with the output script and execute them.

<signature> <public key> DUP HASH160 <hash of public key> EQUALVERIFY CHECKSIG
stack: (empty)

A stack is like a list of items. Think of a pile of papers with numbers written on them. You write the number of a friend (data) and put it on top of the stack. As you do things, you take papers off the stack or put new ones onto the stack.

The first two operations push two pieces of data to the stack. After pushing to the stack, our script looks like:

DUP HASH160 <hash of public key> EQUALVERIFY CHECKSIG
stack: <signature> <public key>

DUP duplicates the top item on the stack:

HASH160 <hash of public key> EQUALVERIFY CHECKSIG
stack: <signature> <public key> <public key>

HASH160 hashes the top item on the stack:

<hash of public key> EQUALVERIFY CHECKSIG
stack: <signature> <public key> <public key hashed>

Next is another piece of data- the bitcoin address reversed into computer readable form. This item is added to the stack and then EQUALVERIFY is executed. If the <public key hashed> does not match the one specified by the user who sent the bitcoins then the script will fail. We are now left with the final stage of the script’s execution.

CHECKSIG
stack: <signature> <public key>

Using public-key cryptography, this final stage checks the digital signature of the transaction using the public key we just verified is correct to ensure the correctness of the transaction. If (and only if) this final stage passes, will the payment be accepted. Those interested in the details should examine my implementation of op_checksig(...).

Bitcoin Improvement Proposals

There are four functional fundamental implementations of the bitcoin protocol: the original Satoshi client, BitCoinJ by Mike Hearn, BitcoinJS by Stefan Thomas and libbitcoin by me (Amir Taaki). All the clients derive from or use these four original codebases such as bitcoin-qt (Satoshi), MultiBit (BitCoinJ), SafeBit (BitcoinJS) or subvertx (libbitcoin).

The fear was that the flourishing diversity of the bitcoin ecosystem would lead to many incompatible ad-hoc standards, and a poorly functioning bitcoin network. By having a process for formalised agreements among the implementations, we mitigate fracturing of the system.

The BIP (Bitcoin. Improvement. Proposal.) follows a general process as specified in BIP 0001.

  1. Usually a proposed BIP should be discussed in the forums or mailing list. This step is to save the time for the champion of that BIP (author).
  2. The BIP champion requests a number to be reserved from the BIP editor. The editor may specify any optional prerequisites such as prior discussion.
  3. The BIP editor has the right to arbitrarily reject BIPs such as if the ideas are too vague or being technically unsound. Once accepted, the BIP is given a Draft status and a number.
  4. BIP statuses change depending on community consensus. Particularly important is agreement between the major groups participating in development of the bitcoin system.

The disagreement is between BIP 0016 by Gavin Andresen, and BIP 0017 by Luke Dashjr.

The BIP editor has their own personal thoughts about BIPs, but the BIP process is independent of their personal feelings. The editor should remain objective and gauge how to approve proposals based on the consensus. A standard is only as good as the people willing to implement it, and a large part of a standard is whether the major implementations agree to it.

Motivation

Both BIP 0016 and BIP 0017 are addressing the same issue. The issue is not enabling m-of-n transactions that need multiple people to spend (a common misconception) but barging the bulk of output script code into the input.

Barging the script data allows the usage of specialised bitcoin addresses using BIP 0013. Complex scripts can be represented by a short and more usable bitcoin address rather than having to copy paste a longer bitcoin address. The benefit is allowing a sender to fund any arbitrary transaction, no matter how complicated, using a fixed-length 20-byte hash that is short enough to scan from a QR code or easily copied and pasted. Without this change addresses are 70 bytes or more.

Without:
57HrrfEw6ZgRS58dygiHhfN7vVhaPaBE7HrrfEw6ZgRS58dygiHhfN7vVhaPaBiTE7vVhaPaBE7Hr
With:
32higDjoCCNXSA95xZMWUdPvXNmkAduhWv

The longer address is inconvenient compared to the usual commonplace form.

It is generally agreed that the payee of the funds should not be responsible for the costs. Rather the recipient should. If the recipient demands crazy conditions for a payment, then they should bear the costs. It is not agreed whether making this change to bitcoin is worth the cost.

A strong argument for why this kind of change is needed, is that with complex scripts, the code specifying how that output is spent can be long. A transaction sending 1000 BTC and 1 BTC follow the same format, and there are a large number of unspent outputs. If the bulk of the script is in the output then the bulk of the data for a transaction is in the output.

Since most outputs are unspent, there would be blockchain-bloat because outputs would contain more data than needed. These changes attempt to decrease the blockchain size by keeping the data out until the output is spent by putting the bulk of the data in the input. If the script is a large or complicated script, then the burden of paying for it (in increased transaction fees due to more signature operations or transaction size) is shifted from the sender to the receiver.

With a transaction which requires multiple people to spend it (m-of-n transaction) this means high fees for the person who makes the transaction rather than the person who spends the transaction. These changes shift it the other way.

OP_EVAL

The original solution for addressing this was to take an existing operation NOP1 and redefine it to become a new operation in new clients; EVAL. NOP1‘s purpose is as a place-holder for future operations and currently does nothing.

This new operation would take the data on the current top of the stack and executes it as another script. This is dangerous because it allows loops if you make a script that keeps recreating and executing itself. The standard specified that EVAL has a maximum execution depth before it stops. The scripting system would need to keep a record of its execution depth. Russel O’Connor (roconnor) found a bug in the test implementation in late December to circumvent this restriction. A new fix was added.

During a private email discussion among developers on the 1st January, further problems were found out. Stefan Thomas discovered that if the arbitrary script is a piece of data which is the result of script, then what that script will be, is unknown until after the script has been executed. Since the script’s structure will be unknown, it would make it difficult to run static analysis. Stefan actually wrote code to exploit the EVAL proposal.

CHECKSIG operations are expensive. The code for validating transactions deliberately limits the number of CHECKSIGs. An attacker can create a transaction with hundreds of CHECKSIGs and perform a denial of service attack on a bitcoin node through the scripting system. Using static analysis we can predict beforehand the number of CHECKSIG operations and reject invalid insecure transactions. EVAL would make that check impossible.

The scripting system despite being a Turing incomplete system is a huge risk and has to be hugely controlled. IsStandard(...)‘s purpose it to limit the scripting system’s freedom to not be dangerous. EVAL introduced new risks from arbitrary code and had to be shelved.

Viewpoints

Gavin Andresen is the author of a new standard P2SH (BIP 0016). Miners have been asked to place the value of /P2SH/ in their blocks. On the 1st February if 55% of the blocks contain /P2SH/, the change will become live in the Satoshi client. Otherwise the voting date will be pushed back and the blockchain re-checked again later.

Luke Dashjr is the author of a competing proposal CHV (BIP 0017). Miners voting in favour of CHV, should place p2sh/CHV in their blocks.

A number of respectable developers are opposed to any changes. Another matter of contention is the schedule is rushed or too fast since real discussion began mid December. Gavin makes the point that without putting the software into practice, it may never reach fruition because of endless debate and discussion. That pointless discussion will continue endlessly and nothing will get done.

[Tycho] runs the largest pool of bitcoin miners; Deepbit. He will vote against the proposals and not contribute his power. He views the proposal as being too risky without the necessary due diligence.

[Tycho] believes the changes to be immature before they can move into the production environment. He objects on the ground that among developers there is no clear consensus.

I would like to add something about one of the reasons why I don’t want to be the FIRST to adopt P2SH: I don’t like doing beta tests in a production environment.

In last 2 days I already got 3 messages from Gavin about new bugs found in his implementation: one “minor bug” and one “major bug” (“one critical line was dropped in a merge and missed in my testing”). Also some coins were possibly destroyed in the process because a bug caused block fees to be lost.

There is a real chance of risk with these changes that are non-negligible. The question is whether the risk outweighs the reward. The risk is loosing the entire bitcoin market. The return is a better blockchain.

Mike Hearn who authored the BitCoinJ version which is the basis for MultiBit, and the android and iPhone bitcoin versions is against the changes also. Mike is worried that too many rushed through changes to the bitcoin system are going to result in an unmaintainable convoluted future system. A fundamental lesson of computer architecture design is that systems become more complex over time as their feature set expands. The best you can do is to mitigate its degradation by careful planning and caution.

Software architecture does not age gracefully. Software architecture degrades in direct proportion to the number of changes made to the software: bug fixes corrode the layering and new features stress design. … as the architecture degrades, maintenance and development become more difficult and at the end of that path is a legacy piece of software maintainable only by having an army of brute-force testers for every release, because nobody understands how the software works inside.
- The Architecture of Open Source Applications: Berkeley DB

A more complex system that is difficult for the designers to understand, can result in unsuspected bugs and security flaws. When a system is harder to fully comprehend, there is less scrutiny over its internal functioning.

These are both valid viewpoints which is why the decision is not so clear cut.

P2SH (BIP 0016)

We defined earlier that there are certain categories of scripts which make different payment types.

P2SH defines a new payment type that works with old non-P2SH enabled clients. When P2SH-enabled clients see see this payment type they invoke a special behaviour.

The biggest objection to P2SH is that this is special unexpected behaviour and is not elegant. The problem is that trying to deal with old clients while creating a new system is going to involve some form of ugly hacks. Satoshi had a great idea then dumped us with an incomplete system that is now in production with $50 million economy. It’s a delicate situation.

if 10 == 10:
    print 'Hello'

The analogy is if a programming language, when running a program comparing 10 == 10 and printing ‘Hello’ instead decided to compute Fibonacci numbers. It recognises the format of the program, then does something completely different.

The actual new payment type scripts look like:

input script: <signature> {<public key> CHECKSIG}
output script: HASH160 <20-byte-hash of data inside the {}s> EQUAL

Upon recognising that particular output script format, bitcoin will interpret that in a unique way. First the script will execute as normal, but then on completion, the top stack item will be popped off and executed as another script. Also the current stack is passed to the subscript when executing. If the subscript passes then the parent script also passes.

Begin:

script: <signature> {...data...} HASH160 <20-byte-hash of data inside the {}s> EQUAL
stack: (empty)

Special part:

  1. Take input script as your stack.
  2. Remove top item from stack as script.
  3. Execute it.
script: <public key> CHECKSIG
stack: <signature>

Note that the input script is no longer treated like a script but a stack. The system will fail if the input script has any operations- it can only contain operations for pushing data.

All the arguments against BIP 0016 boil down to its aesthetic effects on the bitcoin system. Increasingly complex systems are harder to manage- potentially leading to bigger problems and issues down the line.

One bug was found in the P2SH implementation 4 days before voting was complete. No developer writes bug-free code, but [Tycho] sees this as a sign of the standard being premature.

SIGOPS limit

Supporters of P2SH tout its ability to increase the maximum number of SIGOPS (signature operations) in a block over CHV.

These are the possible signature operations:

  • CHECKSIG
  • CHECKSIGVERIFY
  • CHECKMULTISIG
  • CHECKMULTISIGVERIFY

Scripts have a maximum size which is sufficient with the other operations to stop a denial of service attack. Pack several hundred CHECKSIGs or CHECKMULTISIGs inside scripts in a block and it causes the validating node to do far more work than necessary since it must compute the results of every single CHECKSIG/CHECKMULTISIG operation. A denial of service attack.

Satoshi added a restriction to the number of allowed SIGOPs in a block as a response. 20000 per block is the current limit. It is a huge number, but it may need to be raised in the future once bitcoin is performing several thousand transactions per second.

P2SH provides a way to hide these SIGOPs from Satoshi’s rule to allow a newer more precise method for counting them to be developed. This delays the time until the block level SIGOPs limit is raised from 20000 in the future. Raising the limit will be a blockchain forking event and a very difficult change.

There is a block size limit of 1000000 bytes. Assuming 1 transaction has an average of 10 output spends (high estimate; more usual is 2) and is around 200 bytes (very low estimate). The number of transactions per block is approximately 1000000 / 200 = 1000. Assuming 5000 transactions with 10 outputs, the total number of SIGOPs per block is 5000 * 10 = 50000. That is more the 20000 limit.

When the number of transactions starts reaching the block size limit, the SIGOPs count limit could start being a problem. However the block size limit itself would be an issue, and it is likely that a blockchain fork would be needed for raising the block size anyway.

P2SH does not solve this issue, but it buys more time.

CHV (BIP 0017)

Rather than introducing a new paradigm of executing a piece of data on the stack upon recognising a particular script schema, CHV (BIP 0017) uses an existing operation that seemed to be included for this purpose by Satoshi: CODESEPARATOR.

A new proposed operation CHECKHASHVERIFY (hence the name CHV) replaces NOP2. The NOP* series of operations were reserved by Satoshi for future extensions and new operations. In CHV, one of these reserved operations is adapted into the new operation.

input script: <signature> CODESEPARATOR <public key> CHECKSIG
output script: <20-byte-hash of subscript> CHECKHASHVERIFY DROP

Where the subscript is everything from the CODESEPARATOR onwards.

<public key> CHECKSIG

There are two main differences with the other P2SH proposal.

  1. CHV uses an existing operation to define a subscript rather than interpreting a piece of data from the script.
  2. CHV uses a new operation to define the script’s actions rather than implicitly recognising the schema and behaving in a special unexpected way.

It’s argued that CODESEPARATOR is a bad operation because it breaks the flow of the code. The operation exhibits certain oddities and its own weird corner cases. Before this proposal, there was a general consensus that this operation had no potential use following bugs made in an old Satoshi bitcoin client version.

CHV’s disadvantage over P2SH is nodes will accept any transactions spending an output as valid. To old clients it looks like a transaction that is spendable by anybody while P2SH requires the hashed data.

Note that P2SH will only be accepted by the network if more than 55% of the mining power is in favour. Because miners would not accept invalid transactions, nor build off of blocks containing invalid transactions, this should not be a problem for CHV if the majority of mining power remains in favour of it.

It is not a problem; once a CHV is spent, its security properties become equivalent to P2SH.

A minor issue is that old clients will not propagate CHV payments. The old clients will accept blocks with CHV payments, but they will not pass them onto other nodes in the network. This is not a problem as transaction propagation speed is usually far quicker than confirmation speed (especially with 6 confirms or more).

Rules and practicality

Realistically this divisive issue rests upon personal preference for how developers envision that complex systems are developed.

Special cases aren’t special enough to break the rules.
Although practicality beats purity.
- PEP 20 – The Zen of Python

Summarising:

  • P2SH introduces a complexity-inducing solution to a tough problem.
  • CHV introduces a new operation code. Unexpected combinations of opcodes have been a problem in the past.
  • Remain where we are with all of bitcoin’s imperfections and problems. Use 70+ character addresses for multiple person transactions instead of 20 character ones.

If Deepbit maintains their current stance of not voting for either P2SH or CHV, then the remaining part of the network will need to muster enough power to overcome Deepbit’s vote. Examining the current blockchain (28 Jan) we see a split of votes among P2SH and CHV. Assuming the current voting proportions remain steady, I predict a rejection of both new schemes.

45 Responses to The Truth behind BIP 16 and 17

  1. Amir Taaki (genjix) on January 29, 2012 at 3:56 am

    Other developers disagree with giving this information away and feel like you as users should trust their judgement. I strongly disagree. I’d rather people have a say in such fundamental matters such as this, even if it makes the developer’s lives harder because they have to explain their decisions thoroughly.

    My worry is bitcoin someday becomes corrupted. Developers: see this extra scrutiny as an opportunity to build a culture of openness. It is not at all bad.

    Many Thanks:
    - Stefan Thomas (justmoon)
    - Luke Dashjr (luke-jr)
    - Nils Schneider (tcatm)
    For their proof-reading and feedback on this article.

    • molecular on January 29, 2012 at 10:09 pm

      I fail to see how this:
      57HrrfEw6ZgRS58dygiHhfN7vVhaPaBE7HrrfEw6ZgRS58dygiHhfN7vVhaPaBiTE7vVhaPaBE7Hr
      is any worse than this:
      32higDjoCCNXSA95xZMWUdPvXNmkAduhWv

      Does not fit in qr-code? really?
      Easier to copy-paste? really?

      I must be missing something. If the problem is hitting scalability issues a little earlier and/or having long addresses for complex transactions and/or changing who _technically_ pays the transaction fee, then I don’t understand why we have to take the risk of such a fundamental change.

      We’re talking about the holy blockchain here, not some possible wallet encryption bug.

      Maybe I just fail to see all the unbelievably cool things we can do with complex transactions and the script language.

      I really don’t understand what’s going on here fully, so I have to trust others… when the people I trust disagree, I’m be very cautious to vote for anything.

      Can someone explain why this is so important?

      • Atheros on January 29, 2012 at 11:17 pm

        Ok, so your top address is ~70 characters, right? What about 200? What about 1000? It’s completely untenable to do it this way. All of that data will be in your blockchain permanently until someone comes along and spends the funds further. This mass of transaction data can’t be pruned.

        A pay to script hash (P2SH) solution changes that. All of the developers agree that it is important- even Luke Jr. They disagree on which implementation is best and how backwards-compatible it should be. This article didn’t talk anything about where the developers agree; its purpose was to teach you about the places where people disagree.

        Also, you mentioned the “risk”. The biggest risk is that 51% of everyone will have to download a new version of Bitcoin at a moment’s notice. That’s it. I think we can handle that worst-case-scenario. It’s happened before and it will happen again.

    • molecular on January 29, 2012 at 10:11 pm

      sorry for replying here, I cant, for the love of my live, find the “reply to article” button. Is it somewhere among these colorfull icons?

      • Jack on January 30, 2012 at 12:18 am

        It’s at the very bottom of the page

  2. Toni on January 29, 2012 at 4:33 am

    “Other developers disagree with giving this information away and feel like you as users should trust their judgement. I strongly disagree.”

    Thank you for that, genjix.

    I’m not a developer. Not that kind of tinker. But here’s what I see, for what it’s worth.

    There are very few Bitcoin users capable of coming to a truly informed opinion on the matter. If every user was actually casting an individual ballot, it would come down to the personalities of tycho, Gavin, Mike Hearn, luke-jr, and possibly yourself. As it is, we actually are voting with the pool we use to mine, as I understand it. Where is slush in this?

    I must say I support tycho’s position – although I don’t use Deepbit.

    It doesn’t seem to me that there is any increased elegance in either CHV or P2SH. And I do NOT like bugs being found in the fashion that they have been. I do not like breaking older clients – even a little bit.

    If, as you say, there is time before the SIGOPs count limit becomes a real problem, I see no reason at all to tempt fate by pushing out a fix that appears a bit sloppy and only buys a little more time – as opposed to methodically attacking the problem in search of a true solution supported by everyone.

    I respond to your excellent Zen of Python quote with one from the field of medical ethics:

    “Primum non nocere”

    I ask again – as his is the pool I currently use – where is slush on this?

    Toni

    • Atheros on January 29, 2012 at 7:58 pm

      Exactly how long would you like to struggle to hold onto old clients? Months? Years? Decades?

      Bitcoin is BETA software. This is all experimental. We should feel able to change it. If you don’t accept this premise then you shouldn’t be using Bitcoin yet. The people using Bitcoin should understand that they will be expected to upgrade their client from time to time. It would be bad if old wallets became useless but clients can and *should* become obsolete as we improve Bitcoin.

      • Anu on January 31, 2012 at 1:08 pm

        The developers may call it Beta and 0.5.2, but a system that deals with $52 Million is production in my book. People are relying on this for their businesses. Whatever the developers decide, I hope it’s not with the thought “This is all experimental” in the back of their head.

    • Luke Dashjr on January 29, 2012 at 8:28 pm

      Slush is currently supporting BIP 16.

  3. Rune Christensen on January 29, 2012 at 4:51 am

    Thanks for the easy to understand breakdown of the code-drama.

    It is my belief that when it’s fundementals have been indisputably proven, Bitcoin’s functionality will one day be rewritten from the bottom up as bitcoin 2.0 by corporations or similar institutions with huge amounts of resources.

    While all functionality of Bitcoin needs to be implemented with a long term perspective in mind, I don’t think meta-issues such as the code itself being messy, are as big a concern as improving short term functionality and adoption.

    An economy of critical mass will always find a way.

    • Atheros on January 29, 2012 at 7:51 pm

      No one cares about the code; we know it will be rewritten. We here are changing the protocol.

  4. Luke Dashjr on January 29, 2012 at 5:11 am

    1. It is confusing to refer to BIP 16 as “P2SH” since BIP 17 is also; both BIPs are P2SH.
    2. While Bitcoin does currently support m-of-n transactions, these would require at minimum 93 (not 70) character addresses, and even then have significant security issues. In practice, P2SH of some form *is* necessary for multisig.
    3. The exploit in OP_EVAL was not related to static analysis at all.
    3b. The inability to statically analyse Bitcoin scripts has no known practical value, but was deemed a desirable property by some developers.
    4. Miners are NOT being asked to merely place “/P2SH/” or “p2sh/CHV” in blocks. These are first and foremost advertising not only for ‘political’ support, but more importantly for *technical* support. If miners advertise BIP 16 or 17 support without actually doing the verification required by the BIPs, this will *break* the upgrade plan. Please do NOT cast a vote for either proposal without applying the relevant verification patch!
    5. Neither BIP actually *works* with non-supporting clients. They will merely gracefully ignore them, and accept them as valid in blocks.
    6. The effects of BIP 16 on the Bitcoin system are not merely aesthetic. BIP 16 is in practice a fundamental change to the very structure of the protocol in a very inconsistent way with how it has always worked.
    7. BIP 16′s “one bug” mentioned (there are others, but only this one was deemed notable because it caused BIP 16-supporting miners to lose all transaction fees) is basically unrelated to the P2SH goals entirely. This only could have happened because of how fundamentally BIP 16 changes Bitcoin, requiring significant rewrites of other unrelated parts of the code.
    8. CODESEPARATOR, while useless without BIP 17, does not break the flow of code at all, nor have any weird corner cases of its own. It does nothing but mark a new position as the “start of script” for use in signature-checking operations (which is part of how BIP 17 uses it).
    9. Both BIPs are affected by the “old nodes will accept any trasactions without a majority of miners behind them” risk – it is not CHV-specific. This is *why* both BIPs require a majority of miners behind them before becoming active.
    10. While there may have been a problem with unexpected opcode combinations in the past, CHV only ever acts like OP_NOP2 (ie, the current system) or rejects a transaction. Nobody has even conceived of a potential way this could be a problem (and if they did, it would apply to all other P2SH proposals).

    • Rune K. Svendsen on January 29, 2012 at 10:14 am

      Wrt. to point 3b, does the inability to statically analyse Bitcoin scripts not prevent us from counting SIGOPS before executing scripts, thus preventing DoS attacks?

      • Luke Dashjr on January 29, 2012 at 8:30 pm

        No. You can always abort when you hit the limit at runtime. Sure, you have to verify up to the limit before you know to abort, but the same attack could be done by a script only including in the first place.

    • deep6dev on January 29, 2012 at 6:56 pm

      I agree with many of your points, but note this,

      3b – Static Analysis – You are wrong, and you present no proof of nonexistence. A valid counter example is the ability to predict the number of checksig ops before executing even one, which improves DoS protection over not knowing. (Your point that one can abort the script when exceeding the limit, has obvious drawbacks, e.g. wrt optimizations). N.B. there may be other examples.

      8, 10 – Unexpected Problems – “Nobody has even conceived of a potential way this could be a problem” – This is no proof either so this statement convinces no one.

      Given this sounds critical, I would like to add that I do support the style of BIP 17 over the “bypass” of BIP 16. But for now, the deal is off. The discussion have become mired in subjectivity, we will, and should be stuck here until we can prove things.

      • Luke Dashjr on January 29, 2012 at 8:31 pm

        You can’t prove general non-existence…

        • deep6dev on January 30, 2012 at 12:18 am

          Exactly, but for 3b I gave one counter example. So that claim is false. BIP 12 is off the table so it is not highly relevant anyway.

          Regarding point 10, we should formalize what properties we want for bitcoin and prove them under some constraints. These constraints can then be built into the interpreter in addition to new opcodes etc.

          My general point is that for making fundamental changes to the protocol, and BIP 16/17 should maybe be classified as such, we should have more formal correctness arguments than just feelings and personal style. There is no real urgency according to me. Eventually we need this and I am sure it can be done.

          • Luke Dashjr on January 30, 2012 at 8:24 pm

            (3b) No, that example doesn’t hold water; see my reply to Rune above yours.

          • deep6dev on January 31, 2012 at 1:00 am

            In general static analysis is an well established desirable trait on syntax/code for many reasons. This may be the reason developers “like” this. To be more formal, another example in this case is possible optimizations. It is much harder to optimize code that must be executed to be known. If script code could be statically analyzed to be of certain well known common types, an optimized (possibly hardware) path may be selected. This path may skip error checking completely if the static analysis can prove correctness.

  5. reginald hardy on January 29, 2012 at 5:12 am

    as a non programmer and new user of BTC I read and believe understand the problems outlined in your appraisal. I think your prediction will be correct but do not believe that is necessarily a bad thing. Let me use an old adage from the war- “order, counter-order = disorder. Yes the current os has known deficiencies as you have outlined but as BTC is an existing and functioning system it is understandable that users are loath to abandon it in favour of either of the new proposals given the effect of unintended consequences. the risk currently seems to outweigh the advantage. If an attack is imminent that would be a reason to quickly adopt a change -but I think it must be shown and believed to be the case before implementing a change and I have the impression there is still time to evaluate. Maybe there is something to sensitive or complex not revealed that will alter my perception but I think a better case for change has to be more broadly understood to change the risk/advantage ratio from risk towards advantage. reg.

  6. Plato on January 29, 2012 at 6:26 am

    Seems to me that the only problem with keeping the status quo is bigger transaction sizes for complicated transactions, which means we can fit fewer of them in a block. We’re not close to hitting the limit and many (most?) miners still include blocks with no fee attached. In my opinion it’s heedless, nay, criminally irresponsible for Gavin to say “We’ll vote on this in a couple weeks and if we agree, I’ll change Satoshi’s client.” Decentralized as it may be, the developers of the mainline client have more clout than the rest of the community, as their client is the first google hit for “Bitcoin” and is labeled the “official client.”

    I consider myself to be quite involved in Bitcoin, yet this is the first I’ve heard of this issue, with three days to go before this “vote.” We should be discussing this thoroughly as a community for months, not weeks.

    I am not convinced any changes are necessary at this time. If it ain’t broke, don’t fix it.

    • NickRaize on January 29, 2012 at 5:19 pm

      A bigger transaction size is going to require someone pay the transaction fees. In a situation where you want two people to sign off on a transaction, or multiple verification points (safer client) before a transaction takes place, it doesn’t make sense to require fees.

    • Atheros on January 29, 2012 at 7:40 pm

      But it will be ‘broke’ in the future. And the future will be too late to change it- it is already proving difficult to get people to make what is really a relatively small change to Bitcoin. Paying to a script hash is so obvious that it should have been the method Bitcoin used from day 1 – except that no one thought of it.

      Without this change, Bitcoin will take up twice the hard drive space and the payee will have to find a way to charge the payer for the added cost of their complex transaction. This isn’t a problem today because transactions are free but it will definitely be a problem in the future! This shouldn’t be a debate with three options. Implementing some P2SH solution is critical!

  7. ics on January 29, 2012 at 8:06 am

    Likewise, the first I’ve heard of it, I’m sure both sides have put a lot of thought in, but it seems the community hasn’t really had chance to learn of implications. Changing the whole protocol at this point I would think should be done only if it will make it more robust, not more likely to break it. Never liked mixing script/code and data, and a transaction log should be data only. Robust script could be referenced in another block-system ie abstract one more level.

  8. anon on January 29, 2012 at 8:11 am

    Voting is based on mining power, yes and this shows how easy it could be in future for a group to hijack this by modifying script code in the block, thus forking right away. I had a gut feeling something was up, hence my article ‘shaft of worry in the bit mine’. I say keep the core as robust as possible, do not break existing clients.

  9. wcoenen on January 29, 2012 at 12:05 pm

    I’m still wildly confused by the current script system, I didn’t even get to the explanation of the BIPs.

    For example, how can the first operation ever be DUP? Shouldn’t it be preceded by another operation that actually puts something on the stack? Otherwise the stack will be empty and there is nothing to duplicate, right?

    • wcoenen on January 29, 2012 at 12:32 pm

      Nevermind, just realized that the notation implies the RAW_DATA operation or some other operation that pushes onto the stack.

  10. ribuck on January 29, 2012 at 12:13 pm

    BIP17 puts less data into the block chain, and is a more elegant design. Thus it has the long-term advantage.

    In the short term, BIP16 is better-tested. But surely if BIP17 is selected as the better design it will be thoroughly tested before using it for valuable transactions.

    Bitcoin is here for the long run. In the long run, it’s always worth a little short-term pain for long-term gain.

  11. Yifu Guo on January 29, 2012 at 1:25 pm

    I’d just like to add quickly where BitSyncom stands in this debate:
    currently we do not support neither BIPs due to lack of testing and the method of voting, we never liked the idea of giving the mining pools too much power. In addition what about https://bitcointalk.org/index.php?topic=55842.0 ? could we have similar networks ontop of bitcoin to solve some issues such as things one? what about OpenTransactions? why can an overlaying network handle some complex features.

    I’m one personally for not changing the original protocol as much as possible.

    • Luke Dashjr on January 29, 2012 at 8:34 pm

      The voting is not left to miners by choice, but by design: the new rules can only be enforced with a majority of miners supporting it.

  12. GoWest on January 29, 2012 at 3:57 pm

    I’m not a programmer, so my perspective is a little outside the norm.

    It seems to me that growing the size of the pubkeys is not the end of the world, as long as URI-scheme adoption becomes common-place. Multibit has already done it, and it works well. It’s time for the other clients to follow suit.

    For transactions between individuals, we already have services like “first bits” to simplify the handling of clunky Bitcoin addresses.

    People will adapt, and they will happily do so knowing that the network remains robust and their money is safe.

    • Luke Dashjr on January 29, 2012 at 8:35 pm

      “First bits” doesn’t scale, and encourages people to spam the block chain to “claim” their “first bits” name.

  13. Dusty on January 29, 2012 at 8:08 pm

    I’ve read countless posts in the forum about these two proposals without understanding completely the heart of the problem while with your analysis everything now makes sense to me.

    So thanks, Amir, for your work.

    I was leaning initially toward Gavin’s proposal, but after understanding better the issue I find now that CHV is less a hack and a somewhat more elegant solution.

    Thanks,
    Dusty

  14. Atheros on January 29, 2012 at 8:27 pm

    Isn’t the worst case scenario for this change that the blockchain must be reset from a checkpoint, thus forking, forcing clients and miners to upgrade? There has been an unplanned blockchain fork before and there will someday be one again. If anything, this “worst case scenario” would be nothing more than good practice.

  15. Jason on January 29, 2012 at 10:02 pm

    Wow, this makes absolutely no sense whatsoever. Somebody who doesn’t speak computer code is going to have to explain this in a different way because I am not in anyway about to support something that cant be explained as a simple big picture adjustment. Inputs, outputs, and hashs do not create an image of whats going on in my head. And it seems like the added functionality (at least the examples used) are totally arbitrary and unnecessary. Plus, how on earth is a shorter key easier to copy/paste WTF? Shorter Key = less secure in my head, just like a 4 letter password is less secure than a 20 letter password. I’ll learn the details on my own but I can’t even get what the hell the purpose of including the “only the owner of , blah blah key, can spend these bitcoin,” which is already true so why would I risk the fundamentals of the Bitcoin system for the ability to spell out something that’s already true of Bitcoin? If the key doesn’t belong to me how could i spend it?

    One thing I do understand incredibly well is economics. And I don’t like the idea that people are possibly screwing with the economics of Bitcoin, poorly explaining it, and then asking me to choose which one I want. I’m sure this is a great explanation for someone who stares at code all day on their computers but that doesn’t ensure anything regarding the solid economics of Bitcoin. I’m voting gtfo until there’s a better explanation.

    • Jack on January 30, 2012 at 12:52 am

      Dude, if you can’t understand an article as meticulously laid out as this one, you’re not in any position to be tossing around half-baked opinions.

      Neither does your comment count as a vote, only miners get to vote on protocol changes.

      This decision is going to have little if any noticeable effect on the end user, so don’t waste your ‘incredible understanding of economics’ worrying about technical programming issues like this. Go back to school or gtfo yourself.

  16. Ade on January 30, 2012 at 3:58 am

    I don’t understand the code so I can’t comment from that perspective but I’d like to see more consensus before changes.
    It seems some are asking the public to board a new aircraft while there are engineers running around saying they haven’t completed all the tests they’d like to.
    Would you get on board an aircraft in those circumstances.

  17. bitcoinspot on January 30, 2012 at 7:45 am

    Hi there guys,

    I would like to post a newsitem about this on my wbesite but i dont quite get the problem i guess.
    Is there anyone who can maybe break it down in a few smaller chunks?

    Thanks!
    webmaster@bitcoinspot.nl

  18. Gary Rowe on January 30, 2012 at 11:02 am

    The benefits of P2SH are enormous to the overall Bitcoin economy. it will enable a vast number of new ways to use it. The question is how to implement it. At the start I was firmly in favour of the cool hand of Gavin for BIP16, but after carefully reading how it would be implemented (same input, different output depending on client version) I have found myself convinced that BIP17 is the better long term approach (specific opcode for this case).

    I am not a miner so I don’t have a vote, but I do contribute to the BitCoinJ and MultiBit projects so I would be directly affected by these changes.

  19. Samuel Walter on January 30, 2012 at 7:47 pm

    Regardless of the pros and cons of each of the proposed changes, I don’t understand why there’s a rush to make an implementation decision on the production network. While I understand Gavin’s position that a prolonged discussion and debate will just lead to complete inaction, a rush to judgement is potentially far more dangerous to the system. Without further testing and empirical evidence as to the ramification and overall stability of the system, I don’t see that either BIP16 or 17 is a necessary protocol change at the time. In short… more testing, more discussion, and more qualified opinions before any change is made.

  20. lol on January 30, 2012 at 9:11 pm

    “The risk is loosing”?

    No.
    The risk is losing. If it’s “loose”, put glue on it, you illiterate retard.

  21. Davinci on January 31, 2012 at 7:07 pm

    I run NMCBIT.COM and I am with [Tycho] on this one you are moving to fast for such a MAJOR change to $50 million dollar system. Also this is the first I have heard of this change and I am sure there are many more miners in my boat.

    May I suggest that the script analysis be added with the transactions such as loop time and a script signature. Thus with a trusted signature so that later a coder can add a list of trusted clients that have done the right thing and ignore the rest, or create a firewall that pre-executes the script to validate it.

    Bottom line there must be more discussion!!!

  22. Matt W. on February 10, 2012 at 8:02 pm

    As there is no urgent need to adopt either proposal, the period of debate and refinement should be MUCH longer. The severely abbreviated schedule and the intense push to “DO SOMETHING NOW!” are immature. That kind of behavior is how laws like the USA PATRIOT Act get passed. Please, let’s have a lengthy discussion (perhaps spanning a year or more) before we make a fundamental change to the core protocol.

Leave a Reply

Your email address will not be published. Required fields are marked *

*