paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Subkey derived SR25519 keys do not display seeds. #2260

Closed drewstone closed 5 years ago

drewstone commented 5 years ago

Example

ED25519 keys display seeds when inspected, but not SR25519.

./target/release/subkey generate
Phrase `hazard hedgehog material napkin breeze road miss destroy umbrella squeeze cake belt` is account:
  Seed: 0x7d996577227010e31e371e7ee01d073d1a2159d6628873f6f8a01de7006d0a4f
  Public key (hex): 0xd8fdf922261f9c18d19a4ca32febaca4da31542a7115767cb1464b60f4d11e43
  Address (SS58): 5GyDeRZc3dZvb5exCQTvJdDyKF8jEeEfDkVBnXzgG9qJE6NJ

./target/release/subkey -p "" -s inspect "hazard hedgehog material napkin breeze road miss destroy umbrella squeeze cake belt"
Secret Key URI `hazard hedgehog material napkin breeze road miss destroy umbrella squeeze cake belt` is account:
  Public key (hex): 0xd8fdf922261f9c18d19a4ca32febaca4da31542a7115767cb1464b60f4d11e43
  Address (SS58): 5GyDeRZc3dZvb5exCQTvJdDyKF8jEeEfDkVBnXzgG9qJE6NJ

./target/release/subkey -p "" -e inspect "hazard hedgehog material napkin breeze road miss destroy umbrella squeeze cake belt"
Secret Key URI `hazard hedgehog material napkin breeze road miss destroy umbrella squeeze cake belt` is account:
  Seed: 0x7d996577227010e31e371e7ee01d073d1a2159d6628873f6f8a01de7006d0a4f
  Public key (hex): 0x7253aa70032250cb30f596b42ae2f91c2c658de4f8c9194ac01770bb5660b9c6
  Address (SS58): 5EecAowShqxEWyTonWxExdcYkFVVW5ULx6qH8Sto1WvAMJhA
folsen commented 5 years ago

@burdges can you see any reason why it shouldn't?

burdges commented 5 years ago

Nope. There are 32 byte seeds for sr25519 private keys but we call them MiniSecretKeys while ed25519 calls them SecretKeys, so maybe someone is only storing the 64 byte SecretKey somewhere.

Just fyi, I changed the naming because HDKD only works with the 64 byte version, so after doing HDKD then seed no longer makes sense, but that should not be happening here.

kaichaosun commented 5 years ago

I testest this scenario, it seems this issue has been resolved at master.

@ ./target/debug/subkey generate                                                                                                         
Secret phrase `honey initial impulse rebel arm visit lab easily physical sponsor power brisk` is account:
  Secret seed: 0xf85e5060ba7f646e6510afbd3331b77d1a3f5e3f59e7be794af7f1b6f21e509a
  Public key (hex): 0xc4f50bf1f331fa15a454d93a9459c7b3b4d4f67985c68868b8c7efdf0e8c8632
  Address (SS58): 5GWx35Tn7eKitR14UzrDmYt9jZnBzrXNjbV8X2zrLR356yp6

@ ./target/debug/subkey -p "" -e inspect "honey initial impulse rebel arm visit lab easily physical sponsor power brisk"
Secret phrase `honey initial impulse rebel arm visit lab easily physical sponsor power brisk` is account:
  Secret seed: 0xf85e5060ba7f646e6510afbd3331b77d1a3f5e3f59e7be794af7f1b6f21e509a
  Public key (hex): 0xee1171254f3b3f58c46bb5e64dafb89174ae45c769800cad0db20228474d4b6d
  Address (SS58): 5HSrSBprbvKv4vFXVabgPxmNuRENKbGFgd1ChAwPytFSPHDL

@ ./target/debug/subkey -p "" -s inspect "honey initial impulse rebel arm visit lab easily physical sponsor power brisk"
Secret phrase `honey initial impulse rebel arm visit lab easily physical sponsor power brisk` is account:
  Secret seed: 0xf85e5060ba7f646e6510afbd3331b77d1a3f5e3f59e7be794af7f1b6f21e509a
  Public key (hex): 0xc4f50bf1f331fa15a454d93a9459c7b3b4d4f67985c68868b8c7efdf0e8c8632
  Address (SS58): 5GWx35Tn7eKitR14UzrDmYt9jZnBzrXNjbV8X2zrLR356yp6
bkchr commented 5 years ago

If it is solved, we can close this :)