Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dtaipov opened this issue Dec 29, 2018 · 0 comments

Comments

@dtaipov
Copy link
Contributor

dtaipov commented Dec 29, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant