[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [local‑first/Protocol](https://evolu.dev/docs/api-reference/common/local-first/Protocol) › decryptAndDecodeDbChange

```ts
function decryptAndDecodeDbChange(
  message: EncryptedCrdtMessage,
  key: Uint8Array<ArrayBufferLike> &
    Brand<"Entropy"> &
    Brand<"Length32"> &
    Brand<"EncryptionKey">,
): Result<
  DbChange,
  | DecryptWithXChaCha20Poly1305Error
  | ProtocolInvalidDataError
  | ProtocolTimestampMismatchError
>;
```

Defined in: [packages/common/src/local-first/Protocol.ts:2404](https://github.com/evoluhq/evolu/blob/113517df8a8da4e4eed41363077878e657b22fca/packages/common/src/local-first/Protocol.ts#L2404)

Decrypts and decodes an [EncryptedCrdtMessage](https://evolu.dev/docs/api-reference/common/local-first/Storage/interfaces/EncryptedCrdtMessage) using the provided
owner's encryption key. Verifies that the embedded timestamp matches the
expected timestamp to ensure message integrity.

A change with a newer format version than [encodeAndEncryptDbChange](https://evolu.dev/docs/api-reference/common/local-first/Protocol/functions/encodeAndEncryptDbChange)
writes is a [ProtocolInvalidDataError](https://evolu.dev/docs/api-reference/common/local-first/Protocol/interfaces/ProtocolInvalidDataError).