Skip to main content
added 78 characters in body
Source Link
alper
  • 8.4k
  • 11
  • 67
  • 155

I have tried to use ecrecover() to verify the signature of a message.

I have looked at lots of references here and elsewhere, like:

and others.

But I still cannot get ecrecover() to return the signing address. So I am hoping that someone can point out some stupid mistake I am making.

Here is my code:

pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}
 

Then in geth, I do:

var msg = web3.sha3("hello") "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

eth.accounts[0] --> "0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

var sig = eth.sign(eth.accounts[0], msg) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

var r = sig.substr(0,66) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

var s = "0x" + sig.substr(66,64) "0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

var v = 28 --> 28

test.verify(msg,v,r,s) --> "0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

> var msg = web3.sha3("hello")
"0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

> eth.accounts[0] -->
"0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

> var sig = eth.sign(eth.accounts[0], msg)
"0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

> var r = sig.substr(0,66)
"0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

> var s = "0x" + sig.substr(66,64)
"0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

> var v = 28
28

> test.verify(msg,v,r,s)
"0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

I have tried to use ecrecover() to verify the signature of a message.

I have looked at lots of references here and elsewhere, like:

and others.

But I still cannot get ecrecover() to return the signing address. So I am hoping that someone can point out some stupid mistake I am making.

Here is my code:

pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}

Then in geth, I do:

var msg = web3.sha3("hello") "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

eth.accounts[0] --> "0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

var sig = eth.sign(eth.accounts[0], msg) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

var r = sig.substr(0,66) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

var s = "0x" + sig.substr(66,64) "0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

var v = 28 --> 28

test.verify(msg,v,r,s) --> "0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

I have tried to use ecrecover() to verify the signature of a message.

I have looked at lots of references here and elsewhere, like:

and others.

But I still cannot get ecrecover() to return the signing address. So I am hoping that someone can point out some stupid mistake I am making.

Here is my code:

pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}
 

Then in geth, I do:

> var msg = web3.sha3("hello")
"0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

> eth.accounts[0] -->
"0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

> var sig = eth.sign(eth.accounts[0], msg)
"0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

> var r = sig.substr(0,66)
"0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

> var s = "0x" + sig.substr(66,64)
"0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

> var v = 28
28

> test.verify(msg,v,r,s)
"0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

Removed thanks, fixed minor typo, added list formatting and code formatting
Source Link

I have tried to use ecrecoverecrecover() to verify the signature of a message.

I have looked at lots of references here and elsewhere, like

https://lab-blog.ey.com/2016/12/19/ecrecover/

How does one properly use ecrecover to verify Ethereum signatures?:

Ethereum ecrecover signature verification and encryption

and others.

But I still cannot get ecrecoverecrecover() to return the signing address. So I am hoping that someone can point out some stupid mistake I aam making.

Here is my code:


pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}
pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}

Then in geth, I do:

var msg = web3.sha3("hello") "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

eth.accounts[0] --> "0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

var sig = eth.sign(eth.accounts[0], msg) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

var r = sig.substr(0,66) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

var s = "0x" + sig.substr(66,64) "0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

var v = 28 --> 28

test.verify(msg,v,r,s) --> "0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

Many thanks!

I have tried to use ecrecover to verify the signature of a message.

I have looked at lots of references here and elsewhere, like

https://lab-blog.ey.com/2016/12/19/ecrecover/

How does one properly use ecrecover to verify Ethereum signatures?

Ethereum ecrecover signature verification and encryption

and others.

But I still cannot get ecrecover to return the signing address. So I am hoping that someone can point out some stupid mistake I a making.

Here is my code:


pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}

Then in geth, I do:

var msg = web3.sha3("hello") "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

eth.accounts[0] --> "0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

var sig = eth.sign(eth.accounts[0], msg) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

var r = sig.substr(0,66) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

var s = "0x" + sig.substr(66,64) "0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

var v = 28 --> 28

test.verify(msg,v,r,s) --> "0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

Many thanks!

I have tried to use ecrecover() to verify the signature of a message.

I have looked at lots of references here and elsewhere, like:

and others.

But I still cannot get ecrecover() to return the signing address. So I am hoping that someone can point out some stupid mistake I am making.

Here is my code:

pragma solidity ^0.4.0;

contract test {

  function test() {
  }

  function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
   address signer = ecrecover(_message, _v, _r, _s);
   return signer;
  }
}

Then in geth, I do:

var msg = web3.sha3("hello") "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"

eth.accounts[0] --> "0x7156526fbd7a3c72969b54f64e42c10fbb768c8a"

var sig = eth.sign(eth.accounts[0], msg) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac80388256084f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada1c"

var r = sig.substr(0,66) "0x9242685bf161793cc25603c231bc2f568eb630ea16aa137d2664ac8038825608"

var s = "0x" + sig.substr(66,64) "0x4f8ae3bd7535248d0bd448298cc2e2071e56992d0774dc340c368ae950852ada"

var v = 28 --> 28

test.verify(msg,v,r,s) --> "0x33692ee5cbf7ecdb8ca43ec9e815c47f3db8cd11"

...which of course, is NOT eth.accounts[0]

I am totally stumped. Is there anyone who can see what I am doing wrong?

edited tags; edited title
Link
eth
  • 86.5k
  • 53
  • 287
  • 411

Totally baffled by ecrecover from Geth and web3.eth.sign

edited tags
Link
eth
  • 86.5k
  • 53
  • 287
  • 411
Loading
Source Link
Loading