{"id":20673021,"url":"https://github.com/relph1119/tinyblockchains","last_synced_at":"2026-03-01T02:03:01.270Z","repository":{"id":106543839,"uuid":"184222037","full_name":"Relph1119/TinyBlockChains","owner":"Relph1119","description":"《从零开始自己动手写区块链》代码和笔记","archived":false,"fork":false,"pushed_at":"2019-06-14T05:34:31.000Z","size":890,"stargazers_count":38,"open_issues_count":0,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T20:45:40.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Relph1119.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-30T08:23:24.000Z","updated_at":"2025-03-13T01:58:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"5db4b153-b451-4ef4-816a-201fd6aa2b83","html_url":"https://github.com/Relph1119/TinyBlockChains","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Relph1119/TinyBlockChains","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relph1119%2FTinyBlockChains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relph1119%2FTinyBlockChains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relph1119%2FTinyBlockChains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relph1119%2FTinyBlockChains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Relph1119","download_url":"https://codeload.github.com/Relph1119/TinyBlockChains/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relph1119%2FTinyBlockChains/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017381,"owners_count":26086052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T20:39:48.994Z","updated_at":"2025-10-14T00:09:05.614Z","avatar_url":"https://github.com/Relph1119.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 记录自己学习《从零开始自己动手写区块链》这本书的全部过程 #\n\n本书上传的所有代码都是可以运行的，在此附上本书源码的github地址：\n[https://github.com/YaoyaoBae/simchain](https://github.com/YaoyaoBae/simchain)\u003cbr/\u003e\n在此向本书作者表示感谢\n\n## 运行环境 ##\nPython 版本：3.7.2  \nPyCharm 版本：PyCharm 2018.3.5 (Professional Edition)\n\n## 代码结构 ##\n\u003cpre\u003e\nnote\n|    +----ch2.3_SimchainIntroduction.ipynb----------------Simchain简介\n|    +----ch3.2.1_HashAlgorithm.ipynb---------------------哈希算法\n|    +----ch3.2.2_PrivateKeyPublicKeyAddress.ipynb--------私钥、公钥和地址\n|    +----ch3.2.3_EllipticCurve.ipynb---------------------椭圆曲线\n|    +----ch3.2.5_EllipticCurveCryptography.ipynb---------椭圆曲线加密\n|    +----ch3.2.6_Wallet.ipynb----------------------------钱包\n|    +----ch3.4.2_BasicLattice.ipynb----------------------格基础知识\n|    +----ch3.4.3_LatticeProblem.ipynb--------------------格问题\n|    +----ch3.4.6_GGH\u0026Lyubashevshy.ipynb------------------GGH数字签名\n|    +----ch4.1_CreateTransactions.ipynb------------------创建交易\n|    +----ch4.3_VerifyingTransactions.ipynb---------------验证交易\n|    +----ch4.5_ProgrammableTransactions.ipynb------------可编程的交易\n|    +----ch5.1_Block.ipynb-------------------------------区块\n|    +----ch5.2_BlockChain.ipynb--------------------------区块链\n|    +----ch6.1_ConsensusAlgorithm.ipynb------------------常见的共识算法\n|    +----ch6.2_CreateCandidateBlocks.ipynb------------创建候选区块、挖矿、打包、广播\n|    +----ch6.4_VerifyBlock.ipynb----------------------验证区块\n|    +----ch6.6_AddtoBlockChain.ipynb---------------------添加到区块链\nsrc\n\u003c/pre\u003e\n\n## 运行截图 ##\n区块链运行的截图，全部都来自于[模拟器的GUI游戏](https://github.com/YaoyaoBae/Blockchain-simulator-exe)，非常感谢作者创建了这个模拟器，能更好的理解区块链原理。\n1. 点击开始按钮  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/begin.png)\n2. 创建随机交易  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/random.png)  \n在共识之前都是未确认的交易    \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/unconfirmed.png)\n3. 创建共识  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/mining.png)  \n我们可以看到交易在达成共识后得到确认。获胜者得到了奖励和交易费。  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/reached.png)\n\n4. 执行定向交易  \n我们可以让英雄与他人交易。但最多只有1000分。  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/one.png)  \n之后，我们只能看到网络中的一个交易，达成共识后将交易写入区块链。  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/onedone.png)  \n5个随机交易将持续进行并达成共识。  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/five.png)\n\n5. 添加新的节点  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/add.png)  \n![image](https://github.com/Relph1119/TinyBlockChains/blob/master/pics/last.png)\n\n## 个人总结 ##\n\u0026emsp;\u0026emsp;看完整本书前后用了3个月，由于本书的代码示例采用的都是Python Shell，于是笔者把代码示例都搬到了Jupyter Notebook上，书中有一些代码漏写了，在本次学习中都已经补写了，需要区块链入门的小伙伴可以参考。  \n\u0026emsp;\u0026emsp;本书主要讲了区块链相关的原理，主要还是创币和、发币、交易、加密和共识。作为区块链入门，还是一本很不错的书，书中的代码示例还是很详细的，比一般的介绍区块链的书籍要好很多。笔者敲完了书中所有的示例代码，对于区块链的原理有了一定的理解。  \n\u0026emsp;\u0026emsp;上传的git代码中note文件夹下面是笔者在练习时的Jupyter NoteBook笔记，里面包括了书中所有的Python Shell的代码示例，由于生成区块链网络的随机性，生成的网络和书中不一样，但是并不影响本书的代码练习和原理理解。\n\n## 区块链原理总结 ##\n\u0026emsp;\u0026emsp;系统由对等节点构成P2P网络，为交易和区块的传播提供基本条件，交易和区块又由节点创建和负责传播。区块链系统采用的是分布式存储，为了保证所有节点数据的一致性，需要一个分布式共识过程。UTXO是指用户资产存储在交易的未消费输出但愿你中，加密算法对UTXO进行锁定，应用梅克尔树根哈希值对交易数据进行归纳。采用工作量证明算法进行对“挖矿”的奖励。分布式存储的区块链要保证数据一直，必须要达成全网共识，采用工作量证明的共识算法。  \n\u0026emsp;\u0026emsp;健康的区块链系统必须具备四要素：P2P网络、连续的交易、足够多的存储节点，以及足够多的共识节点。当P2P网络搭建完成后，节点发起的交易通过泛洪路由协议在网络中传播，其他节点对照自己的区块链数据独立验证交易的有效性，有效交易被存放在各自的交易池中，然后打包之后，将区块广播到网络中，其他节点对照自己的区块链数据独立验证区块的有效性，如果有效且符合添加原则，则会扩展自己的链条，从而保证了全网数据的一致。以上就是区块链系统的工作过程。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelph1119%2Ftinyblockchains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelph1119%2Ftinyblockchains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelph1119%2Ftinyblockchains/lists"}