Skip to content

Commit

Permalink
package: use coinstring over bs58check
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Jul 3, 2014
1 parent 0b5168e commit e6b67c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/bip38.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var AES = require('aes')
var assert = require('assert')
var base58check = require('bs58check')
var crypto = require('crypto')
var cs = require('coinstring')
var scrypt = require('scryptsy')

var ecurve = require('ecurve')
Expand Down Expand Up @@ -58,15 +58,15 @@ Bip38.prototype.encryptRaw = function(buffer, compressed, passphrase, saltAddres
}

Bip38.prototype.encrypt = function(wif, passphrase, saltAddress) {
var d = base58check.decode(wif).slice(1)
var d = cs.decode(wif).slice(1)
var compressed = (d.length === 33) && (d[32] === 0x01)

// truncate the compression flag
if (compressed) {
d = d.slice(0, -1)
}

return base58check.encode(this.encryptRaw(d, compressed, passphrase, saltAddress))
return cs.encode(this.encryptRaw(d, compressed, passphrase, saltAddress))
}

//some of the techniques borrowed from: https://github.com/pointbiz/bitaddress.org
Expand Down Expand Up @@ -122,7 +122,7 @@ Bip38.prototype.decryptRaw = function(encData, passphrase) {
}

Bip38.prototype.decrypt = function(encryptedBase58, passphrase) {
var encBuffer = base58check.decode(encryptedBase58)
var encBuffer = cs.decode(encryptedBase58)
var decrypt = this.decryptRaw(encBuffer, passphrase)

// Convert to WIF
Expand All @@ -136,7 +136,7 @@ Bip38.prototype.decrypt = function(encryptedBase58, passphrase) {
buffer.writeUInt8(0x01, 33)
}

return base58check.encode(buffer)
return cs.encode(buffer)
}

Bip38.prototype.decryptECMult = function(encData, passphrase) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"aes": "~0.1.0",
"bigi": "^1.2.0",
"bs58check": "^1.0.0",
"coinstring": "^2.0.0",
"ecurve": "^1.0.0",
"scryptsy": "^1.0.0"
},
Expand Down

0 comments on commit e6b67c8

Please sign in to comment.