# Key Switching in LWE

DevFeed: [Key Switching in LWE](<https://devfeed.tech/articles/key-switching-in-lwe-40456.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2022/08/29/key-switching-in-lwe/>)

Published: 2022-08-29T08:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Encryption](<https://devfeed.tech/topics/encryption.md>), [Cryptography](<https://devfeed.tech/topics/cryptography.md>), [scheme](<https://devfeed.tech/topics/scheme.md>)

Tags: [cryptography](<https://devfeed.tech/tags/cryptography.md>), [decrypt](<https://devfeed.tech/tags/decrypt.md>), [encryption](<https://devfeed.tech/tags/encryption.md>), [gadget-decomposition](<https://devfeed.tech/tags/gadget-decomposition.md>), [gaussian](<https://devfeed.tech/tags/gaussian.md>), [homomorphic-encryption](<https://devfeed.tech/tags/homomorphic-encryption.md>), [learning-with-errors](<https://devfeed.tech/tags/learning-with-errors.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [modulus-switching](<https://devfeed.tech/tags/modulus-switching.md>), [real-analysis](<https://devfeed.tech/tags/real-analysis.md>), [secret](<https://devfeed.tech/tags/secret.md>)

## AI overview

This tutorial explains key switching in the LWE encryption scheme: transforming a ciphertext encrypted under one secret key into a ciphertext under another without knowing either key. It introduces the key-switching key, shows why the naïve approach causes excessive error growth, and explains how gadget decomposition reduces that error.

## Source excerpt

Last time we covered an operation in the LWE encryption scheme called modulus switching, which allows one to switch from one modulus to another, at the cost of introducing a small amount of extra noise, roughly $\sqrt{n}$, where $n$ is the dimension of the LWE ciphertext. This time we'll cover a more sophisticated operation called key switching, which allows one to switch an LWE ciphertext from being encrypted under one secret key to another, without ever knowing either secret key.