bip38-network

3.0.0 • Public • Published

bip38-network

build status Coverage Status Version

js-standard-style

A JavaScript component that adheres to the BIP38 standard to secure your crypto currency private keys. Fully compliant with Node.js and the browser (via Browserify).

bip38-network is a fork of the original bip38, with added support for alternative networks (bip38 only supports bitcoin main network) and relies on an async library for scrypt, making it more performant.

Performance:

Intel Core i7-8700K

  • bip38: ~8700ms
  • bip38-network: ~430ms

Why?

BIP38 is a standard process to encrypt Bitcoin and crypto currency private keys that is imprevious to brute force attacks thus protecting the user.

Backwards compatibility

The 2.0.2 release that adds support for different networks, is available and is compatible with the existing bip38 package. While the latest (3+) version contains breaking changes and only supports async usage.

Installation (compatibility package):

npm install bip38-network@2.0.2

Package Info

Usage

Installation

npm install bip38-network

API

encrypt(buffer, compressed, passphrase[, progressCallback, scryptParams])

var bip38 = require('bip38-network')
var wif = require('wif')
 
var myWifString = '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR'
var decoded = wif.decode(myWifString)
 
bip38.encryptAsync(decoded.privateKey, decoded.compressed, 'TestingOneTwoThree', (encryptedKey) => {
console.log(encryptedKey)
})
 
// => '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg'

decrypt(encryptedKey, passphrase[, progressCallback, scryptParams])

var bip38 = require('bip38')
var wif = require('wif')
 
var encryptedKey = '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg'
bip38.decryptAsync(encryptedKey, 'TestingOneTwoThree', function (decryptedKey) {
  console.log(decryptedKey)
})
 
console.log(wif.encode(0x80, decryptedKey.privateKey, decryptedKey.compressed))
// => '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR'

References

Package Sidebar

Install

npm i bip38-network

Weekly Downloads

0

Version

3.0.0

License

none

Unpacked Size

16.1 kB

Total Files

5

Last publish

Collaborators

  • sondreb