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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bcoin-native

v0.0.23

Published

Native bindings to bitcoin-related functions

Downloads

111

Readme

bcoin-native

The missing crypto and encoding bindings for node.js.

This module provides native bindings to all lowlevel optimizable things used in bitcoin.

Used in bcoin.

Functions

  • hash(alg, data)
  • hmac(alg, data)
  • ripemd160(data)
  • sha1(data)
  • sha256(data)
  • hash160(data)
  • hash256(data)
  • root256(left, right)
  • toBase58(data)
  • fromBase58(data)
  • toBech32(hrp, version, hash)
  • fromBech32(str)
  • scrypt(pass, salt, n, r, p, klen)
  • scryptAsync(pass, salt, n, r, p, klen)
  • murmur3(data, seed)
  • siphash(data, key)
  • siphash256(data, key)
  • cleanse(data)
  • encipher(data, key, iv)
  • decipher(data, key, iv)

Objects

  • Poly1305()
    • #init(key)
    • #update(data)
    • #finish()
    • .verify(mac1, mac2)
    • .auth(data, key)
  • ChaCha20()
    • #init(key?, iv?, counter?)
    • #initKey(key)
    • #initIV(iv, counter?)
    • #encrypt(data)
    • #getCounter()
    • #setCounter(counter)

Usage

var native = require('bcoin-native');
var data = Buffer.from('01020304', 'hex');
var key = Buffer.from('05060708', 'hex');

var hash1 = native.sha256(data);
var hash2 = native.hash256(data);

console.log('sha256: %s', hash1.toString('hex'));
console.log('double sha256: %s', hash2.toString('hex'));

Outputs:

sha256: 9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a
double sha256: 8de472e2399610baaa7f84840547cd409434e31f5d3bd71e4d947f283874f9c0

Benchmarks

$ node bench.js
crypto.sha256: ops=100000, time=0.41668067, rate=239991.93435
native.sha256: ops=100000, time=0.328309021, rate=304591.08219
crypto.hash160: ops=100000, time=0.698852504, rate=143091.71024
native.hash160: ops=100000, time=0.32359362, rate=309029.57852
crypto.hash256: ops=100000, time=0.65909456, rate=151723.29749
native.hash256: ops=100000, time=0.313477282, rate=319002.38308
crypto.sha256hmac: ops=100000, time=0.589858488, rate=169532.18786
native.sha256hmac: ops=100000, time=0.444996526, rate=224720.85546
utils.toBase58: ops=100000, time=0.808880157, rate=123627.70818
native.toBase58: ops=100000, time=0.458057275, rate=218313.31027
utils.fromBase58: ops=100000, time=0.77960898, rate=128269.43066
native.fromBase58: ops=100000, time=0.746901487, rate=133886.46527
js poly1305.update: ops=31250, time=1.6195938239999998, rate=19294.96120
js poly1305.finish: ops=31250, time=2.9935169999999998, rate=10439.22583
c poly1305.update: ops=31250, time=0.184753504, rate=169144.28860
c poly1305.finish: ops=31250, time=1.434867264, rate=21779.01802
js murmur3: ops=1000000, time=4.714874642, rate=212094.71639
c murmur3: ops=1000000, time=0.412050096, rate=2426889.37512
js siphash256: ops=1000000, time=13.218189886, rate=75653.32384
c siphash256: ops=1000000, time=1.19912212, rate=833943.41854

License

Copyright (c) 2016, Christopher Jeffrey. (MIT License)

See LICENSE for more info.