Share Commitments

Each share is committed to in the bitcoin coinbase, which is committed to in the bitcoin header through the merkle root. This bitcoin header is embedded in the share header. The commitment serves two goals:

  1. Each bitcoin proof of work can build only one share.

  2. Each sharechain coinbase is unique, even among shares mined on the same bitcoin block template.

The share commitment is a SHA256 hash of the shareblock header’s fields and of the share witness root. The share witness root is the the BIP141 witness root of the share’s non-coinbase sharechain transactions.

The diagram below shows the committed fields. The commitment sits in the last output of the bitcoin coinbase, the coinbase txid feeds into the bitcoin header’s merkle root, and the miner hashes that header. The shareblock header’s fields therefore commit to the bitcoin block hash, and one proof of work can stand behind only one shareblock, which meets the first goal.

The sharechain coinbase’s scriptSig carries the bitcoin block hash. Each proof of work has its own nonce and so its own block hash, which makes each sharechain coinbase unique and meets the second goal.

The share coinbase cannot be in the commitment, because the block hash exists only once the work is done. The commitment binds the miner’s sharechain address and the share witness root instead, and with those fixed, the header alone determines the share coinbase.

share commitment
Figure 1. The commitment ties the shareblock to its proof of work

Checking the Commitment From the Header

P2Poolv2 uses the commitment trick of the original P2Pool to tie the share header to the bitcoin coinbase. A node checks that tie from the header alone, before it has the shareblock body and without reading PPLNS data from its store.

The miner splits the serialized bitcoin coinbase into a prefix and a tail. The prefix holds the version, the input with its scriptSig, the payout outputs, the witness commitment, and a padding output. The tail holds the share commitment output and the locktime. The padding brings the prefix to a whole number of 64-byte SHA256 blocks, so SHA256 can hash the prefix and pause. The state it pauses in, the midstate, stands in for the whole prefix. The miner puts the midstate and the prefix length in the share header’s coinbase proof, beside the share witness root.

coinbase midstate
Figure 2. The midstate stands in for the coinbase prefix

A node rebuilds the tail from the header: the commitment output from the share commitment, and the locktime from the bitcoin height. It checks the proof in three steps:

  1. Rebuild the share commitment from the header fields and the share witness root.

  2. Resume SHA256 from the midstate over the commitment output and the locktime, then hash again to get the coinbase txid.

  3. Fold the coinbase merkle branch into the txid, and require the result to equal the bitcoin header’s merkle root.

The proof of work fixes the merkle root, so a forged proof needs a SHA256 collision, and one bitcoin header can stand behind only one shareblock. The share commitment is checked as part of the share validation scheme.


Back to top

Copyright © 2024-2026 P2Poolv2 Developers. Distributed under the MIT or Apache-2.0 license.

Describes P2Poolv2 at commit dc5bb652 (2026-10-08).

This site uses Just the Docs, a documentation theme for Jekyll.