Skip to main content

encrypt_account_label

Function encrypt_account_label 

Source
pub fn encrypt_account_label(
    shared_key: &[u8; 32],
    iv: &[u8; 16],
    label: &str,
) -> Vec<u8> ⓘ
Expand description

Encrypt an account label for DashPay (DIP-15)

The label is normalized to the DIP-15 plaintext bounds before encryption (see [fit_account_label]): short labels are space-padded so the output clears the 48-byte floor, and over-long labels are truncated so it never exceeds the 80-byte cap. The output is therefore always a valid encryptedAccountLabel for any input. decrypt_account_label strips the padding.

§Arguments

  • shared_key - 32-byte shared secret from ECDH
  • iv - 16-byte initialization vector (must be randomly generated, different from xpub IV)
  • label - Account label string to encrypt

§Returns

Encrypted label with IV prepended (48-80 bytes: 16-byte IV + 32-64 byte encrypted data)