DoubleSharp
sloth-vdf
Verifiable delaynpm
sloth-vdf
sloth-vdf pairs a JavaScript and TypeScript implementation of Sloth with a Solidity verification library. An application supplies a seed, prime and iteration count, computes a proof outside the contract, and submits that proof for verification. This separation is useful when a contract needs to check a result that took work to produce. The package leaves the application responsible for choosing its seed and configuring the computation. Start with the README example to understand the exchange between the client and contract before adapting it to a randomness workflow.
Keep the parameters with the seed
Proof generation and verification must use the same seed, prime and iteration count. In the README, the client reads these values from the example contract after the seed transaction completes. That is a useful integration pattern because the client follows the contract configuration. Keep the original integer values throughout this exchange. The TypeScript API uses bigint, so converting a large seed through a JavaScript number can change the input before computation starts.
Install the npm package
The README installs the package as a development dependency. Its Solidity example imports contracts/SlothVDF.sol and declares Solidity ^0.8.19. For contract compilation, install unsafe-math as well. The verifier imports that library, but the published Sloth package lists it only as a development dependency.
npm install -D @0xdoublesharp/sloth-vdf
npm install -D @0xdoublesharp/unsafe-mathMove a Sloth proof from client to contract
Create the seed
Define how the application chooses and records its seed. Wait for the seed transaction before the client reads the value it will prove.
Read the configuration
Fetch the recorded seed, prime and iteration count. Convert contract integers to bigint without passing large values through JavaScript floating point numbers.
Compute the proof
Call computeBeacon with those three values. Measure the work on the client environment you intend to support before selecting an iteration count.
Check the submitted result
Pass the proof and matching parameters to SlothVDF.verify. Define rejection and repeated-submission behavior in the application contract, as the README example demonstrates.
Compute and check the same input
This client fragment assumes seed, prime and iterations already contain bigint values read from your contract. The local check helps catch mismatched inputs before submission. The contract still performs its own verification.
import sloth from '@0xdoublesharp/sloth-vdf';
const proof = sloth.computeBeacon(seed, prime, iterations);
const valid = sloth.verifyBeacon(proof, seed, prime, iterations);Separate verification from timing assumptions
The example uses 1,000 iterations and tells readers to adjust for block finality. It supplies no fixed wall-clock delay. The Solidity source also retains an unresolved comment about removing quadratic-residue checks. Review that algorithmic question before relying on the implementation for a security-sensitive randomness design. A successful verification alone does not establish how long a particular machine spent computing the result or whether the application chose an appropriate seed.