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

micro-sr25519

v0.1.3

Published

Minimal implementation of sr25519 (polkadot) cryptography, with Merlin and Strobe

Downloads

4,012

Readme

micro-sr25519

Minimal JS implementation of sr25519 cryptography for Polkadot.

  • 🧜‍♂️ sr25519 curve
  • Schnorr signature on Ristretto compressed Ed25519
  • Hierarchical Deterministic Key Derivation (HDKD)
  • Verifiable random function (VRF)
  • Uses Merlin, which is based on Strobe128.
    • NOTE: We implement only parts of these protocols which required for sr25519.
  • ➰ Uses noble-curves for underlying arithmetics

Usage

npm install micro-sr25519

import * as sr25519 from 'micro-sr25519';

We support all major platforms and runtimes. For Deno, ensure to use npm specifier.

Basic

const signature = sr25519.sign(pair.secretKey, msg);
const isValid = sr25519.verify(msg, polkaSig, pair.publicKey);
const secretKey = sr25519.secretFromSeed(seed);
const publicKey = sr25519.getPublicKey(secretKey);
const sharedSecret = sr25519.getSharedSecret(secretKey, publicKey);

HDKD

// hard
const secretKey = sr25519.HDKD.secretHard(pair.secretKey, cc);
const publicKey = sr25519.getPublicKey(secretKey);

// soft
const secretKey = sr25519.HDKD.secretSoft(pair.secretKey, cc);
const publicKey = sr25519.getPublicKey(secretKey);

// public
const publicKey = sr25519.HDKD.publicSoft(pubSelf, cc);

VRF

const signature = sr25519.vrf.sign(msg, pair.secretKey);
const isValid = sr25519.vrf.verify(msg, sig, pair.publicKey);

Migration from @polkadot/utils-crypto

  • most derive methods in original return {publicKey, privateKey}, we always return only privateKey, you can get publicKey via getPublicKey
  • privateKey is 64 byte (instead of 32 byte in ed25519), this is because we need nonce and privateKey can be derived from others (HDKD), and there would be no seed for that.

Security

The library has not been independently audited yet. Use at your own risk.

Speed

Benchmark results on Apple M2 with node v22:

sr25519
secretFromSeed
├─wasm x 15,323 ops/sec @ 65μs/op
└─micro x 116,509 ops/sec @ 8μs/op
getSharedSecret
├─wasm x 4,516 ops/sec @ 221μs/op
└─micro x 799 ops/sec @ 1ms/op
HDKD.secretHard
├─wasm x 11,930 ops/sec @ 83μs/op
└─micro x 26,340 ops/sec @ 37μs/op
HDKD.secretSoft
├─wasm x 12,147 ops/sec @ 82μs/op
└─micro x 2,756 ops/sec @ 362μs/op
HDKD.publicSoft
├─wasm x 12,627 ops/sec @ 79μs/op
└─micro x 3,134 ops/sec @ 319μs/op
sign
├─wasm x 12,223 ops/sec @ 81μs/op
└─micro x 1,741 ops/sec @ 574μs/op
verify
├─wasm x 5,085 ops/sec @ 196μs/op
└─micro x 669 ops/sec @ 1ms/op
vrfSign
├─wasm x 1,847 ops/sec @ 541μs/op
└─micro x 313 ops/sec @ 3ms/op
vrfVerify
├─wasm x 2,181 ops/sec @ 458μs/op
└─micro x 243 ops/sec @ 4ms/op

Contributing & testing

  1. Clone the repository
  2. npm install to install build dependencies like TypeScript
  3. npm run build to compile TypeScript code
  4. npm run test will execute all main tests

License

The MIT License (MIT)

Copyright (c) 2024 Paul Miller (https://paulmillr.com)

See LICENSE file.