Below, we provide an overview of the BTC-Relay components - offering references to the full specification contained in the rest of this document.
This component stores the Bitcoin block headers and additional data structures, necessary for operating BTC-Relay. See Data Model for more details.
The Verification component offers functionality to verify Bitcoin block headers and transaction inclusion proofs. See Functions: Storage and Verification for the full function specification.
Difficulty Adjustment - check and keep track of Bitcoin’s difficulty adjustment mechanism, so as to be able to determine when the PoW difficulty target needs to be recomputed.
PoW Verification - check that, given a 80 byte Bitcoin block header and its block hash, (i) the block header is indeed the pre-image to the hash and (ii) the PoW hash matches the difficulty target specified in the block header.
Chain Verification - check that the block header references an existing block already stored in BTC-Relay.
Main Chain Detection / Fork Handling - when given two conflicting Bitcoin chains, determine the main chain, i.e., the chain with the most accumulated PoW (longest chain in Bitcoin, though under consideration of the difficulty adjustment mechanism).
Transaction Inclusion Verification - given a transaction, a reference to a block header, the transaction’s index in that block and a Merkle tree path, determine whether the transaction is indeed included in the specified block header (which in turn must be already verified and stored in the Bitcoin main chain tracked by BTC-Relay).
An overview and explanation of the different classes of blockchain state verification in the context of cross-chain communication, specifically the difference between full validation of transactions and mere verification of their inclusion in the underlying blockchain, can be found in this paper (Section 5).
The Utils component provides “helper” functions used by the Storage and Verification components, such as the calculation of Bitcoin’s double SHA256 hash, or re-construction of Merkle trees. See Functions: Utils for the full function specification.
The Parser component offers functions to parse Bitcoin’s block and transaction data structures, e.g. extracting the Merkle tree root from a block header or the OP_RETURN field from a transaction output. See Functions: Parser for the full function specification.