The following code snippet works:
//pragma solidity ^0.5.0
function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix,h));
signer = ecrecover(prefixedHash, v, r, s);
}
//web3 1.0
//multisig is my constract instance and second is an account address.
const message = "SchoolBus";
const h = web3.utils.soliditySha3(message);
let signature = await web3.eth.sign(h, second);
var r = signature.slice(0, 66);
var s = "0x" + signature.slice(66, 130);
var v = "0x" + signature.slice(130, 132);
v = web3.utils.toDecimal(v);
v = v + 27;
const result = await multisig.checkSignature(h, v, r, s);
//result === second
Note: web3.sha3
is a method from v0.2x. in v1.0 the function used is as described above. ecrecover
gets the signer details from a piece of data, usually a hash and the signature obtained when the signer signed the data.