Skip to content
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

Generating Deterministic Polkadot Addresses #8

Closed
farukterzioglu opened this issue Dec 1, 2020 · 2 comments
Closed

Generating Deterministic Polkadot Addresses #8

farukterzioglu opened this issue Dec 1, 2020 · 2 comments

Comments

@farukterzioglu
Copy link
Owner

With my implementation, anyone can generate Polkadot addresses based on Bip32-Ed25519.

My implementation has the same results with test vectors here;
https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519

I can also confirm that addresses I generated is same with generate from subkey with private key if I investigate it.

Results from my code;

Address: 5G6tXDeie2KaUgGrwkBfzApKSCm9sE5QvBm1bi1vmBZ4gcCN
Public key: b29b533725c02f6e69d8774c92d8a5a98506c2f09e13a1adbe4db367fbfa512a
Private key: 8bd78fe8b30abf91d3e9474c8927d9874fabc7e31ce2d866cf795378161f954a
Expanded private key: 8bd78fe8b30abf91d3e9474c8927d9874fabc7e31ce2d866cf795378161f954ab29b533725c02f6e69d8774c92d8a5a98506c2f09e13a1adbe4db367fbfa512a
Result from Subkey

subkey inspect 0x8bd78fe8b30abf91d3e9474c8927d9874fabc7e31ce2d866cf795378161f954a --scheme Ed25519
Secret Key URI 0x8bd78fe8b30abf91d3e9474c8927d9874fabc7e31ce2d866cf795378161f954a is account:
Secret seed: 0x8bd78fe8b30abf91d3e9474c8927d9874fabc7e31ce2d866cf795378161f954a
Public key (hex): 0xb29b533725c02f6e69d8774c92d8a5a98506c2f09e13a1adbe4db367fbfa512a
Account ID: 0xb29b533725c02f6e69d8774c92d8a5a98506c2f09e13a1adbe4db367fbfa512a
SS58 Address: 5G6tXDeie2KaUgGrwkBfzApKSCm9sE5QvBm1bi1vmBZ4gcCN
When I investigate the private key from my hd wallet implementation, Subkey prints the same address as I generated.

The problem here that, my implementation is not suitable with official hd wallet implementation which uses path like P//hard//soft (where P is mnemonic)
I rather use a path as m/44/354/0/0/0, to define 0. account's 0. deposit wallet.

The gotcha here is that, from same mnemonic I can't produce the same set of addresses with other available wallets.

@danforbes
Copy link

@farukterzioglu - I am not an expert in these issues, but I can provide two other suggestions for places to look for help:

  1. make a post on Stack Overflow and tag it substrate
  2. open an Issue on the Substrate subport repo: https://github.com/paritytech/subport/issues/new

@jacogr
Copy link

jacogr commented Dec 3, 2020

If you are using the standard mnemonic -> seed as per eg. ETH/BTC it won’t match.

Substrate goes from mnemonic-> entropy and then does pdkdf2 rounds (with the ///password and a known prefix) to get the private key (mini secret in Substrate terminology)

The outputs are vastly different between the 2 approaches so even something with no derivation will not match.

Trivia tidbits -

  • Around poc-1 the first approach was still taken in Polkadot, it was changed in poc-2 for better use of the available material
  • Ledger keys are derived like yours, so non-Substrate-matching, but obviously still works since the crypto is ed25519 and supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants