Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 5.9 KB

factor-consensus.md

File metadata and controls

68 lines (43 loc) · 5.9 KB

Mathematical consensus

FACTOR proof of work binds a factorization to candidate block data. It replaces conventional hash-target searching as the principal mining workload; hashing remains essential.

Reviewed source: e224c5277, version fields 6.0.43; documentation review December 2, 2026. This is a descriptive engineering reference. The applicable implementation and validated chain state determine active behavior; release publication alone does not prove activation.

Header and challenge

CBlockHeader serializes these fields in this exact order:

Field Serialized width Meaning
nP1 128 bytes Submitted unsigned factor p
hashPrevBlock 32 bytes Parent identifier
hashMerkleRoot 32 bytes Transaction commitment
nNonce 8 bytes Unsigned exploration nonce
wOffset 8 bytes Signed offset from challenge
nVersion 4 bytes Version and deployment signaling
nTime 4 bytes Timestamp
nBits 2 bytes Integer bit length d, not Bitcoin compact target

The header is 218 bytes. Integral serialization uses the inherited little-endian serializers; hash display strings are not a substitute for internal byte order. GetHash hashes the serialized header to identify a block; that identifier is distinct from gHash.

gHash constructs a 72-byte password from previous-block bytes, Merkle-root bytes and nonce, and a 10-byte salt from version, difficulty and time. The implementation uses raw memcpy for scalar challenge inputs and GMP imports with native word endianness: portable reimplementations must reproduce the actual byte semantics, not assume that network serialization alone defines this function.

It derives 256 bytes with scrypt (N=4096, r=2, p=1), then runs the configured hashRounds (mainnet: 1) of further scrypt, population-count-dependent BLAKE2b/SHA3-512, integer roots, next-prime and modular-inverse operations, and data-dependent modular exponentiation/hash branches including Whirlpool. The branch population count explicitly reads 8 bytes, preserving historical 64-bit behavior. Finally it trims to d low bits and sets the highest retained bit, yielding W. The submitted factor and offset are not challenge inputs. This summary is not a replacement for the complete function or cross-platform test vectors.

Proof acceptance

Let L(x) be positive-integer bit length, d=nBits, delta=wOffset, W=gHash(header,params), N=W+delta. CheckProofOfWork requires:

  1. 1 <= d <= 1023 and abs(delta) <= 16*d.
  2. L(N)=d; p=nP1 is nonzero and L(p)=ceil(d/2).
  3. Reconstruct q=floor(N/p), then check p*q=N and p<=q.
  4. Both factors pass mpz_probab_prime_p with the configured rounds (mainnet: 50); a zero result rejects the proof.

These are probable-primality checks, not accompanying primality certificates. Consensus mandates verification conditions, not GNFS, ECM or any particular solver.

Equal factor bit lengths are not a universal acceptance condition. Put b=ceil(d/2). For odd d=2b-1, p<=q and N<2^(2b-1) force L(q)=b. For even d=2b, they allow L(q)=b or b+1. For example 253=11*23 has d=8, L(p)=4, L(q)=5 and satisfies these structural conditions. It is an arithmetic illustration, not a claimed block or a gHash test vector.

The proof-checking bound is distinct from ASERT's even 32–1022 range, and from Deadpool target limits.

Context and chain selection

ContextualCheckBlockHeader requires exactly GetNextWorkRequired, a timestamp strictly greater than the parent's timestamp, checkpoint compatibility and applicable version rules. Future timestamps are limited to adjusted time plus 30 seconds, except regtest's 24-hour allowance at this revision. Transaction, Merkle/witness, weight, script, UTXO, coinbase and deployment checks still apply. consensus.h sets maximum block weight to 80,000,000; this is not Bitcoin's block-weight constant.

GetBlockProof uses the submitted factor's bit length b. For b>=16, it evaluates with floating-point functions:

a = sqrt(2*b*log2(b))
k = floor(a)
f = floor(1024*(a-k))
work = (1 << k) + (f << (k-11))

For b<16 it returns zero. The integer work is an ECM-inspired scoring proxy; it is neither measured energy nor Bitcoin's inverse-target work formula, and it is separate from the ASERT compute table. validation.cpp accumulates parent work plus block work and selects among valid chains using work, with inherited tie-breaking and activation logic. Block count alone does not select a chain.

Assumptions and evidence

Factoring is not proved to require superpolynomial classical time. Mining economics and attack resistance depend on actual algorithms, compute distribution and networking. An integer factorization does not itself guarantee chain security, confidentiality, quantum resistance or external usefulness of each candidate tested.

See PoW wrapper tests, ASERT arithmetic tests, mining functional tests and future-tip regression. This review did not execute these tests. Floating-point reward/work behavior and native-endian challenge construction deserve reproducibility review when porting.

Further reading

Consensus knowledge · Website consensus reference

Documentation index · Release history · Repository knowledge index