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

@ergots/avltree

v0.2.0

Published

Pure-TypeScript Ergo batch AVL+ authenticated tree verifier — proof verification + per-operation result computation.

Readme

@ergots/avltree

Pure-TypeScript AVL+ authenticated dictionary verifier. Browser-compatible. Validated byte-for-byte against ergo_avltree_rust (HEAD 879545c).

Given a starting digest, a serialized AD proof, a tree configuration, and a batch of operations, verifyAvlBatch reconstructs the mutated tree, checks every leaf hash, and returns the resulting 33-byte digest plus the old value at each key — or null if the proof is invalid. The package is independently useful to wallets, DEX simulators, and light clients verifying Ergo state transitions, and is also a runtime dependency of @ergots/ergoscript (phase 2h-b).

Install

npm install @ergots/avltree

Usage

import { verifyAvlBatch, verifyAvlLookup, type AvlTreeConfig, type Operation } from '@ergots/avltree';

// Config matches the on-chain tree parameters.
const config: AvlTreeConfig = {
  keyLength: 32,
  valueLengthOpt: null,   // variable-length values
};

// Starting digest from the chain state (33 bytes: 32-byte root label + 1-byte height).
const startingDigest = new Uint8Array(33);
// (fill from actual chain state)

// Serialized AD proof bytes from the block's extension section.
const proof = new Uint8Array([/* aabb...cc */]);

// A batch of operations to verify.
const operations: Operation[] = [
  { tag: 'Lookup',  key: new Uint8Array(32) /* actual key bytes */ },
  { tag: 'Insert',  key: new Uint8Array(32), value: new Uint8Array([0x01, 0x02, 0x03]) },
];

const result = verifyAvlBatch(startingDigest, proof, config, operations);
if (result === null) {
  // Proof invalid — digest mismatch, malformed proof, or operation precondition failed.
} else {
  console.log('new digest:', result.newDigest);  // Uint8Array, 33 bytes
  console.log('old values:', result.results);    // (Uint8Array | null)[] — null = key was absent
}

// Single-key read convenience wrapper:
const lookup = verifyAvlLookup(startingDigest, proof, config, new Uint8Array(32));
if (lookup === null) {
  // Proof invalid.
} else if (lookup.value === null) {
  console.log('key absent from tree');
} else {
  console.log('value:', lookup.value);
}

See API.md for the full reference (every export, signature, error codes, and type definitions).

Browser compatibility

Runs unchanged in evergreen browsers and Node >= 20. No Buffer, no node:crypto, no dynamic Node built-ins, no WASM. ESM-only.

The verifier is stateless: inputs in, structured result (or null) out. No I/O, no clock, no storage.

What this package does NOT do

  • Proof construction. The prover (BatchAVLProver) is not ported. Fixture generation lives in the Rust fixture-gen/ crate.
  • Storage. No versioned AVL storage, no IndexedDB, no persistent tree state.
  • Cost accounting. Ergo's per-operation cost charging is the responsibility of @ergots/ergoscript's SAvlTree.* method handlers.

Reference implementation

This package is a clean-room TypeScript port of ergo_avltree_rust (verifier path only), validated byte-for-byte against fixtures generated by the Rust reference. The algorithmic basis is the KMZ16 AVL+ authenticated dictionary; KMZ17 Appendix B documents the keyMatchesLeaf range semantics.

See facts/avltree.md for the load-bearing interface contract.

License

MIT