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

stealth

v0.4.0

Published

Stealth addresses for Bitcoin and other crypto currencies.

Downloads

32

Readme

stealth

build status Coverage Status

js-standard-style

This module is used for stealth addresses for Bitcoin and other crypto currencies.

Usage

First, you should really read this excellent resource: https://gist.github.com/ryanxcharles/1c0f95d0892b4a92d70a

This module depends upon ecurve and may change to elliptic in the future. However, this is just an implementation detail that shouldn't affect your code.

Example

If you're the payer (sender)

var Stealth = require('stealth')

// you get this from the person you're going to pay (receiver)
var addr = 'vJmtuUb8ysKiM1HtHQF23FGfjGAKu5sM94UyyjknqhJHNdj5CZzwtpGzeyaATQ2HvuzomNVtiwsTJSWzzCBgCTtUZbRFpzKVq9MAUr'
var stealth = Stealth.fromString(addr)

// single-use nonce key pair, works with CoinKey, bitcoinjs-lib, bitcore, etc
var keypair = require('coinkey').createRandom()

// generate payment address
var payToAddress = stealth.genPaymentAddress(keypair.privateKey)

// create transaction with two outputs:
// 1. Regular pay-to-pubkeyhash with `payToAddress` as recipient
// 2. OP_RETURN with `keypair.publicKey`

If you're the payee (recipient)

var Stealth = require('stealth')

// you need to scan every transaction and look for the following:
// 1. does the transaction contain an OP_RETURN?
// 2. if yes, then extract the OP_RETURN
// 3. is the OP_RETURN data a compressed public key (33 bytes)?
// 4. if yes, check if mine

// generate two key pairs, can use CoinKey, bitcoinjs-lib, bitcore, etc
var payloadKeyPair = require('coinkey').createRandom()
var scanKeyPair = require('coinkey').createRandom()

// note, the private keys are NOT encoded in the Stealth address
// you need to save them somewhere
var stealth = new Stealth({
  payloadPrivKey: payloadKeyPair.privateKey,
  payloadPubKey: payloadKeyPair.publicKey,
  scanPrivKey: scanKeyPair.privateKey,
  scanPubKey: scanKeyPair.publicKey
})

var addr = stealth.toString()
// => 'vJmtuUb8ysKiM1HtHQF23FGfjGAKu5sM94UyyjknqhJHNdj5CZzwtpGzeyaATQ2HvuzomNVtiwsTJSWzzCBgCTtUZbRFpzKVq9MAUr'

// publish addr or give it someone
// unlike regular Bitcoin addresses, you can use
// stealth address as much as you like

// scan and decode transactions

var opReturnPubKey = /* */
var pubKeyHashWithPayment = /* */

var keypair = stealth.checkPaymentPubKeyHash(opReturnPubKey, pubKeyHashWithPayment)

// it NOT YOURS, `keypair` will be falsey

if (keypair == null) {
  console.log('payment is not mine')
} else {
  console.log('payment is mine')

  // redeem with `privKey`
  console.log(keypair.privKey)
}

API

(TODO)

+ fromRandom([config])

Class method to create a stealth key from a random entropy. Optionally pass in config with the following:

  • rng: A function that should accept a number n and return a Buffer/Array with length n.
  • version: Version code for stealth string.

Resources

Credits

The creation of this module owes a lot of credit to the prior work of Ryan X. Charles, specifically the following resources:

  • https://github.com/ryanxcharles/fullnode
  • https://gist.github.com/ryanxcharles/1c0f95d0892b4a92d70a

Additional Resources

  • Dark Wallet description: https://wiki.unsystem.net/en/index.php/DarkWallet/Stealth
  • Dark Wallet infographic: https://wiki.unsystem.net/en/images/e/e5/RHhNKL6.jpg
  • Stealth Whitepaper: http://sourceforge.net/p/bitcoin/mailman/message/31813471/

License

MIT