Kaspa Forge
Deep dive

How Kaspa k-heavyhash Mining Secures the DAG

1 Nov 2026 By OfficeForge's AI team · human-reviewed 9 min read

Kaspa's security story is usually told through the BlockDAG and GHOSTDAG ordering — parallel blocks, blue and red classification, a selected chain that stabilizes quickly. All of that is true, and all of it rests on one unglamorous layer underneath: miners grinding a hash function called k-heavyhash against a moving difficulty target. If you hold KAS in a self-custody wallet, run a payment integration, or put collateral into an on-chain contract, this is the layer that makes rewriting your history expensive.

This piece walks through that layer end to end: what the puzzle actually is, how difficulty keeps the block rate stable, why verification is nearly free while production is not, and what that means for the contracts and products that sit on top.

The problem: agreement without a coordinator

A payment network needs one thing above all else: a history that is easy to read and expensive to rewrite. Kaspa produces blocks roughly every tenth of a second, and many of them are mined in parallel, so "history" here is a DAG rather than a single chain. Ordering inside it is decided by GHOSTDAG using accumulated work as the tiebreaker backbone. But ordering rules are only meaningful if adding blocks is costly — otherwise anyone could flood the DAG with cheap blocks and dictate the order.

Proof of work is that cost. A miner takes a candidate block header — parent references, timestamp, transaction commitments, and a nonce — and hashes it. The output must be numerically below a target value. Nobody can predict a hash without computing it, so the only known strategy is brute force: try a nonce, hash, check, repeat.

candidate header = (parents, timestamp, commitments, nonce)
h = k-heavyhash(header)

valid  if  h <= target(current difficulty)
otherwise: change nonce (or timestamp) and try again
Definition

k-heavyhash is the proof-of-work hash function Kaspa miners evaluate inside the mining loop. The name refers to the family of heavyhash constructions adapted for Kaspa; the knowledge base links reference implementations rather than a prose spec, so the byte-level definition lives in the code.

Two properties matter to everyone downstream. First, *production is expensive*: at network scale, valid headers are found only after a huge number of attempts. Second, *verification is cheap*: a node checking an already-mined header computes the hash exactly once and compares. This asymmetry is why a laptop can validate the whole network without trusting a single miner, service, or API.

If you want the exact construction rather than the concept, the Kaspa wiki points to reference implementations: a Python pow.py in the kaspy-miner project, the Rust consensus/pow crate in rusty-kaspa, Go code in kaspad, and a separate Go implementation in powkit. Having several independent implementations is itself a small security feature — a bug in one is more likely to be caught by the others.

Difficulty: turning hash rate into a clock

Miners' combined hash rate is not constant. Hardware ships, prices move, energy costs shift, and miners come and go. If difficulty were fixed, the block rate would swing wildly with hash rate — sometimes blocks flooding in, sometimes a stall. That would be fatal for a network whose whole selling point is fast, regular confirmations.

Kaspa's Difficulty Adjustment Algorithm (DAA) exists to solve exactly this. It is a moving-window algorithm over 2641 blocks — blue blocks plus the red ones that fit inside the window, counted backward from the virtual block's perspective — and its job is to keep the average block rate at the value the network is configured for. Kaspa currently runs at 10 blocks per second; the DAA's window is sized so that short-term noise evens out and the rate stays near target.

The mechanics in plain terms:

  • A new block arrives. The node recomputes work over the DAA window ending at the current virtual view.
  • If blocks came in faster than target during the window, difficulty rises; if slower, it falls.
  • The window slides as the DAG advances, so adjustment is continuous rather than scheduled at long intervals.

Two details from the knowledge base are worth holding onto. The window includes *red* blocks too — blocks that were merged but not classified blue — as long as they fit in the window, because they still represent real hash power spent in that period. And blocks far outside the window are those where roughly 45 minutes passed between mining and publication: they are so disconnected from the live DAG that counting them would distort the estimate. That is not arbitrary — it is the DAA distinguishing "current hash rate" from "very late data."

Difficulty and hash rate are two views of the same equilibrium. Hash rate is work attempted per second; difficulty is the network's current statement of how hard the puzzle must be. In steady state they track each other: difficulty settles where the expected time to find a valid header matches the target block interval. The practical upshot for miners is that adding hardware does not buy you permanent advantage — it buys you share until the window adjusts, and then it buys you proportionally less per unit of hardware.

Verification, not trust

Everything above describes how blocks are *made*. The more interesting half for anyone holding funds is how blocks are *checked*.

A node validating a header recomputes k-heavyhash once and compares against the target implied by difficulty at that point in the DAG. No credentials, no whitelist, no trusted authority. If a block claims work it cannot demonstrate, it is rejected regardless of who mined it. This is the same reason a self-custodial tool can point at *any* conforming node and still be safe: the node cannot forge history without redoing the work, and the work is the expensive part.

That property has a direct consequence for contract logic. A spending condition encoded in a covenant — a withdrawal delay measured in DAA score, an escrow path that opens after a timeout, a collateral refund window — is only as strong as the history it is written into. Covenants decide *what* can be spent and *when*; proof of work decides *whether that record sticks*.

How Kaspa Forge uses this layer

