npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fairflip

v0.1.2

Published

Cryptographically fair, verifiable coin flip - zero dependencies

Readme

fairflip

A cryptographically fair, verifiable coin flip library. Zero dependencies. Works in Node.js, browsers, and Deno.

Install

npm install fairflip

Usage

Basic flip

import { flip, verifyProof } from "fairflip";

const { result, proof } = await flip();
console.log(result); // "heads" or "tails"

// Verify the result independently
const valid = await verifyProof(result, proof);
console.log(valid); // true

Flip with a label

const { result } = await flip({ label: "game-round-1" });

Batch flips with statistical audit

import { flipBatch } from "fairflip";

const { flips, audit } = await flipBatch(1000);
console.log(audit.verdict);    // "pass" | "fail" | "insufficient-data"
console.log(audit.chiSquared); // test statistic
console.log(audit.pValue);     // > 0.05 means fair at 95% confidence

Two-party commit-reveal (multiplayer)

Neither side can manipulate the outcome.

import { createCommit, computeFlip, verifyProof } from "fairflip";

// Server: generate commitment before seeing client nonce
const { serverSeed, serverCommitment } = await createCommit();
// → send serverCommitment to client

// Client: send their nonce after seeing commitment
const clientNonce = "...32 random bytes as hex...";

// Server: compute result and reveal
const { result, proof } = await computeFlip(serverSeed, serverCommitment, clientNonce);

// Anyone: verify
const valid = await verifyProof(result, proof); // true

Replace Math.random() globally

import "fairflip/shim";

// Math.random() now uses a CSPRNG everywhere in your app
Math.random();

Human-readable proof report

import { verifyWithReport } from "fairflip";

const result = await flip();
console.log(await verifyWithReport(result));
═══════════════════════════════════════════
  fairflip — Proof Verification Report
═══════════════════════════════════════════
  Result   : HEADS
  Timestamp: 2025-01-01T00:00:00.000Z
  Algorithm: SHA-256-commit-reveal-v1

  Verification steps:
  [✓] Step 1: SHA-256(serverSeed) == serverCommitment
  [✓] Step 2: SHA-256(serverSeed ‖ clientNonce) == combinedHash
  [✓] Step 3: LSB(combinedHash) matches result

  VERDICT: ✓ VALID — proof is cryptographically sound
═══════════════════════════════════════════

Running tests

cd packages/core
npm install
npx vitest run

How it works

Each flip generates a random server seed, commits to it via SHA-256(seed), then combines it with a client nonce: SHA-256(seed ‖ nonce). The result is derived from the LSB of that hash. The proof lets anyone verify the outcome without trusting the server.

See MATH_PROOF.md for the formal proofs.

License

MIT