Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmountaintop committed Apr 21, 2019
1 parent 4a6cad7 commit 3ea5a9b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
44 changes: 43 additions & 1 deletion bitcoin/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,46 @@ James O’Beirne 在 Bitcoin-Dev mailing list 发了个 [帖子](https://lists.l
* 数字 1 隔断 HRP 与地址的数据部分
* HRP `bc`: mainnet
* HRP `tb`: testnet
-
+ Sending to a P2PKH address vs Sending to a equivalent bech32 P2WPKH address
* P2PKH
- for `1B6FkNg199ZbPJWG5zjEiDekrCc2P7MVyC`, base58check library will decode that to a 20-byte commitment:
```
6eafa604a503a0bb445ad1f6daa80f162b5605d6
```
- This commitment is inserted into a scriptPubKey template:
```
OP_DUP OP_HASH160 OP_PUSH20 6eafa604a503a0bb445ad1f6daa80f162b5605d6 OP_EQUALVERIFY OP_CHECKSIG
```
- Converting the opcodes to hex, this looks like:
```
76a9146eafa604a503a0bb445ad1f6daa80f162b5605d688ac
```
- This is inserted into the scriptPubKey part of an output that also includes the length of the script (25 bytes) and the amount being paid:
```
amount scriptPubKey
|--------------| |------------------------------------------------|
00e1f505000000001976a9146eafa604a503a0bb445ad1f6daa80f162b5605d688ac
|
size: 0x19 -> 25 bytes
```
+ `scriptpubkey` vs `scriptsigs`
* 在两笔交易中, 按顺序组合并执行, 分别锁定和解锁
* `scriptpubkey` 的原因是 地址只不过是公钥的哈希值, 发送方不知道接收方的公钥
* ![LockingUnlocking](/img/LockingUnlocking.png)
## getaddressinfo
An current example of the descriptor format with key origin information and an error-detecting checksum:
```
$ bitcoin-cli getaddressinfo bc1qsksdpqqmsyk9654puz259y0r84afzkyqdfspvc | jq .desc
"wpkh([f6bb4c63/0'/0'/21']034ed70f273611a3f21b205c9151836d6fa9051f74f6e6bbff67238c9ebc7d04f6)#mtdep7g7"
```
+ The address is a Witness Public Key Hash `wpkh()`, otherwise known as P2WPKH. Descriptors can succinctly describe all common uses of P2PKH, P2SH, P2WPKH, P2WSH, and nested segwit.
+ The [key origin](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md#key-origin-identification) is described between the square brackets `[]`.
* `f6bb4c63` is a fingerprint that identifies the key at the root of the path provided. The fingerprint is the first 32 bits of its `ripemd(sha256())` hash as [defined by BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers). This makes it easy for tools, such as those used with PSBTs, to work with multisig scripts and other cases where you have multiple signing devices using different keys.
* `/0'/0'/21'` is the HD key path, corresponding to `m/0'/0'/21'` in standard [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) notation. This allows a wallet that doesn’t have all of its public keys precomputed to know which private key it needs to generate in order to produce the signature. (Bitcoin Core precomputes its public keys and so usually doesn’t need this information when used as a cold wallet—but hardware wallets with minimal storage and computational speed need HD path information in order to work efficiently.)
+ The actual public key used to generate the P2WPKH key hash is `034ed7...04f6`
+ A checksum following a # protects the descriptor string against typos on import, `mtdep7g7`
## mul-sig 多重签名
Expand Down Expand Up @@ -429,6 +468,9 @@ sqrt(n_max) = 2.4061596916800453e+38
虽然 sqrt 后量级已经大大减少,但还是 trillion trillion trillion 级别,在一个可以预见的时间内无法破解。所以,即便使用了 Grover 算法,也无法有效地通过钱包地址破解出公钥,进而进一步使用 Shor 算法从公钥破解出私钥。
### NewHope 密钥交换协议
[该协议](https://newhopecrypto.org/) 被认为可抵抗量子计算机的攻击,因此今天记录两个对等体之间通信的窃听者将无法在将来解密该数据他们拥有一台快速量子计算机。
## Schnorr签名
可以用来改善区块链的隐私,同时通过将无关数据移出区块链来提高可伸缩性。
Expand Down
20 changes: 19 additions & 1 deletion blockchain/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ __Block Header__

+ merkle tree root hash 作用
+ 如果给定一个 tx hash,最少还需要知道哪些信息才能确定该 tx 是否在一个block中
+


### Coinbase

Expand Down Expand Up @@ -82,6 +82,24 @@ Pedersen commitment scheme has the following properties:
* bitcoin 原本的规则可以保证在任何时候至少有一个节点知道主链是什麽——因为它知道所有的区块。GHOST 则无法保证这一点。(虽然通过广播所有的区块可以解决,但是这又带来 DoS 的风险——恶意节点狂发低难度的区块。这种情况下,GHOST表现得比原生协议要差,因为广播区块开销超过了选链规则带来的好处等到GHOST有实用解决方案,比如说广播区块头而非整个块,可以用来补足 bitcoin-NG)
* GHOST 中,被剪枝的子树上的区块只在分岔点影响链选择。Bitcoin-NG 在高带宽和吞吐的情况下分叉很小,使得算力更加充分被利用,选链更加公平。

### pruning
once your node has downloaded the block data and validated the blocks/transactions in it, it throws away the old data that it no longer needs (since it's already been validated).


## transaction 'pinning'?
Transaction pinning happens when:

+ I broadcast a transaction that signals opt-in RBF
+ the transaction does not get confirmed because the feerate is too low
+ someone else broadcasts a new (child) transaction spending one of the outputs of my transaction
+ I now can't bump the fee on the transaction unless I include a fee greater than that of the combined original transaction + the child transaction (BIP 125, rule 3).

If the child transaction in (3) is large (eg a commercial service sweeping up lots of transaction outputs), then the total fee that __I'd need to pay for a valid RBF would be very large__.

In this scenario, my original transaction has been 'pinned' by the child transaction.

Russell O'Connor has proposed [changing the RBF policy rules](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-February/015717.html) to alleviate this problem.


## 公有链 vs 联盟链 vs 私有链

Expand Down
1 change: 1 addition & 0 deletions explorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## database
+ [bitcoin-abe](https://github.com/bitcoin-abe/bitcoin-abe)
+ [Blockstream/esplora](https://github.com/blockstream/esplora)
+ update logic
```
chain_height = get_chain_height()
Expand Down
Binary file added img/LockingUnlocking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
+ [Realtime mining hardware profitability](https://www.asicminervalue.com/)
+ [WhatToMine](https://whattomine.com/)

## BetterHash
可能会 替代 stratum, 可以用来解决 矿池不需矿工同意挪动算力改挖其他币

## 挖矿进化史
历史上,各种 PoW 数字货币曾设计了若干种
Anti-ASIC 算法,试图达到这一目标,但这些算法都不尽人意。这些算法大致可
Expand Down

0 comments on commit 3ea5a9b

Please sign in to comment.