Truffle web3.eth.sign produces wrong signature

by Jambo Dev   Last Updated January 11, 2019 11:28 AM

Somehow truffle produces an invalid signature. To clarify this I imported the private key of the first Ganache account to metamask and compared the results.

The following code used in a chrome console returns the following (verifiable correct) signature:

// frontend
let msg = web3.sha3("truffle"); // => 0x28610e27d085e348e6ebd0da2c982947eddf7d308b82e951a896432cdac99a74
let sig;
web3.eth.sign(web3.eth.accounts[0], msg, (err, res) => {
  if(!err) {
    sig = res;

// sig => 0xb453386b73ba5608314e9b4c7890a4bd12cc24c2c7bdf5f87778960ff85c56a8520dabdbea357fc561120dd2625bd8a904f35bdb4b153cf706b6ff25bb0d898d1c

Here's the code in truffle which should produce the same signature - but doesn't.

// Truffle:
let first = accounts[0];
let msg = web3.sha3("truffle");
let sig = await web3.eth.sign(first, msg)
// sig => 0x511fafdf71306ff89a063a76b52656c18e9a7d80d19e564c90f0126f732696bb673cde46003aad0ccb6dab2ca91ae38b82170824b0725883875194b273f709b901

This sucks as I am trying to test my contracts which rely on these signatures.

Answers 1

Apparently it's an issue with Truffle, see this issue here. More info here and here.

Jambo Dev
Jambo Dev
June 12, 2018 20:32 PM

Related Questions

How use Truffle Framework

Updated March 26, 2019 04:28 AM

ParserError compiling Smart Contract, what's wrong?

Updated December 30, 2018 23:28 PM