Skip to content

nmc: build-side merged-mining commitment (PC-prep, build/verify symmetry) - #408

Merged
frstrtr merged 1 commit into
masterfrom
nmc/pc-prep-mm-commitment
Jun 24, 2026
Merged

nmc: build-side merged-mining commitment (PC-prep, build/verify symmetry)#408
frstrtr merged 1 commit into
masterfrom
nmc/pc-prep-mm-commitment

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Adds nmc::coin::build_mm_commitment() — the build-side inverse of the existing scan_mm_commitment() verifier. Emits the canonical merged-mining commitment payload a parent (BTC) coinbase scriptSig must carry so an embedded NMC aux chain is provable.

Byte layout is bit-for-bit what the scanner walks:
MM_HEADER_MAGIC(4) | chain_merkle_root REVERSED(32) | size_le32 | nonce_le32, size = 2^chain_height, slot = aux_expected_index(nonce, chain_id, height).

Why

Closes the build/verify symmetry gap: the verify side (slot derivation, scanner, aux_merkle_root) already exists; the build side that PD wires into the dual-target parent coinbase did not. PB-independent (no NameOp/mempool dependency) — cut off master per slice-base rule, NOT stacked on #402.

Tests

+3 KATs in nmc_auxpow_merkle_test (already allowlisted — no build.yml change, no #137 NOT_BUILT trap): round-trip emit->scan MATCH at the expected slot; explicit byte-layout pin; tampered root/slot -> MISMATCH. 77->80, all green locally.

Fence

src/impl/nmc/ only (header_chain.hpp + auxpow_merkle_test.cpp). NMC-local, std + core types only; btc tree consumed READ-ONLY; no core/shared/other-coin edits.

…try)

Add nmc::coin::build_mm_commitment(), the build-side inverse of
scan_mm_commitment(): emit the canonical merged-mining commitment payload
a parent (BTC) coinbase scriptSig must carry for an embedded NMC aux chain.

Byte layout matches the scanner the verifier already runs bit-for-bit:
MM_HEADER_MAGIC(4) | chain_merkle_root REVERSED(32) | size_le32 | nonce_le32,
size = 2^chain_height, slot = aux_expected_index(nonce, chain_id, height).

PB-independent (no NameOp/mempool dependency); overlaps PD dual-target.
NMC-local per the coin fence (std + core types only); btc tree READ-ONLY.

+3 KATs in nmc_auxpow_merkle_test (already allowlisted, no build.yml change):
round-trip emit->scan MATCH at the expected slot; explicit byte-layout pin;
tampered root/slot -> MISMATCH. 77->80 tests, all green.
@frstrtr
frstrtr merged commit 9825c61 into master Jun 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant