Super Simple Payment Verification

Sven Mutzl
4 min readAug 10, 2018

--

The Simplified Payment Verification (SPV) is a technique that Satoshi Nakamoto described in the paper “Bitcoin: A Peer-to-Peer Electronic Cash System”. It solves the problem that the full Blockchain can be too much data to store for devices with little storage.

Transaction Verification

For a client that does have the full Blockchain it is obvious how to verify that a certain transaction has happened. It just must be included in a block that has a valid chain of previous blocks back to the genesis block and also must be in the longest chain (not orphan). As both proofs already get calculated during for every new block it is basically just a lookup if the transaction is part of a known block.

Simplified Transaction Verification

The term Simplified might be a little bit confusing as the protocol is less simple as the “regular” verification. It’s simple in a way that the verifying party does not need to store the whole Blockchain but just the block headers.

Merkle tree

One part of the block header is the merkle root. The merkle root gets calculated from all transactions that are included in the block. For the calculation all transactions get arranged as leaves of a binary tree.

Each step up the tree is a hash that gets calculated from the combined child hashes. The node AB for example is hash( hash(A) +hash(B) ).

Proof Path

To proof that a given transaction hash E really is contained in the block one just need to provide the corresponding hashes for every step up the tree. In this case it would be F, GH, ABCD, IJKL because from E and F one can calculate EF which together with GH lead to EFGH… up to the merkle root.

The proof will always consist of one hash for every step up the tree. A block of 16 transactions would require 4 hashes to calculate and verify that a given transaction is included in the block. If the transactions would just be arranged as a list it would require all 15 other transactions to calculate the hash of the transactions. This advantage becomes even more obvious for larger numbers of transactions. For a block of 1024 transactions it would require only 10 hashes for verification.

Another important part are of course the block headers themselves. For a SPV verification is is necessary to have all block headers and also to verify the validity of the blocks (previous block hash, difficulty,…).

Space Requirements

For a block header size of 80 bytes (like Bitcoin) it requires blockheight * 80 bytes which currently (height 530361) requires 40 Megabytes. This is not much for a Blockchain with more than 5 years of history.

Scaling

SPV is a good way to validate Bitcoin transactions even on devices like phones where you usually don’t want to store the complete Blockchain copy of currently 173 Gigabytes. For other Blockchains that have a shorter blocktime SPV does not scale.

Metaverse for example has an average blocktime of around 33 seconds compared to Bitcoins 10 minutes. Just one year of Metaverse headers already requires 70 Megabytes.

Superblocks

To avoid having to store that many headers one could combine multiple block headers and use the same technique as used to arrange transactions within a block to build a new layer of Superblocks. For example one could store just the merkle root of 1024 block headers. This would compress one year of the Metaverse Blockchain from 70 Megabytes down to just 28 Kilobytes (32 bytes for every Superblock).

Verification

The first steps of the verification process are the same as the regular SPV process. After the merkle root calculation however the verifying party also needs to get information about the steps in the Superblock tree. The proof path for the Superblocks works just like the paths of the transaction merkle tree. For a 1024 blocks Supertree 10 more steps are required to reach the Superblock hash that can then be compared to the previously stored Superblock hash.

Validity

Even if the required storage capacity is significantly less compared to regular SPV the verifying party is still required to download all block headers to be able to verify the validity of the blocks because just from the Superblocks there is not possibility to verify the difficulty of the blocks.

So for the SSPV preparation the verifying party must:

  1. Download and verify all block headers
  2. Create Superblocks from the blocks merkle roots
  3. Sync following blocks and continue Superblock building
  4. Apply changes to Superblocks in case of a fork

--

--