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.2 to 1.0.3

42

index.js

@@ -182,10 +182,26 @@ const SHA3 = require('sha3'),

exports.privateToAddress = function(privateKey){
/**
* Returns the ethereum public key of a given private key
* @method privateToPublic
* @param {Buffer} privateKey
* @return {Buffer}
*/
var privateToPublic = exports.privateToPublic = 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);
return key;
}
/**
* Returns the ethereum address of a given private key
* @method privateToAddress
* @param {Buffer} privateKey
* @return {Buffer}
*/
exports.privateToAddress = function(privateKey){
return pubToAddress(privateToPublic(privateKey));
}
/**
* Generates a new address

@@ -245,5 +261,3 @@ * @method generateAddress

if (typeof v === 'string') {
if (v.slice(0, 2) === '0x') {
v = v.slice(2);
}
v= stripHex(v);
v = new Buffer(v, 'hex');

@@ -423,1 +437,19 @@ } else if (typeof v === 'number') {

};
const isHexPrefixed = exports.isHexPrefixed = function(str){
return str.slice(0, 2) === '0x';
}
const stripHex = exports.stripHex = function(str){
if (typeof str !== 'string')
return str
return isHexPrefixed ? str.slice(2) : str
}
exports.addHex = function(str){
if (typeof str !== 'string')
return str
return isHexPrefixed(str) ? '0x' + str : str
}

2

package.json
{
"name": "ethereumjs-util",
"version": "1.0.2",
"version": "1.0.3",
"description": "a collection of utility functions for Ethereum",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -51,2 +51,10 @@ # SYNOPSIS [![Build Status](https://travis-ci.org/ethereum/ethereumjs-util.svg)](https://travis-ci.org/ethereum/ethereumjs-util)

### `privateToPublic(privateKey)`
Returns the ethereum public key of a given private key
- `privateKey` - the private key as a `buffer`
### `privateToAddress(privateKey)`
Returns the ethereum address of a given private key
- `privateKey` - the private key as a `buffer`
### `defineProperties(self, fields)`

@@ -53,0 +61,0 @@ defines properties on a `Object`

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