diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-10-13 08:12:52 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-10-13 08:12:52 +0800 |
commit | 7cba71fc5590af115997f8120ac59f1293d6e2b9 (patch) | |
tree | 9028874304e96f0aa543e707c25eedce660aace0 /app/scripts/keyring-controller.js | |
parent | 8d5b2478e3aa939cb4b0a58b20b199cded62769e (diff) | |
parent | cd2c00a31873490c9129023abb35dd7983604b60 (diff) | |
download | tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar.gz tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar.bz2 tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar.lz tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar.xz tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.tar.zst tangerine-wallet-browser-7cba71fc5590af115997f8120ac59f1293d6e2b9.zip |
Merge branch 'i328-MultiVault' of github.com:MetaMask/metamask-plugin into origin/i328-MultiVault
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r-- | app/scripts/keyring-controller.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js new file mode 100644 index 000000000..d96b9c101 --- /dev/null +++ b/app/scripts/keyring-controller.js @@ -0,0 +1,102 @@ +const scrypt = require('scrypt-async') +const bitcore = require('bitcore-lib') +const configManager = require('./lib/config-manager') +const EventEmitter = require('events').EventEmitter + +module.exports = class KeyringController extends EventEmitter { + + constructor (opts) { + super() + this.configManager = opts.configManager + this.ethStore = opts.ethStore + this.keyChains = [] + } + + getKeyForPassword(password, callback) { + let salt = this.configManager.getSalt() + + if (!salt) { + salt = generateSalt(32) + configManager.setSalt(salt) + } + + var logN = 14 + var r = 8 + var dkLen = 32 + var interruptStep = 200 + + var cb = function(derKey) { + try { + var ui8arr = (new Uint8Array(derKey)) + this.pwDerivedKey = ui8arr + callback(null, ui8arr) + } catch (err) { + callback(err) + } + } + + scrypt(password, salt, logN, r, dkLen, interruptStep, cb, null) + } + + getState() { + return {} + } + + setStore(ethStore) { + this.ethStore = ethStore + } + + createNewVault(password, entropy, cb) { + cb() + } + + submitPassword(password, cb) { + cb() + } + + setSelectedAddress(address, cb) { + this.selectedAddress = address + cb(null, address) + } + + approveTransaction(txId, cb) { + cb() + } + + cancelTransaction(txId, cb) { + if (cb && typeof cb === 'function') { + cb() + } + } + + signMessage(msgParams, cb) { + cb() + } + + cancelMessage(msgId, cb) { + if (cb && typeof cb === 'function') { + cb() + } + } + + setLocked(cb) { + cb() + } + + exportAccount(address, cb) { + cb(null, '0xPrivateKey') + } + + saveAccountLabel(account, label, cb) { + cb(/* null, label */) + } + + tryPassword(password, cb) { + cb() + } + +} + +function generateSalt (byteCount) { + return bitcore.crypto.Random.getRandomBuffer(byteCount || 32).toString('base64') +} |