Skip to content

Consider introducing AccountIdKey #2443

@PhilippGackstatter

Description

@PhilippGackstatter

After #2442 we have equivalent miden_protocol::block::account_tree::account_id_to_smt_key and TransactionAdviceInputs::account_id_map_key implementations. Maybe we should improve this with a dedicated type, for example:

/// The account ID as the key in the [`AccountTree`] and advice map in [`TransactionAdviceInputs`].
pub struct AccountIdKey(AccountId);

impl AccountIdKey {
    // Returns `[0, 0, account_id_suffix, account_id_prefix]`.
    pub fn as_word(&self) -> Word { ... }

    // Converts `[0, 0, account_id_suffix, account_id_prefix]` to Self.
    pub fn from_word(word: Word) -> Result<Self, todo!()> { ... }

    pub fn to_leaf_index(&self) -> LeafIndex<{ AccountTree::DEPTH }> { ... }
}

impl From<AccountId> for AccountIdKey { ... }

And then we can remove:

  • TransactionAdviceInputs::account_id_map_key
  • miden_protocol::block::account_tree::{account_id_to_smt_key, smt_key_to_account_id, account_id_to_smt_index}

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersrustIssues that affect or pull requests that update Rust code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions