react-native-matrix-crypto
    Preparing search index...

    Function decryptAttachment

    • Decrypts a file this library encrypted and you downloaded.

      Two failures, told apart

      A secret this library did not produce is refused as malformed. Bytes that are not the bytes the secret announced are refused as that, separately — Matrix's attachment encryption carries a SHA-256 of the ciphertext, and this is that check failing. It means the download was truncated, corrupted or substituted.

      The distinction is worth acting on: the first is a bug upstream of the download and retrying will not help, the second is a download worth making again. Neither ever returns partial bytes — the check runs at the end of the file, and a failure discards everything.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The file's bytes.

      CryptoError if the secret is malformed, or if the bytes are not what it announced.