Skip to content

sign_hash gives different from web3.sign last byte of the result signature #91

@dtaipov

Description

@dtaipov

Piece of code to prepare hash for KeyChain

const keyname = 'test1@76de427d42c38be4';
const message = '12345';
const prefix = "\x19Ethereum Signed Message:\n" + message.length;
const messageHash = web3.utils.sha3(prefix + message).substr(2);
const result = await keychain.signHash(messageHash, keyname);

Example messageHash: 0xffdc74e2c931e2639c9642e818d04d9e13ce814360876d99c8738521cb0502bf

KeyChain result:
f9d5c73b846d85b13ca588338a98002babaf5581c3bcea87b71cc811ee31d85b58cc4ed45bcb5a4c902f9b2b246c3caefa33138e97dbc4fd446c4b7d0df65bfc01

Web3
const privateKey = '0xb3d3427eea7867c243baaf2f4c67a9551eea2ea96556acfb0051dffa18d182d4';
web3.eth.accounts.sign('12345', privateKey) result:

{ message: '12345',
  messageHash:
   '0xffdc74e2c931e2639c9642e818d04d9e13ce814360876d99c8738521cb0502bf',
  v: '0x1c',
  r: '0xf9d5c73b846d85b13ca588338a98002babaf5581c3bcea87b71cc811ee31d85b',
  s: '0x58cc4ed45bcb5a4c902f9b2b246c3caefa33138e97dbc4fd446c4b7d0df65bfc',
  signature: '0xf9d5c73b846d85b13ca588338a98002babaf5581c3bcea87b71cc811ee31d85b58cc4ed45bcb5a4c902f9b2b246c3caefa33138e97dbc4fd446c4b7d0df65bfc1c' }

Web3 result: '0xf9d5c73b846d85b13ca588338a98002babaf5581c3bcea87b71cc811ee31d85b58cc4ed45bcb5a4c902f9b2b246c3caefa33138e97dbc4fd446c4b7d0df65bfc1c'

The last byte in signature is different
What can be done to make the last bytes the same?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions