Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Ensure TestKeyring Matches Substrate #160

Closed
ansermino opened this issue Mar 5, 2020 · 5 comments
Closed

Ensure TestKeyring Matches Substrate #160

ansermino opened this issue Mar 5, 2020 · 5 comments
Assignees

Comments

@ansermino
Copy link
Member

ansermino commented Mar 5, 2020

Key information (for sr25519) can be found using subkey:

d@P51:~$ subkey inspect //Alice
Secret Key URI `//Alice` is account:
  Secret seed:      0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a
  Public key (hex): 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  Account ID:       0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  SS58 Address:     5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY

We should add tests to ensure we are getting these results from our derivation.

@anthonychernyak
Copy link
Contributor

Is //Alice the right key/account?
The private key should be generated by a byte constructed by prepending 0's to `byte{"Alice"} to a length of 32.

//Alice seems to be a super user from the tutorial, but im not sure if we are using that user, since the addresses are different.
paritytech/substrate#1989

@ansermino

@ansermino
Copy link
Member Author

subkey should be considered the sole source of truth, not the other way around.

The Alice, Bob, etc. keyring is a concept used throughout substrate. For example, here's where they derive the address for a chain configuration: https://github.com/paritytech/substrate/blob/75116bd8c45c7e46a9b8eed9cb29ee4256ed631b/bin/node/cli/src/chain_spec.rs#L211

@anthonychernyak
Copy link
Contributor

I'm not agruing that subkey shouldn't be the source of truth. I'm saying that we currently use a different seed than just "Alice", "Bob" (the seeds are the 32 byte length constructed from a base of "Alice", "Bob"). If we want to use the keyring in substrate, that should be mentioned in the ticket, since it changes the initial assumptions of the keyring.

@ansermino
Copy link
Member Author

There are really two things that need to be assessed here:

  1. Are we using the right seed/private key?
    This is going to require some digging through the Substrate codebase. This might help: https://polkadot.js.org/apps/
  2. Are we producing the same public key/address given that seed?
    Requires trial and error. Maybe we need to pad with zeros, or encode with SCALE codec?

@anthonychernyak
Copy link
Contributor

Commenting for Documentation/Visibility:

https://substrate.dev/docs/en/ecosystem/subkey
Under Well-Known Keys section, they show the same public address and public key, so the seed should be the same (for now). Still researching if the Alice seed changes based on the version of substrate.

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