Skip to content

Instantly share code, notes, and snippets.

View philmorley's full-sized avatar

Phil Morley philmorley

View GitHub Profile
@alexanderattar
alexanderattar / verify-eth-sig.js
Last active October 4, 2023 15:11
Example of how to sign a message with web3 and recover the address that signed it
var ethUtil = require('ethereumjs-util');
var data = 'Login';
var message = ethUtil.toBuffer(data);
var msgHash = ethUtil.hashPersonalMessage(message);
var privateKey = new Buffer('62debf78d596673bce224a85a90da5aecf6e781d9aadcaedd4f65586cfe670d2', "hex")
var sig = ethUtil.ecsign(msgHash, privateKey);
var signature = ethUtil.toBuffer(sig)