wip: 区块链基础
This commit is contained in:
parent
f9652d5e1e
commit
97a0a6bd46
|
|
@ -9,8 +9,12 @@ tag:
|
|||
- 专业课程
|
||||
---
|
||||
|
||||
# 区块链基础
|
||||
## 2024-2025学年下学期
|
||||
|
||||
!!! warning "施工中"
|
||||
### 叫啥来着
|
||||
|
||||
本目录包含区块链基础课程的相关资料。
|
||||
#### 教学资料
|
||||
|
||||
- [南京大学慕课](https://drive.vanillaaaa.org/SharedCourses/软件工程学院/区块链基础/2024-2025学年下学期/课件/南京大学慕课)
|
||||
- [蚂蚁区块链](https://drive.vanillaaaa.org/SharedCourses/软件工程学院/区块链基础/2024-2025学年下学期/课件/蚂蚁区块链)
|
||||
- [作业](https://drive.vanillaaaa.org/SharedCourses/软件工程学院/区块链基础/2024-2025学年下学期/作业)
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
def calculate_total_bitcoin():
|
||||
initial_reward = 50.0
|
||||
halving_interval = 210000
|
||||
total_btc = 0.0
|
||||
current_reward = initial_reward
|
||||
halving_count = 0
|
||||
|
||||
while current_reward >= 1e-8:
|
||||
period_coins = halving_interval * current_reward
|
||||
total_btc += period_coins
|
||||
halving_count += 1
|
||||
current_reward /= 2
|
||||
|
||||
print(f"\n最终减半次数: {halving_count}次")
|
||||
print(f"总发行量: {total_btc:,.8f} BTC ≈ {round(total_btc)} BTC")
|
||||
|
||||
def estimate_mining_end_year():
|
||||
start_year = 2009
|
||||
blocks_per_halving = 210000
|
||||
block_time_minutes = 10
|
||||
|
||||
minutes_per_year = 365 * 24 * 60
|
||||
blocks_per_year = minutes_per_year / block_time_minutes
|
||||
years_per_halving = blocks_per_halving / blocks_per_year
|
||||
|
||||
halving_count = 0
|
||||
|
||||
initial_reward = 50.0
|
||||
while initial_reward / (2 ** halving_count) >= 1e-8:
|
||||
halving_count += 1
|
||||
|
||||
end_year = start_year + years_per_halving * halving_count
|
||||
print(f"\n预计全部挖完年份: {end_year:.0f}年")
|
||||
|
||||
|
||||
calculate_total_bitcoin()
|
||||
estimate_mining_end_year()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
|
|
@ -1,4 +0,0 @@
|
|||
\relax
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}比特币的总量上限计算}{1}{}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}比特币的终止时间计算}{1}{}\protected@file@percent }
|
||||
\gdef \@abspage@last{1}
|
||||
|
|
@ -1,442 +0,0 @@
|
|||
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex 2024.12.12) 18 MAR 2025 13:31
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
file:line:error style messages enabled.
|
||||
%&-line parsing enabled.
|
||||
**c:/Users/USER/Desktop/大三下/区块链基础/作业/第一次作业/10225101408_朱炎_Excercise01
|
||||
(c:/Users/USER/Desktop/大三下/区块链基础/作业/第一次作业/10225101408_朱炎_Excercise01.tex
|
||||
LaTeX2e <2023-11-01> patch level 1
|
||||
L3 programming layer <2024-02-20>
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/base/article.cls
|
||||
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/base/size10.clo
|
||||
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
|
||||
)
|
||||
\c@part=\count184
|
||||
\c@section=\count185
|
||||
\c@subsection=\count186
|
||||
\c@subsubsection=\count187
|
||||
\c@paragraph=\count188
|
||||
\c@subparagraph=\count189
|
||||
\c@figure=\count190
|
||||
\c@table=\count191
|
||||
\abovecaptionskip=\skip48
|
||||
\belowcaptionskip=\skip49
|
||||
\bibindent=\dimen140
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/amsmath/amsmath.sty
|
||||
Package: amsmath 2023/05/13 v2.17o AMS math features
|
||||
\@mathmargin=\skip50
|
||||
|
||||
For additional information on amsmath, use the `?' option.
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/amsmath/amstext.sty
|
||||
Package: amstext 2021/08/26 v2.01 AMS text
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/amsmath/amsgen.sty
|
||||
File: amsgen.sty 1999/11/30 v2.0 generic functions
|
||||
\@emptytoks=\toks17
|
||||
\ex@=\dimen141
|
||||
)) (e:/texlive/2024/texmf-dist/tex/latex/amsmath/amsbsy.sty
|
||||
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
|
||||
\pmbraise@=\dimen142
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/amsmath/amsopn.sty
|
||||
Package: amsopn 2022/04/08 v2.04 operator names
|
||||
)
|
||||
\inf@bad=\count192
|
||||
LaTeX Info: Redefining \frac on input line 234.
|
||||
\uproot@=\count193
|
||||
\leftroot@=\count194
|
||||
LaTeX Info: Redefining \overline on input line 399.
|
||||
LaTeX Info: Redefining \colon on input line 410.
|
||||
\classnum@=\count195
|
||||
\DOTSCASE@=\count196
|
||||
LaTeX Info: Redefining \ldots on input line 496.
|
||||
LaTeX Info: Redefining \dots on input line 499.
|
||||
LaTeX Info: Redefining \cdots on input line 620.
|
||||
\Mathstrutbox@=\box51
|
||||
\strutbox@=\box52
|
||||
LaTeX Info: Redefining \big on input line 722.
|
||||
LaTeX Info: Redefining \Big on input line 723.
|
||||
LaTeX Info: Redefining \bigg on input line 724.
|
||||
LaTeX Info: Redefining \Bigg on input line 725.
|
||||
\big@size=\dimen143
|
||||
LaTeX Font Info: Redeclaring font encoding OML on input line 743.
|
||||
LaTeX Font Info: Redeclaring font encoding OMS on input line 744.
|
||||
\macc@depth=\count197
|
||||
LaTeX Info: Redefining \bmod on input line 905.
|
||||
LaTeX Info: Redefining \pmod on input line 910.
|
||||
LaTeX Info: Redefining \smash on input line 940.
|
||||
LaTeX Info: Redefining \relbar on input line 970.
|
||||
LaTeX Info: Redefining \Relbar on input line 971.
|
||||
\c@MaxMatrixCols=\count198
|
||||
\dotsspace@=\muskip16
|
||||
\c@parentequation=\count199
|
||||
\dspbrk@lvl=\count266
|
||||
\tag@help=\toks18
|
||||
\row@=\count267
|
||||
\column@=\count268
|
||||
\maxfields@=\count269
|
||||
\andhelp@=\toks19
|
||||
\eqnshift@=\dimen144
|
||||
\alignsep@=\dimen145
|
||||
\tagshift@=\dimen146
|
||||
\tagwidth@=\dimen147
|
||||
\totwidth@=\dimen148
|
||||
\lineht@=\dimen149
|
||||
\@envbody=\toks20
|
||||
\multlinegap=\skip51
|
||||
\multlinetaggap=\skip52
|
||||
\mathdisplay@stack=\toks21
|
||||
LaTeX Info: Redefining \[ on input line 2953.
|
||||
LaTeX Info: Redefining \] on input line 2954.
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/amsfonts/amssymb.sty
|
||||
Package: amssymb 2013/01/14 v3.01 AMS font symbols
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/amsfonts/amsfonts.sty
|
||||
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
|
||||
\symAMSa=\mathgroup4
|
||||
\symAMSb=\mathgroup5
|
||||
LaTeX Font Info: Redeclaring math symbol \hbar on input line 98.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold'
|
||||
(Font) U/euf/m/n --> U/euf/b/n on input line 106.
|
||||
)) (e:/texlive/2024/texmf-dist/tex/latex/amscls/amsthm.sty
|
||||
Package: amsthm 2020/05/29 v2.20.6
|
||||
\thm@style=\toks22
|
||||
\thm@bodyfont=\toks23
|
||||
\thm@headfont=\toks24
|
||||
\thm@notefont=\toks25
|
||||
\thm@headpunct=\toks26
|
||||
\thm@preskip=\skip53
|
||||
\thm@postskip=\skip54
|
||||
\thm@headsep=\skip55
|
||||
\dth@everypar=\toks27
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/geometry/geometry.sty
|
||||
Package: geometry 2020/01/02 v5.9 Page Geometry
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/graphics/keyval.sty
|
||||
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
|
||||
\KV@toks@=\toks28
|
||||
) (e:/texlive/2024/texmf-dist/tex/generic/iftex/ifvtex.sty
|
||||
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
|
||||
(e:/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty
|
||||
Package: iftex 2022/02/03 v1.0f TeX engine tests
|
||||
))
|
||||
\Gm@cnth=\count270
|
||||
\Gm@cntv=\count271
|
||||
\c@Gm@tempcnt=\count272
|
||||
\Gm@bindingoffset=\dimen150
|
||||
\Gm@wd@mp=\dimen151
|
||||
\Gm@odd@mp=\dimen152
|
||||
\Gm@even@mp=\dimen153
|
||||
\Gm@layoutwidth=\dimen154
|
||||
\Gm@layoutheight=\dimen155
|
||||
\Gm@layouthoffset=\dimen156
|
||||
\Gm@layoutvoffset=\dimen157
|
||||
\Gm@dimlist=\toks29
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/ctex/ctex.sty (e:/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
|
||||
Package: expl3 2024-02-20 L3 programming layer (loader)
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
|
||||
File: l3backend-xetex.def 2024-02-20 L3 backend support: XeTeX
|
||||
\g__graphics_track_int=\count273
|
||||
\l__pdf_internal_box=\box53
|
||||
\g__pdf_backend_object_int=\count274
|
||||
\g__pdf_backend_annotation_int=\count275
|
||||
\g__pdf_backend_link_int=\count276
|
||||
))
|
||||
Package: ctex 2022/07/14 v2.5.10 Chinese adapter in LaTeX (CTEX)
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty
|
||||
Package: ctexhook 2022/07/14 v2.5.10 Document and package hooks (CTEX)
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/ctex/ctexpatch.sty
|
||||
Package: ctexpatch 2022/07/14 v2.5.10 Patching commands (CTEX)
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/base/fix-cm.sty
|
||||
Package: fix-cm 2020/11/24 v1.1t fixes to LaTeX
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/base/ts1enc.def
|
||||
File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
|
||||
LaTeX Font Info: Redeclaring font encoding TS1 on input line 47.
|
||||
))
|
||||
\l__ctex_tmp_int=\count277
|
||||
\l__ctex_tmp_box=\box54
|
||||
\l__ctex_tmp_dim=\dimen158
|
||||
\g__ctex_section_depth_int=\count278
|
||||
\g__ctex_font_size_int=\count279
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/ctex/config/ctexopts.cfg
|
||||
File: ctexopts.cfg 2022/07/14 v2.5.10 Option configuration file (CTEX)
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def
|
||||
File: ctex-engine-xetex.def 2022/07/14 v2.5.10 XeLaTeX adapter (CTEX)
|
||||
(e:/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
|
||||
Package: xeCJK 2022/08/05 v3.9.1 Typesetting CJK scripts with XeLaTeX
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty (e:/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-2023-10-10.sty
|
||||
Package: xtemplate 2023-10-10 L3 Experimental prototype document functions
|
||||
\l__xtemplate_tmp_dim=\dimen159
|
||||
\l__xtemplate_tmp_int=\count280
|
||||
\l__xtemplate_tmp_muskip=\muskip17
|
||||
\l__xtemplate_tmp_skip=\skip56
|
||||
))
|
||||
\l__xeCJK_tmp_int=\count281
|
||||
\l__xeCJK_tmp_box=\box55
|
||||
\l__xeCJK_tmp_dim=\dimen160
|
||||
\l__xeCJK_tmp_skip=\skip57
|
||||
\g__xeCJK_space_factor_int=\count282
|
||||
\l__xeCJK_begin_int=\count283
|
||||
\l__xeCJK_end_int=\count284
|
||||
\c__xeCJK_CJK_class_int=\XeTeXcharclass1
|
||||
\c__xeCJK_FullLeft_class_int=\XeTeXcharclass2
|
||||
\c__xeCJK_FullRight_class_int=\XeTeXcharclass3
|
||||
\c__xeCJK_HalfLeft_class_int=\XeTeXcharclass4
|
||||
\c__xeCJK_HalfRight_class_int=\XeTeXcharclass5
|
||||
\c__xeCJK_NormalSpace_class_int=\XeTeXcharclass6
|
||||
\c__xeCJK_CM_class_int=\XeTeXcharclass7
|
||||
\c__xeCJK_HangulJamo_class_int=\XeTeXcharclass8
|
||||
\l__xeCJK_last_skip=\skip58
|
||||
\c__xeCJK_none_node=\count285
|
||||
\g__xeCJK_node_int=\count286
|
||||
\c__xeCJK_CJK_node_dim=\dimen161
|
||||
\c__xeCJK_CJK-space_node_dim=\dimen162
|
||||
\c__xeCJK_default_node_dim=\dimen163
|
||||
\c__xeCJK_CJK-widow_node_dim=\dimen164
|
||||
\c__xeCJK_normalspace_node_dim=\dimen165
|
||||
\c__xeCJK_default-space_node_skip=\skip59
|
||||
\l__xeCJK_ccglue_skip=\skip60
|
||||
\l__xeCJK_ecglue_skip=\skip61
|
||||
\l__xeCJK_punct_kern_skip=\skip62
|
||||
\l__xeCJK_indent_box=\box56
|
||||
\l__xeCJK_last_penalty_int=\count287
|
||||
\l__xeCJK_last_bound_dim=\dimen166
|
||||
\l__xeCJK_last_kern_dim=\dimen167
|
||||
\l__xeCJK_widow_penalty_int=\count288
|
||||
|
||||
Package xtemplate Info: Declaring object type 'xeCJK/punctuation' taking 0
|
||||
(xtemplate) argument(s) on line 2396.
|
||||
|
||||
\l__xeCJK_fixed_punct_width_dim=\dimen168
|
||||
\l__xeCJK_mixed_punct_width_dim=\dimen169
|
||||
\l__xeCJK_middle_punct_width_dim=\dimen170
|
||||
\l__xeCJK_fixed_margin_width_dim=\dimen171
|
||||
\l__xeCJK_mixed_margin_width_dim=\dimen172
|
||||
\l__xeCJK_middle_margin_width_dim=\dimen173
|
||||
\l__xeCJK_bound_punct_width_dim=\dimen174
|
||||
\l__xeCJK_bound_margin_width_dim=\dimen175
|
||||
\l__xeCJK_margin_minimum_dim=\dimen176
|
||||
\l__xeCJK_kerning_total_width_dim=\dimen177
|
||||
\l__xeCJK_same_align_margin_dim=\dimen178
|
||||
\l__xeCJK_different_align_margin_dim=\dimen179
|
||||
\l__xeCJK_kerning_margin_width_dim=\dimen180
|
||||
\l__xeCJK_kerning_margin_minimum_dim=\dimen181
|
||||
\l__xeCJK_bound_dim=\dimen182
|
||||
\l__xeCJK_reverse_bound_dim=\dimen183
|
||||
\l__xeCJK_margin_dim=\dimen184
|
||||
\l__xeCJK_minimum_bound_dim=\dimen185
|
||||
\l__xeCJK_kerning_margin_dim=\dimen186
|
||||
\g__xeCJK_family_int=\count289
|
||||
\l__xeCJK_fam_int=\count290
|
||||
\g__xeCJK_fam_allocation_int=\count291
|
||||
\l__xeCJK_verb_case_int=\count292
|
||||
\l__xeCJK_verb_exspace_skip=\skip63
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty (e:/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
|
||||
Package: xparse 2024-02-18 L3 Experimental document command parser
|
||||
)
|
||||
Package: fontspec 2024/02/13 v2.9a Font selection for XeLaTeX and LuaLaTeX
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
|
||||
Package: fontspec-xetex 2024/02/13 v2.9a Font selection for XeLaTeX and LuaLaTeX
|
||||
\l__fontspec_script_int=\count293
|
||||
\l__fontspec_language_int=\count294
|
||||
\l__fontspec_strnum_int=\count295
|
||||
\l__fontspec_tmp_int=\count296
|
||||
\l__fontspec_tmpa_int=\count297
|
||||
\l__fontspec_tmpb_int=\count298
|
||||
\l__fontspec_tmpc_int=\count299
|
||||
\l__fontspec_em_int=\count300
|
||||
\l__fontspec_emdef_int=\count301
|
||||
\l__fontspec_strong_int=\count302
|
||||
\l__fontspec_strongdef_int=\count303
|
||||
\l__fontspec_tmpa_dim=\dimen187
|
||||
\l__fontspec_tmpb_dim=\dimen188
|
||||
\l__fontspec_tmpc_dim=\dimen189
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty
|
||||
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (e:/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg
|
||||
File: xeCJK.cfg 2022/08/05 v3.9.1 Configuration file for xeCJK package
|
||||
))
|
||||
\ccwd=\dimen190
|
||||
\l__ctex_ccglue_skip=\skip64
|
||||
)
|
||||
\l__ctex_ziju_dim=\dimen191
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber.sty
|
||||
Package: zhnumber 2022/07/14 v3.0 Typesetting numbers with Chinese glyphs
|
||||
\l__zhnum_scale_int=\count304
|
||||
\l__zhnum_tmp_int=\count305
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg
|
||||
File: zhnumber-utf8.cfg 2022/07/14 v3.0 Chinese numerals with UTF8 encoding
|
||||
)) (e:/texlive/2024/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def
|
||||
File: ctex-scheme-chinese.def 2022/07/14 v2.5.10 Chinese scheme for generic (CTEX)
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg
|
||||
File: ctex-name-utf8.cfg 2022/07/14 v2.5.10 Caption with encoding UTF-8 (CTEX)
|
||||
)) (e:/texlive/2024/texmf-dist/tex/latex/tools/indentfirst.sty
|
||||
Package: indentfirst 2023/07/02 v1.03 Indent first paragraph (DPC)
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/ctex/ctex-c5size.clo
|
||||
File: ctex-c5size.clo 2022/07/14 v2.5.10 c5size option (CTEX)
|
||||
) (e:/texlive/2024/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def
|
||||
File: ctex-fontset-windows.def 2022/07/14 v2.5.10 Windows fonts definition (CTEX)
|
||||
|
||||
Package fontspec Info: Could not resolve font "KaiTi/B" (it probably doesn't
|
||||
(fontspec) exist).
|
||||
|
||||
|
||||
Package fontspec Info: Could not resolve font "SimHei/I" (it probably doesn't
|
||||
(fontspec) exist).
|
||||
|
||||
|
||||
Package fontspec Info: Could not resolve font "SimSun/BI" (it probably doesn't
|
||||
(fontspec) exist).
|
||||
|
||||
|
||||
Package fontspec Info: Font family 'SimSun(0)' created for font 'SimSun' with
|
||||
(fontspec) options
|
||||
(fontspec) [Script={CJK},BoldFont={SimHei},ItalicFont={KaiTi}].
|
||||
(fontspec)
|
||||
(fontspec) This font family consists of the following NFSS
|
||||
(fontspec) series/shapes:
|
||||
(fontspec)
|
||||
(fontspec) - 'normal' (m/n) with NFSS spec.:
|
||||
(fontspec) <->"SimSun/OT:script=hani;language=dflt;"
|
||||
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
|
||||
(fontspec) - 'bold' (b/n) with NFSS spec.:
|
||||
(fontspec) <->"SimHei/OT:script=hani;language=dflt;"
|
||||
(fontspec) - 'bold small caps' (b/sc) with NFSS spec.:
|
||||
(fontspec) - 'italic' (m/it) with NFSS spec.:
|
||||
(fontspec) <->"KaiTi/OT:script=hani;language=dflt;"
|
||||
(fontspec) - 'italic small caps' (m/scit) with NFSS spec.:
|
||||
|
||||
)) (e:/texlive/2024/texmf-dist/tex/latex/ctex/config/ctex.cfg
|
||||
File: ctex.cfg 2022/07/14 v2.5.10 Configuration file (CTEX)
|
||||
) (./10225101408_朱炎_Excercise01.aux)
|
||||
\openout1 = `10225101408_朱炎_Excercise01.aux'.
|
||||
|
||||
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 11.
|
||||
LaTeX Font Info: ... okay on input line 11.
|
||||
|
||||
*geometry* driver: auto-detecting
|
||||
*geometry* detected driver: xetex
|
||||
*geometry* verbose mode - [ preamble ] result:
|
||||
* driver: xetex
|
||||
* paper: <default>
|
||||
* layout: <same size as paper>
|
||||
* layoutoffset:(h,v)=(0.0pt,0.0pt)
|
||||
* modes:
|
||||
* h-part:(L,W,R)=(72.26999pt, 469.75502pt, 72.26999pt)
|
||||
* v-part:(T,H,B)=(72.26999pt, 650.43001pt, 72.26999pt)
|
||||
* \paperwidth=614.295pt
|
||||
* \paperheight=794.96999pt
|
||||
* \textwidth=469.75502pt
|
||||
* \textheight=650.43001pt
|
||||
* \oddsidemargin=0.0pt
|
||||
* \evensidemargin=0.0pt
|
||||
* \topmargin=-37.0pt
|
||||
* \headheight=12.0pt
|
||||
* \headsep=25.0pt
|
||||
* \topskip=10.0pt
|
||||
* \footskip=30.0pt
|
||||
* \marginparwidth=65.0pt
|
||||
* \marginparsep=11.0pt
|
||||
* \columnsep=10.0pt
|
||||
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
|
||||
* \hoffset=0.0pt
|
||||
* \voffset=0.0pt
|
||||
* \mag=1000
|
||||
* \@twocolumnfalse
|
||||
* \@twosidefalse
|
||||
* \@mparswitchfalse
|
||||
* \@reversemarginfalse
|
||||
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
|
||||
|
||||
|
||||
Package fontspec Info: Adjusting the maths setup (use [no-math] to avoid
|
||||
(fontspec) this).
|
||||
|
||||
\symlegacymaths=\mathgroup6
|
||||
LaTeX Font Info: Overwriting symbol font `legacymaths' in version `bold'
|
||||
(Font) OT1/cmr/m/n --> OT1/cmr/bx/n on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \acute on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \grave on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \ddot on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \tilde on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \bar on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \breve on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \check on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \hat on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \dot on input line 11.
|
||||
LaTeX Font Info: Redeclaring math accent \mathring on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Gamma on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Delta on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Theta on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Lambda on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Xi on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Pi on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Sigma on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Upsilon on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Phi on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Psi on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \Omega on input line 11.
|
||||
LaTeX Font Info: Redeclaring math symbol \mathdollar on input line 11.
|
||||
LaTeX Font Info: Redeclaring symbol font `operators' on input line 11.
|
||||
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
|
||||
(Font) `operators' in the math version `normal' on input line 11.
|
||||
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
|
||||
(Font) OT1/cmr/m/n --> TU/lmr/m/n on input line 11.
|
||||
LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font
|
||||
(Font) `operators' in the math version `bold' on input line 11.
|
||||
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
|
||||
(Font) OT1/cmr/bx/n --> TU/lmr/m/n on input line 11.
|
||||
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
|
||||
(Font) TU/lmr/m/n --> TU/lmr/m/n on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `normal'
|
||||
(Font) OT1/cmr/m/it --> TU/lmr/m/it on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathbf' in version `normal'
|
||||
(Font) OT1/cmr/bx/n --> TU/lmr/b/n on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `normal'
|
||||
(Font) OT1/cmss/m/n --> TU/lmss/m/n on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `normal'
|
||||
(Font) OT1/cmtt/m/n --> TU/lmtt/m/n on input line 11.
|
||||
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
|
||||
(Font) TU/lmr/m/n --> TU/lmr/b/n on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathit' in version `bold'
|
||||
(Font) OT1/cmr/bx/it --> TU/lmr/b/it on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `bold'
|
||||
(Font) OT1/cmss/bx/n --> TU/lmss/b/n on input line 11.
|
||||
LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `bold'
|
||||
(Font) OT1/cmtt/m/n --> TU/lmtt/b/n on input line 11.
|
||||
LaTeX Font Info: Trying to load font information for U+msa on input line 13.
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/amsfonts/umsa.fd
|
||||
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
|
||||
)
|
||||
LaTeX Font Info: Trying to load font information for U+msb on input line 13.
|
||||
(e:/texlive/2024/texmf-dist/tex/latex/amsfonts/umsb.fd
|
||||
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
|
||||
) [1
|
||||
|
||||
] (./10225101408_朱炎_Excercise01.aux)
|
||||
***********
|
||||
LaTeX2e <2023-11-01> patch level 1
|
||||
L3 programming layer <2022/07/14>
|
||||
***********
|
||||
)
|
||||
Here is how much of TeX's memory you used:
|
||||
8158 strings out of 474773
|
||||
217885 string characters out of 5761288
|
||||
1928842 words of memory out of 5000000
|
||||
30207 multiletter control sequences out of 15000+600000
|
||||
567395 words of font info for 93 fonts, out of 8000000 for 9000
|
||||
1348 hyphenation exceptions out of 8191
|
||||
93i,6n,97p,423b,270s stack positions out of 10000i,1000n,20000p,200000b,200000s
|
||||
|
||||
Output written on 10225101408_朱炎_Excercise01.pdf (1 page).
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,34 +0,0 @@
|
|||
\documentclass{article}
|
||||
\usepackage{amsmath, amssymb, amsthm}
|
||||
\usepackage{geometry}
|
||||
\usepackage{ctex}
|
||||
\geometry{margin=1in}
|
||||
|
||||
\title{区块链基础第一次作业}
|
||||
\author{10225101408 朱炎}
|
||||
\date{2025.3.18}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
比特币总量上限为2100万个且预计在2140年基本挖完的核心机制源于其区块奖励减半规则。
|
||||
|
||||
\section{比特币的总量上限计算}
|
||||
比特币的初始奖励为50个比特币,每210000个区块奖励减半一次,第一个周期内产生$50 \times 210000 = 10500000$个比特币。
|
||||
则我们可以通过以下等比数列求和公式计算比特币总量上限:
|
||||
\begin{equation}
|
||||
10500000 \times \sum_{n=0}^{\infty} (\frac{1}{2})^n = 10500000 \times \frac{1}{1 - \frac{1}{2}} = 21000000 \text{BTC}
|
||||
\end{equation}
|
||||
即2100万个比特币。
|
||||
|
||||
\section{比特币的终止时间计算}
|
||||
比特币每210000个区块奖励减半一次,每个区块的产生时间约为10分钟,故210000个区块的生成耗时约为210000*10分钟 = 35000小时 = 1458天 = 4年。
|
||||
|
||||
比特币于2009年1月3日开始发行,到2140年约为131年,即32个周期。32个周期后,比特币的奖励为:
|
||||
\begin{equation}
|
||||
50 \times 2^{-32} \approx 1.16 \times 10^{-8} \text{BTC}
|
||||
\end{equation}
|
||||
而比特币的最小单位1聪(Satoshi)为$10^{-8}$比特币,故比特币的奖励将约等于0,挖矿终止。
|
||||
|
||||
\end{document}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
class Blockchain:
|
||||
def __init__(self, genesis_recipient=None, genesis_amount=0):
|
||||
self.utxo = {} # 格式: {tx_id: (receiver, amount)}
|
||||
|
||||
# 生成创世交易(仅第一次初始化时调用)
|
||||
if genesis_recipient is not None and genesis_amount > 0:
|
||||
self.add_genesis(genesis_recipient, genesis_amount)
|
||||
|
||||
def add_genesis(self, receiver, amount):
|
||||
# 添加创世区块
|
||||
genesis_tx_id = "genesis_tx_0x1"
|
||||
self.utxo[genesis_tx_id] = (receiver, amount)
|
||||
|
||||
def validate_transaction(self, tx):
|
||||
# 验签
|
||||
if not tx.is_valid():
|
||||
return False
|
||||
# 验证发送方余额
|
||||
sender_balance = sum(amt for (addr, amt) in self.utxo.values() if addr == tx.sender)
|
||||
return sender_balance >= tx.amount
|
||||
|
||||
def add_transaction(self, tx):
|
||||
if self.validate_transaction(tx):
|
||||
tx_id = hash(tx) # 简化交易ID生成
|
||||
self.utxo[tx_id] = (tx.receiver, tx.amount)
|
||||
return True
|
||||
return False
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
from py_ecc.bls12_381 import G1, G2, add, multiply, is_inf, pairing, curve_order, field_modulus
|
||||
from py_ecc.fields import bls12_381_FQ as FQ
|
||||
from functools import reduce
|
||||
import hashlib
|
||||
|
||||
def hash_to_g1(message: bytes):
|
||||
G1_cofactor = 0x396c8c005555e1568c00aaab0000aaab
|
||||
|
||||
hashed = int.from_bytes(hashlib.sha256(message).digest(), 'big')
|
||||
x_val = hashed % field_modulus
|
||||
|
||||
while True:
|
||||
y_squared = (pow(x_val, 3, field_modulus) + 4) % field_modulus
|
||||
y_val = pow(y_squared, (field_modulus + 1) // 4, field_modulus)
|
||||
if pow(y_val, 2, field_modulus) == y_squared:
|
||||
x = FQ(x_val)
|
||||
y = FQ(y_val)
|
||||
point = (x, y)
|
||||
point = multiply(point, G1_cofactor)
|
||||
if not is_inf(point):
|
||||
return point
|
||||
x_val = (x_val + 1) % field_modulus
|
||||
|
||||
import random
|
||||
|
||||
def generate_private_key():
|
||||
return random.randint(1, curve_order - 1)
|
||||
|
||||
def generate_public_key(sk):
|
||||
return multiply(G2, sk)
|
||||
|
||||
def sign(sk, message: bytes):
|
||||
H_m = hash_to_g1(message)
|
||||
return multiply(H_m, sk)
|
||||
|
||||
def verify(pk, message: bytes, signature) -> bool:
|
||||
H_m = hash_to_g1(message)
|
||||
left = pairing(G2, signature)
|
||||
right = pairing(pk, H_m)
|
||||
return left == right
|
||||
|
||||
def aggregate_signatures(signatures: list) -> tuple:
|
||||
return reduce(add, signatures)
|
||||
|
||||
def aggregate_verify(pubkeys: list, messages: list, aggregate_sig: tuple) -> bool:
|
||||
if len(pubkeys) != len(messages):
|
||||
return False
|
||||
product = 1
|
||||
for pk, msg in zip(pubkeys, messages):
|
||||
H_m = hash_to_g1(msg)
|
||||
product *= pairing(pk, H_m)
|
||||
left = pairing(G2, aggregate_sig)
|
||||
return left == product
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 单个签名的情况
|
||||
sk = generate_private_key()
|
||||
pk = generate_public_key(sk)
|
||||
message = b"Hello, BLS!"
|
||||
signature = sign(sk, message)
|
||||
print("验证结果:", verify(pk, message, signature))
|
||||
print("错误消息验证:", verify(pk, b"Wrong message", signature))
|
||||
|
||||
# 多个签名的情况
|
||||
num_signers = 3
|
||||
sks = [generate_private_key() for _ in range(num_signers)]
|
||||
pks = [generate_public_key(sk) for sk in sks]
|
||||
messages = [f"Message {i}".encode() for i in range(num_signers)]
|
||||
signatures = [sign(sk, msg) for sk, msg in zip(sks, messages)]
|
||||
agg_sig = aggregate_signatures(signatures)
|
||||
valid = aggregate_verify(pks, messages, agg_sig)
|
||||
print("聚合验证结果:", valid)
|
||||
corrupted_messages = [msg + b"no" for msg in messages]
|
||||
invalid = aggregate_verify(pks, corrupted_messages, agg_sig)
|
||||
print("篡改消息后的验证结果:", invalid)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
from wallet import Wallet
|
||||
from transaction import Transaction
|
||||
from blockchain import Blockchain
|
||||
from bls import aggregate_signatures, aggregate_verify
|
||||
|
||||
alice = Wallet()
|
||||
bob = Wallet()
|
||||
blockchain = Blockchain( # 给Alice初始10个代币
|
||||
genesis_recipient=alice.get_address(),
|
||||
genesis_amount=10
|
||||
)
|
||||
|
||||
alice_balance = sum(
|
||||
amt for (addr, amt) in blockchain.utxo.values()
|
||||
if addr == alice.get_address()
|
||||
)
|
||||
print("Alice 的初始余额:", alice_balance)
|
||||
|
||||
tx1 = Transaction(alice.get_address(), bob.get_address(), 10)
|
||||
tx1.sign(alice)
|
||||
print("交易1验证结果:", tx1.is_valid())
|
||||
|
||||
if blockchain.add_transaction(tx1):
|
||||
print("交易1成功上链")
|
||||
|
||||
# Bob向Alice转账15个代币(失败,余额不足)
|
||||
tx2 = Transaction(bob.get_address(), alice.get_address(), 15)
|
||||
tx2.sign(bob)
|
||||
print("交易2验证结果:", tx2.is_valid()) # True,但余额不足
|
||||
print("交易2上链结果:", blockchain.add_transaction(tx2)) # False
|
||||
|
||||
# 聚合签名
|
||||
carol = Wallet()
|
||||
tx3_data = b"Multisig_Transaction"
|
||||
signature_alice = alice.sign_transaction(tx3_data)
|
||||
signature_carol = carol.sign_transaction(tx3_data)
|
||||
agg_sig = aggregate_signatures([signature_alice, signature_carol])
|
||||
valid = aggregate_verify([alice.pk, carol.pk], [tx3_data, tx3_data], agg_sig)
|
||||
print("聚合签名验证结果:", valid) # True
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
class Transaction:
|
||||
def __init__(self, sender, receiver, amount, signature=None):
|
||||
self.sender = sender # 公钥
|
||||
self.receiver = receiver # 地址
|
||||
self.amount = amount # 金额
|
||||
self.signature = signature
|
||||
|
||||
def serialize(self) -> bytes:
|
||||
# 序列化交易数据用于签名
|
||||
return f"{self.sender}{self.receiver}{self.amount}".encode()
|
||||
|
||||
def sign(self, wallet):
|
||||
self.signature = wallet.sign_transaction(self.serialize())
|
||||
|
||||
def is_valid(self) -> bool:
|
||||
from bls import verify
|
||||
return verify(self.sender, self.serialize(), self.signature)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
from bls import generate_private_key, generate_public_key
|
||||
|
||||
class Wallet:
|
||||
def __init__(self):
|
||||
self.sk = generate_private_key()
|
||||
self.pk = generate_public_key(self.sk)
|
||||
|
||||
def get_address(self):
|
||||
return self.pk # 公钥作为地址
|
||||
|
||||
def sign_transaction(self, tx_data: bytes):
|
||||
from bls import sign
|
||||
return sign(self.sk, tx_data)
|
||||
Loading…
Reference in New Issue