> For the complete documentation index, see [llms.txt](https://chenyangwang.gitbook.io/mathematical-base-for-information-safety/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chenyangwang.gitbook.io/mathematical-base-for-information-safety/yuan-gen-yu-zhi-biao/elgamal-jia-mi.md).

# ElGamal加密

*利用离散对数对大素数取模计算的困难性*

> * **STEP1: 获取密钥**$$\left(p,r,b\right)$$
>   * $$p$$: 选择一个素数$$p$$
>   * $$r$$: $$p$$的原根为$$r$$
>   * $$a$$: 选取整数$$a$$，$$0\leq a\leq p-1$$
>   * $$b$$: $$b\equiv r^a\left(\mod p\right)$$
> * **STEP2: 加密信息**$$M$$
>   * $$k$$: 选取整数$$k$$，$$1\leq k\leq p-2$$
>   * $$\gamma$$: $$\gamma\equiv r^k\left(\mod p\right),0\leq\gamma\leq p-1$$
>   * $$\delta$$: $$\delta\equiv M\cdot b^k\left(\mod p\right),0\leq\delta\leq p-1$$
> * **STEP3: 解密信息**$$\left(\gamma,\delta\right)$$
>
>   $$M\equiv \overline{{\gamma^{a}}}\delta\left(\mod p\right)$$
