Coding

How Monero's proof of work works

Monero's consensus algorithm is redefined by its unique proof-of-work mechanism, which leverages cryptographically secure hash functions and adaptive block size targeting to secure transactions, while also employing a memory-hard proof-of-work function, RandomX, to mitigate ASIC mining and maintain network decentralization. This approach enables Monero to maintain a high level of security and resistance to centralization. The result is a robust, decentralized cryptocurrency. AI-assisted, human-reviewed.

Monero’s proof of work is called RandomX. Unlike Bitcoin’s SHA-256, which runs the same tiny hash function on every attempt, RandomX asks miners to execute a small random program on a virtual machine, hit memory hard while doing it, and then hash the result. The goal is to make efficient mining look as much like a normal CPU workload as possible — and to make custom ASIC design much harder.

Overview

RandomX takes two inputs: a key K (derived from an older block hash, changed roughly every 2.8 days) and a hashing input H (the candidate block header plus a nonce, changed with every attempt). The key builds a large shared memory dataset; the per-attempt input seeds a virtual machine that runs 8 chained programs. The final machine state is hashed into a 256-bit output. If that output is below the network target, the block is valid.

Step-by-step: what a miner actually computes

  1. Build the cache from the key. RandomX runs Argon2d on K to produce a 256 MiB cache. Argon2d is memory-hard, forcing the machine to touch a lot of memory.

  2. Expand the cache into the dataset. From that cache, RandomX builds a dataset of about 2080 MiB (2,147,483,648 bytes base + 33,554,368 bytes extra). This is read-only during hashing and forces regular DRAM traffic — each program iteration reads one 64-byte dataset item, totaling 16,384 reads per hash.

  3. Initialize the scratchpad from the block input. RandomX computes Hash512(H) using Blake2b, then uses an AES-based generator to fill a 2 MiB scratchpad. The scratchpad is split to mimic CPU cache levels: 16 KiB L1, 256 KiB L2, 2 MiB L3. It is meant to live in CPU cache, not DRAM.

  4. Generate a random program. RandomX generates a 256-instruction program for its virtual machine. Every instruction is 8 bytes long, and any 8-byte word is a valid instruction — so programs can be generated by filling a buffer with random bytes. Instructions include integer math, 64-bit multiplies, floating-point operations (IEEE 754 double precision, including division and square root, using all four rounding modes), 128-bit vector operations, memory loads and stores, and occasional branches.

  5. Run the program loop. The VM executes the 256-instruction program in a loop for 2048 iterations. Each iteration reads about 504 bytes from memory and writes

Similar Articles

More articles like this

Coding 1 min

Trillions in Retirement Dollars Flow into Opaque Trusts

Billions of dollars in US retirement savings are being quietly redirected into opaque, privately managed trusts that mimic the performance of exchange-traded funds, raising concerns about transparency and regulatory oversight. These trusts, often referred to as "alternative investment vehicles," have grown exponentially in recent years, now holding trillions in assets. Their lack of disclosure and accountability has sparked fears of a new era of unregulated financial risk. AI-assisted, human-reviewed.

Coding 1 min

Stop big tech from making users behave in ways they don't want to

As users increasingly surrender control to opaque algorithms, a growing body of research reveals that Big Tech's manipulative tactics, including the strategic deployment of "nudges" and "choice architecture," are systematically influencing user behavior in ways that erode autonomy and compromise decision-making. These insidious techniques, often rooted in behavioral economics and machine learning, can be as subtle as a default setting or as overt as a personalized recommendation. It's time to reclaim agency from the algorithms. AI-assisted, human-reviewed.

Coding 1 min

I am worried about Bun

A new, open-source AI model called Bun is gaining traction, but its reliance on a proprietary, closed-source runtime environment raises concerns about vendor lock-in and long-term maintainability. Bun's use of a custom, V8-based JavaScript engine and its lack of transparency around its compilation process exacerbate these issues. As Bun's popularity grows, so do the risks of a monoculture in AI development. AI-assisted, human-reviewed.

Coding 1 min

OpenAI, Google, and Microsoft Back Bill to Fund 'AI Literacy' in Schools

Tech giants OpenAI, Google, and Microsoft are backing a bipartisan bill to inject $500 million into federal funding for AI literacy programs in K-12 schools, aiming to equip students with skills to navigate and develop the increasingly pervasive technology. The proposed legislation, dubbed the "AI Literacy Act," seeks to establish a national framework for AI education, with a focus on coding, data science, and ethics. This push for AI education comes as the tech industry grapples with the consequences of its own creations. AI-assisted, human-reviewed.

Coding 1 min

Homebridge 2.0 is here, and it speaks Matter

The Home automation landscape shifts as Homebridge 2.0, a popular open-source hub, gains Matter compatibility, enabling seamless integration with a growing array of Matter-enabled devices, including robot vacuums, and expanding its reach to a broader ecosystem of smart home products. This upgrade leverages the new Matter protocol to simplify device interactions and enhance interoperability. The move positions Homebridge 2.0 as a key player in the Matter ecosystem. AI-assisted, human-reviewed.

Coding 1 min

GitHub Is Down

Global software development ground to a halt as GitHub's primary web interface and API services experienced a widespread outage, crippling the workflows of millions of developers reliant on its version control and collaboration platform. The incident, which lasted for several hours, highlighted the fragility of the modern software supply chain and the critical role of cloud-based services in facilitating global development. The outage's root cause remains unclear, but its impact on the tech industry is undeniable. AI-assisted, human-reviewed.