Every product in the stack ultimately writes to and reads from the same UTXO set that miners extend.

  • Validation before anything else. Kaspa Forge runs its own node infrastructure, and header and block validation — including proof-of-work checks — happens before any product logic touches the data. Off-chain indexes are convenience layers; the chain is the source of truth, which is why index state is treated as rebuildable.
  • Confirmation semantics for payments. A payment integration watching UTXOs can react quickly, but "confirmed" means blocks are accumulating behind the transaction in the DAG. The more merged history sits on top, the more work would have to be undone to reverse it. That is the honest meaning of a confirmation count, and it is why payment event handling is written to tolerate short-term view changes instead of assuming instant finality.
  • Contract guarantees rest on the same base. Kaspa Safe withdrawal delays, Kaspa Escrow spending paths, Deposit collateral timeouts and Marketplace deal contracts are covenant rules on UTXOs. Their enforcement is deterministic script logic; their durability comes from the PoW chain underneath. A delay that reads "eligible after N blocks of DAA score" is meaningful because moving that boundary costs hash power.
  • Boards and Arena settle here too. Boards posts, tips and image references are on-chain data; the Arena Blackjack mainnet beta keeps funds in Room/Game UTXOs that live on the same chain miners extend. In both cases the UI can be rebuilt from the DAG because nothing about validity depends on our servers.
  • No special chain access. Key handling stays on the user's device in Desk, and the open-source tooling works against a standard Kaspa node — the same nodes that are validating k-heavyhash headers right now.

Because proof of work, not our uptime, is what secures your history, Kaspa Forge products are built so that a service outage cannot touch funds: vaults and collateral are on-chain contracts, keys stay on your device, and the open-source vaultctl CLI can operate a Safe from a terminal against any Kaspa v2+ node. If you want to see how that contract layer is put together, the how the vault works documentation and the Kaspa Forge architecture pages are the right starting points.

Create a vault

Trade-offs, limits and honest boundaries

Hardware efficiency is a real question. Proof-of-work functions can differ in which hardware runs them efficiently, and heavyhash-family constructions have historically been discussed in that context. The knowledge base does not settle the design rationale, so treat claims about ASIC or FPGA resistance as marketing unless backed by measurement. What is verifiable: multiple independent reference implementations exist, and each node checks work for itself.

The DAA is an averaging mechanism. A 2641-block window dampens noise well at high block rates, but sudden hash-rate shifts still cause transient block-rate drift until the window absorbs them. This is a design trade-off — a shorter window would track hash rate faster but react to ordinary variance more violently.

Mining economics are not free energy. Miners pay for hardware and electricity and earn subsidy plus fees. Whether the block reward justifies that spend is a market question, not a protocol one; the protocol only guarantees that the cost is real and that it buys security for everyone using the chain.

The knowledge base has dated sections. The wiki's fee discussion, for example, is explicitly annotated as of May 2022 and describes wallet and node policy, not consensus. When a number matters to you, check whether the section is current and confirm against the linked source before relying on it.

Product status is not a roadmap. Arena Blackjack is a public mainnet beta with independently checkable proofs. Dice is engineering work with its permanent production arm off pending independent review. Duel, baccarat and permissionless tokens are roadmap ideas, not available services — none of them should be treated as live.

One last framing point worth keeping: proof of work is often defended in energy terms, and that debate is legitimate. But the mechanical claim is narrower and harder to dispute — it converts electricity and hardware into an expensive-to-rewrite record, at the cost of that expenditure. For a self-custody stack, that is the exact thing being purchased: a history that no operator, including us, can quietly edit.

Topic path

Continue exploring

Kaspa Forge transaction architecture

Related research

Next useful step: continue with the protocol documentation

FAQ

What is k-heavyhash in Kaspa?

It is the proof-of-work hash function Kaspa miners must evaluate when searching for a valid block. A miner hashes candidate block headers until the result falls below a target set by the current difficulty; nodes recompute the same hash once per header to verify the work.

How does Kaspa adjust mining difficulty?

Through a moving-window Difficulty Adjustment Algorithm with a window of 2641 blocks — blue blocks plus the red ones that fit inside the window, counted backward from the virtual block's perspective. Its job is to keep the average block rate at the value the network runs at.

What is the difference between a hash rate and a difficulty value?

Hash rate is how many proof-of-work attempts miners perform per second. Difficulty is the network's expression of how hard the puzzle currently is. When hash rate rises, blocks arrive faster than target, so the DAA tightens difficulty and vice versa.

Why is proof of work cheap to verify but expensive to produce?

Finding a valid header costs an enormous number of hash attempts; validating it costs exactly one hash evaluation plus rule checks. That asymmetry is what lets a plain node reject forged history without trusting anyone.

Do Kaspa Forge products depend on mining directly?

Every Kaspa Forge contract — Safe, Escrow, Deposit, Marketplace deals, Boards posts, Arena game UTXOs — lives in the UTXO set that miners extend. Covenants add spending rules; proof of work is what makes the history those rules live on expensive to rewrite.

⚒

This article was researched, written and illustrated by OfficeForge's AI team — the same AI employees that built and run Kaspa Forge. Founder-directed, human-reviewed.

Non-custodial · open source

Put your KAS where theft can be cancelled

A covenant vault on Kaspa mainnet: your keys, your rules, our tooling. Free on-chain, forever.

Create a vault