-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Keybase: Multiple Signature Algorithms #5439
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7970983
in progress
sunnya97 90b1f5c
in progress
sunnya97 a16e40f
in progress
sunnya97 2923b54
in progress
sunnya97 97fc60a
in progress
sunnya97 4b056de
fixed defaults
sunnya97 8934b61
fixed unconvert
sunnya97 1a7c67b
with functions
sunnya97 ef203f6
modularize full key derivation process
sunnya97 f32a1a4
exposed StdDerive and StdGenerate functions
sunnya97 86c5618
hdpath fix
sunnya97 11a9117
expose ConsumeMultisignatureVerificationGas
sunnya97 f417acf
improve code cov
sunnya97 b164ca0
CHANGELOG
sunnya97 1a8ffb2
CHANGELOG updates
sunnya97 b130d52
tests fix
sunnya97 7fd09ca
constant
sunnya97 c3c30e8
Merge branch 'master' into keybase_multi_algo
sunnya97 a3d1c97
fixed lint issue
sunnya97 08059ce
address some comments review
sunnya97 6e50c29
Merge branch 'master' into keybase_multi_algo
sunnya97 8faaca3
Update crypto/keys/keybase_base.go
fedekunze 6777c23
added err check
sunnya97 906a5ee
added return type info to godoc of UnarmorDecryptPrivKey
sunnya97 318c145
Merge branch 'master' into keybase_multi_algo
sunnya97 959575a
Cleanup changelog
alexanderbez 2c3aa4e
address @alexanderbez comments
sunnya97 e10933a
added constants for header keys
sunnya97 59874b4
added errors
sunnya97 930c3be
Merge branch 'master' into keybase_multi_algo
alexanderbez fe70610
Merge branch 'master' into keybase_multi_algo
fedekunze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ const ( | |
flagIndex = "index" | ||
flagMultisig = "multisig" | ||
flagNoSort = "nosort" | ||
flagHDPath = "hd-path" | ||
flagKeyAlgo = "algo" | ||
|
||
// DefaultKeyPass contains the default key password for genesis transactions | ||
DefaultKeyPass = "12345678" | ||
|
@@ -71,9 +73,11 @@ the flag --nosort is set. | |
cmd.Flags().Bool(flagRecover, false, "Provide seed phrase to recover existing key instead of creating") | ||
cmd.Flags().Bool(flagNoBackup, false, "Don't print out seed phrase (if others are watching the terminal)") | ||
cmd.Flags().Bool(flagDryRun, false, "Perform action, but don't add key to local keystore") | ||
cmd.Flags().String(flagHDPath, "", "Manual HD Path derivation (overrides BIP44 config)") | ||
cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation") | ||
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation") | ||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response") | ||
cmd.Flags().String(flagKeyAlgo, string(keys.Secp256k1), "Key signing algorithm to generate keys for") | ||
return cmd | ||
} | ||
|
||
|
@@ -112,6 +116,14 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keys.Keybase, inBuf *bufio. | |
interactive := viper.GetBool(flagInteractive) | ||
showMnemonic := !viper.GetBool(flagNoBackup) | ||
|
||
algo := keys.SigningAlgo(viper.GetString(flagKeyAlgo)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Secp256k1 is already the default. Why manually do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting |
||
if algo == keys.SigningAlgo("") { | ||
algo = keys.Secp256k1 | ||
} | ||
if !keys.IsSupportedAlgorithm(kb.SupportedAlgos(), algo) { | ||
return keys.ErrUnsupportedSigningAlgo | ||
} | ||
|
||
if !viper.GetBool(flagDryRun) { | ||
_, err = kb.Get(name) | ||
if err == nil { | ||
|
@@ -164,7 +176,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keys.Keybase, inBuf *bufio. | |
if err != nil { | ||
return err | ||
} | ||
_, err = kb.CreateOffline(name, pk) | ||
_, err = kb.CreateOffline(name, pk, algo) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -174,8 +186,26 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keys.Keybase, inBuf *bufio. | |
account := uint32(viper.GetInt(flagAccount)) | ||
index := uint32(viper.GetInt(flagIndex)) | ||
|
||
useBIP44 := !viper.IsSet(flagHDPath) | ||
var hdPath string | ||
|
||
if useBIP44 { | ||
hdPath = keys.CreateHDPath(account, index).String() | ||
} else { | ||
hdPath = viper.GetString(flagHDPath) | ||
} | ||
|
||
// If we're using ledger, only thing we need is the path and the bech32 prefix. | ||
if viper.GetBool(flags.FlagUseLedger) { | ||
|
||
if !useBIP44 { | ||
return errors.New("cannot set custom bip32 path with ledger") | ||
} | ||
|
||
if !keys.IsSupportedAlgorithm(kb.SupportedAlgosLedger(), algo) { | ||
return keys.ErrUnsupportedSigningAlgo | ||
} | ||
|
||
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix() | ||
info, err := kb.CreateLedger(name, keys.Secp256k1, bech32PrefixAccAddr, account, index) | ||
if err != nil { | ||
|
@@ -240,7 +270,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keys.Keybase, inBuf *bufio. | |
} | ||
} | ||
|
||
info, err := kb.CreateAccount(name, mnemonic, bip39Passphrase, DefaultKeyPass, account, index) | ||
info, err := kb.CreateAccount(name, mnemonic, bip39Passphrase, DefaultKeyPass, hdPath, algo) | ||
if err != nil { | ||
return err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.