SahyadriX

A three-stage memory-hard Proof-of-Work. BLAKE3 fills a 16 MB buffer, a 1024-round memory loop mixes it, and a Poseidon2 permutation over Goldilocks compresses the result. The middle stage is the ASIC-killer; the final stage is the STARK enabler.

1. Formal Definition

SahyadriX maps a block header and a nonce to a 256-bit output. The output is compared against the network target; a block is valid if and only if its output is below target.

SahyadriX : Header × ℕ → {0,1}^256

  pow(h, n) = Poseidon2_12(
                 MemLoop_1024(
                     B3Chain_524288( pre_pow(h) ‖ t(h) ‖ n )
                 )
             )

  where:
    pre_pow(h)  = h with nonce = 0, timestamp = 0 (deterministic)
    t(h)        = h's timestamp (u64)
    n           = nonce being searched (u64)
    B3Chain_k   = k iterations of BLAKE3, chained
    MemLoop_r   = r rounds of data-dependent memory mixing
    Poseidon2_12 = width-12 Poseidon2 over Goldilocks

Block validity:

  valid(h, n)  ⟺  pow(h, n) ≤ target(h)

  target(h)    = difficulty-derived threshold from h.bits field

Mining:

  Find n such that pow(h, n) ≤ target(h)

  Expected attempts: 2^256 / target(h)
  Expected time:     2^256 / (target(h) · H)
                     where H is the miner's hash rate.

The function is deterministic. Given identical (h, n), every node computes identical output. This is what makes verification cheap: one hash check confirms the block's PoW.

2. Stage 1 — BLAKE3 Chain

The pre-PoW header (nonce and timestamp zeroed) is concatenated with the timestamp and nonce, then hashed with BLAKE3. The output seeds a chain of BLAKE3 iterations that fill a 16 MB buffer.

Stage 1: Fill buffer

  seed  = BLAKE3( pre_pow ‖ timestamp ‖ nonce )
  state = seed

  for i in 0..524288:
    buffer[i * 32 .. (i+1) * 32] = state
    state = BLAKE3( state )

  Output: 16 MB buffer, fully populated
          state (32 bytes, the last BLAKE3 output)

BLAKE3 was chosen over SHA3-256 for speed. At 524,288 iterations per nonce attempt, the difference between BLAKE3 (~3× faster on typical CPUs) and SHA3-256 is material to mining throughput. Both offer ~128-bit quantum preimage resistance under Grover's algorithm; the difference in classical speed is the sole reason BLAKE3 is used here.

The buffer fill is deterministic. Two miners with the same header produce identical buffer contents, which is necessary — the buffer must be reconstructible by the verifier.

3. Stage 2 — Memory Loop

The buffer is mixed with 1024 rounds of data-dependent random access. The address for each round's read is derived from the current state, so the access pattern cannot be precomputed. The next read depends on the previous hash's output.

Stage 2: Memory mixing

  state = BLAKE3( pre_pow ‖ timestamp ‖ nonce )

  for round in 0..1024:
    idx   = u32_from_le(state[0..4]) % 524288
    addr  = idx * 32

    mix   = state ‖ buffer[addr .. addr+32]
    state = BLAKE3( mix )

  Output: state (32 bytes, mixed by 1024 rounds)

This is the ASIC-resistant stage. The reads are serialized by data-dependency: round r+1's read address depends on round r's output hash. An ASIC cannot pipeline these reads because it does not know the next address until the current hash completes. It must serialize on memory latency, exactly as a CPU does.

A pure arithmetic ASIC (like a Bitcoin ASIC) is hundreds of times faster than a CPU at SHA-256. But it gains no advantage here, because the bottleneck is memory latency, not arithmetic throughput. The 16 MB working set forces the ASIC to include 16 MB of fast on-chip SRAM per pipeline — which is expensive (~$800-1600 per chip at current SRAM prices) — and the serialized reads negate the arithmetic advantage.

4. Stage 3 — Poseidon2 Final Binding

The final 32-byte state is compressed through a Poseidon2 permutation over the Goldilocks field. This stage is the least obvious and the most important for the protocol's recursive proof claim.

