leonardocustodio / polkadart

Polkadart provides developers the ability to query a node and interact with the Polkadot based chains using Dart.
https://polkadart.dev
Apache License 2.0
39 stars 16 forks source link

Substrate BIP39 #313

Closed Lohann closed 1 year ago

Lohann commented 1 year ago

Description

This PR creates a new package that implements Substrate-BIP39, necessary for extracting the seed from mneumonic phrases.

Substrate uses a custom implementation of BIP39, which uses different derivation functions depending of the signature scheme being used, examples:

Mneumonic: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice"
   Scheme: Sr25519
     Seed: 0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a

Mneumonic: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice"
   Scheme: Ed25519
     Seed: 0xabf8e5bdbe30c65656c0a3cbd181ff8a56294a69dfedd27982aace4a76909115

Mneumonic: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice"
   Scheme: ECDSA
     Seed: 0xcb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854

Obs: Currently only Ed25519 is supported.

The output of this package was compared against the output of Subkey Tool

TODO

Will do the Sr25519 and ECDSA support in follow up PR, because currently we only support Ed25519 signatures.

References: