上文已经说过,交易脚本最重要的两点,其中第二点就是公钥和私钥的密码体制的设计,也就是非对称加密算法。
《精通比特币》第四章也简单说了一下椭圆曲线加密算法,但是这个算法,或者说非对称加密算法很值得进一步了解。非对称加密算法,签名使用私钥,验证使用公钥,从而实现了加密和解密分离,如果没有这个算法,区块链根本就无法实现。
我们先从另一个经典的非对称加密算法RSA开始说起。
RSA利用的是欧拉定理。阅读下文之前,请先参见阮一峰的博客 RSA算法原理(一) 和 阮一峰的博客 RSA算法原理(二)。
上文浅显易懂,其中需要解释一下,第二篇文章中《九、私钥解密的证明》,需要证明的是 med ≡ m (mod n)。怎么得到这个证明目的,其实很简单:
明文是m,密文是c,其中c ≡ me (mod n),而解密的时候,是cd ≡ m (mod n),需要证明的是:cd ≡ (me)d ≡ med ≡ m (mod n)
证明 m与n不是互质关系的情况时,有几点说明:
1. 由于n等于质数p和q的乘积,m和n又有公约数,而m只有p和q两个约数,所以m必然等于kp或kq。以 m = kp为例,m < n, 即 kp < qp,即k < q, 并且q还是质数,那么k和q必然互质,因为一个质数和小于它的数都是互质的。
2. 由 (kp)ed = tq + kp 得到 (kp)ed = t’pq + kp,是因为:
(kp)ed = tq + kp ,则 (kp)ed – 1 = (tq) / (kp) + 1,则 (kp)ed – 1 – 1 = (tq) / (kp),左边肯定是一个整数,那么右边肯定也是一个整数,而q和p互质,那么只可能 t = t’p。
大家想要得到更深入的证明,可以参考《密码学原理与实践》的第五章。
RSA的证明理解起来比较简单,正是由于简单易懂,所以再讲比特币的非对称加密算法,也就是椭圆曲线加密算法之前,先讲解 RSA,便于理解其中的思想。RSA保证了密码一分为二,私钥用于数字签名或者解密,公钥用于验证签名或者加密。下一篇会讲解椭圆曲线加密算法。
prednisolone
40 mg sildenafil
buy metformin 500mg tablets
doxy 100
generic viagra sildenafil
where can you buy doxycycline
prednisone steroid
ventolin 500 mg
albuterol ipratropium
buy sildenafil
losartan hydrochlorothiazide
acyclovir capsules
lisinopril 40 mg
Very well written post. It will be supportive to anybody who usess it, including yours truly :). Keep doing what you are doing – can’r wait to read more posts.
You actually make it seem so easy with your presentation but I find this matter to be actually something that I think I would never understand. It seems too complicated and very broad for me. I’m looking forward for your next post, I will try to get the hang of it!
elimite over the counter canada
buy elimite cream online
elimite cream over the counter
where to buy elimite cream
Hi, Neat post. There is a problem with your website in internet explorer, would check this… IE still is the market leader and a good portion of people will miss your fantastic writing due to this problem.