Skip to main content

calculate_account_reference

Function calculate_account_reference 

Source
pub fn calculate_account_reference(
    sender_secret_key: &[u8; 32],
    compact_xpub: &[u8],
    account_index: u32,
    version: u32,
) -> u32
Expand description

Calculate the masked DIP-15 accountReference: result = (version << 28) | (ASK28 ^ (account_index & 0x0FFF_FFFF)).

Top 4 bits carry the rotation version (bumped on each friendship re-key); the low 28 bits are the account index masked by a PRF of the contact xpub so observers can’t correlate accounts across requests. Keyed by the sender’s 32-byte ECDH private key (the same key that encrypts the xpub).