WIP: keyfork-shard: traitify functionality #22

Manually merged
ryan merged 8 commits from keyfork-shard-traitify into main 2024-02-19 10:51:04 +00:00
1 changed files with 8 additions and 11 deletions
Showing only changes of commit 6a3018e5e8 - Show all commits

View File

@ -173,7 +173,6 @@ pub trait Format {
reader: impl Read + Send + Sync,
) -> Result<(), Box<dyn std::error::Error>> {
let mut pm = Terminal::new(stdin(), stdout())?;
let wordlist = Wordlist::default();
// parse input
let private_keys = private_key_discovery
@ -207,12 +206,12 @@ pub trait Format {
let validator = MnemonicSetValidator {
word_lengths: [9, 24],
};
let [nonce_mnemonic, pubkey_mnemonic] = pm.prompt_validated_wordlist(
QRCODE_COULDNT_READ,
&wordlist,
3,
validator.to_fn(),
)?;
let [nonce_mnemonic, pubkey_mnemonic] = pm
.prompt_validated_wordlist::<English, _>(
QRCODE_COULDNT_READ,
3,
validator.to_fn(),
)?;
let nonce = nonce_mnemonic
.as_bytes()
@ -228,8 +227,7 @@ pub trait Format {
// create our shared key
let our_key = EphemeralSecret::random();
let our_pubkey_mnemonic =
Mnemonic::from_entropy(PublicKey::from(&our_key).as_bytes(), Default::default())?;
let our_pubkey_mnemonic = Mnemonic::from_bytes(PublicKey::from(&our_key).as_bytes())?;
let shared_secret = our_key
.diffie_hellman(&PublicKey::from(their_pubkey))
.to_bytes();
@ -279,8 +277,7 @@ pub trait Format {
}
// safety: size of out_bytes is constant and always % 4 == 0
let payload_mnemonic =
unsafe { Mnemonic::from_raw_entropy(&out_bytes, Default::default()) };
let payload_mnemonic = unsafe { Mnemonic::from_raw_bytes(&out_bytes) };
#[cfg(feature = "qrcode")]
{