Skip to main content

message_decrypt_prekey

Function message_decrypt_prekey 

Source
pub async fn message_decrypt_prekey<R: Rng + CryptoRng>(
    ciphertext: &PreKeySignalMessage,
    remote_address: &ProtocolAddress,
    local_address: &ProtocolAddress,
    session_store: &mut dyn SessionStore,
    identity_store: &mut dyn IdentityKeyStore,
    pre_key_store: &mut dyn PreKeyStore,
    signed_pre_key_store: &dyn SignedPreKeyStore,
    kyber_pre_key_store: &mut dyn KyberPreKeyStore,
    csprng: &mut R,
) -> Result<PreKeyDecryptResult>
Expand description

Decrypt a PreKeySignalMessage from remote_address.

If a session for the incoming base key already exists, the inner SignalMessage is decrypted against that session directly. This covers both retransmitted pre-key messages and messages 1+ of the initial chain, which all carry the same base key. The peer’s identity is always trust-checked, but only saved for an active session. Messages on existing archived sessions cannot replace the stored identity.

Otherwise this builds a candidate session from the pre-key material, AEAD-verifies the inner SignalMessage against the candidate, and only commits the session + consumes pre-keys + saves identity on AEAD success. This enforces the protocol invariant that a session is committed only after AEAD decrypts.