Stage 3: Poseidon2 final compression

  inputs: [Goldilocks; 12]

  inputs[0..8]  = buffer[-64..]  as 8 Goldilocks elements
  inputs[8..12] = state          as 4 Goldilocks elements

  perm = Poseidon2_12( Goldilocks )
  perm.permute_mut( &mut inputs )

  output = fold_12_to_32_bytes( inputs )

  Output: 32-byte hash, compared against target

Why Poseidon2 as the last stage. The final output must be verifiable inside a proof system for the chain to be recursively provable. BLAKE3 in a STARK costs ~30,000 constraints per hash. Poseidon2 over Goldilocks costs ~300 constraints per permutation — 100× cheaper.

Without Poseidon2, proving the PoW inside a recursive STARK would require proving 524,288 BLAKE3 iterations (Stage 1) plus 1,024 BLAKE3 iterations (Stage 2) — roughly 15 million constraints per block. The recursion would take minutes per block, defeating the purpose.

With Poseidon2 as the final stage, only the final permutation must be proven — roughly 300 constraints. The BLAKE3 work is verified outside the proof system, once, at block acceptance time. The recursive proof merely attests that the block's declared PoW hash matches Poseidon2's output on some input.

Recursion requirement:

  For a block's PoW to be provable in a recursive STARK:

    Prove[ Poseidon2(final_state) = declared_pow_output ] = ⊤

  Without Poseidon2 final stage:

    Prove[ B3Chain(524288) ∘ MemLoop(1024) = declared_pow_output ]

    Constraint count: ~15,000,000
    Time per proof:   minutes
    Verdict:          Non-viable

  With Poseidon2 final stage:

    Prove[ Poseidon2( witness ) = declared_pow_output ]

    Constraint count: ~300
    Time per proof:   milliseconds
    Verdict:          Viable

This is the entire reason for the 3-stage design. BLAKE3 gives fast search; MemLoop gives ASIC resistance; Poseidon2 gives STARK provability. Removing any of the three breaks a property the protocol depends on.

5. Constants (from code)

// FILE: consensus/pow/src/lib.rs

pub const MEMORY_SIZE: usize = 16 * 1024 * 1024;   // 16 MiB
pub const MEMORY_ROUNDS: usize = 256;               // consensus-verify side
pub const WINDOW: usize = 32;                       // bytes per access

// FILE: sahyadri-miner/src/pow/hasher.rs
// Mining side runs a heavier loop:

pub const MEMORY_ROUNDS_MINER: usize = 1024;        // mining side
pub const FILL_ITERS: usize = 524288;               // BLAKE3 chain length

Two different round counts appear: 256 on the consensus verification path, 1024 on the mining path. This is intentional, not a bug.

Why the asymmetry. Mining is search: the miner spends CPU searching for a valid nonce, and a heavier loop (1024 rounds) makes the search more expensive per attempt — raising the cost of an attack. Verification is check: every node verifies the result, and a lighter loop (256 rounds) keeps verification bounded. Both converge on the same final output because the Poseidon2 binding is identical in both cases.

A node does not need 16 MB of memory to verify a block's PoW. It runs the lighter reference loop, checks that the Poseidon2 output matches the declared PoW hash, and moves on. The heavier mining loop is the miner's choice, not the protocol's requirement.

6. Memory-Hard Design

The 16 MB constant is chosen at the intersection of three constraints: CPU L3 cache size, ASIC SRAM cost, and GPU bandwidth.

Constraint 1: CPU L3 cache fit

  Modern CPU L3 caches:
    Low-end:   4 MB  (Celeron, older i3)
    Mid-range: 16-24 MB (i5 12th gen+, Ryzen 5)
    High-end:  32-96 MB (i9 13th gen+, Ryzen 9)

  A 16 MB working set:
    - Fits entirely in mid-range and high-end L3
    - Spills partially on low-end (still competitive)
    - Fits comfortably in GPU L2

  A 32 MB working set would exclude most mid-range CPUs.
  A 64 MB working set would exclude all consumer CPUs.

  Choice: 16 MB. Keeps the broadest CPU population competitive.

Constraint 2: ASIC SRAM cost floor

  Fast on-chip SRAM (SRAM close to compute units):
    $50-100 per MB in volume

  16 MB per hash pipeline:  $800-1600 per chip minimum,
                            before compute, I/O, packaging
  Realistic total cost:     $2000+ per chip

  Comparison at higher memory:
    32 MB: $4000+ per chip
    64 MB: $8000+ per chip
    256 MB (RandomX-class): $25,000+ per chip

  Choice: 16 MB. High enough to deter small attackers,
          low enough that ASICs remain conceivable for well-funded ones.
          Absolute ASIC resistance is not the goal.

