Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a package-lock.json and npm-shrinkwrap.json file #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build/aes-cbc-decrypter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
var scrypt_encryption_key_1 = require("./scrypt-encryption-key");
var crypto = require("crypto");
var ByteBuffer = require("bytebuffer");
var FRAGMENT_SIZE = 16;
var Decrypter = (function () {
function Decrypter(key) {
this.key = key;
Expand All @@ -21,9 +20,11 @@ var Decrypter = (function () {
Decrypter.prototype.decrypt = function (data, iv) {
return this.initialize(iv)
.then(function (aesCbc) {
var mainBuffer = aesCbc.update(Buffer.from(data.toBuffer()));
var finalBuffer = aesCbc.final();
var decrypted = Buffer.concat([
aesCbc.update(Buffer.from(data.toBuffer())),
aesCbc.final()
mainBuffer,
finalBuffer
]);
return ByteBuffer.wrap(decrypted);
});
Expand All @@ -32,8 +33,7 @@ var Decrypter = (function () {
return this.key.keyPromise
.then(function (key) {
return crypto.createDecipheriv('aes-256-cbc', key.toBuffer(), iv.toBuffer());
})
.catch(function () { return console.log('whoa. fail.'); });
});
};
return Decrypter;
}());
Expand Down
23 changes: 18 additions & 5 deletions build/mbexport
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ var aes_cbc_decrypter_1 = require("./aes-cbc-decrypter");
var fs = require("fs");
var bcoin = require("bcoin");
var prompt = require('prompt');
var FIXED_IV = ByteBuffer.wrap(new Uint8Array([
0xa3, 0x44, 0x39, 0x1f, 0x53, 0x83, 0x11, 0xb3,
0x29, 0x54, 0x86, 0x16, 0xc4, 0x89, 0x72, 0x3e
]));
prompt.message = '';
prompt.delimiter = '';
var Wallet = require('../build/wallet').wallet.Wallet;
Expand Down Expand Up @@ -41,14 +45,23 @@ try {
}
catch (e) {
console.log('MultibitHD wallet opened');
var decrypter_1;
walletPromise = getPassphrase()
.then(function (passphrase) {
return aes_cbc_decrypter_1.Decrypter
.factory(passphrase)
.decrypt(pb.slice(16), pb.slice(0, 16));
decrypter_1 = aes_cbc_decrypter_1.Decrypter
.factory(passphrase);
pb.reset();
return decrypter_1.decrypt(pb.slice(16), pb.slice(0, 16))
.then(function (payload) {
return Wallet.decode(payload);
});
})
.then(function (payload) {
return Wallet.decode(payload);
.catch(function (e) {
pb.reset();
return decrypter_1.decrypt(pb, FIXED_IV)
.then(function (payload) {
return Wallet.decode(payload);
});
});
}
walletPromise.then(function (wallet) {
Expand Down
23 changes: 18 additions & 5 deletions build/mbexport.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ var aes_cbc_decrypter_1 = require("./aes-cbc-decrypter");
var fs = require("fs");
var bcoin = require("bcoin");
var prompt = require('prompt');
var FIXED_IV = ByteBuffer.wrap(new Uint8Array([
0xa3, 0x44, 0x39, 0x1f, 0x53, 0x83, 0x11, 0xb3,
0x29, 0x54, 0x86, 0x16, 0xc4, 0x89, 0x72, 0x3e
]));
prompt.message = '';
prompt.delimiter = '';
var Wallet = require('../build/wallet').wallet.Wallet;
Expand Down Expand Up @@ -41,14 +45,23 @@ try {
}
catch (e) {
console.log('MultibitHD wallet opened');
var decrypter_1;
walletPromise = getPassphrase()
.then(function (passphrase) {
return aes_cbc_decrypter_1.Decrypter
.factory(passphrase)
.decrypt(pb.slice(16), pb.slice(0, 16));
decrypter_1 = aes_cbc_decrypter_1.Decrypter
.factory(passphrase);
pb.reset();
return decrypter_1.decrypt(pb.slice(16), pb.slice(0, 16))
.then(function (payload) {
return Wallet.decode(payload);
});
})
.then(function (payload) {
return Wallet.decode(payload);
.catch(function (e) {
pb.reset();
return decrypter_1.decrypt(pb, FIXED_IV)
.then(function (payload) {
return Wallet.decode(payload);
});
});
}
walletPromise.then(function (wallet) {
Expand Down
Loading