add master addr export + private export

This commit is contained in:
Michele Balistreri 2022-10-26 10:14:05 +02:00
parent 95e1c1249a
commit e4fef0fb36
4 changed files with 21 additions and 3 deletions

View File

@ -106,7 +106,8 @@ func main() {
testFlow(skg.RecoverAccount, skg.FlowParams{skg.PairingPass: "WrongPass", skg.PIN: "234567"})
testFlow(skg.Login, skg.FlowParams{skg.KeyUID: "60a78c98d5dd659f714eb7072bfb2c0d8a65f74a8f6aff7bb27cf56ae1feec17"})
testFlow(skg.GetAppInfo, skg.FlowParams{})
testFlow(skg.ExportPublic, skg.FlowParams{skg.BIP44Path: "m/44'/60'/0'/0/1"})
testFlow(skg.ExportPublic, skg.FlowParams{skg.BIP44Path: "m/44'/60'/0'/0/1", skg.ExportMaster: true})
testFlow(skg.ExportPublic, skg.FlowParams{skg.BIP44Path: "m/43'/60'/1581'/1'/0", skg.ExportPriv: true})
testFlow(skg.Sign, skg.FlowParams{skg.TXHash: "60a78c98d5dd659f714eb7072bfb2c0d8a65f74a8f6aff7bb27cf56ae1feec17", skg.BIP44Path: "m/44'/60'/0'/0/0"})
testFlow(skg.StoreMetadata, skg.FlowParams{skg.CardName: "TestCard", skg.WalletPaths: []interface{}{"m/44'/60'/0'/0/0", "m/44'/60'/0'/0/1", "m/44'/60'/0'/0/5", "m/44'/60'/0'/0/6"}})
testFlow(skg.GetMetadata, skg.FlowParams{})

15
flow.go
View File

@ -355,13 +355,26 @@ func (f *KeycardFlow) exportPublicFlow(kc *keycardContext) (FlowStatus, error) {
return nil, err
}
result := FlowStatus{KeyUID: f.cardInfo.keyUID}
if exportMaster, ok := f.params[ExportMaster]; ok && exportMaster.(bool) {
masterKey, err := f.exportKey(kc, masterPath, true)
result[MasterAddr] = masterKey.Address
if err != nil {
return nil, err
}
}
key, err := f.exportBIP44Key(kc)
if err != nil {
return nil, err
}
return FlowStatus{KeyUID: f.cardInfo.keyUID, ExportedKey: key}, nil
result[ExportedKey] = key
return result, nil
}
func (f *KeycardFlow) loadKeysFlow(kc *keycardContext) (FlowStatus, error) {

View File

@ -382,7 +382,8 @@ func (f *KeycardFlow) exportKey(kc *keycardContext, path string, onlyPublic bool
func (f *KeycardFlow) exportBIP44Key(kc *keycardContext) (*KeyPair, error) {
if path, ok := f.params[BIP44Path]; ok {
return f.exportKey(kc, path.(string), true)
exportPrivate, ok := f.params[ExportPriv]
return f.exportKey(kc, path.(string), (!ok || !exportPrivate.(bool)))
}
err := f.pauseAndWait(EnterPath, ErrorExporting)

View File

@ -104,6 +104,7 @@ const (
PUK = "puk"
NewPUK = "new-puk"
MasterKey = "master-key"
MasterAddr = "master-key-address"
WalleRootKey = "wallet-root-key"
WalletKey = "wallet-key"
EIP1581Key = "eip1581-key"
@ -118,6 +119,8 @@ const (
TXSignature = "tx-signature"
Overwrite = "overwrite"
ResolveAddr = "resolve-addresses"
ExportMaster = "export-master-address"
ExportPriv = "export-private"
CardMeta = "card-metadata"
CardName = "card-name"
WalletPaths = "wallet-paths"