0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

如何验证Bitcoin Core软件签名

Last updated at Posted at 2021-05-30


本文使用的Bitcoin Core 软件版本有点老旧,方法却是一致的。

背景

了解下 Electrum 钱包钓鱼事件

GPG 的来历

1991 年,Phil Zimmermann开发了加密软件 PGP,被用来加密邮件。这个软件非常好用,迅速流传开来,成了许多工程师的必备工具。但它是商业软件,不能自由使用。于是自由软件基金会决定,开发一个 PGP 的替代品,取名为 GnuPG。这就是 GPG 的由来。

签名:是为了接收方能够确认信息确实来自信息所声称的发送方,并且没有在传递过程中被第三方修改。在签名操作中,OpenPGP 首先对信息进行取散列值的操作,然后使用信息发送者的私钥加密这个散列值,获得一个数字签名,并将签名和原信息一同发送。接收方的 OpenPGP 软件也根据协议计算信息的散列值,并用信息发送者的公钥解密数字签名中的散列值信息,能解密就说明信息的发送者确实是预想的发送方,而两个散列值比对,就能确定信息并未被篡改。

安装

sudo apt-get install gnupg

发现签名所用的 GPG key

下载文件
https://bitcoin.org/bin/bitcoin-core-0.17.1/bitcoin-0.17.1-x86_64-linux-gnu.tar.gz

https://bitcoin.org/bin/bitcoin-core-0.17.1/SHA256SUMS.asc

文件内容如下:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

5659c436ca92eed8ef42d5b2d162ff6283feba220748f9a373a5a53968975e34  bitcoin-0.17.1-aarch64-linux-gnu.tar.gz
aab3c1fb92e47734fadded1d3f9ccf0ac5a59e3cdc28c43a52fcab9f0cb395bc  bitcoin-0.17.1-arm-linux-gnueabihf.tar.gz
b1e1dcf8265521fef9021a9d49d8661833e3f844ca9a410a9dd12a617553dda1  bitcoin-0.17.1-i686-pc-linux-gnu.tar.gz
6aa567381b95a20ac96b0b949701b04729a0c5796c320481bfa1db22da25efdb  bitcoin-0.17.1-osx64.tar.gz
e3d785d800b71d277959d15b2c2b33d44dd72c1288e559928a40488dd935c949  bitcoin-0.17.1-osx.dmg
3e564fb5cf832f39e930e19c83ea53e09cfe6f93a663294ed83a32e194bda42a  bitcoin-0.17.1.tar.gz
e9245e682126ef9fa4998eabbbdd1c3959df811dc10df60be626a5e5ffba9b78  bitcoin-0.17.1-win32-setup.exe
6464aa2d338f3697950613bb88124e58d6ce78ead5e9ecacb5ba79d1e86a4e30  bitcoin-0.17.1-win32.zip
fa1e80c5e4ecc705549a8061e5e7e0aa6b2d26967f99681b5989d9bd938d8467  bitcoin-0.17.1-win64-setup.exe
1abbe6aa170ce7d8263d262f8cb0ae2a5bb3993aacd2f0c7e5316ae595fe81d7  bitcoin-0.17.1-win64.zip
53ffca45809127c9ba33ce0080558634101ec49de5224b2998c489b6d0fc2b17  bitcoin-0.17.1-x86_64-linux-gnu.tar.gz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJcIeQ5AAoJEJDIAZ42wulk0NoQAIunIBT06bd2IhhxV/48NUvf
sgTto4qYrKuX5Vkn+kfGuMBvNpmILi5CiVtnucWo7fKM6k5IPMyBQuE9iDVDzT9i
YemA9Au8Xy2aIGmVriuQoXxk8b17wAMS9uw362A3nXCz3kA+BWMDuMfBp3P3NPM/
PeOg6n04Q7seO/zNdT5i/ysaFB/XA8szrQxCRukSrXeGMUpv79UbcWOu3+nfGit9
yYo/F2yO57Yacv597rKILlg29QxEVTqa5+slMdwuU7NP5AdAcQV4EtFqoCOqM7C7
JL/zZWYnTywK3l0hOuCBJiY86izutWME5xgm7Eh3ORj+K6ZYT4iXw2JIkTdumeuS
X0WDE3ShH4rb35IaQX75FJLp5R7hLTXiNgng7b8Xhy/62bJ75Ob4HVVSLG1Lkhps
vtml10br+78qXiofzk8zaAW6KaG7G9nbBa0hfDjUEsYzA6P5iWA+53ykupc82HNa
ZT2gk+wWhNhZOd/ANheriM0eqm/ZlK7oydYRRtf9Tamk+XJgREU1x8cWlMZcCPEE
uIUzb7/REvYSjwcwArYLCq/eFPfjQe7jcG2WexnpxxkKJBvu2v4zVw9LLUPll094
BAmfk34iJKhN2cGVhvjO0Q9GKk0B2HzvhD5xn1Hnlp+NbXVNbKonYvkB71D3GY4W
t/eRyv7Erfi4dhHf+8oQ
=UEoM
-----END PGP SIGNATURE-----

使用命令验证文件

gpg --verify SHA256SUMS.asc

# gpg: Signature made 2018/12/25 using RSA key ID 36C2E964
# gpg: Can't check signature: public key not found

发现关键信息 RSA key ID 36C2E964

导入 public key

gpg --keyserver hkp://keys.gnupg.net/ --recv-keys 36C2E964

# gpg: requesting key 36C2E964 from hkp server keys.gnupg.net
# gpg: key 36C2E964: "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>" not changed
# gpg: Total number processed: 1
# gpg:              unchanged: 1

验证

gpg --verify SHA256SUMS.asc

gpg: Signature made Tue 25 Dec 2018 04:03:05 PM CST using RSA key ID 36C2E964
gpg: Good signature from "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 01EA 5486 DE18 A882 D4C2  6845 90C8 019E 36C2 E964

Good signature from ... 说明这个文件是由 Wladimir J. van der Laan 签发。

这只是验证了 SHA256SUMS.asc 文件是由 Wladimir 签发的,我们还要验证 Bitcoin Core 的签名。

验证 Bitcoin Core 软件

Bitcoin Core 软件是由 sha256 算法签名的

sha256sum bitcoin-0.17.1-x86_64-linux-gnu.tar.gz
# 53ffca45809127c9ba33ce0080558634101ec49de5224b2998c489b6d0fc2b17

把得到的结果与 SHA256SUMS.asc 做对比,如果结果吻合,可以放心使用

还有另一种方式

sha256sum -c SHA256SUMS.asc
# bitcoin-0.17.1-x86_64-linux-gnu.tar.gz: OK

删除 public key

gpg --list-keys
gpg --delete-key 36C2E964

Don’t Trust, Verify

不要相信它,去验证它!


参考:

https://zhuanlan.zhihu.com/p/21267738
http://www.ruanyifeng.com/blog/2013/07/gpg.html
http://pool.sks-keyservers.net
https://linux.cn/article-4378-1.html
https://superuser.com/a/999312

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?