Constraint 3: GPU memory bandwidth

  Consumer GPU GDDR6 bandwidth:  400-1000 GB/s
  CPU DDR4/DDR5 bandwidth:      50-100 GB/s

  In a memory-latency-bound algorithm:
    GPU advantage: ~4-8× (from parallelism)
    Not 100× as in arithmetic-bound algorithms

  Choice: 16 MB. GPU advantage remains 4-8×, keeping both device
          classes viable for participation.

The design does not aim for absolute ASIC resistance. It aims to keep ASICs, GPUs, and CPUs close enough that a mining advantage does not become a mining monopoly.

7. Device Balance

DeviceWorking set fitRelative throughputCost floor
CPU (low-end, 4 MB L3)Spills to RAM~0.15× GPU$200 laptop
CPU (mid-range, 16+ MB L3)Fits in L3~0.3-0.5× GPU$400 desktop
CPU (high-end, 32+ MB L3)Fits in L3~0.8-1.2× GPU$1500 workstation
GPU (consumer, 8 GB VRAM)Fits, high bandwidthBaseline (1.0×)$400-1500
ASIC (theoretical)On-chip, expensive~2-3× GPU$2000+ per chip

A mid-range laptop CPU stays within 2-3× of a gaming GPU. That margin is small enough that mining remains a distributed activity rather than an industrial one. Any participant who wants to mine can do so on their existing hardware at a competitive rate.

8. Post-Quantum Stack

SahyadriX is bound into a fully post-quantum stack. Every primitive in the PoW path is chosen for quantum resistance.

Component             Algorithm         Quantum security

PoW hash              BLAKE3            128-bit preimage (Grover)
PoW final             Poseidon2         ~128-bit (Goldilocks 256-bit commitment)
Block hash            SHA3-256          128-bit preimage (Grover)
Content hash          SHA3-256          128-bit preimage (Grover)
State commitment      Poseidon2         ~128-bit
Signatures            ML-DSA-65         NIST Level 3 (lattice-based)

Cryptographic assumptions in the PoW path:

  1. BLAKE3 preimage resistance under Grover (2^128)
  2. Poseidon2 collision resistance under Grover (2^128)
  3. Goldilocks field arithmetic

No elliptic curves, no pairing-based crypto, no trusted setup.

A quantum adversary gains no meaningful advantage against the PoW path. The signature path is similarly post-quantum — ML-DSA-65 rests on lattice problems that Shor's algorithm does not solve.

9. PoW Bound to Block Contents

The PoW output is cryptographically bound to the exact block template. Any change to block contents, or to the header's committed state root, invalidates the nonce and forces a full recomputation.

Bound to block contents:

  pre_pow(h) is derived from:
    - version
    - parents_by_level       (DAG structure)
    - hash_merkle_root       (tx Merkle root)
    - accepted_id_merkle_root
    - account_commitment     (SMT state root)
    - daa_score
    - blue_work
    - blue_score
    - pruning_point

  All of these fields are hashed into pre_pow. Changing any one of them
  changes pre_pow, which changes pow(h, n) for all n.

  Effect: a miner cannot reuse work across template variations.
          Precomputation attacks are structurally impossible.

This is a property that not all PoW chains have. If PoW were not bound to block contents, a miner could reuse work across templates — finding a nonce for one block and reusing it for another. Sahyadri's PoW function explicitly prevents this by including the block's committed state root in the input.

10. Verification

Verification re-evaluates the full SahyadriX hash. There is no shortcut, no low-memory mode, no time-memory trade-off.

Verification:

  Given header h and nonce n:

  1. Compute pre_pow(h) — SHA3-256 over header fields
  2. Run Stage 1: BLAKE3 chain, 524,288 iterations
  3. Run Stage 2: MemLoop, 256 rounds (consensus loop)
  4. Run Stage 3: Poseidon2 permutation
  5. Check: pow(h, n) ≤ target(h)

  Cost: ~5-15 ms on modern CPU, single-threaded
  Memory: 16 MB working set

