Skip to main content
added 273 characters in body
Source Link
Alex
  • 115
  • 2
  • 7

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed):

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work):

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value: 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230 And at the output of web3js function (web3.eth.accounts.sign), we get signature: 0xd19241ed816026e846c8511e03a468aa6e038165ecb3c2229eee38b04c64b235408389dfad2b65d776dba236e7de1b63fdb6b2579e70c4ce9ad1b09a35da96521c And this is the correct value. Web3py has other value.

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed):

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work):

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed):

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work):

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value: 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230 And at the output of web3js function (web3.eth.accounts.sign), we get signature: 0xd19241ed816026e846c8511e03a468aa6e038165ecb3c2229eee38b04c64b235408389dfad2b65d776dba236e7de1b63fdb6b2579e70c4ce9ad1b09a35da96521c And this is the correct value. Web3py has other value.

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed): let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser); console.log('signature ='+signature.signature);

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work): signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser) print('signature ='+signature.signature.hex())

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed): let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser); console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work): signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser) print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed):

let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser);
console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work):

signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser)
print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

added 118 characters in body
Source Link
Alex
  • 115
  • 2
  • 7

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed): let signature = await web3.eth.accounts.sign(msgmsgHash, '0x' + privateKeyUser); console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work): signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser) print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed): let signature = await web3.eth.accounts.sign(msg, '0x' + privateKeyUser); console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work): signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser) print('signature ='+signature.signature.hex())

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function (link https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-message). This documentation says that the same hashing mechanism, but as a result, execution returns not the same as in web3js (web3.eth.accounts.sign).

I used this function in web3js to get signature (and then using ECDSA library (on Solidity) to get signer. On web3js works correctly (but on web3py - no). I connect to test network (ropsten) via Infura.

On web3js (where msg - what is signed): let signature = await web3.eth.accounts.sign(msgHash, '0x' + privateKeyUser); console.log('signature ='+signature.signature);

On web3py (I try, but doesn't work): signature = web3.eth.account.signHash(msgHash, '0x' + privateKeyUser) print('signature ='+signature.signature.hex())

And for example in variable "msgHash" value 0x058c3b4c8e5dc4632b5c6b861b2c1861d53e426dc673c907ddf2651942b0f230

What is exact analogue in web3py of how this web3.eth.accounts.sign function works in web3js? Thank you!

added 534 characters in body
Source Link
Alex
  • 115
  • 2
  • 7
Loading
Source Link
Alex
  • 115
  • 2
  • 7
Loading