Skip to content
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

Make BIP39 passphrase optional #2442

Merged
merged 23 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/2417-wallet-zip32-0.30.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Implemented ZIP32 functionality for shielded pool keys.
([\#2417](https://github.com/anoma/namada/pull/2417))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- BIP39 passphrase made optional.
([\#2442](https://github.com/anoma/namada/pull/2442))
87 changes: 71 additions & 16 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2975,8 +2975,11 @@ pub mod args {
arg("validator");
pub const HALT_ACTION: ArgFlag = flag("halt");
pub const HASH_LIST: Arg<String> = arg("hash-list");
pub const HD_WALLET_DERIVATION_PATH: ArgDefault<String> =
pub const HD_DERIVATION_PATH: ArgDefault<String> =
arg_default("hd-path", DefaultFn(|| "default".to_string()));
pub const HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH: ArgFlag =
flag("allow-non-compliant");
pub const HD_PROMPT_BIP39_PASSPHRASE: ArgFlag = flag("bip39-passphrase");
pub const HISTORIC: ArgFlag = flag("historic");
pub const IBC_TRANSFER_MEMO_PATH: ArgOpt<PathBuf> = arg_opt("memo-path");
pub const INPUT_OPT: ArgOpt<PathBuf> = arg_opt("input");
Expand Down Expand Up @@ -6196,7 +6199,11 @@ pub mod args {
let alias_force = ALIAS_FORCE.parse(matches);
let unsafe_dont_encrypt = UNSAFE_DONT_ENCRYPT.parse(matches);
let use_device = USE_DEVICE.parse(matches);
let derivation_path = HD_WALLET_DERIVATION_PATH.parse(matches);
let derivation_path = HD_DERIVATION_PATH.parse(matches);
let allow_non_compliant =
HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.parse(matches);
let prompt_bip39_passphrase =
HD_PROMPT_BIP39_PASSPHRASE.parse(matches);
Self {
scheme,
shielded,
Expand All @@ -6205,6 +6212,8 @@ pub mod args {
unsafe_dont_encrypt,
use_device,
derivation_path,
allow_non_compliant,
prompt_bip39_passphrase,
}
}

Expand Down Expand Up @@ -6234,14 +6243,34 @@ pub mod args {
"Derive an address and public key from the seed stored on the \
connected hardware wallet.",
))
.arg(HD_WALLET_DERIVATION_PATH.def().help(
.arg(HD_DERIVATION_PATH.def().help(
"HD key derivation path. Use keyword `default` to refer to a \
scheme default path:\n- m/44'/60'/0'/0/0 for secp256k1 \
scheme\n- m/44'/877'/0'/0'/0' for ed25519 scheme.\nFor \
ed25519, all path indices will be promoted to hardened \
indexes. If none is specified, the scheme default path is \
used.",
scheme default path:\n- m/44'/60'/0'/0/0 for the transparent \
secp256k1 scheme\n- m/44'/877'/0'/0'/0' for the transparent \
ed25519 scheme\n- m/32'/877'/0' for the shielded \
setting\nFor ed25519 scheme, all path indices will be \
promoted to hardened indexes. If none is specified, the \
scheme default path is used.",
))
.arg(HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.def().help(
"Allow non-compliant HD derivation path. The compliant \
derivation path schemes include:\n- \
m/44'/60'/account'/change/address_index for the transparent \
secp256k1 scheme\n- \
m/44'/877'/account'/change'/address_index' for the \
transparent ed25519 scheme\n- m/32'/877'/account' and\n- \
m/32'/877'/account'/address_index for the shielded setting",
))
.group(
ArgGroup::new("requires_group")
.args([HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.name])
.requires(HD_DERIVATION_PATH.name),
)
.arg(
HD_PROMPT_BIP39_PASSPHRASE.def().help(
"Use an additional passphrase for HD-key generation.",
),
)
}
}

Expand All @@ -6253,7 +6282,11 @@ pub mod args {
let alias = ALIAS.parse(matches);
let alias_force = ALIAS_FORCE.parse(matches);
let unsafe_dont_encrypt = UNSAFE_DONT_ENCRYPT.parse(matches);
let derivation_path = HD_WALLET_DERIVATION_PATH.parse(matches);
let derivation_path = HD_DERIVATION_PATH.parse(matches);
let allow_non_compliant =
HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.parse(matches);
let prompt_bip39_passphrase =
HD_PROMPT_BIP39_PASSPHRASE.parse(matches);
Self {
scheme,
shielded,
Expand All @@ -6262,6 +6295,8 @@ pub mod args {
alias_force,
unsafe_dont_encrypt,
derivation_path,
allow_non_compliant,
prompt_bip39_passphrase,
}
}

Expand All @@ -6280,7 +6315,7 @@ pub mod args {
.arg(
RAW_KEY_GEN
.def()
.conflicts_with(HD_WALLET_DERIVATION_PATH.name)
.conflicts_with(HD_DERIVATION_PATH.name)
.help(
"Generate a random non-HD secret / spending key. No \
mnemonic code is generated.",
Expand All @@ -6294,14 +6329,34 @@ pub mod args {
"UNSAFE: Do not encrypt the keypair. Do not use this for keys \
used in a live network.",
))
.arg(HD_WALLET_DERIVATION_PATH.def().help(
.arg(HD_DERIVATION_PATH.def().help(
"HD key derivation path. Use keyword `default` to refer to a \
scheme default path:\n- m/44'/60'/0'/0/0 for secp256k1 \
scheme\n- m/44'/877'/0'/0'/0' for ed25519 scheme.\nFor \
ed25519, all path indices will be promoted to hardened \
indexes. If none is specified, the scheme default path is \
used.",
scheme default path:\n- m/44'/60'/0'/0/0 for the transparent \
secp256k1 scheme\n- m/44'/877'/0'/0'/0' for the transparent \
ed25519 scheme\n- m/32'/877'/0' for the shielded \
setting\nFor ed25519 scheme, all path indices will be \
promoted to hardened indexes. If none is specified, the \
scheme default path is used.",
))
.arg(HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.def().help(
"Allow non-compliant HD derivation path. The compliant \
derivation path schemes include:\n- \
m/44'/60'/account'/change/address_index for the transparent \
secp256k1 scheme\n- \
m/44'/877'/account'/change'/address_index' for the \
transparent ed25519 scheme\n- m/32'/877'/account' and\n- \
m/32'/877'/account'/address_index for the shielded setting",
))
.group(
ArgGroup::new("requires_group")
.args([HD_ALLOW_NON_COMPLIANT_DERIVATION_PATH.name])
.requires(HD_DERIVATION_PATH.name),
)
.arg(
HD_PROMPT_BIP39_PASSPHRASE.def().help(
"Use an additional passphrase for HD-key generation.",
),
)
}
}

Expand Down
Loading
Loading