Commit bd0f451e authored by SilentCicero's avatar SilentCicero

version 0.1.1 -- remove ethjs-sha3 for js-sha3

parent 7dc65f38
# 0.1.1 -- remove ethjs-sha3
1. Removed the `ethjs-sha3` for `js-sha3`
# 0.1.0 -- first release
1. Basic testing
......
......@@ -51,14 +51,14 @@ npm install --save ethjs-signer
const HttpProvider = require('ethjs-provider-http');
const Eth = require('ethjs-query');
const eth = new Eth(HttpProvider('http://localhost:8545'));
const sign = require('ethjs-signer');
const sign = require('ethjs-signer').sign;
const address = '0x0F6af8F8D7AAD198a7607C96fb74Ffa02C5eD86B';
const privateKey = '0xecbcd9838f7f2afa6e809df8d7cdae69aa5dfc14d563ee98e97effd3f6a652f2';
eth.getTransactionCount(address).then((nonce) => {
eth.sendRawTransaction(sign({
to: '0xcG31a19193d4b23f4e9d6163d7247243bAF801c3',
to: '0xce31a19193d4b23f4e9d6163d7247243bAF801c3',
value: 300000,
gas: new BN('43092000'),
nonce: nonce,
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -122,22 +122,20 @@ https://polyfill.io/
## Latest Webpack Figures
```
Hash: ab378ace2dcbcdc84923
Version: webpack 2.1.0-beta.15
Time: 1041ms
Asset Size Chunks Chunk Names
ethjs-signer.js 313 kB 0 [emitted] main
ethjs-signer.js.map 385 kB 0 [emitted] main
[37] multi main 28 bytes {0} [built]
+ 37 hidden modules
Hash: f6b69ff438836239c7a6
Time: 1756ms
Asset Size Chunks Chunk Names
ethjs-signer.js 361 kB 0 [emitted] main
ethjs-signer.js.map 443 kB 0 [emitted] main
[44] multi main 28 bytes {0} [built]
+ 44 hidden modules
Version: webpack 2.1.0-beta.15
Time: 4124ms
Asset Size Chunks Chunk Names
ethjs-signer.min.js 164 kB 0 [emitted] main
[37] multi main 28 bytes {0} [built]
+ 37 hidden modules
Time: 7583ms
Asset Size Chunks Chunk Names
ethjs-signer.min.js 181 kB 0 [emitted] main
[44] multi main 28 bytes {0} [built]
+ 44 hidden modules
```
## Other Awesome Modules, Tools and Frameworks
......
{
"name": "ethjs-signer",
"version": "0.1.0",
"version": "0.1.1",
"description": "A simple module for signing Ethereum transactions.",
"main": "lib/index.js",
"files": [
......@@ -95,7 +95,7 @@
}
},
"dependencies": {
"ethjs-sha3": "0.1.2",
"js-sha3": "0.5.5",
"rlp": "2.0.0",
"strip-hex-prefix": "1.0.0",
"number-to-bn": "1.1.0",
......
const rlp = require('rlp');
const elliptic = require('elliptic');
const sha3 = require('ethjs-sha3');
const keccak256 = require('js-sha3').keccak_256;
const secp256k1 = new (elliptic.ec)('secp256k1'); // eslint-disable-line
const stripHexPrefix = require('strip-hex-prefix');
const numberToBN = require('number-to-bn');
......@@ -50,7 +50,7 @@ function recover(rawTx, v, r, s) {
raw[fieldIndex] = signedTransaction[fieldIndex];
});
const publicKey = secp256k1.recoverPubKey(sha3(rlp.encode(raw), true), { r, s }, v - 27);
const publicKey = secp256k1.recoverPubKey((new Buffer(keccak256(rlp.encode(raw)), 'hex')), { r, s }, v - 27);
return (new Buffer(publicKey.encode('hex', false), 'hex')).slice(1);
}
......@@ -103,7 +103,7 @@ function sign(transaction, privateKey, toObject) {
// private key is not stored in memory
const signature = secp256k1.keyFromPrivate(new Buffer(privateKey.slice(2), 'hex'))
.sign(sha3(rlp.encode(raw), true), { canonical: true });
.sign((new Buffer(keccak256(rlp.encode(raw)), 'hex')), { canonical: true });
raw.push(new Buffer([27 + signature.recoveryParam]));
raw.push(bnToBuffer(signature.r));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment