-
Notifications
You must be signed in to change notification settings - Fork 28
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
Bug: the function 'deriveAddress' from a public key with ecdsa #292
Comments
Thanks for the detailed explanation and examples. I'll have a look into this by tomorrow afternoon and respond! |
@drhanlondon Yes to an extent it is a bug, and it fixed with the latest PR above. Thanks for bringing this up, and support for |
@TarikGul Thanks for your reply and effort to fix the bug. I would be grateful if you could advice me further on the Question 2 above. |
In regards to question 2, honestly I am not completely sure. I would say that is a great question for |
Hello,
Question 1: On Substrate-default (Westend testnet),
To derive an address from a publicKey with "sr25519", it works as below
The result is
But, next, to derive from a public key with "ecdsa", I did in the same way above with a different seed phrase
The result is
We can see that unexpectedly the returned value "KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH" is not an address (ss58), but just a public key (ss58).
By using Subkey tool, we can confirm that "KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH" is a public key(ss58).
#########################################################
from seed phrase
$ subkey inspect "asthma stereo budget skill frequent sunny enemy train kiwi word hold evil" --scheme Ecdsa
Secret phrase: asthma stereo budget skill frequent sunny enemy train kiwi word hold evil
Network ID: substrate
Secret seed: 0x67c9fddc7e706f33e3e20e4918e7e68abd986caade7c1d35e7596df4be9ca5bd
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: 5HpStbV2wnRhqiy8zsxeKYxJRLyKrsbH3Pyq9nrXtTeWXwcq
###################
from secret seed
$ subkey inspect 0x67c9fddc7e706f33e3e20e4918e7e68abd986caade7c1d35e7596df4be9ca5bd --scheme Ecdsa
Secret Key URI 0x67c9fddc7e706f33e3e20e4918e7e68abd986caade7c1d35e7596df4be9ca5bd is account:
Network ID: substrate
Secret seed: 0x67c9fddc7e706f33e3e20e4918e7e68abd986caade7c1d35e7596df4be9ca5bd
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: 5HpStbV2wnRhqiy8zsxeKYxJRLyKrsbH3Pyq9nrXtTeWXwcq
####################
from public key(hex)
$ subkey inspect --public 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc --scheme Ecdsa
Network ID/Version: substrate
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
#####################
from public key (ss58)
$ subkey inspect KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH --scheme Ecdsa
Public Key URI KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH is account:
Network ID/Version: substrate
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
############################
even with Substrate
$ cargo run --release -p subkey -- inspect "KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH" --scheme Ecdsa
Finished release [optimized] target(s) in 0.72s
Running
target/release/subkey inspect KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH --scheme Ecdsa
Public Key URI KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH is account:
Network ID/Version: substrate
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
##############################
$ cargo run --release -p subkey -- inspect "asthma stereo budget skill frequent sunny enemy train kiwi word hold evil" --scheme Ecdsa
Finished release [optimized] target(s) in 0.60s
Running target/release/subkey inspect 'asthma stereo budget skill frequent sunny enemy train kiwi word hold evil' --scheme Ecdsa
Secret phrase: asthma stereo budget skill frequent sunny enemy train kiwi word hold evil
Network ID: substrate
Secret seed: 0x67c9fddc7e706f33e3e20e4918e7e68abd986caade7c1d35e7596df4be9ca5bd
Public key (hex): 0x02e59f872a5a49b7d4807f4f52db82c6d62ce11ba6ce1d13e490cb6cab302874fc
Account ID: 0xfe8995168a62071594194772c371a72f1c57149273235556e2711f3a76dab5e0
Public key (SS58): KW87j6aqqJ8heTCTBeoxMLH1Yg2YmkeTz4Xwg4yHAmhmVX7wH
SS58 Address: 5HpStbV2wnRhqiy8zsxeKYxJRLyKrsbH3Pyq9nrXtTeWXwcq
##############################
As we see above, deriveAddress() returns a public key (ss58) in case of "ecdsa and Westend(42)" although we expect an address "5HpStbV2wnRhqiy8zsxeKYxJRLyKrsbH3Pyq9nrXtTeWXwcq"
But, this bug does not occur on Polkadot with "ecdsa"
const shan_address = deriveAddress(shan_substrateKeypair.publicKey, 0);
I would like to know whether this is a bug or not on Westend.
Question 2: as we see the above tests with Subkey and Substrate, I would like to know why "SS58 Address" does not show a proper ss58 address when inspecting with either a public key(hex) or a public key (ss58).
This report has been left on polkadot-js/common as well: polkadot-js/common#1822
Thank you
The text was updated successfully, but these errors were encountered: