两次计算 SHA256 - 为什么?

Calculating SHA256 twice - what for?

我正在努力了解比特币协议,有时会看到这样的说明:

The TransactionId is defined by SHA256(SHA256(txbytes))

The hash of the public key is generated by performing a SHA256 hash on the public key, and then performing a RIPEMD160 hash on the result, with Big Endian notation. The function could look like this: RIPEMD160(SHA256(pubkey))

哈希计算两次是为了什么目的?

"A common rationale for hashing twice is to guard against the length-extension property of the hash"

这里有完整的答案https://crypto.stackexchange.com/questions/50017/why-hashing-twice