Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Failure to recover signature address, for web3.accounts.{sign/recover} #2120

Closed
coventry opened this issue Dec 11, 2018 · 1 comment
Closed

Comments

@coventry
Copy link

Hi, I'd be grateful for an explanation of how to recover the signature address from a signature object. Intuitively, I would have expected this to work:

truffle(test)> // This is with the second account from traditional truffle seed mnemonic, "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
truffle(test)> signatureObject = web3.eth.accounts.sign("Hello world", "0xf17f52151EbEF6C7334FAD080c5704D77216b732")
{ message: 'Hello world',
  messageHash: '0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede',
  v: '0x1c',
  r: '0x1239d9e6d7a8e881a60759479678397139d11964dd95636d92975d66561a8e76',
  s: '0x7013924aa3423231e8afbd0be50ebe46ddca025252d241c611533e38e6a6f464',
  signature: '0x1239d9e6d7a8e881a60759479678397139d11964dd95636d92975d66561a8e767013924aa3423231e8afbd0be50ebe46ddca025252d241c611533e38e6a6f4641c' }
truffle(test)> ////////////////////////////////////////////////////////////////////////
truffle(test)> // !!! Does not recover "0xf17f52151EbEF6C7334FAD080c5704D77216b732" !!!
truffle(test)> web3.eth.accounts.recover(signatureObject)
'0x9f5F258D9e092c64E577533F0035184b8a7963aD'
truffle(test)> ////////////////////////////////////////////////////////////////////////
truffle(test)> web3.version
'1.0.0-beta.37'

This is with versions Truffle v5.0.0-next.19 (core: 5.0.0-beta.2) and Node v8.10.0, in case it's relevant.

@nivida nivida added the support label Dec 12, 2018
@coventry
Copy link
Author

I see my error in the example: using the public instead of the private key. I had tested that, but without the 0x key. Would you take a PR to fail if there's no 0x prefix, or refrain from truncating the first two characters (assuming that's the issue?)

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

No branches or pull requests

2 participants