git / moonbite-core / src/crypto/randomx_hasher.h · raw

// Copyright (c) 2026 The MoonBite Core developers// Distributed under the MIT software license, see the accompanying// file COPYING or http://www.opensource.org/licenses/mit-license.php.#ifndef BITCOIN_CRYPTO_RANDOMX_HASHER_H#define BITCOIN_CRYPTO_RANDOMX_HASHER_H#include <cstddef>// MoonBite (ADR-001): compute the RandomX proof-of-work hash of `input`// (the 80-byte block header) into `output` (32 bytes, little-endian as the// RandomX library emits it).//// Consensus-critical: the RandomX dataset is keyed by MBITE_RX_SEED, the// 32-byte SHA-256 of "MBITE-RX-1" (see randomx_hasher.cpp). A stock Monero// miner/pool keyed with Monero's seed computes the wrong dataset and produces// invalid shares; an XMRig pointed at a MoonBite pool advertising this seed// computes the right one. The hash value is independent of the RandomX// runtime flags (JIT vs interpreter, light vs fast mode), so every node agrees// on the result regardless of hardware.//// NOTE: per-epoch seed rotation (ADR-001 ยง2, every 2048 blocks) is a documented// follow-up. It requires threading the block height/seed-block hash through the// PoW path; the initial consensus deliberately uses a single fixed salted key// so CBlockHeader::GetPoWHash() remains a pure function of the header.// The single consensus RandomX key. Every component that initialises a// RandomX cache (validation, the in-node miner, tests) MUST use exactly this.constexpr size_t MBITE_RX_SEED_LEN = 32;extern const unsigned char MBITE_RX_SEED[MBITE_RX_SEED_LEN];void RandomXHashBytes(const void* input, size_t inputSize, unsigned char output[32]);#endif // BITCOIN_CRYPTO_RANDOMX_HASHER_H