Every node and every light client performing full header validation runs the same 16 MB loop. Verification is not fast-path optimized because the memory-hardness property would be broken by such an optimization — a cheap verifier implies a cheap attack.

For a light client verifying millions of headers, this is expensive. But a light client does not verify every header — it verifies a checkpoint and follows a chain proof forward. The 5-15 ms per-header cost is acceptable for full nodes and block explorers, not for light clients.

11. Evolution Path

The memory size, round count, and hash window are consensus parameters. They can be raised through a coordinated hard fork if the hardware landscape changes.

Version   Memory   Trigger for upgrade

v1        16 MB    Genesis — broad CPU/GPU participation
v2        32 MB    GPU dominance; mid-range CPUs uncompetitive
v3        64 MB    FPGA/ASIC becomes economically visible
v4+       128 MB+  Ongoing hardening against industrial centralization

Upgrades are reactive, not scheduled. The protocol changes only when
the hardware landscape requires it.

Current parameters (v1) remain stable until an upgrade is demonstrated
to be necessary by the empirical state of mining hardware.

"Why not start at 32 MB?" A 32 MB working set excludes a significant portion of the consumer CPU market at launch. The protocol starts where participation is highest and grows only under demonstrated pressure. A premature memory increase would defeat the design's purpose — broad participation — before it had a chance to work.

12. Comparison with Other PoW Designs

AlgorithmMemoryPrimary targetASIC resistanceRecursively provable
SHA-256 (Bitcoin)Small, on-chipRaw computeNoneNo (30k constraints)
Ethash~1 GB DAGGPU memory bandwidthPartialNo
RandomX~256 MBCPU-centricStrong (CPU)No
kHeavyHash~32 MBGPU arithmeticPartialNo
SahyadriX16 MBBalanced CPU/GPULatency-bound + cost-flooredYes (300 constraints)

SahyadriX is not RandomX (which excludes GPUs) and not kHeavyHash (which excludes CPUs). It sits in the middle: a working set small enough for CPU L3, large enough to matter for ASICs, and balanced enough that neither device class dominates.

The "recursively provable" column is unique to SahyadriX. No other production PoW algorithm was designed with STARK provability as a requirement. This is because no other production chain attempts to recursively prove its own PoW — they treat PoW as a consensus primitive, not as a provable computation.

13. Why Not cSHAKE256

An earlier draft of this document referred to cSHAKE256 as SahyadriX's hash primitive. This was incorrect. cSHAKE256 appears in code comments (a leftover from an earlier design) but is not part of the implementation.

What the code actually uses:

  Stage 1: BLAKE3
  Stage 2: BLAKE3
  Stage 3: Poseidon2 over Goldilocks

What the code does NOT use:

  cSHAKE256 — not called anywhere in the PoW path
  Keccak — only used in SHA3-256 for content hashing
  SHAKE256 — not used

Source of confusion: comments in crypto/hashes/src/hashers.rs:

  // struct PowHash => "cSHAKE256"
  // struct SahyadriX => "cSHAKE256"

These are outdated doc-comments from an earlier design iteration.
The implementation uses BLAKE3 + Poseidon2.

This is documented publicly because honesty about the implementation is more valuable than hiding a stale comment. If an auditor reads the code and finds cSHAKE256 in a comment but not in a call, they will ask. The answer is: the comment is wrong, the code is correct.

14. Summary

SahyadriX is a three-stage memory-hard PoW. BLAKE3 chain fills a 16 MB buffer; a 1024-round data-dependent memory loop mixes it; a Poseidon2 permutation compresses it into a difficulty-checked output. The middle stage provides ASIC resistance by forcing serialized memory access. The final stage provides STARK provability by reducing the PoW's constraint count from ~15 million to ~300.

The 16 MB constant is chosen to fit mid-range CPU L3, impose a $2000+ cost floor on specialized hardware, and keep CPUs and GPUs within a factor of 4-8 in throughput. The algorithm does not aim for absolute ASIC resistance — it aims for broad participation over time.

Every primitive is post-quantum. Every input field of the header is hashed into the PoW input, preventing cross-template precomputation. Every parameter is upgradable via hard fork if the hardware landscape shifts. The algorithm accepts a simple truth: no PoW is permanently ASIC-proof. The goal is to slow the specialization race enough that mining remains distributed, not to win it outright.