{"id":325366,"date":"2021-06-23T15:00:44","date_gmt":"2021-06-23T15:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325366"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325366","title":{"rendered":"\u0410\u043d\u0434\u0440\u0435\u0439 \u041a\u0430\u0440\u043f\u0430\u0442\u0438: Bitcoin \u043d\u0430 Python (\u0447\u0430\u0441\u0442\u044c 1)"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ff7\/5f1\/c25\/ff75f1c2581fd8a2c4c1a53b67a2bf10.jpg\" alt=\"image\"><\/div>\n<p>  <i>\u0410\u043d\u0434\u0440\u0435\u0439 \u041a\u0430\u0440\u043f\u0430\u0442\u0438 \u2014 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440 \u043f\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443 \u0438 Autopilot Vision \u0432 Tesla.<\/i> <\/p>\n<p>  \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d \u2014 \u043a\u043b\u0430\u0441\u0441\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 open source \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0444\u0442\u0430 \u0434\u043e open source + state. \u042d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0430\u0445; \u041c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u043e \u0438 \u0431\u0435\u0437 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0421\u0435\u043c\u0435\u043d\u0430 \u044d\u0442\u043e\u0439 \u0440\u0435\u0432\u043e\u043b\u044e\u0446\u0438\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0430\u043b\u0438\u0441\u044c \u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e \u0432\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0418 \u0432 \u0434\u0443\u0445\u0435 \u00ab\u0442\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u044f \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u00bb, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430 \u0441 \u043d\u0443\u043b\u044f?<\/p>\n<p>  \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0446\u0438\u0444\u0440\u043e\u0432\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Python, \u0441 \u043d\u0443\u043b\u044f \u0438 \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0431\u0438\u0442\u043a\u043e\u0439\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c.<\/p>\n<p>  (\u043a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u0432\u0430\u0441 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e <a href=\"https:\/\/github.com\/karpathy\/cryptos\/blob\/main\/blog.ipynb\" rel=\"nofollow noopener noreferrer\">jupyter notebook<\/a>, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442).<\/p>\n<h3>\u0428\u0430\u0433 1: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0440\u0438\u043f\u0442\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u0443\u044e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447\u0435\u0439: \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439. \u0411\u0438\u0442\u043a\u043e\u0439\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445 (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Elliptic-curve_cryptography\" rel=\"nofollow noopener noreferrer\">Elliptic-\u0421urve \u0421ryptography<\/a>, ECC) \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 RSA, \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439. \u042f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0437\u0434\u0435\u0441\u044c \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 ECC, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u0441\u0447\u0438\u0442\u0430\u044e <a href=\"https:\/\/andrea.corbellini.name\/2015\/05\/17\/elliptic-curve-cryptography-a-gentle-introduction\/\" rel=\"nofollow noopener noreferrer\">\u0441\u0435\u0440\u0438\u044e \u043f\u043e\u0441\u0442\u043e\u0432 \u0432 \u0431\u043b\u043e\u0433\u0435 \u0410\u043d\u0434\u0440\u0435\u0430 \u041a\u043e\u0440\u0431\u0435\u043b\u043b\u0438\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c<\/a>. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u0441\u0442\u044b.<br \/>  <a name=\"habracut\"><\/a><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fk\/6c\/ec\/fk6cecf1igh3ghmda-tqwmqefpu.jpeg\" alt=\"image\" align=\"left\">\u0418\u0442\u0430\u043a, \u0431\u0438\u0442\u043a\u043e\u0439\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0440\u0438\u0432\u0443\u044e <a href=\"https:\/\/en.bitcoin.it\/wiki\/Secp256k1\" rel=\"nofollow noopener noreferrer\">secp256k1<\/a>. \u041a\u0430\u043a \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u044f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u2014 \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0440\u0438\u0432\u044b\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c, \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b, \u043c\u0438\u043d\u0443\u0441\u044b \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. NIST \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043b\u044e\u0434\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, secp256k1), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0431\u044d\u043a\u0434\u043e\u0440\u044b. \u041a\u0430\u043a \u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e, \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u0440\u0438\u0432\u0430\u044f \u2014 \u044d\u0442\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e 3 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430:<\/p>\n<pre><code class=\"python\">from __future__ import annotations # PEP 563: Postponed Evaluation of Annotations from dataclasses import dataclass # https:\/\/docs.python.org\/3\/library\/dataclasses.html I like these a lot  @dataclass class Curve:     &quot;&quot;&quot;     Elliptic Curve over the field of integers modulo a prime.     Points on the curve satisfy y^2 = x^3 + a*x + b (mod p).     &quot;&quot;&quot;     p: int # the prime modulus of the finite field     a: int     b: int  # secp256k1 uses a = 0, b = 7, so we're dealing with the curve y^2 = x^3 + 7 (mod p) bitcoin_curve = Curve(     p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F,     a = 0x0000000000000000000000000000000000000000000000000000000000000000, # a = 0     b = 0x0000000000000000000000000000000000000000000000000000000000000007, # b = 7 )<\/code><\/pre>\n<p>  \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u043a\u0440\u0438\u0432\u043e\u0439 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u043e\u0447\u043a\u0443 Generator, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u00ab\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439\u00bb \u0432 \u0446\u0438\u043a\u043b\u0435 \u043a\u0440\u0438\u0432\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u00ab\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0431\u043b\u0443\u0436\u0434\u0430\u043d\u0438\u044f\u00bb \u043f\u043e \u043a\u0440\u0438\u0432\u043e\u0439. \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e \u043e\u0431\u0449\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430:<\/p>\n<pre><code class=\"python\">@dataclass class Point:     &quot;&quot;&quot; An integer point (x,y) on a Curve &quot;&quot;&quot;     curve: Curve     x: int     y: int  G = Point(     bitcoin_curve,     x = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,     y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8, )  # we can verify that the generator point is indeed on the curve, i.e. y^2 = x^3 + 7 (mod p) print(&quot;Generator IS on the curve: &quot;, (G.y**2 - G.x**3 - 7) % bitcoin_curve.p == 0)  # some other totally random point will of course not be on the curve, _MOST_ likely import random random.seed(1337) x = random.randrange(0, bitcoin_curve.p) y = random.randrange(0, bitcoin_curve.p) print(&quot;Totally random point is not: &quot;, (y**2 - x**3 - 7) % bitcoin_curve.p == 0)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Generator IS on the curve:  True Totally random point is not:  False<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 G, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u00bb, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c, \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 (x, y) \u0432 \u0446\u0438\u043a\u043b\u0435 \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0440\u0438\u0432\u043e\u0439. \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0437\u043e\u0432\u0443 Generator:<\/p>\n<pre><code class=\"python\">@dataclass class Generator:     &quot;&quot;&quot;     A generator over a curve: an initial point and the (pre-computed) order     &quot;&quot;&quot;     G: Point     # a generator point on the curve     n: int       # the order of the generating point, so 0*G = n*G = INF  bitcoin_gen = Generator(     G = G,     # the order of G is known and can be mathematically derived     n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141, )<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u0440\u0438\u0432\u044b\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c\u0438 \u0432 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0435. \u042d\u0442\u043e \u0441\u043a\u043e\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447. \u0417\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 (\u0438\u043b\u0438 \u00ab\u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447\u00bb, \u043a\u0430\u043a \u044f \u0431\u0443\u0434\u0443 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c) \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044e 1 &lt;= key &lt;n (\u043d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e n \u2014 \u044d\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a G):<\/p>\n<pre><code class=\"python\"># secret_key = random.randrange(1, bitcoin_gen.n) # this is how you _would_ do it secret_key = int.from_bytes(b'Andrej is cool :P', 'big') # this is how I will do it for reproducibility assert 1 &lt;= secret_key &lt; bitcoin_gen.n print(secret_key)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">22265090479312778178772228083027296664144<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0430\u0448 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u2014 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043a\u0440\u043e\u043c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043d\u043e \u043b\u044e\u0431\u043e\u0439, \u043a\u0442\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0432\u043b\u0430\u0434\u0435\u0435\u0442\u0435 \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u043d\u0438\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u043e\u0432. \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430, \u2014 \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u00ab\u043f\u0430\u0440\u043e\u043b\u044c\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u0448\u0443 \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043c\u0430\u043b\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0410\u043d\u0434\u0440\u0435\u0439 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0432\u043e\u0439 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u0430\u043a \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0432\u044b\u0448\u0435, \u043a\u043e\u0448\u0435\u043b\u0435\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u044d\u0442\u0438\u043c \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u0430\u043b\u0430\u043d\u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u043e\u0432 :). <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447, \u0438 \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435. \u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u2014 \u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u043d\u0430 \u043a\u0440\u0438\u0432\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043a \u0441\u0430\u043c\u043e\u0439 \u0441\u0435\u0431\u0435 secret_key \u0440\u0430\u0437. \u0442.\u0435. \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c: public_key = G + G + G + (\u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430) + G = secret_key * G. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u0431\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 &#8216;+&#8217; (\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c) \u0438 &#8216;*&#8217; (\u0440\u0430\u0437\u044b, \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c) \u0437\u0434\u0435\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0431\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0441 \u0442\u043e\u043b\u043a\u0443. \u0421\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c, \u043d\u043e \u0442\u043e\u0447\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 G \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 (x, y), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0430 \u043a\u0440\u0438\u0432\u043e\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 (x, y), \u0441\u043d\u043e\u0432\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430 \u043a\u0440\u0438\u0432\u043e\u0439. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0421\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439. \u0423 \u043d\u0435\u0433\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f (\u0441\u043c. \u043f\u0440\u043e \u0431\u043b\u043e\u0433 \u0410\u043d\u0434\u0440\u0435\u0430 \u0432\u044b\u0448\u0435), \u043d\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:<\/p>\n<pre><code class=\"python\">INF = Point(None, None, None) # special point at &quot;infinity&quot;, kind of like a zero  def extended_euclidean_algorithm(a, b):     &quot;&quot;&quot;     Returns (gcd, x, y) s.t. a * x + b * y == gcd     This function implements the extended Euclidean     algorithm and runs in O(log b) in the worst case,     taken from Wikipedia.     &quot;&quot;&quot;     old_r, r = a, b     old_s, s = 1, 0     old_t, t = 0, 1     while r != 0:         quotient = old_r \/\/ r         old_r, r = r, old_r - quotient * r         old_s, s = s, old_s - quotient * s         old_t, t = t, old_t - quotient * t     return old_r, old_s, old_t  def inv(n, p):     &quot;&quot;&quot; returns modular multiplicate inverse m s.t. (n * m) % p == 1 &quot;&quot;&quot;     gcd, x, y = extended_euclidean_algorithm(n, p) # pylint: disable=unused-variable     return x % p  def elliptic_curve_addition(self, other: Point) -&gt; Point:     # handle special case of P + 0 = 0 + P = 0     if self == INF:         return other     if other == INF:         return self     # handle special case of P + (-P) = 0     if self.x == other.x and self.y != other.y:         return INF     # compute the &quot;slope&quot;     if self.x == other.x: # (self.y = other.y is guaranteed too per above check)         m = (3 * self.x**2 + self.curve.a) * inv(2 * self.y, self.curve.p)     else:         m = (self.y - other.y) * inv(self.x - other.x, self.curve.p)     # compute the new point     rx = (m**2 - self.x - other.x) % self.curve.p     ry = (-(m*(rx - self.x) + self.y)) % self.curve.p     return Point(self.curve, rx, ry)  Point.__add__ = elliptic_curve_addition # monkey patch addition into the Point class<\/code><\/pre>\n<p>  \u042f \u043f\u0440\u0438\u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0443\u0433\u0430\u044e\u0449\u0438\u043c, \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e \u0437\u0430\u043d\u044f\u043b\u043e \u0443 \u043c\u0435\u043d\u044f \u0434\u043e\u0431\u0440\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0434\u043d\u044f. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u00ab\/\u00bb, \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e <code>inv<\/code>. \u041d\u043e \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0439\/\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c (x, y) \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e p, \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0441\u044e\u0434\u0443 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 (\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445, \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445) \u043f\u0430\u0440 \u043a\u043b\u044e\u0447\u0435\u0439:<\/p>\n<pre><code class=\"python\"># if our secret key was the integer 1, then our public key would just be G: sk = 1 pk = G print(f&quot; secret key: {sk}\\n public key: {(pk.x, pk.y)}&quot;) print(&quot;Verify the public key is on the curve: &quot;, (pk.y**2 - pk.x**3 - 7) % bitcoin_curve.p == 0) # if it was 2, the public key is G + G: sk = 2 pk = G + G print(f&quot; secret key: {sk}\\n public key: {(pk.x, pk.y)}&quot;) print(&quot;Verify the public key is on the curve: &quot;, (pk.y**2 - pk.x**3 - 7) % bitcoin_curve.p == 0) # etc.: sk = 3 pk = G + G + G print(f&quot; secret key: {sk}\\n public key: {(pk.x, pk.y)}&quot;) print(&quot;Verify the public key is on the curve: &quot;, (pk.y**2 - pk.x**3 - 7) % bitcoin_curve.p == 0)<\/code><\/pre>\n<p>   <\/p>\n<pre><code class=\"python\">secret key: 1  public key: (55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424) Verify the public key is on the curve:  True  secret key: 2  public key: (89565891926547004231252920425935692360644145829622209833684329913297188986597, 12158399299693830322967808612713398636155367887041628176798871954788371653930) Verify the public key is on the curve:  True  secret key: 3  public key: (112711660439710606056748659173929673102114977341539408544630613555209775888121, 25583027980570883691656905877401976406448868254816295069919888960541586679410) Verify the public key is on the curve:  True<\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440 \u043a\u043b\u044e\u0447\u0435\u0439, \u043d\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0431\u044b\u043b \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043d\u0430\u0448\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434, \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c G \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u00ab\u0443\u0434\u0432\u043e\u0438\u0442\u044c \u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c\u00bb (double and add), \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432\u044b\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0432\u043e\u0442 \u043e\u043d\u043e:<\/p>\n<pre><code class=\"python\">def double_and_add(self, k: int) -&gt; Point:     assert isinstance(k, int) and k &gt;= 0     result = INF     append = self     while k:         if k &amp; 1:             result += append         append += append         k &gt;&gt;= 1     return result  # monkey patch double and add into the Point class for convenience Point.__rmul__ = double_and_add  # &quot;verify&quot; correctness print(G == 1*G) print(G + G == 2*G) print(G + G + G == 3*G)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">True True True<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\"># efficiently calculate our actual public key! public_key = secret_key * G print(f&quot;x: {public_key.x}\\ny: {public_key.y}&quot;) print(&quot;Verify the public key is on the curve: &quot;, (public_key.y**2 - public_key.x**3 - 7) % bitcoin_curve.p == 0)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">x: 83998262154709529558614902604110599582969848537757180553516367057821848015989 y: 37676469766173670826348691885774454391218658108212372128812329274086400588247 Verify the public key is on the curve:  True<\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439\/\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0430\u0448\u0443 \u043a\u0440\u0438\u043f\u0442\u043e\u0438\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0430. \u0410\u0434\u0440\u0435\u0441 \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0430 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0430\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u0438 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443). \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0411\u0438\u0442\u043a\u043e\u0439\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0435\u0437\u0434\u0435\u0441\u0443\u0449\u0438\u0439 SHA-256, \u0430 \u0442\u0430\u043a\u0436\u0435 RIPEMD-160. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438 \u0438\u0433\u0440\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 <code>hashlib<\/code> Python, \u043d\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e, \u0442\u0430\u043a \u0447\u0442\u043e<code> import hashlib<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0436\u0443\u043b\u044c\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c. \u0418\u0442\u0430\u043a, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SHA256, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Python \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 (\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u043c <a href=\"https:\/\/nvlpubs.nist.gov\/nistpubs\/FIPS\/NIST.FIPS.180-4.pdf\" rel=\"nofollow noopener noreferrer\">NIST FIPS PUB 180-4<\/a>:<\/p>\n<pre><code class=\"python\">def gen_sha256_with_variable_scope_protector_to_not_pollute_global_namespace():      &quot;&quot;&quot;     SHA256 implementation.      Follows the FIPS PUB 180-4 description for calculating SHA-256 hash function     https:\/\/nvlpubs.nist.gov\/nistpubs\/FIPS\/NIST.FIPS.180-4.pdf      Noone in their right mind should use this for any serious reason. This was written     purely for educational purposes.     &quot;&quot;&quot;      import math     from itertools import count, islice      # -----------------------------------------------------------------------------     # SHA-256 Functions, defined in Section 4      def rotr(x, n, size=32):         return (x &gt;&gt; n) | (x &lt;&lt; size - n) &amp; (2**size - 1)      def shr(x, n):         return x &gt;&gt; n      def sig0(x):         return rotr(x, 7) ^ rotr(x, 18) ^ shr(x, 3)      def sig1(x):         return rotr(x, 17) ^ rotr(x, 19) ^ shr(x, 10)      def capsig0(x):         return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22)      def capsig1(x):         return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25)      def ch(x, y, z):         return (x &amp; y)^ (~x &amp; z)      def maj(x, y, z):         return (x &amp; y) ^ (x &amp; z) ^ (y &amp; z)      def b2i(b):         return int.from_bytes(b, 'big')      def i2b(i):         return i.to_bytes(4, 'big')      # -----------------------------------------------------------------------------     # SHA-256 Constants      def is_prime(n):         return not any(f for f in range(2,int(math.sqrt(n))+1) if n%f == 0)      def first_n_primes(n):         return islice(filter(is_prime, count(start=2)), n)      def frac_bin(f, n=32):         &quot;&quot;&quot; return the first n bits of fractional part of float f &quot;&quot;&quot;         f -= math.floor(f) # get only the fractional part         f *= 2**n # shift left         f = int(f) # truncate the rest of the fractional content         return f      def genK():         &quot;&quot;&quot;         Follows Section 4.2.2 to generate K          The first 32 bits of the fractional parts of the cube roots of the first         64 prime numbers:          428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5         d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174         e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da         983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967         27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85         a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070         19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3         748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2         &quot;&quot;&quot;         return [frac_bin(p ** (1\/3.0)) for p in first_n_primes(64)]      def genH():         &quot;&quot;&quot;         Follows Section 5.3.3 to generate the initial hash value H^0          The first 32 bits of the fractional parts of the square roots of         the first 8 prime numbers.          6a09e667 bb67ae85 3c6ef372 a54ff53a 9b05688c 510e527f 1f83d9ab 5be0cd19         &quot;&quot;&quot;         return [frac_bin(p ** (1\/2.0)) for p in first_n_primes(8)]      # -----------------------------------------------------------------------------      def pad(b):         &quot;&quot;&quot; Follows Section 5.1: Padding the message &quot;&quot;&quot;         b = bytearray(b) # convert to a mutable equivalent         l = len(b) * 8 # note: len returns number of bytes not bits          # append but &quot;1&quot; to the end of the message         b.append(0b10000000) # appending 10000000 in binary (=128 in decimal)          # follow by k zero bits, where k is the smallest non-negative solution to         # l + 1 + k = 448 mod 512         # i.e. pad with zeros until we reach 448 (mod 512)         while (len(b)*8) % 512 != 448:             b.append(0x00)          # the last 64-bit block is the length l of the original message         # expressed in binary (big endian)         b.extend(l.to_bytes(8, 'big'))          return b      def sha256(b: bytes) -&gt; bytes:          # Section 4.2         K = genK()          # Section 5: Preprocessing         # Section 5.1: Pad the message         b = pad(b)         # Section 5.2: Separate the message into blocks of 512 bits (64 bytes)         blocks = [b[i:i+64] for i in range(0, len(b), 64)]          # for each message block M^1 ... M^N         H = genH() # Section 5.3          # Section 6         for M in blocks: # each block is a 64-entry array of 8-bit bytes              # 1. Prepare the message schedule, a 64-entry array of 32-bit words             W = []             for t in range(64):                 if t &lt;= 15:                     # the first 16 words are just a copy of the block                     W.append(bytes(M[t*4:t*4+4]))                 else:                     term1 = sig1(b2i(W[t-2]))                     term2 = b2i(W[t-7])                     term3 = sig0(b2i(W[t-15]))                     term4 = b2i(W[t-16])                     total = (term1 + term2 + term3 + term4) % 2**32                     W.append(i2b(total))              # 2. Initialize the 8 working variables a,b,c,d,e,f,g,h with prev hash value             a, b, c, d, e, f, g, h = H              # 3.             for t in range(64):                 T1 = (h + capsig1(e) + ch(e, f, g) + K[t] + b2i(W[t])) % 2**32                 T2 = (capsig0(a) + maj(a, b, c)) % 2**32                 h = g                 g = f                 f = e                 e = (d + T1) % 2**32                 d = c                 c = b                 b = a                 a = (T1 + T2) % 2**32              # 4. Compute the i-th intermediate hash value H^i             delta = [a, b, c, d, e, f, g, h]             H = [(i1 + i2) % 2**32 for i1, i2 in zip(H, delta)]          return b''.join(i2b(i) for i in H)      return sha256  sha256 = gen_sha256_with_variable_scope_protector_to_not_pollute_global_namespace() print(&quot;verify empty hash:&quot;, sha256(b'').hex()) # should be e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 print(sha256(b'here is a random bytes message, cool right?').hex()) print(&quot;number of bytes in a sha256 digest: &quot;, len(sha256(b'')))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">verify empty hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 69b9779edaa573a509999cbae415d3408c30544bad09727a1d64eff353c95b89 number of bytes in a sha256 digest:  32<\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e, \u043f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0445\u043e\u0442\u0435\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043d\u0443\u043b\u044f \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u044e\u0434\u0430, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044f \u0445\u043e\u0447\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e. SHA256 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u044d\u0442\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u0432 \u0442\u043e, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0439 \u00ab\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043c\u0438\u043a\u0441\u0435\u0440\u00bb, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 3, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u044f \u043d\u0435 \u0432 \u0441\u0438\u043b\u0430\u0445 \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 SHA256. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0445\u0430\u043e\u0438\u0447\u043d\u043e-\u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0438\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0440\u0438 \u0442\u043e\u043c \u0441\u043a\u0440\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0440\u0430\u0442\u0438\u043c\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u043e\u043c.<\/p>\n<p>  \u0411\u0438\u0442\u043a\u043e\u0439\u043d \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 SHA256 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u044d\u0448\u0435\u0439, \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u044d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 Proof of Work \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430, \u0446\u0435\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0431\u043b\u043e\u043a \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u044d\u0442\u043e \u043d\u0435 \u0445\u0435\u0448\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 (\u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442\u044b \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0438\u0441\u043b\u043e). \u0427\u0442\u043e \u0438\u0437-\u0437\u0430 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 SHA256 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0440\u0443\u0442 \u0444\u043e\u0440\u0441\u0430, \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0441\u0435 ASIC, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0439\u043d\u0438\u043d\u0433\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435, close-to-the-metal \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0430\u0434\u0440\u0435\u0441, \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f RIPEMD160, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0448\u0435\u043b \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u043b:<\/p>\n<pre><code class=\"python\">def gen_ripemd160_with_variable_scope_protector_to_not_pollute_global_namespace():      import sys     import struct      # -----------------------------------------------------------------------------     # public interface      def ripemd160(b: bytes) -&gt; bytes:         &quot;&quot;&quot; simple wrapper for a simpler API to this hash function, just bytes to bytes &quot;&quot;&quot;         ctx = RMDContext()         RMD160Update(ctx, b, len(b))         digest = RMD160Final(ctx)         return digest      # -----------------------------------------------------------------------------      class RMDContext:         def __init__(self):             self.state = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0] # uint32             self.count = 0 # uint64             self.buffer = [0]*64 # uchar      def RMD160Update(ctx, inp, inplen):         have = int((ctx.count \/\/ 8) % 64)         inplen = int(inplen)         need = 64 - have         ctx.count += 8 * inplen         off = 0         if inplen &gt;= need:             if have:                 for i in range(need):                     ctx.buffer[have+i] = inp[i]                 RMD160Transform(ctx.state, ctx.buffer)                 off = need                 have = 0             while off + 64 &lt;= inplen:                 RMD160Transform(ctx.state, inp[off:])                 off += 64         if off &lt; inplen:             for i in range(inplen - off):                 ctx.buffer[have+i] = inp[off+i]      def RMD160Final(ctx):         size = struct.pack(&quot;&lt;Q&quot;, ctx.count)         padlen = 64 - ((ctx.count \/\/ 8) % 64)         if padlen &lt; 1 + 8:             padlen += 64         RMD160Update(ctx, PADDING, padlen-8)         RMD160Update(ctx, size, 8)         return struct.pack(&quot;&lt;5L&quot;, *ctx.state)      # -----------------------------------------------------------------------------      K0 = 0x00000000     K1 = 0x5A827999     K2 = 0x6ED9EBA1     K3 = 0x8F1BBCDC     K4 = 0xA953FD4E     KK0 = 0x50A28BE6     KK1 = 0x5C4DD124     KK2 = 0x6D703EF3     KK3 = 0x7A6D76E9     KK4 = 0x00000000      PADDING = [0x80] + [0]*63      def ROL(n, x):         return ((x &lt;&lt; n) &amp; 0xffffffff) | (x &gt;&gt; (32 - n))      def F0(x, y, z):         return x ^ y ^ z      def F1(x, y, z):         return (x &amp; y) | (((~x) % 0x100000000) &amp; z)      def F2(x, y, z):         return (x | ((~y) % 0x100000000)) ^ z      def F3(x, y, z):         return (x &amp; z) | (((~z) % 0x100000000) &amp; y)      def F4(x, y, z):         return x ^ (y | ((~z) % 0x100000000))      def R(a, b, c, d, e, Fj, Kj, sj, rj, X):         a = ROL(sj, (a + Fj(b, c, d) + X[rj] + Kj) % 0x100000000) + e         c = ROL(10, c)         return a % 0x100000000, c      def RMD160Transform(state, block): #uint32 state[5], uchar block[64]          x = [0]*16         assert sys.byteorder == 'little', &quot;Only little endian is supported atm for RIPEMD160&quot;         x = struct.unpack('&lt;16L', bytes(block[0:64]))          a = state[0]         b = state[1]         c = state[2]         d = state[3]         e = state[4]          #\/* Round 1 *\/         a, c = R(a, b, c, d, e, F0, K0, 11,  0, x)         e, b = R(e, a, b, c, d, F0, K0, 14,  1, x)         d, a = R(d, e, a, b, c, F0, K0, 15,  2, x)         c, e = R(c, d, e, a, b, F0, K0, 12,  3, x)         b, d = R(b, c, d, e, a, F0, K0,  5,  4, x)         a, c = R(a, b, c, d, e, F0, K0,  8,  5, x)         e, b = R(e, a, b, c, d, F0, K0,  7,  6, x)         d, a = R(d, e, a, b, c, F0, K0,  9,  7, x)         c, e = R(c, d, e, a, b, F0, K0, 11,  8, x)         b, d = R(b, c, d, e, a, F0, K0, 13,  9, x)         a, c = R(a, b, c, d, e, F0, K0, 14, 10, x)         e, b = R(e, a, b, c, d, F0, K0, 15, 11, x)         d, a = R(d, e, a, b, c, F0, K0,  6, 12, x)         c, e = R(c, d, e, a, b, F0, K0,  7, 13, x)         b, d = R(b, c, d, e, a, F0, K0,  9, 14, x)         a, c = R(a, b, c, d, e, F0, K0,  8, 15, x) #\/* #15 *\/         #\/* Round 2 *\/         e, b = R(e, a, b, c, d, F1, K1,  7,  7, x)         d, a = R(d, e, a, b, c, F1, K1,  6,  4, x)         c, e = R(c, d, e, a, b, F1, K1,  8, 13, x)         b, d = R(b, c, d, e, a, F1, K1, 13,  1, x)         a, c = R(a, b, c, d, e, F1, K1, 11, 10, x)         e, b = R(e, a, b, c, d, F1, K1,  9,  6, x)         d, a = R(d, e, a, b, c, F1, K1,  7, 15, x)         c, e = R(c, d, e, a, b, F1, K1, 15,  3, x)         b, d = R(b, c, d, e, a, F1, K1,  7, 12, x)         a, c = R(a, b, c, d, e, F1, K1, 12,  0, x)         e, b = R(e, a, b, c, d, F1, K1, 15,  9, x)         d, a = R(d, e, a, b, c, F1, K1,  9,  5, x)         c, e = R(c, d, e, a, b, F1, K1, 11,  2, x)         b, d = R(b, c, d, e, a, F1, K1,  7, 14, x)         a, c = R(a, b, c, d, e, F1, K1, 13, 11, x)         e, b = R(e, a, b, c, d, F1, K1, 12,  8, x) #\/* #31 *\/         #\/* Round 3 *\/         d, a = R(d, e, a, b, c, F2, K2, 11,  3, x)         c, e = R(c, d, e, a, b, F2, K2, 13, 10, x)         b, d = R(b, c, d, e, a, F2, K2,  6, 14, x)         a, c = R(a, b, c, d, e, F2, K2,  7,  4, x)         e, b = R(e, a, b, c, d, F2, K2, 14,  9, x)         d, a = R(d, e, a, b, c, F2, K2,  9, 15, x)         c, e = R(c, d, e, a, b, F2, K2, 13,  8, x)         b, d = R(b, c, d, e, a, F2, K2, 15,  1, x)         a, c = R(a, b, c, d, e, F2, K2, 14,  2, x)         e, b = R(e, a, b, c, d, F2, K2,  8,  7, x)         d, a = R(d, e, a, b, c, F2, K2, 13,  0, x)         c, e = R(c, d, e, a, b, F2, K2,  6,  6, x)         b, d = R(b, c, d, e, a, F2, K2,  5, 13, x)         a, c = R(a, b, c, d, e, F2, K2, 12, 11, x)         e, b = R(e, a, b, c, d, F2, K2,  7,  5, x)         d, a = R(d, e, a, b, c, F2, K2,  5, 12, x) #\/* #47 *\/         #\/* Round 4 *\/         c, e = R(c, d, e, a, b, F3, K3, 11,  1, x)         b, d = R(b, c, d, e, a, F3, K3, 12,  9, x)         a, c = R(a, b, c, d, e, F3, K3, 14, 11, x)         e, b = R(e, a, b, c, d, F3, K3, 15, 10, x)         d, a = R(d, e, a, b, c, F3, K3, 14,  0, x)         c, e = R(c, d, e, a, b, F3, K3, 15,  8, x)         b, d = R(b, c, d, e, a, F3, K3,  9, 12, x)         a, c = R(a, b, c, d, e, F3, K3,  8,  4, x)         e, b = R(e, a, b, c, d, F3, K3,  9, 13, x)         d, a = R(d, e, a, b, c, F3, K3, 14,  3, x)         c, e = R(c, d, e, a, b, F3, K3,  5,  7, x)         b, d = R(b, c, d, e, a, F3, K3,  6, 15, x)         a, c = R(a, b, c, d, e, F3, K3,  8, 14, x)         e, b = R(e, a, b, c, d, F3, K3,  6,  5, x)         d, a = R(d, e, a, b, c, F3, K3,  5,  6, x)         c, e = R(c, d, e, a, b, F3, K3, 12,  2, x) #\/* #63 *\/         #\/* Round 5 *\/         b, d = R(b, c, d, e, a, F4, K4,  9,  4, x)         a, c = R(a, b, c, d, e, F4, K4, 15,  0, x)         e, b = R(e, a, b, c, d, F4, K4,  5,  5, x)         d, a = R(d, e, a, b, c, F4, K4, 11,  9, x)         c, e = R(c, d, e, a, b, F4, K4,  6,  7, x)         b, d = R(b, c, d, e, a, F4, K4,  8, 12, x)         a, c = R(a, b, c, d, e, F4, K4, 13,  2, x)         e, b = R(e, a, b, c, d, F4, K4, 12, 10, x)         d, a = R(d, e, a, b, c, F4, K4,  5, 14, x)         c, e = R(c, d, e, a, b, F4, K4, 12,  1, x)         b, d = R(b, c, d, e, a, F4, K4, 13,  3, x)         a, c = R(a, b, c, d, e, F4, K4, 14,  8, x)         e, b = R(e, a, b, c, d, F4, K4, 11, 11, x)         d, a = R(d, e, a, b, c, F4, K4,  8,  6, x)         c, e = R(c, d, e, a, b, F4, K4,  5, 15, x)         b, d = R(b, c, d, e, a, F4, K4,  6, 13, x) #\/* #79 *\/          aa = a         bb = b         cc = c         dd = d         ee = e          a = state[0]         b = state[1]         c = state[2]         d = state[3]         e = state[4]          #\/* Parallel round 1 *\/         a, c = R(a, b, c, d, e, F4, KK0,  8,  5, x)         e, b = R(e, a, b, c, d, F4, KK0,  9, 14, x)         d, a = R(d, e, a, b, c, F4, KK0,  9,  7, x)         c, e = R(c, d, e, a, b, F4, KK0, 11,  0, x)         b, d = R(b, c, d, e, a, F4, KK0, 13,  9, x)         a, c = R(a, b, c, d, e, F4, KK0, 15,  2, x)         e, b = R(e, a, b, c, d, F4, KK0, 15, 11, x)         d, a = R(d, e, a, b, c, F4, KK0,  5,  4, x)         c, e = R(c, d, e, a, b, F4, KK0,  7, 13, x)         b, d = R(b, c, d, e, a, F4, KK0,  7,  6, x)         a, c = R(a, b, c, d, e, F4, KK0,  8, 15, x)         e, b = R(e, a, b, c, d, F4, KK0, 11,  8, x)         d, a = R(d, e, a, b, c, F4, KK0, 14,  1, x)         c, e = R(c, d, e, a, b, F4, KK0, 14, 10, x)         b, d = R(b, c, d, e, a, F4, KK0, 12,  3, x)         a, c = R(a, b, c, d, e, F4, KK0,  6, 12, x) #\/* #15 *\/         #\/* Parallel round 2 *\/         e, b = R(e, a, b, c, d, F3, KK1,  9,  6, x)         d, a = R(d, e, a, b, c, F3, KK1, 13, 11, x)         c, e = R(c, d, e, a, b, F3, KK1, 15,  3, x)         b, d = R(b, c, d, e, a, F3, KK1,  7,  7, x)         a, c = R(a, b, c, d, e, F3, KK1, 12,  0, x)         e, b = R(e, a, b, c, d, F3, KK1,  8, 13, x)         d, a = R(d, e, a, b, c, F3, KK1,  9,  5, x)         c, e = R(c, d, e, a, b, F3, KK1, 11, 10, x)         b, d = R(b, c, d, e, a, F3, KK1,  7, 14, x)         a, c = R(a, b, c, d, e, F3, KK1,  7, 15, x)         e, b = R(e, a, b, c, d, F3, KK1, 12,  8, x)         d, a = R(d, e, a, b, c, F3, KK1,  7, 12, x)         c, e = R(c, d, e, a, b, F3, KK1,  6,  4, x)         b, d = R(b, c, d, e, a, F3, KK1, 15,  9, x)         a, c = R(a, b, c, d, e, F3, KK1, 13,  1, x)         e, b = R(e, a, b, c, d, F3, KK1, 11,  2, x) #\/* #31 *\/         #\/* Parallel round 3 *\/         d, a = R(d, e, a, b, c, F2, KK2,  9, 15, x)         c, e = R(c, d, e, a, b, F2, KK2,  7,  5, x)         b, d = R(b, c, d, e, a, F2, KK2, 15,  1, x)         a, c = R(a, b, c, d, e, F2, KK2, 11,  3, x)         e, b = R(e, a, b, c, d, F2, KK2,  8,  7, x)         d, a = R(d, e, a, b, c, F2, KK2,  6, 14, x)         c, e = R(c, d, e, a, b, F2, KK2,  6,  6, x)         b, d = R(b, c, d, e, a, F2, KK2, 14,  9, x)         a, c = R(a, b, c, d, e, F2, KK2, 12, 11, x)         e, b = R(e, a, b, c, d, F2, KK2, 13,  8, x)         d, a = R(d, e, a, b, c, F2, KK2,  5, 12, x)         c, e = R(c, d, e, a, b, F2, KK2, 14,  2, x)         b, d = R(b, c, d, e, a, F2, KK2, 13, 10, x)         a, c = R(a, b, c, d, e, F2, KK2, 13,  0, x)         e, b = R(e, a, b, c, d, F2, KK2,  7,  4, x)         d, a = R(d, e, a, b, c, F2, KK2,  5, 13, x) #\/* #47 *\/         #\/* Parallel round 4 *\/         c, e = R(c, d, e, a, b, F1, KK3, 15,  8, x)         b, d = R(b, c, d, e, a, F1, KK3,  5,  6, x)         a, c = R(a, b, c, d, e, F1, KK3,  8,  4, x)         e, b = R(e, a, b, c, d, F1, KK3, 11,  1, x)         d, a = R(d, e, a, b, c, F1, KK3, 14,  3, x)         c, e = R(c, d, e, a, b, F1, KK3, 14, 11, x)         b, d = R(b, c, d, e, a, F1, KK3,  6, 15, x)         a, c = R(a, b, c, d, e, F1, KK3, 14,  0, x)         e, b = R(e, a, b, c, d, F1, KK3,  6,  5, x)         d, a = R(d, e, a, b, c, F1, KK3,  9, 12, x)         c, e = R(c, d, e, a, b, F1, KK3, 12,  2, x)         b, d = R(b, c, d, e, a, F1, KK3,  9, 13, x)         a, c = R(a, b, c, d, e, F1, KK3, 12,  9, x)         e, b = R(e, a, b, c, d, F1, KK3,  5,  7, x)         d, a = R(d, e, a, b, c, F1, KK3, 15, 10, x)         c, e = R(c, d, e, a, b, F1, KK3,  8, 14, x) #\/* #63 *\/         #\/* Parallel round 5 *\/         b, d = R(b, c, d, e, a, F0, KK4,  8, 12, x)         a, c = R(a, b, c, d, e, F0, KK4,  5, 15, x)         e, b = R(e, a, b, c, d, F0, KK4, 12, 10, x)         d, a = R(d, e, a, b, c, F0, KK4,  9,  4, x)         c, e = R(c, d, e, a, b, F0, KK4, 12,  1, x)         b, d = R(b, c, d, e, a, F0, KK4,  5,  5, x)         a, c = R(a, b, c, d, e, F0, KK4, 14,  8, x)         e, b = R(e, a, b, c, d, F0, KK4,  6,  7, x)         d, a = R(d, e, a, b, c, F0, KK4,  8,  6, x)         c, e = R(c, d, e, a, b, F0, KK4, 13,  2, x)         b, d = R(b, c, d, e, a, F0, KK4,  6, 13, x)         a, c = R(a, b, c, d, e, F0, KK4,  5, 14, x)         e, b = R(e, a, b, c, d, F0, KK4, 15,  0, x)         d, a = R(d, e, a, b, c, F0, KK4, 13,  3, x)         c, e = R(c, d, e, a, b, F0, KK4, 11,  9, x)         b, d = R(b, c, d, e, a, F0, KK4, 11, 11, x) #\/* #79 *\/          t = (state[1] + cc + d) % 0x100000000         state[1] = (state[2] + dd + e) % 0x100000000         state[2] = (state[3] + ee + a) % 0x100000000         state[3] = (state[4] + aa + b) % 0x100000000         state[4] = (state[0] + bb + c) % 0x100000000         state[0] = t % 0x100000000      return ripemd160  ripemd160 = gen_ripemd160_with_variable_scope_protector_to_not_pollute_global_namespace() print(ripemd160(b'hello this is a test').hex()) print(&quot;number of bytes in a RIPEMD-160 digest: &quot;, len(ripemd160(b'')))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">f51960af7dd4813a587ab26388ddab3b28d1f7b4 number of bytes in a RIPEMD-160 digest:  20<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 SHA256 \u0432\u044b\u0448\u0435, \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0438\u0434\u0438\u043c \u00ab\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0435\u043c\u0431\u043b\u0435\u0440\u00bb \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0443\u0442\u043e.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0430\u0434\u0440\u0435\u0441. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441 <code>Point<\/code> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>PublicKey<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0430 \u043a\u0440\u0438\u0432\u043e\u0439, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\/\u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0432 \u0431\u0430\u0439\u0442\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 \u0431\u0438\u0442\u043a\u043e\u0439\u043d.<\/p>\n<pre><code class=\"python\">class PublicKey(Point):     &quot;&quot;&quot;     The public key is just a Point on a Curve, but has some additional specific     encoding \/ decoding functionality that this class implements.     &quot;&quot;&quot;      @classmethod     def from_point(cls, pt: Point):         &quot;&quot;&quot; promote a Point to be a PublicKey &quot;&quot;&quot;         return cls(pt.curve, pt.x, pt.y)      def encode(self, compressed, hash160=False):         &quot;&quot;&quot; return the SEC bytes encoding of the public key Point &quot;&quot;&quot;         # calculate the bytes         if compressed:             # (x,y) is very redundant. Because y^2 = x^3 + 7,             # we can just encode x, and then y = +\/- sqrt(x^3 + 7),             # so we need one more bit to encode whether it was the + or the -             # but because this is modular arithmetic there is no +\/-, instead             # it can be shown that one y will always be even and the other odd.             prefix = b'\\x02' if self.y % 2 == 0 else b'\\x03'             pkb = prefix + self.x.to_bytes(32, 'big')         else:             pkb = b'\\x04' + self.x.to_bytes(32, 'big') + self.y.to_bytes(32, 'big')         # hash if desired         return ripemd160(sha256(pkb)) if hash160 else pkb      def address(self, net: str, compressed: bool) -&gt; str:         &quot;&quot;&quot; return the associated bitcoin address for this public key as string &quot;&quot;&quot;         # encode the public key into bytes and hash to get the payload         pkb_hash = self.encode(compressed=compressed, hash160=True)         # add version byte (0x00 for Main Network, or 0x6f for Test Network)         version = {'main': b'\\x00', 'test': b'\\x6f'}         ver_pkb_hash = version[net] + pkb_hash         # calculate the checksum         checksum = sha256(sha256(ver_pkb_hash))[:4]         # append to form the full 25-byte binary Bitcoin Address         byte_address = ver_pkb_hash + checksum         # finally b58 encode the result         b58check_address = b58encode(byte_address)         return b58check_address<\/code><\/pre>\n<p>  \u041c\u044b \u0435\u0449\u0435 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u044b \u0438\u0441\u043f\u044b\u0442\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f b58 <code>b58encode<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0430\u044f \u0434\u043b\u044f \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0430\u0439\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 58 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0435\u043c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u00abO\u00bb \u0438 \u00ab0\u00bb, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0445 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442\u044c \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435. \u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430\u0448 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0430\u0434\u0440\u0435\u0441 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 25 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435), \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0431\u0430\u0437\u0443 58 \u0438 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b. \u041d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 25 \u0431\u0430\u0439\u0442\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 1 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 (\u00ab\u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u0435\u0442\u044c\u00bb \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430 \u2014 \u044d\u0442\u043e <code>b'\\x00'<\/code>, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u00ab\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u0441\u0435\u0442\u044c\u00bb \u0411\u0438\u0442\u043a\u043e\u0439\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>b'\\x6f'<\/code>), \u0437\u0430\u0442\u0435\u043c 20 \u0431\u0430\u0439\u0442\u043e\u0432 \u0438\u0437 \u0445\u044d\u0448\u0430. \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, 4 \u0431\u0430\u0439\u0442\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u044b\u0434\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e <code>1\u20131\/2** 4 = 93,75%<\/code> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u0432\u0435\u043b \u0441\u0432\u043e\u0439 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0430\u0434\u0440\u0435\u0441 \u0432 \u043a\u0430\u043a\u043e\u0435-\u043b\u0438\u0431\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435. \u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 b58:<\/p>\n<pre><code class=\"python\"># base58 encoding \/ decoding utilities # reference: https:\/\/en.bitcoin.it\/wiki\/Base58Check_encoding  alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'  def b58encode(b: bytes) -&gt; str:     assert len(b) == 25 # version is 1 byte, pkb_hash 20 bytes, checksum 4 bytes     n = int.from_bytes(b, 'big')     chars = []     while n:         n, i = divmod(n, 58)         chars.append(alphabet[i])     # special case handle the leading 0 bytes... \u00af\\_(\u30c4)_\/\u00af     num_leading_zeros = len(b) - len(b.lstrip(b'\\x00'))     res = num_leading_zeros * alphabet[0] + ''.join(reversed(chars))     return res<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u043d\u0430\u0448 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0430\u0434\u0440\u0435\u0441:<\/p>\n<pre><code class=\"python\"># we are going to use the develop's Bitcoin parallel universe &quot;test net&quot; for this demo, so net='test' address = PublicKey.from_point(public_key).address(net='test', compressed=True) print(address)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">mnNcaVkC35ezZSgvn8fhXEa9QTHSUtPfzQ<\/code><\/pre>\n<p>  \u041a\u0440\u0443\u0442\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0435\u0431-\u0441\u0430\u0439\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u0431\u043b\u043e\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f: <a href=\"https:\/\/www.blockchain.com\/btc-testnet\/address\/mnNcaVkC35ezZSgvn8fhXEa9QTHSUtPfzQ\" rel=\"nofollow noopener noreferrer\">www.blockchain.com\/btc-testnet\/address\/mnNcaVkC35ezZSgvn8fhXEa9QTHSUtPfzQ<\/a>. \u041a \u043a\u043e\u043d\u0446\u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043d\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u043b, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u00ab\u0447\u0438\u0441\u0442\u044b\u0439\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0441\u0435\u0442\u0438, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u044b\u0448\u0435. \u042d\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0431\u044b\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u00ab\u0410\u043d\u0434\u0440\u0435\u0439\u00bb \u0441 \u043f\u043b\u043e\u0445\u0438\u043c \u0447\u0443\u0432\u0441\u0442\u0432\u043e\u043c \u044e\u043c\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u0438\u043b\u0441\u044f \u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u043e\u043c. \u041d\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0443\u043f\u0435\u0440\u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u044e\u0434\u044c\u043c\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443, \u0440\u0430\u0432\u043d\u043e\u043c\u0443 1, \u0433\u0434\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u2014 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u0447\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 :). \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code class=\"python\">lol_secret_key = 1 lol_public_key = lol_secret_key * G lol_address = PublicKey.from_point(lol_public_key).address(net='test', compressed=True) lol_address<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">'mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r'<\/code><\/pre>\n<p>  \u0412 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043a\u0430\u043a \u043c\u044b <a href=\"https:\/\/www.blockchain.com\/btc-testnet\/address\/mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r\" rel=\"nofollow noopener noreferrer\">\u0432\u0438\u0434\u0438\u043c<\/a> \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u043e\u0432, \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u043b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 1812 \u0440\u0430\u0437 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0431\u0430\u043b\u0430\u043d\u0441 0,00 BTC. \u042d\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0443 \u043d\u0435\u0433\u043e \u0431\u044b\u043b \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0431\u0430\u043b\u0430\u043d\u0441 (\u0432 \u043d\u0430\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0435\u0439 \u0441 \u044f\u0437\u044b\u043a\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c), \u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0433 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0437\u043d\u0430\u0435\u0442 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 (1) \u0438 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0445 \u0442\u0440\u0430\u0442\u044f\u0442. \u041c\u044b \u0441\u043a\u043e\u0440\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>\u0427\u0430\u0441\u0442\u044c 1: \u0418\u0442\u043e\u0433\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442<\/h3>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 (\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430), \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043c, \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u043f\u0440\u044b\u0433\u0430\u044f \u043f\u043e \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0430\u0434\u0440\u0435\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438, \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u0434\u0432\u0435 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 (SHA256 \u0438 RIPEMD160). \u0412\u043e\u0442 \u0442\u0440\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430, \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0445 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">print(&quot;Our first Bitcoin identity:&quot;) print(&quot;1. secret key: &quot;, secret_key) print(&quot;2. public key: &quot;, (public_key.x, public_key.y)) print(&quot;3. Bitcoin address: &quot;, address)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Our first Bitcoin identity: 1. secret key:  22265090479312778178772228083027296664144 2. public key:  (83998262154709529558614902604110599582969848537757180553516367057821848015989, 37676469766173670826348691885774454391218658108212372128812329274086400588247) 3. Bitcoin address:  mnNcaVkC35ezZSgvn8fhXEa9QTHSUtPfzQ<\/code><\/pre>\n<p>  <i>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442<\/i><\/p>\n<ul>\n<li>Part 2: Obtaining seed funds + intro to Bitcoin under the hood<\/li>\n<li>Part 3: Crafting our transaction<\/li>\n<\/ul>\n<\/div>\n<p> \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\/post\/564256\/\"> https:\/\/habr.com\/ru\/post\/564256\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ff7\/5f1\/c25\/ff75f1c2581fd8a2c4c1a53b67a2bf10.jpg\" alt=\"image\"><\/div>\n<p>  <i>\u0410\u043d\u0434\u0440\u0435\u0439 \u041a\u0430\u0440\u043f\u0430\u0442\u0438 \u2014 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440 \u043f\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443 \u0438 Autopilot Vision \u0432 Tesla.<\/i> <\/p>\n<p>  \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d \u2014 \u043a\u043b\u0430\u0441\u0441\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 open source \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0444\u0442\u0430 \u0434\u043e open source + state. \u042d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0430\u0445; \u041c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u043e \u0438 \u0431\u0435\u0437 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0421\u0435\u043c\u0435\u043d\u0430 \u044d\u0442\u043e\u0439 \u0440\u0435\u0432\u043e\u043b\u044e\u0446\u0438\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u0447\u0430\u043b\u0438\u0441\u044c \u0441 \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e \u0432\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0418 \u0432 \u0434\u0443\u0445\u0435 \u00ab\u0442\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u044f \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u00bb, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043a\u043e\u0439\u043d\u0430 \u0441 \u043d\u0443\u043b\u044f?<\/p>\n<p>  \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0446\u0438\u0444\u0440\u043e\u0432\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442\u043a\u043e\u0439\u043d-\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Python, \u0441 \u043d\u0443\u043b\u044f \u0438 \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0431\u0438\u0442\u043a\u043e\u0439\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c.<\/p>\n<p>  (\u043a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u0432\u0430\u0441 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e <a href=\"https:\/\/github.com\/karpathy\/cryptos\/blob\/main\/blog.ipynb\" rel=\"nofollow noopener noreferrer\">jupyter notebook<\/a>, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442).<\/p>\n<h3>\u0428\u0430\u0433 1: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0440\u0438\u043f\u0442\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u0443\u044e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447\u0435\u0439: \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439. \u0411\u0438\u0442\u043a\u043e\u0439\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043d\u0430 \u044d\u043b\u043b\u0438\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445 (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Elliptic-curve_cryptography\" rel=\"nofollow noopener noreferrer\">Elliptic-\u0421urve \u0421ryptography<\/a>, ECC) \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 RSA, \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439. \u042f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0437\u0434\u0435\u0441\u044c \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 ECC, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u0441\u0447\u0438\u0442\u0430\u044e <a href=\"https:\/\/andrea.corbellini.name\/2015\/05\/17\/elliptic-curve-cryptography-a-gentle-introduction\/\" rel=\"nofollow noopener noreferrer\">\u0441\u0435\u0440\u0438\u044e \u043f\u043e\u0441\u0442\u043e\u0432 \u0432 \u0431\u043b\u043e\u0433\u0435 \u0410\u043d\u0434\u0440\u0435\u0430 \u041a\u043e\u0440\u0431\u0435\u043b\u043b\u0438\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c<\/a>. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u0441\u0442\u044b.  <\/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-325366","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325366","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=325366"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325366\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}