Keystore decryption initial implementation.

This commit is contained in:
Daniel Kaspo 2017-06-07 22:30:25 -04:00
parent c448e7331f
commit ce3749000f
2 changed files with 32 additions and 4 deletions

View File

@ -1,8 +1,33 @@
import React, {Component} from 'react';
import translate from 'translations';
import wallet from 'ethereumjs-wallet';
import ethUtil from 'ethereumjs-util';
export default class KeystoreDecrypt extends Component {
constructor(props) {
super(props);
this.handleFileSelection = this.handleFileSelection.bind(this);
}
handleFileSelection(event) {
const fileReader = new FileReader();
const inputFile = event.target.files[0];
fileReader.onload = () => {
try {
const keyStoreString = fileReader.result;
const decryptedWallet = wallet.fromV3(keyStoreString, 'asdfasdfasdf', true);
const privateHex = ethUtil.bufferToHex(decryptedWallet._privKey);
const publicHex = ethUtil.bufferToHex(ethUtil.privateToAddress(decryptedWallet._privKey));
} catch (e) {
console.error('Could not parse Keystore file.', e);
}
};
fileReader.readAsText(inputFile, 'utf-8');
}
render() {
return (
<section className="col-md-4 col-sm-6">
@ -10,9 +35,10 @@ export default class KeystoreDecrypt extends Component {
<h4>{translate('ADD_Radio_2_alt')}</h4>
<div className="form-group">
<input type="file" id="fselector" />
<a className="btn-file marg-v-sm" id="aria1" tabIndex="0" role="button">{translate('ADD_Radio_2_short')}</a>
<input type="file" id="fselector" onChange={this.handleFileSelection} />
<label htmlFor="fselector">
<a className="btn-file marg-v-sm" id="aria1" tabIndex="0" role="button">{translate('ADD_Radio_2_short')}</a>
</label>
</div>
</div>
</section>

View File

@ -6,6 +6,8 @@
"dependencies": {
"axios": "^0.16.2",
"lodash": "^4.17.4",
"ethereumjs-util": "^5.1.2",
"ethereumjs-wallet": "^0.6.0",
"prop-types": "^15.5.8",
"react": "^15.4.2",
"react-dom": "^15.4.2",