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

@vbyte/crypto

v1.0.1

Published

Sugary wrappers for @noble and @scure crypto libraries.

Downloads

61

Readme

@vbyte/crypto

npm version License: MIT

TypeScript wrappers for Bitcoin-related cryptographic operations, built on audited libraries.

Security Note: This package wraps @noble/curves, @noble/hashes, and @scure/base - all of which have undergone security audits.

Installation

# npm
npm install @vbyte/crypto

# yarn
yarn add @vbyte/crypto

# pnpm
pnpm add @vbyte/crypto

CDN

<script src="https://unpkg.com/@vbyte/crypto/dist/script.js"></script>

Quick Start

ECC (Elliptic Curve Cryptography)

import { get_pubkey, sign_ecdsa, verify_ecdsa, sign_bip340, verify_bip340 } from '@vbyte/crypto/ecc'

// Generate public key from private key
const privateKey = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
const ecdsaPubkey = get_pubkey(privateKey, 'ecdsa')   // 33-byte compressed
const bip340Pubkey = get_pubkey(privateKey, 'bip340') // 32-byte x-only

// ECDSA signatures (message must be hex)
const messageHash = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
const ecdsaSig = sign_ecdsa(privateKey, messageHash)
const isValid = verify_ecdsa(ecdsaSig, messageHash, ecdsaPubkey)

// BIP340 Schnorr signatures
const schnorrSig = sign_bip340(privateKey, messageHash)
const isValidSchnorr = verify_bip340(schnorrSig, messageHash, bip340Pubkey)

Note: All string inputs must be valid hexadecimal. Use Buff.str('text').hex from @vbyte/buff to convert UTF-8 text to hex.

Hash Functions

import { sha256, hash256, hash160, hmac256, pkdf256 } from '@vbyte/crypto/hash'
import { Buff } from '@vbyte/buff'

// SHA-256 (input as hex string or Uint8Array)
const dataHex = '48656c6c6f' // 'Hello' in hex
const hash = sha256(dataHex)

// Double SHA-256 (Bitcoin-style)
const doubleHash = hash256(dataHex)

// RIPEMD160(SHA256(x)) for Bitcoin addresses
const addressHash = hash160(dataHex)

// HMAC-SHA256
const keyHex = '736563726574' // 'secret' in hex
const mac = hmac256(keyHex, dataHex)

// PBKDF2-SHA256
const passwordHex = Buff.str('password').hex
const saltHex = Buff.str('salt').hex
const derivedKey = pkdf256(passwordHex, saltHex, { c: 100000, dk_len: 32 })

Encoding

import { B58chk, Bech32, Bech32m, Base64 } from '@vbyte/crypto/encode'

// Base58Check (Bitcoin addresses)
const encoded = B58chk.encode(data)
const decoded = B58chk.decode(encoded)

// Bech32 (SegWit v0 addresses)
const words = Bech32.to_words(data)
const bech32Addr = Bech32.encode('bc', words)
const { prefix, words: decodedWords } = Bech32.decode(bech32Addr)

// Bech32m (SegWit v1+ / Taproot addresses)
const taprootAddr = Bech32m.encode('bc', [1, ...words])

// Base64
const b64 = Base64.encode(data)
const original = Base64.decode(b64)

Error Handling

All functions throw standard Error on invalid input:

import { verify_seckey } from '@vbyte/crypto/ecc'

try {
  verify_seckey('invalid-key')
} catch (err) {
  console.error(err.message) // "invalid hex string: invalid-key"
}
import { B58chk } from '@vbyte/crypto/encode'

try {
  B58chk.decode('invalid!@#')
} catch (err) {
  console.error(err.message) // "invalid base58 string"
}

API Reference

ECC Module

| Function | Description | |----------|-------------| | get_seckey(secret, even_y?) | Derive secret key, optionally with even Y coordinate | | get_pubkey(seckey, format) | Generate public key ('ecdsa' or 'bip340' format) | | tweak_seckey(seckey, tweak, even_y?) | Tweak a secret key | | tweak_pubkey(pubkey, tweak, format, even_y?) | Tweak a public key | | verify_seckey(seckey) | Validate a secret key | | verify_pubkey(pubkey, format) | Validate a public key | | sign_ecdsa(seckey, message) | Create ECDSA signature | | sign_bip340(seckey, message) | Create BIP340 Schnorr signature | | verify_ecdsa(sig, message, pubkey) | Verify ECDSA signature | | verify_bip340(sig, message, pubkey) | Verify BIP340 signature | | serialize_bytes(bytes) | Serialize hex string or Uint8Array to Buff | | serialize_pubkey(pubkey, format) | Normalize pubkey to specified format | | get_pubkey_format(pubkey) | Detect pubkey format from length |

Hash Module

| Function | Description | |----------|-------------| | sha256(...input) | SHA-256 hash | | hash256(...input) | Double SHA-256 | | hash160(...input) | RIPEMD160(SHA256(x)) | | hashtag(tag) | Create tagged hash prefix | | hash340(tag, ...input) | BIP340-style tagged hash | | hmac256(key, ...input) | HMAC-SHA256 | | hmac512(key, ...input) | HMAC-SHA512 | | pkdf256(secret, salt, options?) | PBKDF2-SHA256 | | pkdf512(secret, salt, options?) | PBKDF2-SHA512 |

Encode Module

| Namespace | Functions | |-----------|-----------| | B58chk | encode(data), decode(str) | | Base64 | encode(data), decode(str) | | B64url | encode(data), decode(str) | | Bech32 | encode(prefix, words, limit?), decode(str, limit?), to_words(data), to_bytes(words) | | Bech32m | encode(prefix, words, limit?), decode(str, limit?), to_words(data), to_bytes(words) |

Module Imports

// Full package (includes all modules)
import { sha256, get_pubkey, B58chk } from '@vbyte/crypto'

// Tree-shaking friendly imports
import { sha256, hash256 } from '@vbyte/crypto/hash'
import { get_pubkey, sign_ecdsa } from '@vbyte/crypto/ecc'
import { B58chk, Bech32 } from '@vbyte/crypto/encode'

Build Outputs

| File | Format | Use Case | |------|--------|----------| | dist/index.js | ESM | Modern bundlers, Node.js | | dist/main.cjs | CommonJS | Legacy Node.js | | dist/script.js | IIFE | Browser script tag |

Browser Usage

<script src="https://unpkg.com/@vbyte/crypto/dist/script.js"></script>
<script>
  const { Hash, Buff } = window.vbyteCrypto
  // Convert text to hex, then hash
  const dataHex = Buff.str('hello world').hex
  const hash = Hash.sha256(dataHex)
  console.log(hash.hex)
</script>

Dependencies

All cryptographic operations are delegated to audited libraries:

| Package | Purpose | Audit | |---------|---------|-------| | @noble/curves | secp256k1, ECDSA, Schnorr | Cure53 (2022) | | @noble/hashes | SHA256, RIPEMD160, HMAC, PBKDF2 | Cure53 (2022) | | @scure/base | Base58, Bech32, Base64 | Cure53 (2022) | | @vbyte/buff | Buffer utilities | - |

Contributing

See CONTRIBUTING.md for guidelines.

Security

Report vulnerabilities via GitHub Security Advisories. See SECURITY.md.

License

MIT