{"id":529,"date":"2021-01-13T23:52:47","date_gmt":"2021-01-13T15:52:47","guid":{"rendered":"http:\/\/eotstxtab.top\/?p=529"},"modified":"2022-02-23T23:37:04","modified_gmt":"2022-02-23T15:37:04","slug":"sm2%e5%9b%bd%e5%af%86%e7%ae%97%e6%b3%95%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/43.142.23.155\/?p=529","title":{"rendered":"SM2\u56fd\u5bc6\u7b97\u6cd5\u5b9e\u73b0"},"content":{"rendered":"\n<p class=\"has-large-font-size\">1\u3001ECC\u7b97\u6cd5\u6982\u8ff0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1\u3001\u7528\u6237A\u9009\u5b9a\u4e00\u6761\u9002\u5408\u52a0\u5bc6\u7684\u692d\u5706\u66f2\u7ebfEp(a,b)(\u5982:y2=x3+ax+b)\uff0c\u5e76\u53d6\u692d\u5706\u66f2\u7ebf\u4e0a\u4e00\u70b9\uff0c\u4f5c\u4e3a\u57fa\u70b9G\u3002<\/li><li>2\u3001\u7528\u6237A\u9009\u62e9\u4e00\u4e2a\u79c1\u6709\u5bc6\u94a5k\uff0c\u5e76\u751f\u6210\u516c\u5f00\u5bc6\u94a5\uff08\u516c\u94a5PB\uff09K=kG\u3002<\/li><li>3\u3001\u7528\u6237A\u5c06Ep(a,b)\u548c\u70b9\uff08\u516c\u94a5\uff09K\uff0cG\u4f20\u7ed9\u7528\u6237B\u3002<\/li><li>4\u3001\u7528\u6237B\u63a5\u5230\u4fe1\u606f\u540e \uff0c\u5c06\u5f85\u4f20\u8f93\u7684\u660e\u6587\uff08M\uff09\u7f16\u7801\u5230Ep(a,b)\u4e0a\u4e00\u70b9M\uff0c\u5e76\u4ea7\u751f\u4e00\u4e2a\u968f\u673a\u6574\u6570r\uff08r&lt;n )<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"%E5%8A%A0%E5%AF%86%E5%BC%80%E5%A7%8B\">\u52a0\u5bc6\u5f00\u59cb<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>5\u3001\u7528\u6237B\u8ba1\u7b97\u70b9C1=M+rK\uff1bC2=rG\u3002<\/li><li>6\u3001\u7528\u6237B\u5c06C1\u3001C2\u4f20\u7ed9\u7528\u6237A\u3002<\/li><li>7\u3001\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<\/li><\/ul>\n\n\n\n<p>\u5bc6\u7801\u5b66\u4e2d\uff0c\u63cf\u8ff0\u4e00\u6761Fp\u4e0a\u7684\u692d\u5706\u66f2\u7ebf\uff0c\u5e38\u7528\u5230\u516d\u4e2a\u53c2\u91cf\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>T=(p,a,b,G,n,h)\u3002<\/li><li>p \u3001a \u3001b \u7528\u6765\u786e\u5b9a\u4e00\u6761\u692d\u5706\u66f2\u7ebf\uff0cG\u4e3a\u57fa\u70b9\uff0cn\u4e3a\u70b9G\u7684\u9636\uff0ch \u662f\u692d\u5706\u66f2\u7ebf\u4e0a\u6240\u6709\u70b9\u7684\u4e2a\u6570m\u4e0en\u76f8\u9664\u7684\u6574\u6570\u90e8\u5206\uff09<\/li><\/ul>\n\n\n\n<p>\u8fd9\u51e0\u4e2a\u53c2\u91cf\u53d6\u503c\u7684\u9009\u62e9\uff0c\u76f4\u63a5\u5f71\u54cd\u4e86\u52a0\u5bc6\u7684\u5b89\u5168\u6027\u3002\u53c2\u91cf\u503c\u4e00\u822c\u8981\u6c42\u6ee1\u8db3\u4ee5\u4e0b\u51e0\u4e2a\u6761\u4ef6\uff1a<\/p>\n\n\n\n<p>1\u3001p \u5f53\u7136\u8d8a\u5927\u8d8a\u5b89\u5168\uff0c\u4f46\u8d8a\u5927\uff0c\u8ba1\u7b97\u901f\u5ea6\u4f1a\u53d8\u6162\uff0c200\u4f4d\u5de6\u53f3\u53ef\u4ee5\u6ee1\u8db3\u4e00\u822c\u5b89\u5168\u8981\u6c42\uff1b<\/p>\n\n\n\n<p>2\u3001p\u2260n\u00d7h\uff1b<\/p>\n\n\n\n<p>3\u3001pt\u22601 (mod n)\uff0c1\u2264t&lt;20\uff1b<\/p>\n\n\n\n<p>4\u30014a3+27b2\u22600 (mod p)\uff1b \u3000\u30005\u3001n \u4e3a\u7d20\u6570\uff1b<\/p>\n\n\n\n<p>6\u3001h\u22644\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-large-font-size\">2\u3001\u6d41\u7a0b\u56fe\uff08\u6bd4\u8f83\u5173\u952e\uff09<\/p>\n\n\n\n<p>\u5bf9\u7167\u770b\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"3787\" height=\"2372\" src=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-1024x641.png\" alt=\"\" class=\"wp-image-537\" srcset=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-1024x641.png 1024w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-300x188.png 300w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-768x481.png 768w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-1536x962.png 1536w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-2048x1283.png 2048w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/1-1568x982.png 1568w\" sizes=\"auto, (max-width: 3787px) 100vw, 3787px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"868\" src=\"http:\/\/39.107.80.187\/wp-content\/uploads\/2021\/01\/2-1024x868.png\" alt=\"\" class=\"wp-image-538\" srcset=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-1024x868.png 1024w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-300x254.png 300w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-768x651.png 768w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-1536x1302.png 1536w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-2048x1735.png 2048w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/2-1568x1329.png 1568w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-large-font-size\">3\u3001\u6e90\u7801\uff08python\uff09<\/p>\n\n\n\n<p class=\"has-medium-font-size\">SM3\uff1a\uff08hash\u652f\u6301\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from math import ceil\n\nIV = \"7380166f 4914b2b9 172442d7 da8a0600 a96f30bc 163138aa e38dee4d b0fb0e4e\"\nIV = int(IV.replace(\" \", \"\"), 16)\na = &#91;]\nfor i in range(0, 8):\n    a.append(0)\n    a&#91;i] = (IV &gt;&gt; ((7 - i) * 32)) &amp; 0xFFFFFFFF\nIV = a\n\n\ndef out_hex(list1):\n    for i in list1:\n        print(\"%08x\" % i)\n    print(\"\\n\")\n\n\ndef rotate_left(a, k):\n    k = k % 32\n    return ((a &lt;&lt; k) &amp; 0xFFFFFFFF) | ((a &amp; 0xFFFFFFFF) &gt;&gt; (32 - k))\n\n\nT_j = &#91;]\nfor i in range(0, 16):\n    T_j.append(0)\n    T_j&#91;i] = 0x79cc4519\nfor i in range(16, 64):\n    T_j.append(0)\n    T_j&#91;i] = 0x7a879d8a\n\n\ndef FF_j(X, Y, Z, j):\n    if 0 &lt;= j &lt; 16:\n        ret = X ^ Y ^ Z\n    elif 16 &lt;= j &lt; 64:\n        ret = (X &amp; Y) | (X &amp; Z) | (Y &amp; Z)\n    return ret\n\n\ndef GG_j(X, Y, Z, j):\n    if 0 &lt;= j &lt; 16:\n        ret = X ^ Y ^ Z\n    elif 16 &lt;= j &lt; 64:\n        # ret = (X | Y) &amp; ((2 ** 32 - 1 - X) | Z)\n        ret = (X &amp; Y) | ((~ X) &amp; Z)\n    return ret\n\n\ndef P_0(X):\n    return X ^ (rotate_left(X, 9)) ^ (rotate_left(X, 17))\n\n\ndef P_1(X):\n    return X ^ (rotate_left(X, 15)) ^ (rotate_left(X, 23))\n\n\ndef CF(V_i, B_i):\n    W = &#91;]\n    for i in range(16):\n        weight = 0x1000000\n        data = 0\n        for k in range(i * 4, (i + 1) * 4):\n            data = data + B_i&#91;k] * weight\n            weight = int(weight \/ 0x100)\n        W.append(data)\n\n    for j in range(16, 68):\n        W.append(0)\n        W&#91;j] = P_1(W&#91;j - 16] ^ W&#91;j - 9] ^ (rotate_left(W&#91;j - 3], 15))) ^ (rotate_left(W&#91;j - 13], 7)) ^ W&#91;j - 6]\n        str1 = \"%08x\" % W&#91;j]\n    W_1 = &#91;]\n    for j in range(0, 64):\n        W_1.append(0)\n        W_1&#91;j] = W&#91;j] ^ W&#91;j + 4]\n        str1 = \"%08x\" % W_1&#91;j]\n\n    A, B, C, D, E, F, G, H = V_i\n    \"\"\"\n    print \"00\",\n    out_hex(&#91;A, B, C, D, E, F, G, H])\n    \"\"\"\n    for j in range(0, 64):\n        SS1 = rotate_left(((rotate_left(A, 12)) + E + (rotate_left(T_j&#91;j], j))) &amp; 0xFFFFFFFF, 7)\n        SS2 = SS1 ^ (rotate_left(A, 12))\n        TT1 = (FF_j(A, B, C, j) + D + SS2 + W_1&#91;j]) &amp; 0xFFFFFFFF\n        TT2 = (GG_j(E, F, G, j) + H + SS1 + W&#91;j]) &amp; 0xFFFFFFFF\n        D = C\n        C = rotate_left(B, 9)\n        B = A\n        A = TT1\n        H = G\n        G = rotate_left(F, 19)\n        F = E\n        E = P_0(TT2)\n\n        A = A &amp; 0xFFFFFFFF\n        B = B &amp; 0xFFFFFFFF\n        C = C &amp; 0xFFFFFFFF\n        D = D &amp; 0xFFFFFFFF\n        E = E &amp; 0xFFFFFFFF\n        F = F &amp; 0xFFFFFFFF\n        G = G &amp; 0xFFFFFFFF\n        H = H &amp; 0xFFFFFFFF\n        \"\"\"\n        str1 = \"%02d\" % j\n        if str1&#91;0] == \"0\":\n            str1 = ' ' + str1&#91;1:]\n        print str1,\n        out_hex(&#91;A, B, C, D, E, F, G, H])\n        \"\"\"\n\n    V_i_1 = &#91;]\n    V_i_1.append(A ^ V_i&#91;0])\n    V_i_1.append(B ^ V_i&#91;1])\n    V_i_1.append(C ^ V_i&#91;2])\n    V_i_1.append(D ^ V_i&#91;3])\n    V_i_1.append(E ^ V_i&#91;4])\n    V_i_1.append(F ^ V_i&#91;5])\n    V_i_1.append(G ^ V_i&#91;6])\n    V_i_1.append(H ^ V_i&#91;7])\n    return V_i_1\n\n\ndef hash_msg(msg):\n    # print(msg)\n    len1 = len(msg)\n    reserve1 = len1 % 64\n    msg.append(0x80)\n    reserve1 = reserve1 + 1\n    # 56-64, add 64 byte\n    range_end = 56\n    if reserve1 &gt; range_end:\n        range_end = range_end + 64\n\n    for i in range(reserve1, range_end):\n        msg.append(0x00)\n\n    bit_length = (len1) * 8\n    bit_length_str = &#91;bit_length % 0x100]\n    for i in range(7):\n        bit_length = int(bit_length \/ 0x100)\n        bit_length_str.append(bit_length % 0x100)\n    for i in range(8):\n        msg.append(bit_length_str&#91;7 - i])\n\n    # print(msg)\n\n    group_count = round(len(msg) \/ 64)\n\n    B = &#91;]\n    for i in range(0, group_count):\n        B.append(msg&#91;i * 64:(i + 1) * 64])\n\n    V = &#91;]\n    V.append(IV)\n    for i in range(0, group_count):\n        V.append(CF(V&#91;i], B&#91;i]))\n\n    y = V&#91;i + 1]\n    result = \"\"\n    for i in y:\n        result = '%s%08x' % (result, i)\n    return result\n\n\ndef str2byte(msg):  # \u5b57\u7b26\u4e32\u8f6c\u6362\u6210byte\u6570\u7ec4\n    ml = len(msg)\n    msg_byte = &#91;]\n    msg_bytearray = msg.encode('utf-8')\n    for i in range(ml):\n        msg_byte.append(msg_bytearray&#91;i])\n    return msg_byte\n\n\ndef byte2str(msg):  # byte\u6570\u7ec4\u8f6c\u5b57\u7b26\u4e32\n    ml = len(msg)\n    str1 = b\"\"\n    for i in range(ml):\n        str1 += b'%c' % msg&#91;i]\n    return str1.decode('utf-8')\n\n\ndef hex2byte(msg):  # 16\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u6210byte\u6570\u7ec4\n    ml = len(msg)\n    if ml % 2 != 0:\n        msg = '0' + msg\n    ml = int(len(msg) \/ 2)\n    msg_byte = &#91;]\n    for i in range(ml):\n        msg_byte.append(int(msg&#91;i * 2:i * 2 + 2], 16))\n    return msg_byte\n\n\ndef byte2hex(msg):  # byte\u6570\u7ec4\u8f6c\u6362\u621016\u8fdb\u5236\u5b57\u7b26\u4e32\n    ml = len(msg)\n    hexstr = \"\"\n    for i in range(ml):\n        hexstr = hexstr + ('%02x' % msg&#91;i])\n    return hexstr\n\n\ndef Hash_sm3(msg, Hexstr=0):\n    if (Hexstr):\n        msg_byte = hex2byte(msg)\n    else:\n        msg_byte = str2byte(msg)\n    return hash_msg(msg_byte)\n\n\ndef KDF(Z, klen):  # Z\u4e3a16\u8fdb\u5236\u8868\u793a\u7684\u6bd4\u7279\u4e32\uff08str\uff09\uff0cklen\u4e3a\u5bc6\u94a5\u957f\u5ea6\uff08\u5355\u4f4dbyte\uff09\n    klen = int(klen)\n    ct = 0x00000001\n    rcnt = ceil(klen \/ 32)\n    Zin = hex2byte(Z)\n    Ha = \"\"\n    for i in range(rcnt):\n        msg = Zin + hex2byte('%08x' % ct)\n        # print(msg)\n        Ha = Ha + hash_msg(msg)\n        # print(Ha)\n        ct += 1\n    return Ha&#91;0: klen * 2]\n\n\nif __name__ == '__main__':\n    y = Hash_sm3(\"abcde\")\n    print(y)\n\n    # klen = 19\n    # print(KDF(\"57E7B63623FAE5F08CDA468E872A20AFA03DED41BF1403770E040DC83AF31A67991F2B01EBF9EFD8881F0A0493000603\", klen))\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">SM2\u4e3b\u51fd\u6570\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from random import choice\nimport SM3\n\n# \u9009\u62e9\u7d20\u57df\uff0c\u8bbe\u7f6e\u692d\u5706\u66f2\u7ebf\u53c2\u6570\nellipseN = int('8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7', 16) # g\u7684\u9636\nellipseP = int('8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3', 16)\nellipseG = '421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2'\nellipse_a = int('787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498',16)\nellipse_b = int('63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A',16)\nellipse_a_3 = (ellipse_a + 3) % ellipseP  # \u500d\u70b9\u7528\u5230\u7684\u4e2d\u95f4\u503c\nFp = 256\n\n# \u968f\u673a\u5b57\u7b26\ndef get_random_str(strlen):\n    letter = &#91;'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']\n    str = ''\n    for i in range(strlen):\n        a = choice(letter)\n        str = str + a\n    return str\n\n# \u6269\u5c55\u6b27\u51e0\u91cc\u5f97\u7b97\u6cd5\ndef exgcd(a, b):\n    old_s, s = 1, 0\n    old_t, t = 0, 1\n    old_r, r = a, b\n    if b == 0:\n        return 1, 0, a\n    else:\n        while r != 0:\n            q = old_r \/\/ r\n            old_r, r = r, old_r - q * r\n            old_s, s = s, old_s - q * s\n            old_t, t = t, old_t - q * t\n    return old_s\n\n\ndef MjrCal(Mj, mj):\n    s = exgcd(Mj, mj)\n    while s &lt; 1:\n        s += mj\n    return s\n\n# \u8ba1\u7b97&#91;k]G\ndef kG(k, point, length):\n    P = point\n    Q = point\n    k1 = bin(k)\n    start = str(k1).find('1')\n    for i in range(len(k1), start):\n        Q = point_double(Q, length)\n        if k1&#91;i] == 1:\n            Q = point_add(Q, P, length)\n    return Q\n\n\ndef point_add(P, Q, length):\n    Px = int(P&#91;:length], 16)\n    Py = int(P&#91;length:], 16)\n    Qx = int(Q&#91;:length], 16)\n    Qy = int(Q&#91;length:], 16)\n\n    lamda = (Qy - Py) * MjrCal(Qx - Px, ellipseP) % ellipseP # \u65b9\u7a0b\u521d\u59cb\u5316\n    xNew = pow(lamda, 2) - Px - Qx\n    yNew = lamda * (Px - xNew) - Py\n    xNew = xNew % ellipseP\n    yNew = yNew % ellipseP\n    xNew = hex(xNew)\n    yNew = hex(yNew)\n    return str(xNew)&#91;2:] + str(yNew)&#91;2:]\n\n\ndef point_double(point, length):\n    xPoint = int(point&#91;:length], 16)\n    yPoint = int(point&#91;length:], 16)\n    lamda = (3 * pow(xPoint, 2) + ellipse_a) * MjrCal(2 * yPoint, ellipseP) % ellipseP\n\n    xNew = pow(lamda, 2) - 2 * xPoint\n    yNew = lamda * (xPoint - xNew) - yPoint\n    xNew = xNew % ellipseP\n    yNew = yNew % ellipseP\n    xNew = hex(xNew)\n    yNew = hex(yNew)\n    return str(xNew)&#91;2:] + str(yNew)&#91;2:]\n\n\ndef encryption(M, PA, length, strHex=0):  # \u52a0\u5bc6\u51fd\u6570\uff0cM\u6d88\u606f\uff0cPA\u516c\u94a5\n    if strHex:\n        msg = M  # \u8f93\u5165\u6d88\u606f\u672c\u8eab\u662f16\u8fdb\u5236\u5b57\u7b26\u4e32\n    else:\n        msg = M.encode('utf-8')\n        msg = msg.hex()  # \u6d88\u606f\u8f6c\u5316\u4e3a16\u8fdb\u5236\u5b57\u7b26\u4e32\n    k = get_random_str(length)\n\n    C1 = kG(int(k, 16), ellipseG, length)\n    # print(len(C1))\n    # print(length)\n\n    if str(PA)&#91;:length] == '0' and str(PA)&#91;length:] == '0':\n        print(\"Infinite point!\")\n        exit(1)\n    xy = kG(int(k, 16), PA, length)\n\n    x2 = xy&#91;0:length]\n    y2 = xy&#91;length:2 * length]\n    lenMsg = len(msg)\n\n    t = SM3.KDF(xy, lenMsg \/ 2)\n\n    if int(t, 16) == 0:\n        temp = encryption(M, PA, length)\n        return temp\n    else:\n        form = '%%0%dx' % lenMsg\n        C2 = form % (int(msg, 16) ^ int(t, 16))\n\n        C3 = SM3.Hash_sm3(x2 + msg + y2, 1)\n\n        return C1 + C3 + C2\n\n\ndef decryption(C, DA, length):  # \u89e3\u5bc6\u51fd\u6570\uff0cC\u5bc6\u6587\uff0816\u8fdb\u5236\u5b57\u7b26\u4e32\uff09\uff0cDA\u79c1\u94a5\n    len_2 = 2 * length\n    len_3 = len_2 + 64\n    C1 = C&#91;0:len_2]\n\n    x = int(C1&#91;:length], 16)\n    y = int(C1&#91;length:], 16)\n    if pow(y, 2) % ellipseP != (pow(x, 3) + ellipse_a * x + ellipse_b) % ellipseP:\n        print(\"C1\u4e0d\u6ee1\u8db3\u65b9\u7a0b\")\n        exit(1)\n    if (C1&#91;:length],C1&#91;length:]) == (0,0):\n        print(\"Infinite point!\")\n        exit(1)\n    C3 = C&#91;len_2:len_3]\n    C2 = C&#91;len_3:]\n    xy = kG(int(DA, 16), C1, length)\n\n    x2 = xy&#91;0:length]\n    y2 = xy&#91;length:len_2]\n    cl = len(C2)\n\n    t = SM3.KDF(xy, cl \/ 2)\n\n    if int(t, 16) == 0:\n        return None\n    else:\n        form = '%%0%dx' % cl\n        M = form % (int(C2, 16) ^ int(t, 16))\n\n        u = SM3.Hash_sm3(x2 + M + y2, 1)\n        if u == C3:\n            return M\n        else:\n            return None\n\n\n# if __name__ == '__main__':\ndef verification(i):\n    len_para = int(Fp \/ 4)\n    # print(len_para)\n    e = get_random_str(len_para)\n    d = get_random_str(len_para)\n    k = get_random_str(len_para)\n\n    Pa = kG(int(d, 16), ellipseG, len_para)\n    print(\"Public key is :\")\n    print(Pa)\n    print(\"\\nSecret key is :\")\n    print(d)\n    with open(\"C:\\\\Users\\\\15568\\\\Desktop\\\\study plus\\\\\u5bc6\u7801\u5b9e\u9a8c\\\\e5\\\\last\\\\test_txt\\\\{}.txt\".format(i)) as f:\n        e = f.readline()\n    # e = \"you can do anything you set your mind to man \"# \u81ea\u5df1\u968f\u4fbf\u7528\u963f\u59c6\u7684\u6b4c\u8bcd\u505a\u7684\u6d88\u606f\u5185\u5bb9\n    print(\"\\nSecret is :\")\n    print(e)\n\n    C = encryption(e, Pa, len_para, 0)\n    print(\"\\nCipher text is :\")\n    print(C)\n\n    m = decryption(C, d, len_para)\n    M = bytes.fromhex(m)\n    print(\"\\nDecrypt secret is :\")\n    print(M.decode())\n\n\n\nfor i in range(1, 11):\n    print(\"\\n\\nNo.{}\".format(i))\n    verification(i)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-large-font-size\">4\u3001\u6e90\u6587\u4ef6\u4e0e\u6d4b\u8bd5<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-9aeef1bc-a9bf-4592-a078-69749f7ab360\" href=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/test_txt.7z\">test_txt<\/a><a href=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/test_txt.7z\" class=\"wp-block-file__button\" download aria-describedby=\"wp-block-file--media-9aeef1bc-a9bf-4592-a078-69749f7ab360\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-1024x440.png\" alt=\"\" class=\"wp-image-546\" width=\"577\" height=\"248\" srcset=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-1024x440.png 1024w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-300x129.png 300w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-768x330.png 768w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-1536x660.png 1536w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image-1568x674.png 1568w, http:\/\/43.142.23.155\/wp-content\/uploads\/2021\/01\/image.png 1762w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/figure>\n\n\n\n<p>\u5dee\u4e0d\u591a\u5f97\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001ECC\u7b97\u6cd5\u6982\u8ff0\uff1a 1\u3001\u7528\u6237A\u9009\u5b9a\u4e00\u6761\u9002\u5408\u52a0\u5bc6\u7684\u692d\u5706\u66f2\u7ebfEp(a,b)(\u5982:y2=x3+ax+b)\uff0c\u5e76\u53d6\u692d\u5706\u66f2\u7ebf\u4e0a\u4e00\u70b9\uff0c\u4f5c\u4e3a\u57fa\u70b9G\u3002 2\u3001\u7528\u6237A\u9009\u62e9\u4e00\u4e2a\u79c1\u6709\u5bc6\u94a5k\uff0c\u5e76\u751f\u6210\u516c\u5f00\u5bc6\u94a5\uff08\u516c\u94a5PB\uff09K=kG&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,7],"tags":[11,21],"class_list":["post-529","post","type-post","status-publish","format-standard","hentry","category-10","category-7","tag-python","tag-21"],"_links":{"self":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=529"}],"version-history":[{"count":2,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":971,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions\/971"}],"wp:attachment":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}