Added function helper, few changes on ECRecover lib

This commit is contained in:
AugustoL
2017-07-17 22:47:00 -03:00
committed by Francisco Giordano
parent f8c0fab5d8
commit 4f44427966
4 changed files with 22 additions and 888 deletions

View File

@ -0,0 +1,8 @@
import utils from 'ethereumjs-util';
// Hash and add same prefix to the hash that testrpc use.
module.exports = function(message) {
const messageHex = new Buffer(utils.sha3(message).toString('hex'), 'hex');
const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString());
return utils.bufferToHex( utils.sha3(Buffer.concat([prefix, messageHex])) );
};