bitcoin Cryptography

Bitcoin Cryptography

Bitcoin = Hash + signature

Cryptographic hash function:

1.collision resistance 抗hash碰撞(冲突):

hash碰撞:

[forall x, exists y, x eq y,H(x) = H(y) ]

is hard to find y

the only way is brute -force

所以没有办法改变message 而不被检测

2.Hiding:

从x到H(x) 简单 ,从H(x) 到 x很难

注意:输入空间要足够大 & 分布均匀

collision resistance + Hiding = digital commitment

这样可以做到不公开预测结果的情况下进行预测

如果不这样:我们预测股票,当我在得到结果之前,公布结果,可能会影响到股票的走势,因此,预测不能提前公开,要给第三方

回到这里:

  1. x 为预测
  2. 结果是H(x),由于Hiding 性质,x得以保护
  3. 公开x,由于collision resistance ,x 不能更改

H(x||nonce) nonce 随机数 以此来保证 : 输入孔吉纳足够大 & 分布均匀

3.puzzle friendly (Bitcoin specially thing)

proof of work:H(X)的计算事先是不可预测的,通过x很难猜出H(x,如果让H(x)在一个范围只能一个一个试

for example: H(x) 需要满足 0000000(k个0)xxxxxxx ,只能一个一个试

mine:hard,H(block header) <= target

Difficult to solve ,but easy to verify

SHA256

Secure Hash Algorithm 满足上述 1,2,3

有趣的是基本上大部分HASH函数的性质不是被证明出来的,都是经验论,计算机算不出来

create accounts: asymmetric encryption (非对称加密)

<public key,private key>

message 通过 public key 加密,再通过 private key 解密(使用同一个人的public&private key)

use private key to signature , use public key to verify

产生同样的<public key,private key> 的概率 比地球爆照要小

原文地址:https://www.cnblogs.com/ARTlover/p/14826548.html