Client side:
web3.eth.sign(address, hash); // generates signature
Server side:
const ethutils = require('ethereumjs-util');
const extractAddress = function(signature, hash){ //signature and hash from the client side
const o = ethutils.fromRpcSig(signature);
const hashBuffer = ethutils.toBuffer(hash);
const publicKeyBuffer = ethutils.ecrecover(hashBuffer, o.v, o.r, o.s);
const publicKeyHex = ethutils.bufferToHex(publicKeyBuffer);
const addressBuffer = ethutils.pubToAddress(publicKeyHex);
const addressHex = ethutils.bufferToHex(addressBuffer);
return addressHex;
}
Addresses don't match. The code worked before (a couple of months ago).
Relevant discussions https://github.com/ethereumjs/ethereumjs-util/pull/67