[BREAKGLASS] Append-only mirror of github.com/bluewallet/bip38
Go to file
2020-04-09 12:46:25 +09:00
test Fix normalization for Async 2020-04-09 12:35:37 +09:00
.gitignore Switch to nyc 2020-04-09 11:44:08 +09:00
.min-wd makefile for testing 2014-02-28 02:29:00 -06:00
.npmignore rm non-existent files 2015-08-13 17:24:02 +10:00
.travis.yml Minimize number of unit test runs 2019-03-22 11:18:24 +09:00
CHANGELOG.md 2.0.3 2019-05-22 17:46:38 -05:00
index.js Fix normalization for Async 2020-04-09 12:35:37 +09:00
LICENSE LICENSE: adds MIT license 2014-09-02 17:39:05 +10:00
package-lock.json 3.1.0 2020-04-09 12:46:25 +09:00
package.json 3.1.0 2020-04-09 12:46:25 +09:00
README.md Add mention of Async 2020-04-09 12:43:18 +09:00

bip38

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).

Why?

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

Package Info

Usage

Installation

npm install --save bip38

Async methods

Async methods are available, but using them will be slower, but free up the event loop in intervals you choose.

For benchmark results, please see the section in the README of the scryptsy library. Increasing the interval will decrease the performance hit, but increase the span between event loop free ups (UI drawing etc.) promiseInterval is the last optional parameter after scryptParams. There is no recommendation currently, as the performance trade off is app specific.

API

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

var bip38 = require('bip38')
var wif = require('wif')

var myWifString = '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR'
var decoded = wif.decode(myWifString)

var encryptedKey = bip38.encrypt(decoded.privateKey, decoded.compressed, 'TestingOneTwoThree')
console.log(encryptedKey)
// => '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg'

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

var bip38 = require('bip38')
var wif = require('wif')

var encryptedKey = '6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg'
var decryptedKey = bip38.decrypt(encryptedKey, 'TestingOneTwoThree', function (status) {
  console.log(status.percent) // will print the percent every time current increases by 1000
})

console.log(wif.encode(0x80, decryptedKey.privateKey, decryptedKey.compressed))
// => '5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR'

References