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

@routedock/nulth-sdk

v0.3.0

Published

Off-chain ZK proof builder for Nulth smart accounts on Stellar

Readme

@routedock/nulth-sdk — Stub / Proof-of-Concept

Status: STUB — not ready for production.

This package provides an insecure mock prover (insecureMockProof). It produces a SHA-512 digest as a placeholder; no real zero-knowledge proof is generated. Use it only for testnet development, never for custody or production policy enforcement. NulthClient rejects every network except testnet and every prover except mock. See Issue #143 for production prover work.

Requirements

Node.js 22 or newer, matching the supported runtime of the RouteDock packages. TypeScript examples use ES2022 or later for native bigint support.

Install

npm install @routedock/nulth-sdk

Example: initialize a testnet client

Set NULTH_ACCOUNT to your testnet smart-account contract address (C...) and TESTNET_PAYEE to an allowed testnet recipient (G... or C...). This example initializes local policy state and prints commitments; it does not submit a payment. Persist the witness secret securely if you need to recreate the same commitments.

import { randomBytes } from 'node:crypto'
import {
  createPolicyState,
  NulthClient,
  stroopsToUsdc,
} from '@routedock/nulth-sdk'

const nulthAccount = process.env.NULTH_ACCOUNT
const payee = process.env.TESTNET_PAYEE
if (!nulthAccount || !payee) {
  throw new Error('Set NULTH_ACCOUNT and TESTNET_PAYEE to testnet addresses')
}

const policy = createPolicyState({
  dailyCapUsdc: '1.00',
  allowedPayees: [payee],
  witnessSecret: randomBytes(32).toString('hex'),
})
const client = new NulthClient({
  nulthAccount,
  network: 'testnet',
  prover: 'mock',
  policy,
})

console.log(client.allowlistCommitment, client.capCommitment)
console.log(stroopsToUsdc(client.dailySpendStroops)) // '0'

Before using the signing adapter, supply the payment's real ledger sequence, asset, payee, and amount through setNulthPaymentContext. createNulthSigner checks the actual Soroban authorization preimage against that context. A missing context or mismatched transfer is rejected. These client-side checks do not make the mock proof secure.

Exports

| Export | Purpose | | --- | --- | | NulthClient | Testnet-only client with policy checks, mock proof construction, encoding, and spend/commitment getters. | | createPolicyState | Initialize off-chain policy from a decimal USDC cap, payees, witness secret, and optional ledger/expiry. | | createNulthSigner | Create an x402-compatible signer for a Nulth account using the mock client. | | setNulthPaymentContext | Set the next payment context on the configuration used by the signer. | | paymentContextFromManifest | Extract asset, payee, amount, and ledger context from manifest pricing. | | assertAuthEntryMatchesContext | Reject an authorization preimage whose transfer does not match the expected payer, payee, asset, or amount. | | usdcToStroops, stroopsToUsdc, USDC_DECIMALS | Convert decimal USDC strings and integer units using seven decimal places. | | commitAllowlist, commitDailyCap | Compute salted SHA-256 commitments to policy values. | | dayBucket | Convert a ledger sequence to its 17,280-ledger day bucket. | | hashPayee, authDigestFromEntry, sha256Hex | Hash payees, authorization preimages, and byte/string inputs. | | encodeAuthSignature, decodeAuthSignature | Encode or decode the mock signature envelope as base64 JSON; decoding is not proof verification. | | insecureMockProof, DEFAULT_PROVER | Produce deterministic SHA-512 placeholder bytes and identify the only supported backend (mock). | | NulthPolicyError | Typed policy rejection with a code such as daily_cap_exceeded or auth_entry_mismatch. | | NulthPolicyState, NulthClientConfig, PaymentAuthContext | Types for policy state, client configuration, and payment authorization inputs. | | NulthSignerConfig, NulthStellarSigner | Types for mutable signer configuration and its signing interface. | | NulthProof, NulthAuthSignature, ProverBackend | Types for the mock proof, signature envelope, and prover selection. |

What the mock prover does and does not prove

NulthClient checks the local allowlist, daily cap, and optional session expiry, then hashes public inputs into deterministic placeholder bytes. Building a proof updates the client's in-memory daily spend; it is not evidence of on-chain settlement and does not provide durable accounting across process restarts.

The digest is not a zero-knowledge proof and proves neither knowledge of a secret witness nor satisfaction of the policy to an on-chain verifier. Anyone can reproduce it from the public preimage. Commitments alone do not provide a production security boundary, and the public inputs expose payment amounts, day buckets, and hashes. A real prover/verifier integration is still required before this package can protect funds.

For contributors, pnpm --filter @routedock/nulth-sdk check:readme typechecks every TypeScript example against the built package exports. It also runs during pnpm verify.

Diagnostics and configuration errors

Diagnostics are silent by default. Pass a logger(level, message, fields?) in NulthClientConfig (also accepted by createNulthSigner) to receive the mock-prover warning. The sink is compatible with RouteDock's RouteDockLogger; the RouteDock SDK adapter retains its console-backed default and accepts the same override.

Invalid networks and prover backends throw NulthConfigError, with code unsupported_network or unsupported_prover. The RouteDock adapter maps these to RouteDockManifestError; policy failures remain NulthPolicyError.

Paying through x402 with a Nulth account

src/scheme.ts carries the pieces the SDK needs to let a Nulth ZK account sign an x402 payment:

  • NULTH_SIGNER_MARKER — a Symbol.for key set on every signer from createNulthSigner(). @routedock/routedock uses it to pick the Nulth payment scheme instead of the plain ed25519 one, so no caller has to opt in.
  • nulthProofScVal / decodeNulthProofScVal — the zk-v1 envelope, a scvVec of one map with nulth, version, proof, auth_digest, allowlist_commitment, cap_commitment, payee_hash, amount_stroops and day_bucket. The proof and its public inputs go into SorobanAddressCredentials.signature; the allowlist and the daily cap never leave the agent.
  • nulthAuthorizeEntry — the authorizeEntry replacement. stellar-sdk's default writes scvVec([nativeToScVal({public_key, signature})]), and for a C... contract account that path throws invalid version byte. expected 48, got 16 (see Issue #356), so a Nulth payment can never be signed with it.

What still is not here: the contract side. There is no Nulth account contract in this repository that implements __check_auth against these public inputs, and no Groth16 verifier is deployed, so a proof produced by the mock prover is not settled on-chain. Testnet builds are for developing the client path only.