{"id":726,"date":"2023-10-19T09:01:01","date_gmt":"2023-10-19T01:01:01","guid":{"rendered":""},"modified":"2023-10-19T09:01:01","modified_gmt":"2023-10-19T01:01:01","slug":"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801","status":"publish","type":"post","link":"https:\/\/mushiming.com\/726.html","title":{"rendered":"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801"},"content":{"rendered":"

\u5f00\u542f\u6398\u91d1\u6210\u957f\u4e4b\u65c5\uff01\u8fd9\u662f\u6211\u53c2\u4e0e\u300c\u6398\u91d1\u65e5\u65b0\u8ba1\u5212 \u00b7 12 \u6708\u66f4\u6587\u6311\u6218\u300d\u7684\u7b2c5\u5929\uff0c\u70b9\u51fb\u67e5\u770b\u6d3b\u52a8\u8be6\u60c5<\/p>\n


\n

\u76f8\u5173\u539f\u7406<\/h3>\n

\uff08\u4e00\uff09DH\u534f\u8bae<\/strong>                                                                 <\/p>\n

     \u7b97\u6cd5\u63cf\u8ff0\uff1a\u7528\u6237A\u548c\u7528\u6237B\u901a\u8fc7\u516c\u5f00\u4fe1\u9053\u5efa\u7acb\u5171\u540c\u7684\u5bc6\u94a5\u3002  <\/p>\n

     1.\u516c\u7528\u53c2\u6570\u751f\u6210\u7b97\u6cd5                                               <\/p>\n

     \u8fd9\u4e00\u6b65\u9aa4\u5c06\u4e3a\u7528\u6237A\u548cB\u751f\u6210\u516c\u7528\u7684\u53c2\u6570\uff0c\u6267\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a    <\/p>\n

\u2460\u9009\u62e9\u5927\u7d20\u6570p\u3002\u2461\u4ee4g\u4e3aZp*(2\u2264g\u2264p-2)\u7684\u751f\u6210\u5143\u3002               <\/p>\n

     2.\u534f\u5546\u5bc6\u94a5                                                        <\/p>\n

     \u2460\u7528\u6237A\u968f\u673a\u9009\u62e9\u6570x(1\u2264x\u2264p-2)\uff0c\u8ba1\u7b97g^x modp\uff0c\u5e76\u5c06\u4e4b\u53d1\u9001\u7ed9B\u3002\u2461\u7528\u6237B\u968f\u673a\u9009\u62e9\u6570y(1\u2264y\u2264p-2)\uff0c\u8ba1\u7b97g^y modp\uff0c\u5e76\u5c06\u4e4b\u53d1\u9001\u7ed9A\u3002\u2462\u7528\u6237B\u6536\u5230g^x modp\u540e\uff0c\u8ba1\u7b97\u5171\u4eab\u7684\u5bc6\u94a5K=(g ^x)^y modp\u3002\u2463\u7528\u6237A\u6536\u5230g^y modp\u540e\uff0c\u8ba1\u7b97\u5171\u4eab\u7684\u5bc6\u94a5K=(g ^y)^x modp\u3002<\/p>\n

\uff08\u4e8c\uff09RSA\u5bc6\u7801<\/strong>                                                           <\/p>\n

     RSA\u52a0\u5bc6\u7b97\u6cd5\u662f\u4e00\u79cd\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u6240\u8c13\u975e\u5bf9\u79f0\uff0c\u5c31\u662f\u6307\u8be5\u7b97\u6cd5\u52a0\u5bc6\u548c\u89e3\u5bc6\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u94a5\uff0c\u5373\u4f7f\u7528\u52a0\u5bc6\u5bc6\u94a5\u8fdb\u884c\u52a0\u5bc6\u3001\u89e3\u5bc6\u5bc6\u94a5\u8fdb\u884c\u89e3\u5bc6\u3002\u5728RAS\u7b97\u6cd5\u4e2d\uff0c\u52a0\u5bc6\u5bc6\u94a5\uff08\u5373\u516c\u5f00\u5bc6\u94a5\uff09PK\u662f\u516c\u5f00\u4fe1\u606f\uff0c\u800c\u89e3\u5bc6\u5bc6\u94a5\uff08\u5373\u79d8\u5bc6\u5bc6\u94a5\uff09SK\u662f\u9700\u8981\u4fdd\u5bc6\u7684\u3002\u52a0\u5bc6\u7b97\u6cd5E\u548c\u89e3\u5bc6\u7b97\u6cd5D\u4e5f\u90fd\u662f\u516c\u5f00\u7684\u3002\u867d\u7136\u89e3\u5bc6\u5bc6\u94a5SK\u662f\u7531\u516c\u5f00\u5bc6\u94a5PK\u51b3\u5b9a\u7684\uff0c\u7531\u4e8e\u65e0\u6cd5\u8ba1\u7b97\u51fa\u5927\u6570n\u7684\u6b27\u62c9\u51fd\u6570phi(N)\uff0c\u6240\u4ee5\u4e0d\u80fd\u6839\u636ePK\u8ba1\u7b97\u51faSK\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u6781\u5927\u6574\u6570\u505a\u56e0\u6570\u5206\u89e3\u7684\u96be\u5ea6\u51b3\u5b9a\u4e86RSA\u7b97\u6cd5\u7684\u53ef\u9760\u6027\u3002\u7406\u8bba\u4e0a\uff0c\u53ea\u8981\u5176\u94a5\u5319\u7684\u957f\u5ea6n\u8db3\u591f\u957f\uff0c\u7528RSA\u52a0\u5bc6\u7684\u4fe1\u606f\u5b9e\u9645\u4e0a\u662f\u4e0d\u80fd\u88ab\u89e3\u7834\u7684\u3002                                      <\/p>\n

     RSA\u7b97\u6cd5\u901a\u5e38\u662f\u5148\u751f\u6210\u4e00\u5bf9RSA\u5bc6\u94a5\uff0c\u5176\u4e2d\u4e4b\u4e00\u662f\u4fdd\u5bc6\u5bc6\u94a5\uff0c\u7531\u7528\u6237\u4fdd\u5b58\uff1b\u53e6\u4e00\u4e2a\u4e3a\u516c\u5f00\u5bc6\u94a5\uff0c\u53ef\u5bf9\u5916\u516c\u5f00\u3002\u4e3a\u63d0\u9ad8\u4fdd\u5bc6\u5f3a\u5ea6\uff0cRSA\u5bc6\u94a5\u81f3\u5c11\u4e3a500\u4f4d\u957f\uff0c\u4e00\u822c\u63a8\u8350\u4f7f\u75281024\u4f4d\u3002\u8fd9\u5c31\u4f7f\u52a0\u5bc6\u7684\u8ba1\u7b97\u91cf\u5f88\u5927\u3002\u4e3a\u51cf\u5c11\u8ba1\u7b97\u91cf\uff0c\u5728\u4f20\u9001\u4fe1\u606f\u65f6\uff0c\u5e38\u91c7\u7528\u4f20\u7edf\u52a0\u5bc6\u65b9\u6cd5\u4e0e\u516c\u5f00\u5bc6\u94a5\u52a0\u5bc6\u65b9\u6cd5\u76f8\u7ed3\u5408\u7684\u65b9\u5f0f\uff0c\u5373\u4fe1\u606f\u91c7\u7528\u6539\u8fdb\u7684DES\u6216IDEA\u5bc6\u94a5\u52a0\u5bc6\uff0c\u7136\u540e\u4f7f\u7528RSA\u5bc6\u94a5\u52a0\u5bc6\u5bf9\u8bdd\u5bc6\u94a5\u548c\u4fe1\u606f\u6458\u8981\u3002\u5bf9\u65b9\u6536\u5230\u4fe1\u606f\u540e\uff0c\u7528\u4e0d\u540c\u7684\u5bc6\u94a5\u89e3\u5bc6\u5e76\u53ef\u6838\u5bf9\u4fe1\u606f\u6458\u8981\u3002                           <\/p>\n

     RSA\u7684\u52a0\u5bc6\u8fc7\u7a0b\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u901a\u5f0f\u6765\u8868\u8fbe\uff1a\u5bc6\u6587=\u660e\u6587^EmodN   \u4e5f\u5c31\u662f\u8bf4RSA\u52a0\u5bc6\u662f\u5bf9\u660e\u6587\u7684E\u6b21\u65b9\u540e\u9664\u4ee5N\u540e\u6c42\u4f59\u6570\u7684\u8fc7\u7a0b\u3002\u4ece\u901a\u5f0f\u53ef\u77e5\uff0c\u53ea\u8981\u77e5\u9053E\u548cN\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u8fdb\u884cRSA\u52a0\u5bc6\u4e86\uff0c\u6240\u4ee5\u8bf4E\u3001N\u662fRSA\u52a0\u5bc6\u7684\u5bc6\u94a5\uff0c\u4e5f\u5c31\u662f\u8bf4E\u548cN\u7684\u7ec4\u5408\u5c31\u662f\u516c\u94a5\u3002\u5176\u4e2dE\u5fc5\u987b\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6\uff1aE\u662f\u4e00\u4e2a\u6bd41\u5927\u6bd4L\u5c0f\u7684\u6570\uff0cE\u548cL\u7684\u6700\u5927\u516c\u7ea6\u6570\u4e3a1\uff08L \u662f p\uff0d1 \u548c q\uff0d1\u7684\u6700\u5c0f\u516c\u500d\u6570\uff09\u3002                                                               <\/p>\n

     RSA\u7684\u89e3\u5bc6\u8fc7\u7a0b\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u901a\u5f0f\u6765\u8868\u8fbe\uff1a\u660e\u6587=\u5bc6\u6587^DmodN   \u4e5f\u5c31\u662f\u8bf4\u5bf9\u5bc6\u6587\u8fdb\u884cD\u6b21\u65b9\u540e\u9664\u4ee5N\u7684\u4f59\u6570\u5c31\u662f\u660e\u6587\uff0c\u8fd9\u5c31\u662fRSA\u89e3\u5bc6\u8fc7\u7a0b\u3002\u77e5\u9053D\u548cN\u5c31\u80fd\u8fdb\u884c\u89e3\u5bc6\u5bc6\u6587\u4e86\uff0c\u6240\u4ee5D\u548cN\u7684\u7ec4\u5408\u5c31\u662f\u79c1\u94a5\u3002\u6570D\u662f\u7531\u6570E\u8ba1\u7b97\u51fa\u6765\u7684\uff0c\u6570D\u5fc5\u987b\u4fdd\u8bc1\u8db3\u591f\u5927\u3002D\u3001E\u548cL\u4e4b\u95f4\u5fc5\u987b\u6ee1\u8db3\uff1a1 < D < L\uff1bE*D mod L \uff1d 1\u3002                                  <\/p>\n

\uff08\u4e09\uff09\u692d\u5706\u66f2\u7ebf\u5bc6\u7801<\/strong>                                           <\/p>\n

     \u692d\u5706\u52a0\u5bc6\u7b97\u6cd5ECC\uff0c\u662f\u57fa\u4e8e\u692d\u5706\u66f2\u7ebf\u6570\u5b66\u7406\u8bba\u7684\u4e00\u79cd\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5(\u516c\u94a5\u52a0\u5bc6\u7b97\u6cd5)\uff0c\u4e0eRSA\u76f8\u6bd4\u53ef\u4ee5\u4f7f\u7528\u66f4\u77ed\u7684\u5bc6\u94a5\u5b9e\u73b0\u4e0eRSA\u76f8\u5f53\u6216\u8005\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002\u8fd9\u91cc\u7684\u692d\u5706\u66f2\u7ebf\u662f\u6307\u5177\u6709\u4ee5\u4e0b\u5f62\u5f0f\u7684\u4e09\u6b21\u65b9\u7a0b:y^2+axy+by=x^3+cx^2+dx+e\u5176\u4e2da\u3001b\u3001c\u3001d\u3001e\u662f\u6ee1\u8db3\u67d0\u4e9b\u7b80\u5355\u6761\u4ef6\u7684\u5b9e\u6570\u3002\u5b9a\u4e49\u4e2d\u5305\u62ec\u4e00\u4e2a\u79f0\u4e4b\u4e3a\u65e0\u7a77\u8fdc\u70b9\u7684\u5143\u7d20\uff0c\u8bb0\u4e3aO\uff0c\u692d\u5706\u66f2\u7ebf\u4e0a\u7684\u52a0\u6cd5\u8fd0\u7b97\u5b9a\u4e49\u5982\u4e0b\uff1a\u5982\u679c\u5176\u4e0a\u76843\u4e2a\u70b9\u4f4d\u4e8e\u540c\u4e00\u76f4\u7ebf\u4e0a\uff0c\u90a3\u4e48\u5b83\u4eec\u7684\u548c\u4e3aO\uff0c\u8fdb\u4e00\u6b65\u53ef\u4ee5\u5b9a\u4e49\u5982\u4e0b\u8fd0\u7b97\u5f8b\uff1a\u2460O\u4e3a\u52a0\u6cd5\u5355\u4f4d\u5143\uff0c\u5373\u5bf9\u692d\u5706\u66f2\u7ebf\u4e0a\u7684\u4efb\u610f\u4e00\u70b9P\uff0c\u6709P+O=P\u3002\u2461\u8bbeP1=(x\uff0cy)\u662f\u692d\u5706\u66f2\u7ebf\u4e0a\u4e00\u70b9\uff0c\u5b83\u7684\u52a0\u6cd5\u9006\u5143\u5b9a\u4e49\u4e3aP2=-P1=\uff08x,-y\uff09\u3002\u2462\u8bbeQ\u548cR\u662f\u692d\u5706\u66f2\u7ebf\u4e0ax\u5750\u6807\u4e0d\u540c\u7684\u4e24\u70b9\uff0cQ+R\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a\u753b\u4e00\u6761\u901a\u8fc7Q\u3001R\u7684\u76f4\u7ebf\uff0c\u4e0e\u692d\u5706\u66f2\u7ebf\u4ea4\u4e8eP1\uff08\u8fd9\u4e00\u4ea4\u70b9\u662f\u552f\u4e00\u7684\uff0c\u9664\u975e\u6240\u505a\u7684\u76f4\u7ebf\u662fQ\u70b9\u6216R\u70b9\u7684\u5207\u7ebf\uff0c\u6b64\u65f6\u5206\u522b\u53d6P1=Q\u548cP1=R\uff09\u3002\u7531Q+R+P1=O\uff0c\u5f97Q+R=-P1\u3002\u2463\u70b9Q\u7684\u500d\u6570\u5b9a\u4e49\u5982\u4e0b\uff1a\u5728Q\u70b9\u505a\u692d\u5706\u66f2\u7ebf\u7684\u4e00\u6761\u5207\u7ebf,\u8bbe\u5207\u7ebf\u4e0e\u692d\u5706\u66f2\u7ebf\u4ea4\u4e8e\u70b9S\uff0c\u5b9a\u4e492Q=Q\uff0bQ=-S\uff0c\u7c7b\u4f3c\u7684\uff0c\u53ef\u4ee5\u5b9a\u4e493Q=Q+Q+Q\uff0c\u7b49\u7b49\u3002\u4ee5\u4e0a\u5b9a\u4e49\u7684\u52a0\u6cd5\u5177\u6709\u52a0\u6cd5\u8fd0\u7b97\u7684\u4e00\u822c\u6027\u8d28\uff0c\u5982\u4ea4\u6362\u5f8b\u3001\u7ed3\u5408\u5f8b\u7b49\u3002                                                 <\/p>\n

    \u692d\u5706\u66f2\u7ebf\u5bc6\u7801\u4f53\u5236\uff1a\u8bbeP\u2208E\uff08Fp\uff09\uff0c\u70b9O\u662fP\u7684\u500d\u6570\uff0c\u5373\u5b58\u5728\u6b63\u6574\u6570x\uff0c\u4f7fQ=dP\uff0c\u5219\u692d\u5706\u66f2\u7ebf\u79bb\u6563\u5bf9\u6570\u95ee\u9898\uff08ECPLP\uff09\u662f\u6307\u7531\u7ed9\u5b9a\u7684P\u548cQ\u786e\u5b9a\u51fax\u3002\u7cfb\u7edf\u6784\u9020\uff1a\u9009\u53d6\u57fa\u57dfFp\uff0c\u692d\u5706\u66f2\u7ebfE\uff0c\u5728E\u4e0a\u9009\u62e9\u9636\u4e3a\u7d20\u6570n\u7684\u70b9P\uff08xp,yp\uff09\u3002\u516c\u5f00\u4fe1\u606f\u4e3a\uff1a\u57fa\u57dfFp\u3001\u692d\u5706\u66f2\u7ebfE\u3001\u70b9P\u53ca\u5176\u9636n\u3002\u5bc6\u94a5\u751f\u6210\uff1a\u7528\u6237 Alice\u968f\u673a\u9009\u53d6\u6574\u6570d\uff0c1<d\u2264n\u20141\uff0c\u8ba1\u7b97Q=dP\uff0c\u5c06\u70b9Q\u4f5c\u4e3a\u516c\u5f00\u5bc6\u94a5\uff0c\u6574\u6570d\u4f5c\u4e3a\u79d8\u5bc6\u5bc6\u94a5\u3002\u52a0\u5bc6\u4e0e\u89e3\u5bc6\uff1a\u82e5\u8981\u7ed9 Alice\u53d1\u9001\u79d8\u5bc6\u4fe1\u606fM\uff0c\u9700\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u2460\u5c06\u660e\u6587M\u8868\u793a\u4e3a\u57dfFp\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20m\u3002\u2461\u5728[1,n-1]\u5185\u968f\u673a\u9009\u62e9\u6574\u6570k\u3002\u2462\u8ba1\u7b97\u70b9\uff08x1,y1\uff09=kP\u3002\u2463\u8ba1\u7b97\u70b9\uff08x2,y2\uff09=kQ\uff0c\u82e5x2=0\uff0c\u5219\u91cd\u65b0\u9009\u62e9k\u3002\u2464\u8ba1\u7b97c=mx2.\u2465\u5c06\uff08x1,y1,c\uff09\u53d1\u9001\u7ed9 Alice\u3002Alice\u6536\u5230\u5bc6\u6587\u540e\uff0c\u5229\u7528\u79d8\u5bc6\u5bc6\u94a5d\uff0c\u8ba1\u7b97\uff1ad\uff08x1,y1\uff09= dkP= K\uff08dP\uff09=kQ=\uff08x2,y2\uff09 \u3002                        <\/p>\n

\uff08\u56db\uff09ELGamal\u52a0\u5bc6\u4f53\u5236<\/strong>                                                                               <\/p>\n

     EIGamal\u52a0\u5bc6\u7b97\u6cd5\u662f\u4e00\u79cd\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u53ef\u4ee5\u5e94\u7528\u5728\u4efb\u610f\u4e00\u4e2a\u5faa\u73af\u7fa4\uff08Cyclic Group)\u4e0a\u3002\u5728\u7fa4\u4e2d\u6709\u7684\u8fd0\u7b97\u6c42\u89e3\u5f88\u56f0\u96be\uff0c\u8fd9\u4e9b\u8fd0\u7b97\u901a\u5e38\u4e0e\u6c42\u89e3\u79bb\u6563\u5bf9\u6570(Discrete Iogarithm)\u76f8\u5173\uff0c\u6c42\u89e3\u7684\u56f0\u96be\u7a0b\u5ea6\u51b3\u5b9a\u4e86\u7b97\u6cd5\u7684\u5b89\u5168\u6027\u3002\u5176\u4e2d\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u91cd\u8981\u7684\u6570\u5b66\u5b9a\u4e49\u3002                       <\/p>\n

     \u516c\u94a5\u751f\u6210\uff1a\u2460\u9009\u53d6\u4e00\u4e2a\u5faa\u73af\u7fa4G\uff0c\u4e14\u5faa\u73af\u7fa4G\u7684\u9636\u6570\u4e3aq\u3002\u2461\u9009\u62e9\u4e00\u4e2a\u968f\u673a\u6570x\uff0cl<x<q-1\u3002\u2462\u8ba1\u7b97h=g ^xmodq\u3002h\u548cg\uff0cG\uff0cq\u5c31\u6784\u6210\u516c\u94a5\uff1bx\u662f\u4fdd\u5bc6\u7684\uff0cx\u4e0eh\uff0cg\uff0cG\uff0cq\u4e00\u8d77\u6784\u6210\u5bc6\u94a5\u3002                  <\/p>\n

     \u516c\u94a5\u52a0\u5bc6\uff1a\u2460\u9009\u53d6\u4e00\u4e2a\u968f\u673a\u6570y\uff0c1<y<q-1\u3002\u2461\u8ba1\u7b97c1=g^ymodq\u2462\u8ba1\u7b97s=h^y=\uff08g^x\uff09^y=g^\uff08x*y\uff09mod q\u3002\u2463\u52a0\u5bc6\u6570\u5b57m\u5f97c2=m *smodq\u3002c1\u3001c2\u6784\u6210\u52a0\u5bc6\u7ed3\u679c\uff0c\u4ea4\u7ed9\u79c1\u94a5\u89e3\u5bc6                               <\/p>\n

     \u79c1\u94a5\u89e3\u5bc6\uff1a\u2460\u901a\u8fc7c1\u8ba1\u7b97\u5f97\u5230s=c1^x=(g^y)^x=g\uff08xy\uff09mod q\u3002\u2461\u8ba1\u7b97c2<\/em>(s^-1)=(m*s)(s^-l)(md q)\uff0c\u5f97\u5230\u660e\u6587\u6570\u5b57m\u3002<\/p>\n


\n

\u5b9e\u73b0\u8fc7\u7a0b<\/h3>\n

**\uff08\u4e00\uff09DH\u534f\u8bae   **                                                              <\/p>\n

     \u57fa\u4e8e\u5927\u6574\u6570\u5e93GMP\uff0c\u4f7f\u7528\u81ea\u5e26\u7684\u51fd\u6570\u5b9e\u73b0\u968f\u673a\u6570\u751f\u6210\u3001\u5927\u7d20\u6570\u751f\u6210\u548c\u6c42\u672c\u539f\u6839\uff0c\u63a5\u7740\u6309\u7167\u5bc6\u94a5\u534f\u5546\u987a\u5e8f\u5b9e\u73b0\u7b97\u6cd5\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\uff08\u4e8c\uff09RSA\u5bc6\u7801                                                           <\/p>\n

RSA\u52a0\u5bc6\u7b97\u6cd5\u7684\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n

\u2460\u53d6\u4e24\u4e2a\u968f\u673a\u5927\u7d20\u6570p\u548cq\uff08\u4fdd\u5bc6\uff09\u3002<\/p>\n

\u2461\u8ba1\u7b97\u516c\u5f00\u7684\u6a21\u6570r=pq\uff08\u516c\u5f00\uff09\u3002<\/p>\n

\u2462\u8ba1\u7b97\u79d8\u5bc6\u7684\u6b27\u62c9\u51fd\u6570\u03c6(r)=(p-1)(q-1)\uff08\u4fdd\u5bc6)\uff0c\u4e24\u4e2a\u7d20\u6570p\u548cq\u4e0d\u518d\u9700\u8981\uff0c\u4e3a\u4e86\u4e0d\u6cc4\u9732\u6700\u597d\u4e22\u5f03\u3002\u2463\u968f\u673a\u9009\u53d6\u6574\u6570e\uff0c\u6ee1\u8db3 gcd(e,\u03c6 (r))=1\uff08\u516c\u5f00e\uff0c\u52a0\u5bc6\u5bc6\u94a5\uff09\u3002<\/p>\n

