Skip to main content

derive_topic_from_account

Function derive_topic_from_account 

Source
pub fn derive_topic_from_account(
    context: &[u8],
    account_id: &[u8; 32],
    extra: &[u8],
) -> [u8; 32]
Expand description

Derive a 32-byte topic from a context string, a raw AccountId, and optional extra bytes.

topic = blake2b_256(SCALE_compact(context.len()) || context || account_id || extra)

The context is length-prefixed with SCALE compact encoding to match the deployed iOS protocol (Data.encode(scaleEncoder:) produces a SCALE Vec<u8> prefix). AccountId is always exactly 32 bytes (enforced by &[u8; 32]), so it acts as a fixed-width separator and needs no length prefix.