FrankC01 / pysui

SUI Python Client SDK
Apache License 2.0
139 stars 38 forks source link

[feature] Enable creating new key/address from mnemonic and keytype. #71

Closed viponedream closed 1 year ago

viponedream commented 1 year ago

if i had already created the address from sui wallet in chrome extension.
how can i use that recovery words to use in pysui?

FrankC01 commented 1 year ago

So, at the moment, pysu does not 'recover' from key phrase but:

If you use: sui keytool import -h can generate a key from the phrase, then if you edit the sui.keystore in the SUI configuration you can add the keystring string from the keytool file.

FrankC01 commented 1 year ago

@viponedream Let me know if you got that working. Otherwise I will details steps with example.

viponedream commented 1 year ago

there is "SuiConfig.from_config_file( )" , maybe you add another "from mnemonic( )" or from private, like web3, all we need is to provide the private key or mnemonic words

FrankC01 commented 1 year ago

There is a function to recover a key pair with mnemonics but I have it (at the moment) not executable as I want to do more rigorous training.

Do you have a "test" full keypair string, the keytype, derivation path and resulting address I can test and compare with?

BTW: The SuiConfig is a look over client.yaml and, as such, just reads keys from the sui.keystore. However; there is a 'recover_key_and_address' in sui_crypto.py that I don't expose via SuiConfig yet. When ready, I will extend SuiConfig.create_new_keypair_and_address to take optional mnemonics and derivation paths.

viponedream commented 1 year ago

client.yaml and keystore client.zip

viponedream commented 1 year ago

memonic: fire secret satisfy piano candy grab spot material youth front child keep avocado pulse stuff wage useless brave stem sweet anger negative father goose

keystore: "AHFAKI8MACQiWoym4sEhixNMWiprArwEAvc/XR71TRvl"

addr: 0x843badffe5ba00864c13b60fdf1784a922ba8a6e

FrankC01 commented 1 year ago

Ok, using your mnemonic and key type of ed25519 it matches your keystring and address.

I will enable this in the next release (publish Thu or Fri this week)

phd0066 commented 2 weeks ago

How to pass the parameters of the derivation path of the recover_keypair_and_address method