Socket
Socket
Sign inDemoInstall

eth-sig-util

Package Overview
Dependencies
44
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

circle.yml

20

index.js

@@ -20,2 +20,22 @@ const ethUtil = require('ethereumjs-util')

personalSign: function (privateKey, msgParams) {
var message = ethUtil.toBuffer(msgParams.data)
var msgHash = ethUtil.hashPersonalMessage(message)
var sig = ethUtil.ecsign(msgHash, privateKey)
var serialized = ethUtil.bufferToHex(this.concatSig(sig.v, sig.r, sig.s))
return serialized
},
recoverPersonalSignature: function (msgParams) {
let senderHex
const message = ethUtil.toBuffer(msgParams.data)
const msgHash = ethUtil.hashPersonalMessage(message)
const signature = ethUtil.toBuffer(msgParams.sig)
const sigParams = ethUtil.fromRpcSig(signature)
const publicKey = ethUtil.ecrecover(msgHash, sigParams.v, sigParams.r, sigParams.s)
const sender = ethUtil.publicToAddress(publicKey)
senderHex = ethUtil.bufferToHex(sender)
return senderHex
},
}

@@ -22,0 +42,0 @@

8

package.json
{
"name": "eth-sig-util",
"version": "1.0.0",
"version": "1.1.0",
"description": "A few useful functions for signing ethereum data",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node test/index.js"
},

@@ -25,3 +25,7 @@ "repository": {

"ethereumjs-util": "^5.1.1"
},
"devDependencies": {
"mocha": "^3.2.0",
"tape": "^4.6.3"
}
}

@@ -16,1 +16,14 @@ # Eth-Sig-Util

Takes an address of either upper or lower case, with or without a hex prefix, and returns an all-lowercase, hex-prefixed address, suitable for submitting to an ethereum provider.
### personalSign (privateKeyBuffer, msgParams)
msgParams should have a `data` key that is hex-encoded data to sign.
Returns the prefixed signature expected for calls to `eth.personalSign`.
### recoverPersonalSignature (msgParams)
msgParams should have a `data` key that is hex-encoded data unsigned, and a `sig` key that is hex-encoded and already signed.
Returns a hex-encoded sender address.
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc