Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1212 lines (901 loc) · 58.2 KB
/
Copy pathindex.html
File metadata and controls
1212 lines (901 loc) · 58.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 7.3.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"ada2pro.github.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"gitalk","storage":true,"lazyload":true,"nav":{"giscus":{"text":"GitHub 评论","order":-1}},"activeClass":"gitalk"},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
</script>
<meta name="description" content="record my life, share my thoughts">
<meta property="og:type" content="website">
<meta property="og:title" content="Ada2pro's blog">
<meta property="og:url" content="https://ada2pro.github.io/index.html">
<meta property="og:site_name" content="Ada2pro's blog">
<meta property="og:description" content="record my life, share my thoughts">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Xzywoo">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://ada2pro.github.io/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'zh-CN'
};
</script>
<title>Ada2pro's blog</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">Ada2pro's blog</h1>
<span class="logo-line-after"><i></i></span>
</a>
<p class="site-subtitle" itemprop="description">Waiting for love</p>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/09/17/plan-250917-250930/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/09/17/plan-250917-250930/" class="post-title-link" itemprop="url">plan_250917~250930</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-09-17 21:04:19 / 修改时间:21:06:57" itemprop="dateCreated datePublished" datetime="2025-09-17T21:04:19+08:00">2025-09-17</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="9-17—9-30"><a href="#9-17—9-30" class="headerlink" title="9.17—9.30"></a>9.17—9.30</h2><p>主要的学习关注点:</p>
<ol>
<li><p>CKKS-OPENMINED 9.17</p>
</li>
<li><p>唐师兄推荐的论文阅读 9.18/19</p>
</li>
<li><p>Dpad-HE论文以及代码阅读 9.20——23</p>
</li>
<li><p>PPT制作</p>
</li>
<li><p>准备博士英语免修</p>
</li>
</ol>
<h4 id="if-otherwise"><a href="#if-otherwise" class="headerlink" title="if otherwise"></a>if otherwise</h4><ol>
<li>观看NVIDIA讲座,知乎文章,官方文档,github实现等。</li>
<li>公众号,X等。</li>
</ol>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/09/05/CKKS%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/09/05/CKKS%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" class="post-title-link" itemprop="url">CKKS学习笔记</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-09-05 17:04:29 / 修改时间:17:10:17" itemprop="dateCreated datePublished" datetime="2025-09-05T17:04:29+08:00">2025-09-05</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<blockquote>
<p>我最近需要学习CKKS,我之前看过openmined的教程,当时看懂了,但过去了一个月,我就几乎忘得差不多了,我认为必须要自己手动进行代码实现才能加深理解,同时,师兄也推荐我去阅读CKKS的原论文</p>
</blockquote>
<hr>
<h1 id="CKKS-同态加密学习路径(三层次法)"><a href="#CKKS-同态加密学习路径(三层次法)" class="headerlink" title="CKKS 同态加密学习路径(三层次法)"></a>CKKS 同态加密学习路径(三层次法)</h1><blockquote>
<p>学习 CKKS 不必一次吃透。结合“框架 → 实践 → 理论”三步走,能有效打通从理解到实现的闭环。</p>
</blockquote>
<h2 id="一、建立高层框架(先见森林)"><a href="#一、建立高层框架(先见森林)" class="headerlink" title="一、建立高层框架(先见森林)"></a>一、建立高层框架(先见森林)</h2><p>在读论文前,先掌握整体脉络,避免迷失细节:</p>
<ul>
<li><strong>核心目标</strong>:支持浮点/实数的<strong>近似同态加密</strong>(允许一定误差)</li>
<li><strong>关键思想</strong>:<ul>
<li>复数向量编码数据</li>
<li>多项式上进行同态加/乘</li>
<li>通过 <strong>rescaling</strong> 控制噪声与精度平衡</li>
</ul>
</li>
<li><strong>主要流程</strong>:<br><code>编码 → 加密 → 同态运算 → 解密 → 解码</code></li>
<li><strong>核心挑战</strong>:<ul>
<li>噪声增长 vs. 计算精度</li>
<li>乘法次数受限 → 需 rescaling + 模数链(modulus chain)</li>
</ul>
</li>
</ul>
<p>📌 <strong>推荐材料</strong>:OpenMined 教程、简明综述或课程笔记,快速唤醒记忆。</p>
<hr>
<h2 id="二、动手实验(代码驱动理解)"><a href="#二、动手实验(代码驱动理解)" class="headerlink" title="二、动手实验(代码驱动理解)"></a>二、动手实验(代码驱动理解)</h2><p>用现成库上手,让抽象概念落地:</p>
<ul>
<li>✅ 使用库:<a target="_blank" rel="noopener" href="https://github.com/microsoft/SEAL">SEAL</a> / <a target="_blank" rel="noopener" href="https://github.com/tuneinsight/lattigo">Lattigo</a> / <a target="_blank" rel="noopener" href="https://github.com/OpenMined/TenSEAL">TenSEAL</a></li>
<li>🔬 实验内容:<ul>
<li>跑通 CKKS 加法、乘法示例</li>
<li>观察:加法几乎无精度损失,乘法后需 rescale</li>
<li>手动封装完整流程:<code>encode → encrypt → eval → decrypt → decode</code></li>
<li>记录误差来源(如 rescale 引入的舍入)</li>
</ul>
</li>
<li>🧩 进阶:<ul>
<li>复现 OpenMined 示例,边跑边注释</li>
<li>提问并尝试回答:<em>“为什么这里要 rescale?” “乘法为何有限?”</em></li>
</ul>
</li>
</ul>
<p>💡 <strong>好处</strong>:再看论文时,公式=代码中的某一步,理解更直观。</p>
<hr>
<h2 id="三、精读原论文(带问题深入)"><a href="#三、精读原论文(带问题深入)" class="headerlink" title="三、精读原论文(带问题深入)"></a>三、精读原论文(带问题深入)</h2><p>论文:<em>Cheon et al., Homomorphic Encryption for Arithmetic of Approximate Numbers (2017)</em></p>
<p>分模块阅读,优先关注与代码对应的机制:</p>
<table>
<thead>
<tr>
<th>模块</th>
<th>学习重点</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Introduction</strong></td>
<td>对比 BGV/BFV,理解 CKKS 为何适合近似计算</td>
</tr>
<tr>
<td><strong>Encoding/Decoding</strong></td>
<td>复数向量如何编码实数向量?精度损失来源?</td>
</tr>
<tr>
<td><strong>Homomorphic Ops</strong></td>
<td>加法、乘法的数学形式,对应代码中的 <code>add</code> 和 <code>mul</code></td>
</tr>
<tr>
<td><strong>Rescaling & Modulus Switching</strong></td>
<td>核心创新!为何要除 <code>q_i</code>?如何维持规模?</td>
</tr>
<tr>
<td><strong>Security & Params</strong></td>
<td>安全基于 RLWE;参数选择影响安全与性能</td>
</tr>
</tbody></table>
<p>📘 <strong>阅读技巧</strong>:</p>
<ul>
<li>带着实验中的疑问去读(如:“rescale 为什么必须降模?”)</li>
<li>公式看不懂?先找代码实现,反向理解</li>
<li>安全性证明等硬核部分可暂时跳过</li>
</ul>
<hr>
<h2 id="四、巩固与提升"><a href="#四、巩固与提升" class="headerlink" title="四、巩固与提升"></a>四、巩固与提升</h2><ul>
<li>📝 <strong>写读书笔记</strong>:每部分用自己的话总结成“小白也能懂”的解释</li>
<li>🔍 <strong>多源对照</strong>:参考 Lattigo 文档、SEAL 示例等工程化资料</li>
<li>💬 <strong>自测能力</strong>:如果让我实现 CKKS,我能写哪部分?哪些依赖库?</li>
</ul>
<hr>
<h2 id="✅-可选:三周学习计划(实践导向)"><a href="#✅-可选:三周学习计划(实践导向)" class="headerlink" title="✅ 可选:三周学习计划(实践导向)"></a>✅ 可选:三周学习计划(实践导向)</h2><table>
<thead>
<tr>
<th>周数</th>
<th>目标</th>
</tr>
</thead>
<tbody><tr>
<td>第1周</td>
<td>熟悉 TenSEAL/SEAL,跑通编码、加/乘、rescaling 示例</td>
</tr>
<tr>
<td>第2周</td>
<td>对照论文,精读 Encoding、HomOp、Rescaling 部分,标注代码对应点</td>
</tr>
<tr>
<td>第3周</td>
<td>实现一个“极简版 CKKS”原型(仅支持编码+加密+加法)或写详细流程图解</td>
</tr>
</tbody></table>
<blockquote>
<p>这样三周下来,你不仅能读懂论文,还能讲清楚、写出来。</p>
</blockquote>
<hr>
<p>📌 <strong>结语</strong>:<br>CKKS 的难点不在单一知识点,而在<strong>数学、安全、工程的交叉理解</strong>。<br>坚持“<strong>先会用,再懂原理</strong>”,你会越学越通透。</p>
<hr>
<p>好👌 我给你设计一个 <strong>3 周 CKKS 学习计划</strong>,目标是:</p>
<ul>
<li><strong>不只是看懂</strong>,还能<strong>动手实现</strong>,把论文和代码结合起来。</li>
<li>节奏循序渐进,避免“一次性啃死”。</li>
</ul>
<hr>
<h1 id="📅-三周-CKKS-学习计划"><a href="#📅-三周-CKKS-学习计划" class="headerlink" title="📅 三周 CKKS 学习计划"></a>📅 三周 CKKS 学习计划</h1><h2 id="第-1-周:重建框架-动手实验"><a href="#第-1-周:重建框架-动手实验" class="headerlink" title="第 1 周:重建框架 &动手实验"></a><strong>第 1 周:重建框架 &动手实验</strong></h2><p><strong>目标</strong>:重新建立 CKKS 的整体理解,用代码跑通基本流程。</p>
<ul>
<li><p><strong>Day 1-2</strong></p>
<ul>
<li><p>回顾 openmined 的 CKKS 教程,写总结:</p>
<ul>
<li>CKKS 解决的问题</li>
<li>编码/加密/解密流程</li>
<li>rescale 在哪里用到</li>
</ul>
</li>
<li><p>输出 1 页笔记(可以画流程图)。</p>
</li>
</ul>
</li>
<li><p><strong>Day 3-4</strong></p>
<ul>
<li><p>用 <strong>TenSEAL 或 SEAL</strong> 跑几个 demo:</p>
<ul>
<li>加法、乘法、rescale</li>
<li>对比误差来源</li>
</ul>
</li>
<li><p>给每段代码加注释,写出你“理解”的解释。</p>
</li>
</ul>
</li>
<li><p><strong>Day 5-6</strong></p>
<ul>
<li>阅读 1 篇 CKKS 入门综述(比原论文轻量的资料)。</li>
<li>总结:CKKS 相比 BGV/BFV 的不同点。</li>
</ul>
</li>
<li><p><strong>Day 7</strong></p>
<ul>
<li>复盘一周:写一个“CKKS 小白笔记”,不超过两页。</li>
</ul>
</li>
</ul>
<hr>
<h2 id="第-2-周:论文精读(带问题读)"><a href="#第-2-周:论文精读(带问题读)" class="headerlink" title="第 2 周:论文精读(带问题读)"></a><strong>第 2 周:论文精读(带问题读)</strong></h2><p><strong>目标</strong>:啃原论文的核心部分,把公式和代码对照起来。</p>
<ul>
<li><p><strong>Day 1-2</strong></p>
<ul>
<li>精读原论文 Introduction + Background</li>
<li>写出论文想解决的痛点 & 为什么需要“近似”同态加密。</li>
</ul>
</li>
<li><p><strong>Day 3-4</strong></p>
<ul>
<li>精读 <strong>Encoding & Decoding</strong> 部分</li>
<li>在代码里跑 encode/decode,观察误差。</li>
<li>笔记:如何把实数/复数映射到多项式?</li>
</ul>
</li>
<li><p><strong>Day 5-6</strong></p>
<ul>
<li>精读 <strong>Homomorphic Addition & Multiplication</strong></li>
<li>跑对应代码,验证 rescale 的作用。</li>
</ul>
</li>
<li><p><strong>Day 7</strong></p>
<ul>
<li>输出一份“代码-公式对照表”。</li>
</ul>
</li>
</ul>
<hr>
<h2 id="第-3-周:实现-深化理解"><a href="#第-3-周:实现-深化理解" class="headerlink" title="第 3 周:实现 &深化理解"></a><strong>第 3 周:实现 &深化理解</strong></h2><p><strong>目标</strong>:动手写简化实现,把 CKKS 的机制讲出来。</p>
<ul>
<li><p><strong>Day 1-2</strong></p>
<ul>
<li><p>尝试实现“玩具版 CKKS”:</p>
<ul>
<li>只做 encode → encrypt → decrypt → decode(用 Python/Numpy)</li>
<li>暂时不管安全性。</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Day 3-4</strong></p>
<ul>
<li>加入加法、乘法运算,手动实现 rescale(哪怕是简化版)。</li>
</ul>
</li>
<li><p><strong>Day 5</strong></p>
<ul>
<li>对照论文 Security 部分,理解为什么要选择那么大的参数。</li>
<li>可以查一下 Lattigo/SEAL 的参数推荐。</li>
</ul>
</li>
<li><p><strong>Day 6</strong></p>
<ul>
<li><p>写一篇“CKKS 学习笔记”:</p>
<ul>
<li>论文精华</li>
<li>代码实验总结</li>
<li>哪些地方还没弄懂(留下问题)。</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Day 7</strong></p>
<ul>
<li>分享/讲解(假设要给别人讲 CKKS,你会怎么讲?)</li>
</ul>
</li>
</ul>
<hr>
<p>✨ 最终成果:</p>
<ul>
<li><p>3 周后你会有:</p>
<ul>
<li>一份完整的 CKKS 学习笔记</li>
<li>一份“代码-公式对照表”</li>
<li>一个玩具版 CKKS 小实现</li>
<li>对原论文核心思路的理解</li>
</ul>
</li>
</ul>
<hr>
<p>要不要我顺便帮你整理一些 <strong>论文 + 教程 + 库文档</strong> 的推荐阅读清单?这样你就不用自己到处找资料了。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/08/25/hexo-next%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/08/25/hexo-next%E5%8D%9A%E5%AE%A2%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA/" class="post-title-link" itemprop="url">hexo-next博客评论系统搭建</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-08-25 22:14:10 / 修改时间:22:22:39" itemprop="dateCreated datePublished" datetime="2025-08-25T22:14:10+08:00">2025-08-25</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>综合调查后,对于next主题,gitalk是最简易部署且免费的评论系统。<br>大致流程如下:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>安装:</span><br><span class="line">npm install hexo-helper-live2d gitalk --save <span class="comment">#看板娘是可选的(hexo-helper-live2d)</span></span><br><span class="line"></span><br><span class="line"><span class="number">2.</span>配置文件</span><br><span class="line">在/themes/<span class="built_in">next</span>/_config.yml中</span><br><span class="line">首先配置comment部分:</span><br><span class="line">comments:</span><br><span class="line"> style: tabs</span><br><span class="line"> active: gitalk</span><br><span class="line"> storage: true</span><br><span class="line"> lazyload: true</span><br><span class="line"> nav:</span><br><span class="line"> giscus:</span><br><span class="line"> text: GitHub 评论</span><br><span class="line"> order: -<span class="number">1</span></span><br><span class="line"></span><br><span class="line">然后按照网页:</span><br><span class="line">https://ericasun.github.io/<span class="number">2024</span>/03/<span class="number">15</span>/hexo/<span class="number">2024</span>/Hexo添加评论系统gitalk/</span><br><span class="line">中的方法配置配置Gitalk,注意,在第二步时只是用方法<span class="number">1</span>即可,且proxy:无需配置。</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/08/25/%E4%B8%8A%E4%BC%A0%E5%8D%9A%E5%AE%A2%E6%96%B9%E5%BC%8F/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/08/25/%E4%B8%8A%E4%BC%A0%E5%8D%9A%E5%AE%A2%E6%96%B9%E5%BC%8F/" class="post-title-link" itemprop="url">上传博客方式</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-08-25 20:44:06 / 修改时间:21:22:30" itemprop="dateCreated datePublished" datetime="2025-08-25T20:44:06+08:00">2025-08-25</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>发现使用https代理上传博客老出现网络TLS问题,咨询GPT后改用SSH进行上传。<br>步骤如下:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">eval</span> <span class="string">"$(ssh-agent -s)"</span></span><br><span class="line">ssh-add ~/.ssh/id_rsa <span class="comment">#对应Ada密钥,提示词是ustc</span></span><br><span class="line">ssh-add -l <span class="comment">#检查是否通过</span></span><br><span class="line">hexo new xxx <span class="comment">#开始写博客</span></span><br><span class="line">hexo clean && hexo g && hexo d <span class="comment">#上传</span></span><br></pre></td></tr></table></figure>
<p><img src="/images/%E5%8D%83%E6%97%A9.jpg" alt="替代文字"></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/08/18/2025-08-18/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/08/18/2025-08-18/" class="post-title-link" itemprop="url">20250818</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-08-18 21:09:32 / 修改时间:21:19:37" itemprop="dateCreated datePublished" datetime="2025-08-18T21:09:32+08:00">2025-08-18</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>今天中午睡到了1点,吃完早饭就去工位了,大约是2点半到工位。<br>现在时间是晚上9点,中途没休息或者吃饭,做了些什么呢?</p>
<ol>
<li>修改学长的大论文,添加及修正了2/3phase的内容,添加了实验表格数据。</li>
<li>编写纵横论坛新闻稿</li>
<li>实现了kyber中keygen阶段的外积矩阵向量乘法,但mont约简没适配,还需修改</li>
<li>似乎能够使用openvpn连接服务器了?</li>
</ol>
<p>我发觉用在写代码的时间(时间3)上绝对没有超过两小时,那么剩下的5小时去哪里了呢?<br>我不理解,总是在做一些低效且不知所云的事情。</p>
<p>明天计划:</p>
<ol>
<li><p>彻底回顾Montgomery约简,修正keygen中的算法流程,分析MMV中为什么会有:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"> int16_t tmp = Mont_Rdc_Dev(tmp_sum[ind]);</span><br><span class="line">tmp = Mont_Rdc_Dev(tmp*MONT_SQUARE);</span><br><span class="line">out_t[KYBER_N*i + ind] = Barrt_Rdc_Dev(tmp);</span><br></pre></td></tr></table></figure>
</li>
<li><p>测试调研一下约简和普通实现的性能差距?</p>
</li>
<li><p>尽量早起,下午晚饭后下工</p>
</li>
</ol>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/2025/08/16/%E5%8D%9A%E5%AE%A2%E9%87%8D%E7%94%9F/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2025/08/16/%E5%8D%9A%E5%AE%A2%E9%87%8D%E7%94%9F/" class="post-title-link" itemprop="url">博客重生</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2025-08-16 01:48:10" itemprop="dateCreated datePublished" datetime="2025-08-16T01:48:10+08:00">2025-08-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2025-08-25 21:22:38" itemprop="dateModified" datetime="2025-08-25T21:22:38+08:00">2025-08-25</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>2025-08-16 01:48:10 ,经过QWen的帮助,我现在可以继续使用此博客了。</p>
<p>但如何更好的管理还在探索中。</p>
<p>一下是保存的一些tips:</p>
<blockquote>
<p>我记得我以前使用了hexo,可以通过写markdown进行编辑提交,但现在我找不到任何的.md文件</p>
</blockquote>
<p>完全理解您的情况。您记得使用了 Hexo,并且是通过编辑 Markdown (<code>.md</code>) 文件来发布内容,但现在克隆下来的仓库里找不到这些文件,这确实会让人困惑。</p>
<p>这其实是一个非常常见且合理的现象,根本原因在于 <strong>GitHub Pages 的发布机制</strong>。</p>
<p>让我为您详细解释,并告诉您如何解决。</p>
<hr>
<h3 id="为什么找不到-md-文件?"><a href="#为什么找不到-md-文件?" class="headerlink" title="为什么找不到 .md 文件?"></a><strong>为什么找不到 <code>.md</code> 文件?</strong></h3><p>在使用 Hexo 这类静态网站生成器(Static Site Generator, SSG)时,您的项目通常包含两个部分:</p>
<ol>
<li><strong>源代码 (Source Code)</strong>: 这是您进行创作和编辑的地方,包含:<ul>
<li><code>source/_posts/</code> 目录下的 <code>.md</code> 文件(您的博客文章)。</li>
<li>主题配置文件(<code>_config.yml</code>)。</li>
<li>草稿、页面等。</li>
</ul>
</li>
<li><strong>生成的静态文件 (Generated Static Files)</strong>: 当您运行 <code>hexo generate</code> 命令时,Hexo 会读取 <code>.md</code> 文件,应用主题模板,将它们转换成纯 HTML、CSS 和 JavaScript 文件。</li>
</ol>
<p><strong>关键点在于,您部署到 GitHub Pages 的,是“生成的静态文件”,而不是“源代码”。</strong></p>
<ul>
<li><strong><code>main</code> / <code>master</code> 分支</strong>: 这个分支通常只包含生成后的 <code>index.html</code>, <code>css/</code>, <code>js/</code>, <code>images/</code> 等文件。GitHub Pages 会直接从这个分支发布网站。您现在克隆下来的就是这个分支,所以里面没有 <code>.md</code> 文件。</li>
<li><strong><code>source</code> 分支 (或 <code>dev</code> 分支)</strong>: 这是一个<strong>非常常见的最佳实践</strong>。开发者会创建一个单独的分支来存放 Hexo 的源代码(包括所有 <code>.md</code> 文件)。当需要更新网站时,他们会:<ol>
<li>在 <code>source</code> 分支上写 <code>.md</code> 文件。</li>
<li>运行 <code>hexo generate</code> 生成新的静态文件。</li>
<li>将生成的文件复制或部署到 <code>main</code> 分支(或使用 <code>hexo deploy</code> 命令自动完成)。</li>
</ol>
</li>
</ul>
<p><strong>结论:您的 <code>.md</code> 文件很可能在一个名为 <code>source</code>、<code>dev</code> 或 <code>hexo-source</code> 的独立分支上,而不在您现在看到的 <code>main</code> 分支里。</strong></p>
<hr>
<h3 id="如何找回您的-md-文件?"><a href="#如何找回您的-md-文件?" class="headerlink" title="如何找回您的 .md 文件?"></a><strong>如何找回您的 <code>.md</code> 文件?</strong></h3><p>请按照以下步骤操作:</p>
<h4 id="第一步:检查是否有-source-分支"><a href="#第一步:检查是否有-source-分支" class="headerlink" title="第一步:检查是否有 source 分支"></a><strong>第一步:检查是否有 <code>source</code> 分支</strong></h4><ol>
<li>打开您的浏览器,进入您 GitHub 仓库的主页(例如 <code>https://github.com/你的用户名/你的用户名.github.io</code>)。</li>
<li>在仓库文件列表的左上角,您会看到一个下拉菜单,显示当前的分支名(很可能是 <code>main</code> 或 <code>master</code>)。</li>
<li>点击这个下拉菜单。</li>
<li>在搜索框中输入 <code>source</code>。</li>
<li>如果存在一个名为 <code>source</code>、<code>dev</code> 或类似名称的分支,请点击它。</li>
<li>浏览这个分支的文件结构。您应该能看到 <code>source/_posts/</code> 目录,您的所有 <code>.md</code> 文件就在这里!</li>
</ol>
<h4 id="第二步:如果找到了-source-分支"><a href="#第二步:如果找到了-source-分支" class="headerlink" title="第二步:如果找到了 source 分支"></a><strong>第二步:如果找到了 <code>source</code> 分支</strong></h4><ol>
<li><p><strong>在新电脑上克隆 <code>source</code> 分支</strong>:</p>
<ul>
<li>在 <code>source</code> 分支的页面上,点击绿色的 <code>Code</code> 按钮。</li>
<li>复制仓库的 URL。</li>
<li>打开终端,<strong>先删除之前克隆的 <code>main</code> 分支仓库</strong>(或者换一个文件夹)。</li>
<li>执行克隆命令,并指定 <code>source</code> 分支:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> -b <span class="built_in">source</span> https://github.com/你的用户名/你的用户名.github.io.git</span><br></pre></td></tr></table></figure></li>
<li>这样,您克隆下来的就直接是包含 <code>.md</code> 文件的源代码仓库了。</li>
</ul>
</li>
<li><p><strong>安装 Hexo 环境</strong>:</p>
<ul>
<li>您需要在新电脑上重新安装 Node.js 和 Hexo CLI。</li>
<li>在终端中进入您克隆的 <code>source</code> 仓库目录:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> 你的用户名.github.io</span><br></pre></td></tr></table></figure></li>
<li>安装项目依赖:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install</span><br></pre></td></tr></table></figure></li>
<li>安装 Hexo 命令行工具(如果尚未安装):<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo-cli</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
<li><p><strong>开始维护</strong>:</p>
<ul>
<li>现在,您可以像以前一样,在 <code>source/_posts/</code> 目录下创建和编辑 <code>.md</code> 文件。</li>
<li>预览:运行 <code>hexo server</code>,然后在浏览器访问 <code>http://localhost:4000</code>。</li>
<li>发布:完成修改后,运行以下命令来生成并部署:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean <span class="comment"># 清理缓存</span></span><br><span class="line">hexo generate <span class="comment"># 生成静态文件</span></span><br><span class="line">hexo deploy <span class="comment"># 部署到 main 分支 (这一步会自动将生成的文件推送到 main 分支)</span></span><br></pre></td></tr></table></figure></li>
</ul>
</li>
</ol>
<h4 id="第三步:如果没找到-source-分支"><a href="#第三步:如果没找到-source-分支" class="headerlink" title="第三步:如果没找到 source 分支"></a><strong>第三步:如果没找到 <code>source</code> 分支</strong></h4><p>这说明您可能没有使用分支分离的策略,而是直接在 <code>main</code> 分支上进行操作,但这非常不推荐,因为会把源代码和生成文件混在一起。</p>
<ol>
<li><p><strong>检查本地是否有旧文件</strong>:</p>
<ul>
<li>回想一下,您是否在旧电脑的某个文件夹里直接运行 <code>hexo init</code> 创建了项目?如果那个旧电脑还能用,去那个文件夹里找找看。</li>
</ul>
</li>
<li><p><strong>重新开始</strong>:</p>
<ul>
<li>如果确认 <code>.md</code> 文件已经丢失,您需要重新开始。</li>
<li>保留您克隆下来的 <code>main</code> 分支仓库作为您的“发布目录”。</li>
<li>在另一个文件夹里,重新初始化一个 Hexo 项目:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo init my-blog</span><br><span class="line"><span class="built_in">cd</span> my-blog</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure></li>
<li>将您 <code>main</code> 分支里的 <code>CNAME</code> 文件(如果有的话)复制到新项目的根目录。</li>
<li>配置 <code>_config.yml</code> 中的 <code>deploy</code> 部分,确保它指向您的 <code>your-username.github.io</code> 仓库。</li>
<li>之后,您就可以开始用 Markdown 写新文章了。</li>
</ul>
</li>
</ol>
<hr>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a><strong>总结</strong></h3><p>您找不到 <code>.md</code> 文件,<strong>几乎可以肯定是它们在一个独立的 <code>source</code> 分支上</strong>。请立即去 GitHub 仓库页面检查分支列表。一旦找到并克隆了 <code>source</code> 分支,您就可以在新电脑上恢复完整的 Hexo 工作流,继续通过写 Markdown 来维护您的网站了。</p>
<blockquote>
<p>只有main分支</p>
</blockquote>
<p>好的,收到您的反馈。如果您的 GitHub 仓库中<strong>只有 <code>main</code> 分支</strong>,并且里面只有生成的 HTML、CSS、JS 等静态文件,而没有 Hexo 的源代码(如 <code>_config.yml</code>, <code>source/_posts/</code> 目录和 <code>.md</code> 文件),那么您的原始源代码确实已经丢失了。</p>
<p>不过,别担心,您仍然可以在新电脑上恢复对网站的维护。我们无法找回旧的 <code>.md</code> 文件,但可以<strong>重建一个全新的 Hexo 工作环境</strong>,并将其连接到您现有的 GitHub 仓库。这样,您就可以重新开始用 Markdown 写文章了。</p>
<p>以下是详细的恢复步骤:</p>
<hr>
<h3 id="第一步:在新电脑上安装必要工具"><a href="#第一步:在新电脑上安装必要工具" class="headerlink" title="第一步:在新电脑上安装必要工具"></a><strong>第一步:在新电脑上安装必要工具</strong></h3><ol>
<li><p><strong>安装 Git</strong></p>
<ul>
<li>访问 <a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a> 下载并安装 Git。</li>
<li>安装后,打开终端(Terminal)或命令行,输入 <code>git --version</code>,确认安装成功。</li>
</ul>
</li>
<li><p><strong>安装 Node.js</strong></p>
<ul>
<li>Hexo 是基于 Node.js 的框架。访问 <a target="_blank" rel="noopener" href="https://nodejs.org/">https://nodejs.org/</a> 下载并安装 <strong>LTS(长期支持)版本</strong>的 Node.js。</li>
<li>安装后,在终端输入 <code>node --version</code> 和 <code>npm --version</code>,如果能显示版本号,说明安装成功。</li>
</ul>
</li>
<li><p><strong>安装 Hexo CLI</strong></p>
<ul>
<li>在终端中运行以下命令来全局安装 Hexo 命令行工具:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo-cli</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
</ol>
<hr>
<h3 id="第二步:克隆您的-GitHub-仓库作为“发布目录”"><a href="#第二步:克隆您的-GitHub-仓库作为“发布目录”" class="headerlink" title="第二步:克隆您的 GitHub 仓库作为“发布目录”"></a><strong>第二步:克隆您的 GitHub 仓库作为“发布目录”</strong></h3><p>这个仓库(<code>your-username.github.io</code>)将专门用于存放生成的静态文件,由 GitHub Pages 直接发布。</p>
<ol>
<li><p>在终端中,导航到您希望存放代码的文件夹,例如:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ~/Documents/MyProjects</span><br></pre></td></tr></table></figure>
</li>
<li><p>克隆您的 GitHub Pages 仓库:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://github.com/你的用户名/你的用户名.github.io.git</span><br></pre></td></tr></table></figure>
<ul>
<li>这个文件夹现在就是您的“发布目录”。</li>
</ul>
</li>
</ol>
<hr>
<h3 id="第三步:创建新的-Hexo-源代码项目"><a href="#第三步:创建新的-Hexo-源代码项目" class="headerlink" title="第三步:创建新的 Hexo 源代码项目"></a><strong>第三步:创建新的 Hexo 源代码项目</strong></h3><p>现在,您需要创建一个新的 Hexo 项目,这个项目将包含您的所有 <code>.md</code> 文件和配置。</p>
<ol>
<li><p>在一个<strong>与“发布目录”不同的位置</strong>创建一个新的文件夹,例如:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> hexo-source</span><br><span class="line"><span class="built_in">cd</span> hexo-source</span><br></pre></td></tr></table></figure>
</li>
<li><p>初始化一个新的 Hexo 项目:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure>
<ul>
<li>这会在当前文件夹下创建完整的 Hexo 源代码结构,包括 <code>source/_posts/</code> 目录。</li>
</ul>
</li>
<li><p><strong>(重要)配置 <code>_config.yml</code></strong></p>
<ul>
<li>用文本编辑器打开 <code>hexo-source</code> 文件夹里的 <code>_config.yml</code> 文件。</li>
<li>找到 <code>deploy</code> 部分,将其配置为指向您第一步中克隆的“发布目录”。配置如下:<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">deploy:</span></span><br><span class="line"> <span class="attr">type:</span> <span class="string">git</span></span><br><span class="line"> <span class="attr">repo:</span> <span class="string">https://github.com/你的用户名/你的用户名.github.io.git</span></span><br><span class="line"> <span class="attr">branch:</span> <span class="string">main</span></span><br></pre></td></tr></table></figure></li>
<li><strong>关键点</strong>:这里的 <code>repo</code> 地址必须是您 <code>your-username.github.io</code> 仓库的 HTTPS 地址。</li>
</ul>
</li>
</ol>
<hr>
<h3 id="第四步:建立两个目录的连接"><a href="#第四步:建立两个目录的连接" class="headerlink" title="第四步:建立两个目录的连接"></a><strong>第四步:建立两个目录的连接</strong></h3><p>为了让 Hexo 知道应该把生成的文件部署到哪个文件夹,我们需要进行一个巧妙的设置。</p>
<ol>
<li><p><strong>进入“发布目录”</strong>:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ../your-username.github.io</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>初始化一个临时的 Git 仓库</strong>(如果还没有的话):</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git init</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>将“发布目录”设置为“源代码目录”的“部署仓库”</strong>:</p>
<ul>
<li>回到“源代码目录”:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ../hexo-source</span><br></pre></td></tr></table></figure></li>
<li>运行以下命令,将“发布目录”的路径添加为一个远程仓库,命名为 <code>deploy</code>:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git remote add deploy ../your-username.github.io</span><br></pre></td></tr></table></figure></li>
<li>这个命令告诉 Git:当我说 <code>git push deploy</code> 时,实际上是把文件推送到 <code>../your-username.github.io</code> 这个本地文件夹。</li>
</ul>
</li>
</ol>
<hr>
<h3 id="第五步:测试并开始维护"><a href="#第五步:测试并开始维护" class="headerlink" title="第五步:测试并开始维护"></a><strong>第五步:测试并开始维护</strong></h3><p>现在,一切都设置好了。让我们来测试一下流程。</p>
<ol>
<li><p><strong>写一篇新文章</strong>:<br>在 <code>hexo-source</code> 文件夹中运行:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new <span class="string">"我的第一篇新文章"</span></span><br></pre></td></tr></table></figure>
<p>这会在 <code>source/_posts/</code> 目录下创建一个名为 <code>我的第一篇新文章.md</code> 的文件。</p>
</li>
<li><p><strong>编辑文章</strong>:<br>用编辑器打开这个 <code>.md</code> 文件,写一些内容。</p>
</li>
<li><p><strong>生成并部署</strong>:<br>运行以下命令:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br><span class="line">hexo generate</span><br><span class="line">hexo deploy</span><br></pre></td></tr></table></figure>
<ul>
<li><code>hexo generate</code> 会将您的 <code>.md</code> 文件生成 HTML、CSS 等静态文件。</li>
<li><code>hexo deploy</code> 会将这些生成的文件推送到 <code>deploy</code> 远程仓库,也就是我们设置的 <code>../your-username.github.io</code> 文件夹。</li>
</ul>
</li>
<li><p><strong>推送更新到 GitHub</strong>:</p>
<ul>
<li>进入“发布目录”:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ../your-username.github.io</span><br></pre></td></tr></table></figure></li>
<li>检查状态:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git status</span><br></pre></td></tr></table></figure>
您会看到有新的文件被添加。</li>
<li>提交并推送到 GitHub:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git add .</span><br><span class="line">git commit -m <span class="string">"发布新文章:我的第一篇新文章"</span></span><br><span class="line">git push origin main</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
<li><p><strong>查看结果</strong>:<br>几分钟后,访问 <code>https://你的用户名.github.io</code>,您应该就能看到新发布的内容了。</p>
</li>
</ol>
<hr>
<h3 id="总结-1"><a href="#总结-1" class="headerlink" title="总结"></a><strong>总结</strong></h3><p>通过以上步骤,您已经成功地在新电脑上重建了一个完整的、可维护的 Hexo 工作流。虽然您丢失了旧的 <code>.md</code> 文件,但您获得了一个更清晰的项目结构:</p>
<ul>
<li><code>hexo-source</code> 文件夹:存放您的所有源代码和 <code>.md</code> 文件(这是您日常工作的目录)。</li>
<li><code>your-username.github.io</code> 文件夹:存放生成的静态文件,专门用于 GitHub Pages 发布。</li>
</ul>
<p>从现在起,您只需要在 <code>hexo-source</code> 目录下写 Markdown,然后运行 <code>hexo deploy</code> 和 <code>git push</code>,就可以轻松地维护您的网站了。</p>
<p>总之,我以后我只需要在hexo new 文件后使用<br> hexo clean<br> hexo generate<br> hexo deploy就行了</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://ada2pro.github.io/1970/01/01/hello-world/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Xzywoo">
<meta itemprop="description" content="record my life, share my thoughts">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Ada2pro's blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/1970/01/01/hello-world/" class="post-title-link" itemprop="url">Hello World</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">