Why Not Simply Use X? An Instructive Instance from Bitcoin

0
65


Bitcoin developer Gregory Maxwell writes the next on Reddit:

There’s a design flaw within the Bitcoin protocol the place its doable for a 3rd celebration to take a legitimate transaction of yours and mutate it in a means which leaves it legitimate and functionally an identical however with a distinct transaction ID. This significantly complicates writing right pockets software program, and it may be used abusively to invalidate lengthy chains of unconfirmed transactions that depend upon the non-mutant transaction (since transactions refer to one another by txid).

This subject arises from a number of sources, one in every of them being OpenSSL’s willingness to simply accept and make sense of signatures with invalid encodings. A standard ECDSA signature encodes two giant integers, the encoding isn’t fixed size— if there are main zeros you might be speculated to drop them.

It’s straightforward to put in writing software program that assumes the signature might be a continuing size after which depart further main zeros in them.

It is a very fascinating cautionary story, and is especially necessary as a result of conditions like these are a part of the explanation why now we have made sure design choices in our improvement philosophy. Particularly, the difficulty is that this: many individuals proceed to deliver up the purpose that we’re in lots of locations unnecessarily reinventing the wheel, creating our personal serialization format, RLP, as an alternative of utilizing the prevailing protobuf and we’re constructing an application-specific scripting language as an alternative of “simply utilizing Lua”. It is a very legitimate concern; not-invented-here syndrome is a commonly-used pejorative, so doing such in-house improvement does require justification.

And the cautionary story I quoted above gives exactly the proper instance of the justification that I’ll present. Exterior applied sciences, whether or not protobuf, Lua or OpenSSL, are superb, and have years of improvement behind them, however in lots of circumstances they had been by no means designed with the proper consensus, determinism and cryptographic integrity in thoughts that cryptocurrencies require. The OpenSSL state of affairs above is the proper instance; other than cryptocurrencies, there actually is not any different conditions the place the truth that you possibly can take a legitimate signature and switch it into one other legitimate signature with a distinct hash is a big downside, and but right here it’s deadly. One among our core ideas in Ethereum is simplicity; the protocol needs to be so simple as doable, and the protocol shouldn’t comprise any black packing containers. Each single function of each single sub-protocol needs to be exactly 100% documented on the whitepaper or wiki, and applied utilizing that as a specification (ie. test-driven improvement). Doing this for an current software program bundle is arguably virtually as laborious as constructing a wholly new bundle from scratch; in reality, it could even be tougher, since current software program packages typically have extra complexity than they should so as to be feature-complete, whereas our options don’t – learn the protobuf spec and evaluate it to the RLP spec to know what I imply.

Observe that the above precept has its limits. For instance, we’re actually not silly sufficient to begin inventing our personal hash algorithms, as an alternative utilizing the universally acclaimed and well-vetted SHA3, and for signatures we’re utilizing the identical outdated secp256k1 as Bitcoin, though we’re utilizing RLP to retailer the v,r,s triple (the v is an additional two bits for public key restoration functions) as an alternative of the OpenSSL buffer protocol. These sorts of conditions are those the place “simply utilizing X” is exactly the suitable factor to do, as a result of X has a clear and well-understood interface and there are not any delicate variations between totally different implementations. The SHA3 of the empty string is c5d2460186…a470 in C++, in Python, and in Javascript; there’s no debate about it. In between these two extremes, it’s principally a matter of discovering the suitable steadiness.

LEAVE A REPLY

Please enter your comment!
Please enter your name here