mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
add BIP-39 entry for passwords in vault
If the "notes" field starts with the characters "bip39" (case insensitive), then, the password field is interpreted as a hexadecimal encoding of BIP39 entropy. To create a BIP-39 entry, leave the password field blank, and then start the Notes field with the characters 'bip39', and this will trigger a dialog box that will only allow valid bip39 entry and check the checksum etc. To view the BIP-39, after opening up the entry for "edit", close it, and it will pop up a second dialog box that interprets the hex data as BIP-39 words. You could also in theory enter the hex digits yourself into the password field, if you're masochist.
This commit is contained in:
parent
874bb655df
commit
f93d9de3f1
2 changed files with 50 additions and 2 deletions
|
|
@ -48,6 +48,27 @@
|
||||||
"ja": "アンマウントするベースを選択します:",
|
"ja": "アンマウントするベースを選択します:",
|
||||||
"zh": "选择要卸载的基础:"
|
"zh": "选择要卸载的基础:"
|
||||||
},
|
},
|
||||||
|
"vault.bip39.input": {
|
||||||
|
"en": "Enter your BIP39 password:",
|
||||||
|
"en-tts": "Enter your BIP39 password:",
|
||||||
|
"fr": "Saisissez votre mot de passe BIP39: *MT*",
|
||||||
|
"ja": "BIP39 パスワードを入力してください:",
|
||||||
|
"zh": "输入您的 BIP39 密码:"
|
||||||
|
},
|
||||||
|
"vault.bip39.output": {
|
||||||
|
"en": "Password as BIP39:",
|
||||||
|
"en-tts": "Password as BIP39:",
|
||||||
|
"fr": "Mot de passe en tant que BIP39: *MT*",
|
||||||
|
"ja": "BIP39としてのパスワード:",
|
||||||
|
"zh": "密码为 BIP39:"
|
||||||
|
},
|
||||||
|
"vault.bip39.output_error": {
|
||||||
|
"en": "Password field is not encodable as BIP39.",
|
||||||
|
"en-tts": "Password field is not encodable as BIP39.",
|
||||||
|
"fr": "Le champ Mot de passe n'est pas encodable en tant que BIP39. *MT*",
|
||||||
|
"ja": "パスワードフィールドはBIP39としてエンコードできません。",
|
||||||
|
"zh": "密码字段不可编码为 BIP39。"
|
||||||
|
},
|
||||||
"vault.completed": {
|
"vault.completed": {
|
||||||
"en": "Operation completed.",
|
"en": "Operation completed.",
|
||||||
"en-tts": "Operation completed.",
|
"en-tts": "Operation completed.",
|
||||||
|
|
|
||||||
|
|
@ -774,8 +774,35 @@ impl<'a> ActionManager<'a> {
|
||||||
pw.password = edit_data.content()[2].content.as_str().unwrap().to_string();
|
pw.password = edit_data.content()[2].content.as_str().unwrap().to_string();
|
||||||
pw.notes = edit_data.content()[3].content.as_str().unwrap().to_string();
|
pw.notes = edit_data.content()[3].content.as_str().unwrap().to_string();
|
||||||
|
|
||||||
// if the password is empty, prompt to generate a new password
|
// if the notes field starts with the word "bip39" (case insensitive), use BIP39 to display/edit the password field
|
||||||
|
if pw.notes.to_ascii_lowercase().starts_with("bip39") {
|
||||||
if pw.password.len() == 0 {
|
if pw.password.len() == 0 {
|
||||||
|
match self.modals.input_bip39(Some(t!("vault.bip39.input", xous::LANG))) {
|
||||||
|
Ok(data) => {
|
||||||
|
pw.password = hex::encode(data);
|
||||||
|
}
|
||||||
|
_ => pw.password = "".to_string(), // leave it blank if invalid or aborted
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match hex::decode(&pw.password) {
|
||||||
|
Ok(data) => {
|
||||||
|
match self.modals.show_bip39(
|
||||||
|
Some(t!("vault.bip39.output", xous::LANG)),
|
||||||
|
&data
|
||||||
|
) {
|
||||||
|
Ok(_) => {},
|
||||||
|
Err(_) => {
|
||||||
|
self.modals.show_notification(t!("vault.bip39.output_error", xous::LANG), None).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
self.modals.show_notification(t!("vault.bip39.output_error", xous::LANG), None).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if pw.password.len() == 0 && !pw.notes.to_ascii_lowercase().starts_with("bip39") {
|
||||||
|
// if the password is empty, prompt to generate a new password
|
||||||
let pg = PasswordGenerator {
|
let pg = PasswordGenerator {
|
||||||
length: 20,
|
length: 20,
|
||||||
numbers: true,
|
numbers: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue