Verifiable delay function (vdf)

Sloth VDF over a fixed 3072-bit safe prime (p), adapted from hyperhyperspace/pulsar and dignity.js sloth-vdf.js.

Operations

FunctionCostRole
eval(steps)(x)O(steps) sequential modSqrtSlow evaluation (the delay)
verify(steps)(x)(y)O(steps) modular squaringFast verification

All values are bigint mod p. Invalid steps < 0 yields null from eval and false from verify (no throw).

API

  • p — Sloth modulus.
  • sloth_vdf(modulus) — builds { quadRes, modSqrt, eval, verify } over a prime.
  • sloth — sloth_vdf(p).
  • Uses prime_field (mod, quadRes on the field; modSqrt, pow2, neg for Sloth).

Hex string wrappers belong in caller code, not this module.

Test vectors

Proofs in proof.f.mjs pin sloth.eval(steps)(x) for several (x, steps) pairs on {@link p}. Values match the reference Sloth implementations linked above (pulsar and dignity.js use the same modulus and algorithm).

Demo

A verifiable delay function takes many sequential steps to evaluate, while anyone can check the result quickly. Sloth evaluates by repeated modular square roots; verification squares the result back. Evaluate, copy y into the verifier, and press Verify; change a digit to see it rejected.

Input x = SHA-256 of the text, hex:

a22d1ef8834e3024bb5653a1dbeb38305bef6d1cef486e450e0dfab718b47afd

Evaluate

Verify

Emergent Testing

Idle. Press Run to start the suite.

  • ./performance/proof.f.mjs
  • ./proof.f.mjs