Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-util

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-util - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

addTest.js

21

index.js
const SHA3 = require('sha3'),
ec = require('elliptic').ec('secp256k1');
assert = require('assert'),

@@ -7,5 +8,5 @@ rlp = require('rlp'),

//the max interger that this VM can handle
var MAX_INTEGER = exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16);
const MAX_INTEGER = exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16);
var TWO_POW256 = exports.TWO_POW256 = new BN('115792089237316195423570985008687907853269984665640564039457584007913129639936');
const TWO_POW256 = exports.TWO_POW256 = new BN('115792089237316195423570985008687907853269984665640564039457584007913129639936');

@@ -22,3 +23,3 @@ //hex string of SHA3-256 hash of `null`

var ETH_UNITS = exports.ETH_UNITS = [
const ETH_UNITS = exports.ETH_UNITS = [
'wei',

@@ -177,10 +178,15 @@ 'Kwei',

*/
exports.pubToAddress = function(pubKey) {
var pubToAddress = exports.pubToAddress = exports.publicToAddress = function(pubKey) {
var hash = new SHA3.SHA3Hash(256);
hash.update(pubKey.slice(1));
hash.update(pubKey.slice(-64));
return new Buffer(hash.digest('hex').slice(-40), 'hex');
};
exports.privateToAddress = function(privateKey){
privateKey = new BN(privateKey);
var key = ec.keyFromPrivate(privateKey).getPublic().toJSON();
key = new Buffer(key[0].toArray().concat(key[1].toArray()));
return pubToAddress(key);
}
/**

@@ -266,3 +272,2 @@ * Generates a new address

if (!(field.empty && v.length === 0) && field.length) {

@@ -269,0 +274,0 @@ assert(field.length === v.length, 'The field ' + field.name + 'must have byte length of ' + field.length);

{
"name": "ethereumjs-util",
"version": "1.0.1",
"version": "1.0.2",
"description": "a collection of utility functions for Ethereum",

@@ -27,2 +27,3 @@ "main": "index.js",

"crypto-js": "^3.1.5",
"elliptic": "^3.1.0",
"rlp": "^1.0.0",

@@ -29,0 +30,0 @@ "sha3": "^1.1.0"

@@ -86,3 +86,3 @@ var assert = require('assert');

var pubKey = 'f049a20000000000f0b08900000000000841b30200000000200000000d000000';
var address = '47f4f63d925e6b35f604a203a7ee365c147500db';
var address = 'ef6a1274aa67f83eadf383016d584cd6185477ae';
pubKey = new Buffer(pubKey, 'hex');

@@ -89,0 +89,0 @@ var r = ethUtils.pubToAddress(pubKey);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc