{"id":464768,"date":"2025-06-27T03:01:57","date_gmt":"2025-06-27T03:01:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=464768"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=464768","title":{"rendered":"<span>\u0422\u0430\u0439\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0432\u0448\u0435\u0435 \u0421\u0428\u0410 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0432\u0441\u0435\u043c\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>1.0 \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 2006 \u0433\u043e\u0434\u0443 \u0410\u041d\u0411 \u0441\u043a\u0440\u044b\u043b\u0430<strong> <\/strong>\u0432<strong> <\/strong>\u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 Dual EC DRBG <strong>\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440<\/strong>. \u0410\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u043b\u043e \u0435\u0433\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u043b\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u0443\u0442\u0435\u0447\u043a\u0438 \u0421\u043d\u043e\u0443\u0434\u0435\u043d\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0432\u043e\u0439\u043d\u044b\u0435 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 (Dual Elliptic Curve) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (RNG). \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443 \u0421\u0428\u0410 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c SSL-\u0442\u0440\u0430\u0444\u0438\u043a \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 (Green 2013)<sup>1<\/sup>.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043d\u0430\u0443\u0447\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e (SP 800-90 2006)<sup>2<\/sup>, \u0438 \u0431\u044d\u043a\u0434\u043e\u0440, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 Microsoft (Shumow &amp; Ferguson 2007)<sup>3<\/sup>.<\/p>\n<p><strong>\u041d\u0430 \u043c\u043e\u0451\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0434\u043b\u044f \u0432\u0437\u043b\u043e\u043c\u0430 28 \u0431\u0430\u0439\u0442 (\u043d\u0435 \u0431\u0438\u0442) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u044d\u043a\u0434\u043e\u0440\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 2 \u043c\u0438\u043d\u0443\u0442\u044b. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0421\u0428\u0410 \u043c\u043e\u0433\u043b\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0443\u043f\u0435\u0440\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 \u041c\u0438\u043d\u0438\u0441\u0442\u0435\u0440\u0441\u0442\u0432\u0430 \u043e\u0431\u043e\u0440\u043e\u043d\u044b.<\/strong><\/p>\n<h3>1.1 \u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u0430\u0436\u043d\u044b \u0430\u0442\u0430\u043a\u0438 \u043d\u0430 RNG<\/h3>\n<p>\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 Dual EC \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443 \u0421\u0428\u0410 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0442\u0440\u0430\u0444\u0438\u043a. \u0412\u043e\u0442 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0430\u0442\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (RNG):<\/p>\n<ol>\n<li>\n<p>\u0412 2009 \u0433\u043e\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0443\u043a\u0438 \u043d\u0435\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c RNG \u0431\u044b\u043b\u0438 \u043f\u043e\u0445\u0438\u0449\u0435\u043d\u044b \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Hacker News. (Dfranke 2009)<sup>4<\/sup><\/p>\n<\/li>\n<li>\n<p>\u0412 2013 \u0433\u043e\u0434\u0443 \u0438\u0437\u044a\u044f\u043d\u044b RNG \u0432 Android \u0431\u044b\u043b\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0430\u0442\u0430\u043a \u043d\u0430 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0438. (Goodin 2013)<sup>5<\/sup><\/p>\n<\/li>\n<\/ol>\n<h2>2.0 \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 RNG<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c48\/ebd\/691\/c48ebd691a100215f9d2cd27eef817e3.jpeg\" alt=\"Section 10.3 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 Dual EC\" title=\"Section 10.3 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 Dual EC\" width=\"1446\" height=\"1364\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c48\/ebd\/691\/c48ebd691a100215f9d2cd27eef817e3.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c48\/ebd\/691\/c48ebd691a100215f9d2cd27eef817e3.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption><strong>Section 10.3 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 Dual EC<\/strong><\/figcaption><\/div>\n<\/figure>\n<p>\u0410\u0432\u0442\u043e\u0440\u044b NIST SP 800-90 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (PRNG), \u043d\u043e \u043f\u043e\u0441\u0432\u044f\u0442\u0438\u043b\u0438 <strong>Section 10.3<\/strong>\u00a0\u0441\u0442\u0430\u0442\u044c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 Dual EC.<\/p>\n<h3>*\u0432 \u0441\u0442\u0430\u0442\u044c\u0435 Dual EC DRBG \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 Dual Elliptic Curve Deterministic Random Bit Generator.<\/h3>\n<p>Dual EC \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 NIST \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c P256 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python\u00a0<code>fastecdsa<\/code>.<\/p>\n<h3>2.1 \u0418\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 PIP<\/h3>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <code>fastecdsa<\/code>\u00a0 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b pip:<\/p>\n<pre><code class=\"powershell\">pip install 'fastecdsa&gt;=1.4.1'<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf6\/277\/933\/cf6277933c36823d1e953def0f991e86.png\" alt=\"\" title=\"\" width=\"1054\" height=\"170\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/cf6\/277\/933\/cf6277933c36823d1e953def0f991e86.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf6\/277\/933\/cf6277933c36823d1e953def0f991e86.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>2.2 \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 Dual EC<\/h3>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6e9\/8f3\/2d5\/6e98f32d530245dc90c001364d86aa06.png\" width=\"940\" height=\"1672\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6e9\/8f3\/2d5\/6e98f32d530245dc90c001364d86aa06.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6e9\/8f3\/2d5\/6e98f32d530245dc90c001364d86aa06.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 <strong><em>P<\/em><\/strong>\u00a0\u0438 <strong><em>Q<\/em><\/strong>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e RNG. \u0412\u0441\u0451 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"python\">class DualEC():     def __init__(self, seed, P, Q):         self.seed = seed # \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 RNG         self.P = P # \u041f\u0435\u0440\u0432\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 (\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440)         self.Q = Q # \u0412\u0442\u043e\u0440\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0441\u043e \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0446\u0435\u043b\u044f\u043c\u0438)<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 RNG \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (seed) \u043d\u0430 <strong><em>P<\/em><\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e seed.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 <strong><em>Q<\/em><\/strong>\u00a0\u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 X.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0443\u0441\u0435\u0447\u0451\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <strong><em>r<\/em><\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>GenerateBits<\/code>:<\/p>\n<pre><code class=\"python\">def GenerateBits(self):         t = self.seed         s = (t * self.P).x # \u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c seed \u043d\u0430 P \u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435         self.seed = s # \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435         r = (s * self.Q).x # \u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 Q \u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         return r &amp; (2**(8 * 30) - 1)  # \u0423\u0441\u0435\u043a\u0430\u0435\u043c \u0434\u043e 30 \u0431\u0430\u0439\u0442\u043e\u0432 (240 \u0431\u0438\u0442)<\/code><\/pre>\n<p>\u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 DualEC \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eca\/228\/6cd\/eca2286cd36abeb82640401c7cd394a4.jpeg\" width=\"1456\" height=\"788\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/eca\/228\/6cd\/eca2286cd36abeb82640401c7cd394a4.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eca\/228\/6cd\/eca2286cd36abeb82640401c7cd394a4.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>3.0 \u041a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0431\u044d\u043a\u0434\u043e\u0440<\/h2>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0445 \u0431\u044d\u043a\u0434\u043e\u0440, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 Dual EC \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <strong><em>Q<\/em><\/strong>.\u00a0\u0422\u043e\u0447\u043a\u0430 <strong><em>Q<\/em><\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 NIST SP 800-90 (2006), \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0430 \u0432\u0437\u044f\u043b\u0430\u0441\u044c (Schneier 2007)<sup>6<\/sup>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ba\/2b1\/dec\/2ba2b1dec489b8298bda5f3458b7c570.png\" alt=\"Q \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b NIST SP 800-90 (2006)\" title=\"Q \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b NIST SP 800-90 (2006)\" width=\"1084\" height=\"628\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/2ba\/2b1\/dec\/2ba2b1dec489b8298bda5f3458b7c570.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ba\/2b1\/dec\/2ba2b1dec489b8298bda5f3458b7c570.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>Q \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b NIST SP 800-90 (2006)<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e P \u2014 \u044d\u0442\u043e <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=true&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/a>\u00a0\u043a\u0440\u0438\u0432\u043e\u0439. \u041d\u041e&#8230; \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0451\u0442 <strong>Q<\/strong>?<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/735\/d2c\/68d\/735d2c68dd701f3e5aab7c2b10039877.jpeg\" alt=\"\u0421\u043b\u0430\u0439\u0434 4 \u0441\u0442\u0430\u0442\u044c\u0438 Shumow &amp; Ferguson (2007), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0430\u0442\u0430\u043a\u0438\" title=\"\u0421\u043b\u0430\u0439\u0434 4 \u0441\u0442\u0430\u0442\u044c\u0438 Shumow &amp; Ferguson (2007), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0430\u0442\u0430\u043a\u0438\" width=\"1456\" height=\"919\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/735\/d2c\/68d\/735d2c68dd701f3e5aab7c2b10039877.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/735\/d2c\/68d\/735d2c68dd701f3e5aab7c2b10039877.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0421\u043b\u0430\u0439\u0434 4 \u0441\u0442\u0430\u0442\u044c\u0438 Shumow &amp; Ferguson (2007), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0430\u0442\u0430\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p>Shumow &amp; Ferguson (2007) \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e <strong><em>e<\/em><\/strong>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043a\u0440\u0438\u0432\u043e\u0439:\u00a0<strong><em>Q<sup>e<\/sup>\u00a0= P.<\/em><\/strong><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0421\u0428\u0410 \u0437\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>e<\/strong>.<\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0430\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong><em>e<\/em><\/strong>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0435 <strong><em>Q<\/em><\/strong>, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432 NIST SP 800-90 (2006). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e proof of concept \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043b\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong><em>Q<\/em><\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0435\u0433\u043a\u043e \u0430\u0442\u0430\u043a\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>3.1 \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0431\u044d\u043a\u0434\u043e\u0440\u0430<\/h3>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043a\u0440\u0438\u0432\u043e\u0439 <strong><em>P, Q<\/em><\/strong>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0430\u0439\u0434\u044f <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0447\u0438\u0441\u043b\u043e<\/a>\u00a0\u0438 <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u0440\u0438\u0432\u043e\u0439<\/a>\u00a0\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def ModularInverse(a, m):     # \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 m \u043f\u0440\u043e\u0441\u0442\u043e\u0435 (\u043f\u043e \u0442\u0435\u043e\u0440\u0435\u043c\u0435 \u042d\u0439\u043b\u0435\u0440\u0430)     return pow(a, m-2, m)  def GenerateBackdoorConstants():     P = P256.G  # \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c P \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439     d = randint(2, P256.q)  # \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u043e\u043b\u0435     e = ModularInverse(d, P256.q)  # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u0443 \u0432 \u043f\u043e\u043b\u0435     Q = e * P  # \u042d\u0442\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c P256      return P, Q, d<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442:<\/p>\n<pre><code class=\"python\">seed = 0x1fc95c3714652fe2 P,Q,d = GenerateBackdoorConstants() print(\"Generated these constants \", P, Q, d) dualec = DualEC(seed, P, Q)  rngBits0 = dualec.GenerateBits() rngBits1 = dualec.GenerateBits() observed = (rngBits0 &lt;&lt; (2 * 8)) | (rngBits1 &gt;&gt; (28 * 8)) print('Observed 32 bytes:\\n{:x}'.format(observed))<\/code><\/pre>\n<h3>3.2 \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u044d\u043a\u0434\u043e\u0440\u0430<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u0430\u0448 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 Dual EC RNG. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p><code>p256_mod_sqrt<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0442\u043e\u0447\u043a\u0438 \u0432 P256.<\/p>\n<pre><code class=\"python\">def p256_mod_sqrt(c):     # \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f P256     p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff     t1 = pow(c, 2, p)     t1 = (t1 * c) % p     t2 = pow(t1, 2**2, p)     t2 = (t2 * t1) % p     t3 = pow(t2, 2**4, p)     t3 = (t3 * t2) % p     t4 = pow(t3, 2**8, p)     t4 = (t4 * t3) % p     r = pow(t4, 2**16, p)     r = (r * t4) % p     r = pow(r, 2**32, p)     r = (r * c) % p     r = pow(r, 2**96, p)     r = (r * c) % p     return pow(r, 2**94, p)<\/code><\/pre>\n<\/li>\n<li>\n<p><code>FindPointOnCurve<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439.<\/p>\n<pre><code class=\"python\">def FindPointOnCurve(x):     # \u042d\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435: y^2 = x^3-ax+b     y2 = (x * x * x) - (3 * x) + P256.b     y2 = y2 % P256.p     y = p256_mod_sqrt(y2)     return y2 == (y * y) % P256.p, y<\/code><\/pre>\n<\/li>\n<li>\n<p><code>GeneratePrediction<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0431\u044d\u043a\u0434\u043e\u0440 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430\u0448\u0438\u043c RNG.<\/p>\n<pre><code class=\"python\">def GeneratePrediction(observed, Q, d):     checkbits = observed &amp; 0xffff      for high_bits in range(2**16):         guess = (high_bits &lt;&lt; (8 * 30)) | (observed &gt;&gt; (8 * 2))         on_curve, y = FindPointOnCurve(guess)          if on_curve:             # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u044d\u043a\u0434\u043e\u0440 \u0434\u043b\u044f \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 30 \u0431\u0430\u0439\u0442             # point = Point(p256.curve, guess, y)             point = Point(guess, y, curve=P256)             s = (d * point).x             r = (s * Q).x &amp; (2**(8 * 30) - 1)              # \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0431\u0430\u0439\u0442\u0430 \u0441 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438             if checkbits == (r &gt;&gt; (8 * 28)):                 # \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 28 \u0431\u0438\u0442                 return r &amp; (2**(8 * 28) - 1)      return 0<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0431\u044d\u043a\u0434\u043e\u0440:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cca\/0a9\/946\/cca0a99469fa4796942d804e65a54057.jpeg\" width=\"1368\" height=\"938\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/cca\/0a9\/946\/cca0a99469fa4796942d804e65a54057.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cca\/0a9\/946\/cca0a99469fa4796942d804e65a54057.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f 2 \u043c\u0438\u043d\u0443\u0442\u044b. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u044d\u0442\u0438 2 \u043c\u0438\u043d\u0443\u0442\u044b 28 \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 RNG.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0432 <a href=\"https:\/\/gist.github.com\/MurageKibicho\/3530c105c5a4afccc4c144a42e76ca42\" rel=\"noopener noreferrer nofollow\">gist<\/a>.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>Green, Matthew. (2009).\u00a0<strong>The Many Flaws of Dual_EC_DRBG<\/strong>.\u00a0<a href=\"https:\/\/blog.cryptographyengineering.com\/2013\/09\/18\/the-many-flaws-of-dualecdrbg\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Barker, E., &amp; Kelsey, J. (2006).\u00a0<strong>Recommendation for Random Number Generation Using Deterministic Random Bit Generators<\/strong>. NIST.\u00a0<a href=\"https:\/\/doi.org\/10.6028\/NIST.SP.800-90A\" rel=\"noopener noreferrer nofollow\">DOI<\/a>.<\/p>\n<\/li>\n<li>\n<p>Shumow, D., &amp; Ferguson, N. (2007)<strong>. On the Possibility of a Back Door in the NIST SP800-90 Dual EC PRNG<\/strong>.\u00a0<a href=\"https:\/\/rump2007.cr.yp.to\/15-shumow.pdf\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430.<\/a><\/p>\n<\/li>\n<li>\n<p>Dfranke. (2009).\u00a0<strong>How I Hacked Hacker News<\/strong>.\u00a0<a href=\"https:\/\/news.ycombinator.com\/item?id=639976\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Goodin, Dan. (2013).\u00a0<strong>Google confirms critical Android crypto flaw used in $5,700 Bitcoin heist.\u00a0<\/strong>ArsTechnica.\u00a0<a href=\"https:\/\/arstechnica.com\/information-technology\/2013\/08\/google-confirms-critical-android-crypto-flaw-used-in-5700-bitcoin-heist\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Schneier, Bruce. (2007). The Strange Story of Dual_EC_DRBG.\u00a0<a href=\"https:\/\/www.schneier.com\/blog\/archives\/2007\/11\/the_strange_sto.html\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/919218\/\"> https:\/\/habr.com\/ru\/articles\/919218\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>1.0 \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 2006 \u0433\u043e\u0434\u0443 \u0410\u041d\u0411 \u0441\u043a\u0440\u044b\u043b\u0430<strong> <\/strong>\u0432<strong> <\/strong>\u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 Dual EC DRBG <strong>\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440<\/strong>. \u0410\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u043b\u043e \u0435\u0433\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u043b\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u0443\u0442\u0435\u0447\u043a\u0438 \u0421\u043d\u043e\u0443\u0434\u0435\u043d\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0432\u043e\u0439\u043d\u044b\u0435 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 (Dual Elliptic Curve) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (RNG). \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443 \u0421\u0428\u0410 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c SSL-\u0442\u0440\u0430\u0444\u0438\u043a \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 (Green 2013)<sup>1<\/sup>.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043d\u0430\u0443\u0447\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e (SP 800-90 2006)<sup>2<\/sup>, \u0438 \u0431\u044d\u043a\u0434\u043e\u0440, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 Microsoft (Shumow &amp; Ferguson 2007)<sup>3<\/sup>.<\/p>\n<p><strong>\u041d\u0430 \u043c\u043e\u0451\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0434\u043b\u044f \u0432\u0437\u043b\u043e\u043c\u0430 28 \u0431\u0430\u0439\u0442 (\u043d\u0435 \u0431\u0438\u0442) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u044d\u043a\u0434\u043e\u0440\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 2 \u043c\u0438\u043d\u0443\u0442\u044b. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0421\u0428\u0410 \u043c\u043e\u0433\u043b\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0443\u043f\u0435\u0440\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 \u041c\u0438\u043d\u0438\u0441\u0442\u0435\u0440\u0441\u0442\u0432\u0430 \u043e\u0431\u043e\u0440\u043e\u043d\u044b.<\/strong><\/p>\n<h3>1.1 \u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u0430\u0436\u043d\u044b \u0430\u0442\u0430\u043a\u0438 \u043d\u0430 RNG<\/h3>\n<p>\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 Dual EC \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443 \u0421\u0428\u0410 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0442\u0440\u0430\u0444\u0438\u043a. \u0412\u043e\u0442 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0430\u0442\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (RNG):<\/p>\n<ol>\n<li>\n<p>\u0412 2009 \u0433\u043e\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0443\u043a\u0438 \u043d\u0435\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c RNG \u0431\u044b\u043b\u0438 \u043f\u043e\u0445\u0438\u0449\u0435\u043d\u044b \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Hacker News. (Dfranke 2009)<sup>4<\/sup><\/p>\n<\/li>\n<li>\n<p>\u0412 2013 \u0433\u043e\u0434\u0443 \u0438\u0437\u044a\u044f\u043d\u044b RNG \u0432 Android \u0431\u044b\u043b\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0430\u0442\u0430\u043a \u043d\u0430 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0438. (Goodin 2013)<sup>5<\/sup><\/p>\n<\/li>\n<\/ol>\n<h2>2.0 \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 RNG<\/h2>\n<figure class=\"full-width\">\n<div><figcaption><strong>Section 10.3 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 Dual EC<\/strong><\/figcaption><\/div>\n<\/figure>\n<p>\u0410\u0432\u0442\u043e\u0440\u044b NIST SP 800-90 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b (PRNG), \u043d\u043e \u043f\u043e\u0441\u0432\u044f\u0442\u0438\u043b\u0438 <strong>Section 10.3<\/strong>\u00a0\u0441\u0442\u0430\u0442\u044c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 Dual EC.<\/p>\n<h3>*\u0432 \u0441\u0442\u0430\u0442\u044c\u0435 Dual EC DRBG \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 Dual Elliptic Curve Deterministic Random Bit Generator.<\/h3>\n<p>Dual EC \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 NIST \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c P256 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python\u00a0<code>fastecdsa<\/code>.<\/p>\n<h3>2.1 \u0418\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 PIP<\/h3>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <code>fastecdsa<\/code>\u00a0 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b pip:<\/p>\n<pre><code class=\"powershell\">pip install 'fastecdsa&gt;=1.4.1'<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>2.2 \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 Dual EC<\/h3>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 <strong><em>P<\/em><\/strong>\u00a0\u0438 <strong><em>Q<\/em><\/strong>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e RNG. \u0412\u0441\u0451 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"python\">class DualEC():     def __init__(self, seed, P, Q):         self.seed = seed # \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 RNG         self.P = P # \u041f\u0435\u0440\u0432\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 (\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440)         self.Q = Q # \u0412\u0442\u043e\u0440\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0441\u043e \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0446\u0435\u043b\u044f\u043c\u0438)<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 RNG \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (seed) \u043d\u0430 <strong><em>P<\/em><\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e seed.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 <strong><em>Q<\/em><\/strong>\u00a0\u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 X.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0443\u0441\u0435\u0447\u0451\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <strong><em>r<\/em><\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>GenerateBits<\/code>:<\/p>\n<pre><code class=\"python\">def GenerateBits(self):         t = self.seed         s = (t * self.P).x # \u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c seed \u043d\u0430 P \u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435         self.seed = s # \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435         r = (s * self.Q).x # \u0423\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 Q \u0438 \u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 X, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         return r &amp; (2**(8 * 30) - 1)  # \u0423\u0441\u0435\u043a\u0430\u0435\u043c \u0434\u043e 30 \u0431\u0430\u0439\u0442\u043e\u0432 (240 \u0431\u0438\u0442)<\/code><\/pre>\n<p>\u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 DualEC \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>3.0 \u041a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0431\u044d\u043a\u0434\u043e\u0440<\/h2>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0445 \u0431\u044d\u043a\u0434\u043e\u0440, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 Dual EC \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <strong><em>Q<\/em><\/strong>.\u00a0\u0422\u043e\u0447\u043a\u0430 <strong><em>Q<\/em><\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 NIST SP 800-90 (2006), \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0430 \u0432\u0437\u044f\u043b\u0430\u0441\u044c (Schneier 2007)<sup>6<\/sup>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>Q \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b NIST SP 800-90 (2006)<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e P \u2014 \u044d\u0442\u043e <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=true&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/a>\u00a0\u043a\u0440\u0438\u0432\u043e\u0439. \u041d\u041e&#8230; \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0451\u0442 <strong>Q<\/strong>?<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043b\u0430\u0439\u0434 4 \u0441\u0442\u0430\u0442\u044c\u0438 Shumow &amp; Ferguson (2007), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0430\u0442\u0430\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p>Shumow &amp; Ferguson (2007) \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e <strong><em>e<\/em><\/strong>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043a\u0440\u0438\u0432\u043e\u0439:\u00a0<strong><em>Q<sup>e<\/sup>\u00a0= P.<\/em><\/strong><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0421\u0428\u0410 \u0437\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>e<\/strong>.<\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0430\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong><em>e<\/em><\/strong>, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0435 <strong><em>Q<\/em><\/strong>, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432 NIST SP 800-90 (2006). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e proof of concept \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043b\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong><em>Q<\/em><\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0435\u0433\u043a\u043e \u0430\u0442\u0430\u043a\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>3.1 \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0431\u044d\u043a\u0434\u043e\u0440\u0430<\/h3>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043a\u0440\u0438\u0432\u043e\u0439 <strong><em>P, Q<\/em><\/strong>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0430\u0439\u0434\u044f <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0447\u0438\u0441\u043b\u043e<\/a>\u00a0\u0438 <a href=\"https:\/\/leetarxiv.substack.com\/p\/a-super-friendly-guide-to-finite-8a8?r=2at73k&amp;utm_campaign=post&amp;utm_medium=web&amp;triedRedirect=true\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u0440\u0438\u0432\u043e\u0439<\/a>\u00a0\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def ModularInverse(a, m):     # \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 m \u043f\u0440\u043e\u0441\u0442\u043e\u0435 (\u043f\u043e \u0442\u0435\u043e\u0440\u0435\u043c\u0435 \u042d\u0439\u043b\u0435\u0440\u0430)     return pow(a, m-2, m)  def GenerateBackdoorConstants():     P = P256.G  # \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c P \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439     d = randint(2, P256.q)  # \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u043e\u043b\u0435     e = ModularInverse(d, P256.q)  # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u0443 \u0432 \u043f\u043e\u043b\u0435     Q = e * P  # \u042d\u0442\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c P256      return P, Q, d<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442:<\/p>\n<pre><code class=\"python\">seed = 0x1fc95c3714652fe2 P,Q,d = GenerateBackdoorConstants() print(\"Generated these constants \", P, Q, d) dualec = DualEC(seed, P, Q)  rngBits0 = dualec.GenerateBits() rngBits1 = dualec.GenerateBits() observed = (rngBits0 &lt;&lt; (2 * 8)) | (rngBits1 &gt;&gt; (28 * 8)) print('Observed 32 bytes:\\n{:x}'.format(observed))<\/code><\/pre>\n<h3>3.2 \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u044d\u043a\u0434\u043e\u0440\u0430<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u0430\u0448 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u044d\u043a\u0434\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 Dual EC RNG. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p><code>p256_mod_sqrt<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0442\u043e\u0447\u043a\u0438 \u0432 P256.<\/p>\n<pre><code class=\"python\">def p256_mod_sqrt(c):     # \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f P256     p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff     t1 = pow(c, 2, p)     t1 = (t1 * c) % p     t2 = pow(t1, 2**2, p)     t2 = (t2 * t1) % p     t3 = pow(t2, 2**4, p)     t3 = (t3 * t2) % p     t4 = pow(t3, 2**8, p)     t4 = (t4 * t3) % p     r = pow(t4, 2**16, p)     r = (r * t4) % p     r = pow(r, 2**32, p)     r = (r * c) % p     r = pow(r, 2**96, p)     r = (r * c) % p     return pow(r, 2**94, p)<\/code><\/pre>\n<\/li>\n<li>\n<p><code>FindPointOnCurve<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439.<\/p>\n<pre><code class=\"python\">def FindPointOnCurve(x):     # \u042d\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435: y^2 = x^3-ax+b     y2 = (x * x * x) - (3 * x) + P256.b     y2 = y2 % P256.p     y = p256_mod_sqrt(y2)     return y2 == (y * y) % P256.p, y<\/code><\/pre>\n<\/li>\n<li>\n<p><code>GeneratePrediction<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0431\u044d\u043a\u0434\u043e\u0440 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430\u0448\u0438\u043c RNG.<\/p>\n<pre><code class=\"python\">def GeneratePrediction(observed, Q, d):     checkbits = observed &amp; 0xffff      for high_bits in range(2**16):         guess = (high_bits &lt;&lt; (8 * 30)) | (observed &gt;&gt; (8 * 2))         on_curve, y = FindPointOnCurve(guess)          if on_curve:             # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u044d\u043a\u0434\u043e\u0440 \u0434\u043b\u044f \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 30 \u0431\u0430\u0439\u0442             # point = Point(p256.curve, guess, y)             point = Point(guess, y, curve=P256)             s = (d * point).x             r = (s * Q).x &amp; (2**(8 * 30) - 1)              # \u0441\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0431\u0430\u0439\u0442\u0430 \u0441 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438             if checkbits == (r &gt;&gt; (8 * 28)):                 # \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 28 \u0431\u0438\u0442                 return r &amp; (2**(8 * 28) - 1)      return 0<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0431\u044d\u043a\u0434\u043e\u0440:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f 2 \u043c\u0438\u043d\u0443\u0442\u044b. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u044d\u0442\u0438 2 \u043c\u0438\u043d\u0443\u0442\u044b 28 \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 RNG.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0432 <a href=\"https:\/\/gist.github.com\/MurageKibicho\/3530c105c5a4afccc4c144a42e76ca42\" rel=\"noopener noreferrer nofollow\">gist<\/a>.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>Green, Matthew. (2009).\u00a0<strong>The Many Flaws of Dual_EC_DRBG<\/strong>.\u00a0<a href=\"https:\/\/blog.cryptographyengineering.com\/2013\/09\/18\/the-many-flaws-of-dualecdrbg\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Barker, E., &amp; Kelsey, J. (2006).\u00a0<strong>Recommendation for Random Number Generation Using Deterministic Random Bit Generators<\/strong>. NIST.\u00a0<a href=\"https:\/\/doi.org\/10.6028\/NIST.SP.800-90A\" rel=\"noopener noreferrer nofollow\">DOI<\/a>.<\/p>\n<\/li>\n<li>\n<p>Shumow, D., &amp; Ferguson, N. (2007)<strong>. On the Possibility of a Back Door in the NIST SP800-90 Dual EC PRNG<\/strong>.\u00a0<a href=\"https:\/\/rump2007.cr.yp.to\/15-shumow.pdf\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430.<\/a><\/p>\n<\/li>\n<li>\n<p>Dfranke. (2009).\u00a0<strong>How I Hacked Hacker News<\/strong>.\u00a0<a href=\"https:\/\/news.ycombinator.com\/item?id=639976\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Goodin, Dan. (2013).\u00a0<strong>Google confirms critical Android crypto flaw used in $5,700 Bitcoin heist.\u00a0<\/strong>ArsTechnica.\u00a0<a href=\"https:\/\/arstechnica.com\/information-technology\/2013\/08\/google-confirms-critical-android-crypto-flaw-used-in-5700-bitcoin-heist\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<li>\n<p>Schneier, Bruce. (2007). The Strange Story of Dual_EC_DRBG.\u00a0<a href=\"https:\/\/www.schneier.com\/blog\/archives\/2007\/11\/the_strange_sto.html\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/919218\/\"> https:\/\/habr.com\/ru\/articles\/919218\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-464768","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=464768"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/464768\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}