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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zkforge/zkstark

v1.0.0

Published

TypeScript implementation of zkSTARK for privacy-preserving applications

Downloads

9

Readme

ZKForge zkSTARK

A TypeScript implementation of a zkSTARK-style, transparent, hash-based argument of knowledge specialized for user authentication.


Installation

npm install @zkforge/zkstark

Overview

This library implements a STARK-style argument for a very specific statement:

“I know a secret s such that, if you iteratively apply a field hash H to s for steps rounds, the final value equals a stored public commitment Y.”

Formally:

  • Work in a prime field Fₚ (STARK_PRIME).
  • Define a simple algebraic hash:
    • H(x) = x³ + 7 (mod p) (toy hash, not a real crypto hash).
  • Build a hash chain (trace):
t[0]   = H(s)
t[i+1] = H(t[i])    for i = 0..steps-2
Y      = t[steps-1] (public commitment stored by the server)

Usage

Here is a complete example of how to generate and verify a proof for a Fibonacci sequence:

import {
  FieldElement,
  STARK_PRIME,
  StarkProver,
  StarkVerifier,
  Statement,
  Constraint,
  Witness
} from '@zkforge/zkstark';

// 1. Define the trace generation (Fibonacci)
function fibonacciTrace(n: number): FieldElement[] {
  const trace: FieldElement[] = [];
  trace.push(new FieldElement(0n, STARK_PRIME));
  trace.push(new FieldElement(1n, STARK_PRIME));

  for (let i = 2; i < n; i++) {
    const next = trace[i - 1].add(trace[i - 2]);
    trace.push(next);
  }
  return trace;
}

// 2. Define the constraint
const fibonacciConstraint: Constraint = {
  evaluate: (trace: FieldElement[]): FieldElement => {
    if (trace.length < 3) return FieldElement.zero(STARK_PRIME);
    const expected = trace[0].add(trace[1]);
    return trace[2].sub(expected);
  }
};

// 3. Setup Statement and Witness
const traceLength = 16;
const trace = fibonacciTrace(traceLength);
const statement: Statement = {
  publicInput: [trace[0], trace[trace.length - 1]],
  constraints: [fibonacciConstraint]
};
const witness: Witness = { privateInput: [], trace: trace };

// 4. Generate Proof
const prover = new StarkProver(statement, witness);
const proof = prover.generateProof();
console.log('Proof generated!');

// 5. Verify Proof
const verifier = new StarkVerifier(statement);
const isValid = verifier.verify(proof);
console.log(`Proof verified: ${isValid}`);

Testing

Run the test suite using:

npm run test

Expected output:

> @zkforge/[email protected] test
> jest --config jest.config.cjs

 PASS  tests/zkstark-auth.test.ts
  zkSTARK-style auth prototype
    ✓ accepts a valid auth proof for the correct secret (15 ms)
    ✓ rejects a proof if the public finalHash is tampered (3 ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        2.499 s, estimated 3 s
Ran all test suites.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.