flow-cli icon indicating copy to clipboard operation
flow-cli copied to clipboard

Refactor key generate API

Open sideninja opened this issue 2 years ago • 4 comments

I believe it would be better to refactor the keys generate service API back to how it was before the key derive functionality: https://github.com/onflow/flow-cli/blob/master/pkg/flowkit/services/keys.go#L56 We should instead extract this to another service method called Derive.

sideninja avatar Aug 03 '22 10:08 sideninja

I am getting this one to make PR, it makes sense totally.

Also I would suggest generate function to take private key. And exposing seed to private key generation in another method. ( Some GenerateKeyFromMnemonic etc )

bluesign avatar Aug 03 '22 10:08 bluesign

Yes, it was actually my bad for not noticing that during PR review, sorry. I think the generate from mnemonic is great API yeah. I would even say that in that spirit we could add mnemonics being generated as well when you would generate a new key.

sideninja avatar Aug 03 '22 10:08 sideninja

@sideninja We have some standard for mnemonic I guess, I remember there was some FLIP some time ago ? I think would be nice to have ledger compatible for example.

Also flow.json can accept mnemonic as private key in advanced mode.

bluesign avatar Aug 03 '22 10:08 bluesign

@sideninja We have some standard for mnemonic I guess, I remember there was some FLIP some time ago ? I think would be nice to have ledger compatible for example.

Yes.

Also flow.json can accept mnemonic as private key in advanced mode.

Yes, that would also be nice.

sideninja avatar Aug 03 '22 10:08 sideninja

@sideninja I finished this, just thinking to add a new command something like flow keys bip44 or update flow keys generate

Output will be like below, but if we update generate it will not be compatible with existing seed.

🔴️ Store private key safely and don't share with anyone!
Private Key 		 5cfcf224b30185116879066ad3f198fce0e703a3d8ac08425828a2221d4f5612
Public Key 		 1ead0c503695d5cc9657607d10be3629d24e793865f88fbb77c942381d21d0d078cfdb6fb27ce65fd6165f82a9ac5a08156d018259f58363a71d60244918205d
Mnemonic 		 grid nothing awkward shuffle bid sense current minimum spawn decrease under token
Derivation Path 	 m/44'/539'/0'/0/0

bluesign avatar Aug 23 '22 18:08 bluesign

I would update the existing generate method.

sideninja avatar Aug 24 '22 09:08 sideninja