pm_accounts/
utils.rs

1use miden_client::{auth::AuthSecretKey, crypto::SecretKey, Word};
2use rand_chacha::rand_core::SeedableRng;
3use rand_chacha::ChaCha20Rng;
4/// Word to MASM
5pub fn word_to_masm(word: Word) -> String {
6    word.iter()
7        .map(|x| x.as_int().to_string())
8        .collect::<Vec<_>>()
9        .join(".")
10}
11
12pub fn get_new_pk_and_authenticator() -> (Word, AuthSecretKey) {
13    let seed = [0; 32];
14
15    let mut rng = ChaCha20Rng::from_seed(seed);
16
17    // Generate Falcon-512 secret key
18    let sec_key = SecretKey::with_rng(&mut rng);
19
20    // Convert public key to `Word` (4xFelt)
21    let pub_key: Word = sec_key.public_key().into();
22
23    // Wrap secret key in `AuthSecretKey`
24    let auth_secret_key = AuthSecretKey::RpoFalcon512(sec_key);
25
26    (pub_key, auth_secret_key)
27}