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

@rolly-dev/auth-sign

v1.0.0

Published

Pure-TypeScript Poseidon2 hashing, provably-fair game math, Schnorr (EcGFp5) & EIP-712 signing for Rolly ZK-Rollup — bit-exact with the Rust circuit, no WASM required

Readme

@rolly-dev/auth-sign

Pure-TypeScript replacement for @rolly-dev/wasm-signer on the frontend (rolly-interface/apps/web, rolly-interface/apps/explorer).

WASM fails to load on some devices and under strict CSP (no wasm-unsafe-eval). This package re-implements the browser-facing surface of the signer in plain TypeScript so the dApp works everywhere, with no init() step. The backend and orchestrator keep using @rolly-dev/wasm-signer (Node, where WASM works).

Correctness contract: hashes and payouts are consumed by proofs already settled on L1. Every function here must be bit-exact with its Rust counterpart (circuit / games-core / tx-validator). Implementations are validated against golden vectors generated from Rust.

Scope

  • Poseidon2 over the Goldilocks field, seed / prediction / user_seed_binding hashes.
  • Provably-fair game math (dice, coinflip, limbo, crash, plinko, keno) — no Blackjack.
  • Client-side Schnorr (EcGFp5) signing and EIP-712 KeyRegistration typed data.

Nonce lanes (anti-replay)

The account leaf holds one nonce, split into two independent counters: nonce = account_lane · 2^40 + game_lane. A signature never commits to the packed value — only to the lane its tx type owns, which the backend hands out separately:

| Transaction | build_tx_hash.signed_nonce / EIP-712 nonce | Backend field | |---|---|---| | in_house_bet, crash_settle, set_provider_allowance | game lane | gameNonce | | withdrawal, transfer | account lane | accountNonce | | key_register (EIP-712) | account lane | accountNonce |

Bets bump only the game lane, so a withdrawal signed at request time stays valid however many bets land before it is approved. Withdrawals / transfers / allowance changes also sign a zero seed_commit — only bets bind the fairness seed.

Provider allowance (set_provider_allowance, tx 13)

Provider bets (tx 2, placed by a game provider through the operator) carry no owner signature. What the owner signs instead is an absolute provider allowance — the total providers may debit; each provider bet decrements it, a provider win does not restore it, 0 revokes it:

import { build_tx_hash, TX_SET_PROVIDER_ALLOWANCE, PROVIDER_ALLOWANCE_MAX } from '@rolly-dev/auth-sign';

const tx_hash = build_tx_hash({
  tx_type: TX_SET_PROVIDER_ALLOWANCE,
  user_id,
  amount: 50_000_000n,            // new absolute allowance (≤ PROVIDER_ALLOWANCE_MAX = 2^62 − 1)
  game_id: 0,
  prediction_hash: new BigUint64Array(4),
  user_seed: new BigUint64Array(4),
  old_seed_hash, crash_seed_hash, // ignored: zero seed_commit
  signed_nonce: gameNonce,        // GAME lane, like a bet
});

An account without a registered Schnorr key cannot sign an allowance, so every non-zero provider bet against it is rejected (ProviderAllowanceExceeded) — by design.

Install

pnpm add @rolly-dev/auth-sign

react is an optional peer dependency (only needed for the /react hook).

This package does not depend on viem: eip712_key_registration_typed_data returns a plain typed-data object that the app passes to its own wallet signTypedData (viem/wagmi) — signing stays in the consumer.

Usage

Synchronous — no async initialization:

import { poseidon2_hash, string_to_user_seed } from '@rolly-dev/auth-sign';

const seed = string_to_user_seed('my-seed-123');
const hash = poseidon2_hash(seed);

React hook (ready is always true — no WASM to load):

import { useRollySigner } from '@rolly-dev/auth-sign/react';

function Component() {
  const { ready, compute_roll_dice } = useRollySigner();
  // `ready` is always true.
}

Note: identifiers here are intentionally not named after "wasm" (e.g. useRollySigner, not useRollyWasm) — this package contains no WebAssembly, and reusing the old name would be misleading. Migrating call sites rename the hook alongside the import path.

Build

pnpm build      # tsup → dist/ (ESM + CJS + .d.ts)
pnpm typecheck  # tsc --noEmit

Golden-vector conformance tests

Correctness is enforced by golden vectors generated from the authoritative Rust — the only way to guarantee bit-exactness with proofs already settled on L1. The two pieces:

  • Generatorprover/circuit/examples/gen_golden_vectors.rs dumps JSON vectors from all four reference sources: tx-validator/src/hash.rs (Poseidon2

    • derived hashes), games-core (payout math), crypto/ecgfp5/native.rs (curve + Schnorr) and crypto/eip712.rs (KeyRegistration hashing). Vectors are deterministic (fixed RNG seed). Regenerate with:
    npm run vectors   # → test/vectors/*.json (committed, do not hand-edit)
  • Harnesstest/*.test.ts (Node's built-in runner, TypeScript stripped at runtime) load test/vectors/*.json and compare against the TS implementation:

    npm test

    Each layer's test auto-skips while its function is still a scaffold stub, so the suite is green today and every implementation flip turns its vectors on automatically. test/_selfcheck.test.ts guards that skip/enforce behavior. Field elements travel as decimal strings in JSON and become bigint in TS.

Status

Scaffold. The implementation layers (Goldilocks field, Poseidon2, seed/prediction utilities, game payout math, EcGFp5 Schnorr, tx-hash + EIP-712) are ported incrementally; every exported function currently throws until its layer lands.