\u2464\u8ba1\u7b97d\uff0c\u6ee1\u8db3de=1(mod\u03c6(r))\uff08\u4fdd\u5bc6d\uff0c\u89e3\u5bc6\u5bc6\u94a5\uff0c\u9677\u95e8\u4fe1\u606f\uff09\u3002<\/p>\n

\u2465\u5c06\u660e\u6587\uff08\u5176\u503c\u7684\u8303\u56f4\u57280\u5230r-1\u4e4b\u95f4\uff09\u6309\u6a21\u4e3ar\u81ea\u4e58e\u6b21\u5e42\u4ee5\u5b8c\u6210\u52a0\u5bc6\u64cd\u4f5c\uff0c\u4ece\u800c\u4ea7\u751f\u5bc6\u6587y(\u5176\u503c\u4e5f\u57280\u5230r-1\u8303\u56f4\u5185)\uff1ay=x^e\uff08mod r\uff09<\/p>\n

\u2466\u5c06\u5bc6\u6587y\u6309\u6a21\u4e3ar\u81ea\u4e58d\u6b21\u5e42\uff0c\u5b8c\u6210\u89e3\u5bc6\u64cd\u4f5c\uff1ax=y^d \uff08mod r\uff09<\/p>\n

int candp<\/span>(int a, int n, int p<\/span>){\/\/\u6570\u636e\u5904\u7406\u51fd\u6570\uff0c\u5b9e\u73b0\u5e42\u7684\u53d6\u4f59\u8fd0\u7b97                        <\/span>\n\n int r=1<\/span>;                                                                       \n\n    n=n+1<\/span>;                                                                       \n\n    while<\/span>(n!=1<\/span>){                                                 \n\nr=(r*a)%p;                                                 \n\nn--;     }                                                                                                  \n\nreturn<\/span> r;                                                                                                  \n\n}                                                                                                  \n\nint fun<\/span>(int x, int y<\/span>){  \/\/x\u4e0ey\u7684\u4e92\u7d20\u5224\u65ad                                                                                                  <\/span>\n\nint t;                                                           \n\nwhile<\/span>(y){                                                           \n\nt=x;                                                           \n\nx=y;                                                           \n\ny=t%y;  }                                                           \n\nif<\/span>(x==1<\/span>)                                                           \n\nreturn<\/span> 0<\/span>; \/\/x\u4e0ey\u4e92\u7d20\u65f6\u8fd4\u56de0                                                           <\/span>\n\nelse<\/span>                                                           \n\nreturn<\/span> 1<\/span>; \/\/x\u4e0ey\u4e0d\u4e92\u7d20\u65f6\u8fd4\u56de1                                                           <\/span>\n\n}                                                           \n\nvoid<\/span> main<\/span>(<\/span>){                                                           \n\nint p,q,e,d,m,n,z,c,r;                                                           \n\n    cout<<\"\u2460\u8f93\u5165\u4e24\u4e2a\u7d20\u6570p,q: \"<\/span>;                                                           \n\ncin>>p>>q;                                                           \n\nn=p*q;                                                           \n\nz=(p-1<\/span>)*(q-1<\/span>);                                                           \n\ncout<<\"\u2461\u8ba1\u7b97n=pq=\"<\/span><<n<<\", z=(p-1)*(q-1)=\"<\/span><<z<<endl;                                                           \n\ncout<<\"\u2462\u8f93\u5165\u516c\u94a5e: \"<\/span>;                                                           \n\ncin>>e;                                                           \n\nif<\/span>(e<1<\/span> || e>z || fun<\/span>(e,z)){\/\/\u9009\u53d6e: e<n,e\u4e0ez\u4e92\u7d20                                                           <\/span>\n\nprintf<\/span>(\"e\u4e0d\u5408\u8981\u6c42\uff0c\u91cd\u65b0\u8f93\u4eba:\"<\/span>);                                                            \n\nscanf<\/span>(\"%d\"<\/span>, &e);                                                           \n\n}                                                           \n\nd=1<\/span>;                                                           \n\nwhile<\/span>(((e*d)%z)!=1<\/span>)\/\/\u8ba1\u7b97\u79c1\u94a5d                                                           <\/span>\n\nd++;                                                                         \n\ncout<<\"\u2463\u6ee1\u8db3ed modz=1\u7684d: \"<\/span><<d<<endl;                                                           \n\ncout<<\"\u2464\u516c\u94a5(\"<\/span><<n<<\",\"<\/span><<e<<\"),\u79c1\u94a5(\"<\/span><<n<<\",\"<\/span><<d<<\")\"<\/span><<endl;\n\ncout<<\"1.\u52a0\u5bc6\"<\/span><<endl<<\"2.\u89e3\u5bc6\"<\/span><<endl<<\"3.\u9000\u51fa\"<\/span><<endl;                                                           \n\n    while<\/span>(1<\/span>){                                                           \n\nprintf<\/span>(\"\u9009\u62e9\u4f60\u6267\u884c\u7684\u64cd\u4f5c:\"<\/span>);                                                           \n\ncin>>r;                                                           \n\nswitch<\/span>(r){                                                           \n\ncase<\/span> 1<\/span>:                                                           \n\nprintf<\/span>(\"\u8bf7\u8f93\u5165\u660e\u6587m: \"<\/span>);                                                             \n\nscanf<\/span>(\"%d\"<\/span>, &m);                                                           \n\nc=candp<\/span>(m, e, n);                                                           \n\nprintf<\/span>(\"\u5bc6\u6587\u4e3a%d\\n\"<\/span>,c);  \/\/c=m^e modn                                                           <\/span>\n\nbreak<\/span>;                                                           \n\ncase<\/span> 2<\/span>:                                                           \n\nprintf<\/span>(\"\u8bf7\u8f93\u5165\u5bc6\u6587c: \"<\/span>);                                                            \n\nscanf<\/span>(\"%d\"<\/span>, &c);                                                           \n\nm=candp<\/span>(c, d, n);                                                           \n\nprintf<\/span>(\"\u660e\u6587\u4e3a%d\\n\"<\/span>, m); \/\/m=c^d modn                                                           <\/span>\n\nbreak<\/span>;                                                           \n\ncase<\/span> 3<\/span>:                                                           \n\nreturn<\/span>;                                                           \n\ndefault<\/span>:                                                           \n\nprintf<\/span>(\"\u8f93\u5165\u9519\u8bef,\u8bf7\u91cd\u65b0\u8f93\u5165:\\n\"<\/span>);                                                           \n\n}  }  }\n<\/code><\/pre>\n

\uff08\u4e09\uff09\u692d\u5706\u66f2\u7ebf\u5bc6\u7801                                           <\/p>\n

\u2460\u7528\u6237A\u9009\u5b9a\u4e00\u6761\u9002\u5408\u52a0\u5bc6\u7684\u692d\u5706\u66f2\u7ebfEp(a,b)(\u5982\uff1ay2=x3+ax+b)\uff0c\u5e76\u53d6\u692d\u5706\u66f2\u7ebf\u4e0a\u4e00\u70b9\uff0c\u4f5c\u4e3a\u57fa\u70b9G\u3002<\/p>\n

\u2461\u7528\u6237A\u9009\u62e9\u4e00\u4e2a\u79c1\u6709\u5bc6\u94a5k\uff0c\u5e76\u751f\u6210\u516c\u5f00\u5bc6\u94a5K=kG\u3002<\/p>\n

\u2462\u7528\u6237A\u5c06Ep(a,b)\u548c\u70b9K\uff0cG\u4f20\u7ed9\u7528\u6237B\u3002<\/p>\n

\u2463\u7528\u6237B\u63a5\u5230\u4fe1\u606f\u540e \uff0c\u5c06\u5f85\u4f20\u8f93\u7684\u660e\u6587\u7f16\u7801\u5230Ep(a,b)\u4e0a\u4e00\u70b9M\uff0c\u5e76\u4ea7\u751f\u4e00\u4e2a\u968f\u673a\u6574\u6570r\uff08r<n\uff09\u3002<\/p>\n

\u2464\u7528\u6237B\u8ba1\u7b97\u70b9C1=M+rK\uff1bC2=rG\u3002<\/p>\n

\u2465\u7528\u6237B\u5c06C1\u3001C2\u4f20\u7ed9\u7528\u6237A\u3002<\/p>\n

\u2466\u7528\u6237A\u63a5\u5230\u4fe1\u606f\u540e\uff0c\u8ba1\u7b97C1-kC2\uff0c\u7ed3\u679c\u5c31\u662f\u70b9M\u3002\u56e0\u4e3aC1-kC2=M+rK-k(rG)=M+rK-r(kG) =M\u3002\u518d\u5bf9\u70b9M\u8fdb\u884c\u89e3\u7801\u5c31\u53ef\u4ee5\u5f97\u5230\u660e\u6587\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\uff08\u56db\uff09ELGamal\u52a0\u5bc6\u4f53\u5236<\/strong>                                                                               <\/p>\n

\u2460\u5bc6\u94a5\u4ea7\u751f\u8fc7\u7a0b\uff1a\u9009\u62e9\u7d20\u6570p\u3001g\u3001\u968f\u673a\u6574\u6570x\u3001\u79d8\u5bc6\u968f\u673a\u6574\u6570y\uff0c\u8ba1\u7b97h = g^x mod p\u3002h\u4f5c\u4e3a\u516c\u5f00\u5bc6\u94a5\uff0cx\u4f5c\u4e3a\u79d8\u5bc6\u5bc6\u94a5\u3002<\/p>\n

\u2461\u52a0\u5bc6\u8fc7\u7a0b\uff1a\u660e\u6587\u6d88\u606fm\uff0c\u968f\u673a\u9009\u4e00\u6574\u6570y<p-1\uff0c\u8ba1\u7b97c1 = g^y mod p\uff0cc2 = (m* h^ymodp)modp\uff0c\u5bc6\u6587\u4e3ac=(c1,c2)\u3002<\/p>\n

\u2462\u89e3\u5bc6\u8fc7\u7a0b\uff1am=(c2\/c1^x)modp =mmodp<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n


\n

\u7ed3\u679c\u6d4b\u8bd5<\/h3>\n

\uff08\u4e00\uff09DH\u534f\u8bae                                                                                <\/p>\n

      \u8fd0\u884c\u7a0b\u5e8f\uff0c\u7ed3\u679c\u5982\u4e0b\u56fe1\u6240\u793a\u3002\u9009\u53d6p=69263\uff0c\u8ba1\u7b97\u5176\u672c\u539f\u6839g=19360\u3002\u968f\u673a\u9009\u62e9\u6570x=11913\uff0c\u90a3\u4e48g ^x mod p=35861\uff1b\u968f\u673a\u9009\u62e9\u6570y=49075\uff0c\u90a3\u4e48g ^y mod p=21039\u3002\u7528\u6237B\u8ba1\u7b97\u7684\u5171\u4eab\u5bc6\u94a5Kb=54047\uff0c\u540c\u6837\u7528\u6237A\u8ba1\u7b97\u7684\u5171\u4eab\u5bc6\u94a5Ka=54047\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\uff08\u4e8c\uff09RSA\u5bc6\u7801                                                           <\/p>\n

      \u7b97\u6cd5\u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b\u56fe2\u6240\u793a\u3002\u9996\u5148\u8f93\u5165\u4e24\u4e2a\u7d20\u6570p\u548cq\u5206\u522b\u4e3a17\u548c11\uff0c\u5f97\u5230n=1711=187,\u03c6\uff08n\uff09=16<\/em>10=160\u3002\u8f93\u5165e\u4e3a7\uff0c7d=160*k+1\u5f97\u5230d=23\u3002\u6b64\u65f6\u516c\u94a5\u4e3a\uff08187,7\uff09\uff0c\u79c1\u94a5\u4e3a\uff08187,23\uff09\u3002\u9009\u62e9\u52a0\u5bc6\uff0c\u660e\u6587m\u4e3a71\uff0c\u5f97\u5230\u5bc6\u6587c=m^e modn=71^7mod187=113\uff1b\u9009\u62e9\u89e3\u5bc6\uff0c\u5bc6\u6587113\uff0c\u5f97\u5230\u660e\u6587m=c^d modn=113^23mod187=71\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\uff08\u4e09\uff09\u692d\u5706\u66f2\u7ebf\u5bc6\u7801                                          <\/p>\n

     \u8fd0\u884c\u7a0b\u5e8f\u5982\u4e0b\u56fe3\uff0c\u8f93\u5165\u8981\u52a0\u5bc6\u7684\u6587\u4ef6\u8def\u5f84\u201cE:\\\u6d4b\u8bd5\\1.txt\u201d,\u52a0\u5bc6\u5b8c\u6210\u540e\uff0c\u52a0\u5bc6\u6587\u4ef6\u5b58\u653e\u57281\u5bc6\u6587.txt\u4e2d\uff1b\u8f93\u5165\u8981\u89e3\u5bc6\u7684\u6587\u4ef6\u8def\u5f84\u201cE:\\\u6d4b\u8bd5\\1\u5bc6\u6587.txt\u201d\uff0c\u89e3\u5bc6\u5b8c\u6210\u540e\uff0c\u89e3\u5bc6\u6587\u4ef6\u5b58\u653e\u57281\u5bc6\u6587\u89e3\u5bc6.txt\u4e2d\uff0c\u7ed3\u679c\u5982\u4e0b\u56fe4\u6240\u793a\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n

\uff08\u56db\uff09ELGamal\u52a0\u5bc6\u4f53\u5236                                          <\/p>\n

     \u8fd0\u884c\u7a0b\u5e8f\u540e\u5982\u4e0b\u56fe5\u6240\u793a\uff0c\u8f93\u5165\u660e\u6587m\u3001\u7d20\u6570p\u3001g\u3001\u968f\u673a\u6574\u6570x\u3001\u79d8\u5bc6\u968f\u673a\u6574\u6570y\uff0c\u5f97\u5230h = g^x mod p=449^12mod509=438\uff0cc1 = g^y mod p=449^18mod509=231\uff0cc2 = (m* h^y modp)mod p=(100438^18 mod509)mod509=492\uff0cc=(c1\uff0cc2)=(231\uff0c492)\uff0c\u9a8c\u8bc1\u5f97\u660e\u6587m=(c2<\/em>(c1^x)^(-1))%p=100\u3002<\/p>\n

\"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801<\/p>\n","protected":false},"excerpt":{"rendered":"\u3010\u5bc6\u7801\u5b66\u3011\u516c\u94a5\u5bc6\u7801\u5f00\u542f\u6398\u91d1\u6210\u957f\u4e4b\u65c5\uff01\u8fd9\u662f\u6211\u53c2\u4e0e\u300c\u6398\u91d1\u65e5\u65b0\u8ba1\u5212 \u00b7 12 \u6708\u66f4\u6587\u6311\u6218\u300d\u7684\u7b2c5\u5929\uff0c\u70b9\u51fb\u67e5\u770b\u6d3b\u52a8\u8be6\u60c5 \u76f8\u5173\u539f\u7406 \uff08\u4e00...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/726"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=726"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/726\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}