TMHASH is 32 bytes. Closes #1990 (#2732)

* tmhash is fully 32 bytes. closes #1990

* AddressSize

* fix tests

* fix max sizes
This commit is contained in:
Ethan Buchman
2018-10-31 12:42:05 -04:00
committed by GitHub
parent 1660e30ffe
commit a22c962e28
16 changed files with 96 additions and 51 deletions

View File

@ -344,7 +344,7 @@ next validator sets Merkle root.
### ConsensusParamsHash
```go
block.ConsensusParamsHash == tmhash(amino(state.ConsensusParams))
block.ConsensusParamsHash == TMHASH(amino(state.ConsensusParams))
```
Hash of the amino-encoded consensus parameters.

View File

@ -176,13 +176,12 @@ greater, for example:
h0 h1 h3 h4 h0 h1 h2 h3 h4 h5
```
Tendermint always uses the `TMHASH` hash function, which is the first 20-bytes
of the SHA256:
Tendermint always uses the `TMHASH` hash function, which is equivalent to
SHA256:
```
func TMHASH(bz []byte) []byte {
shasum := SHA256(bz)
return shasum[:20]
return SHA256(bz)
}
```

View File

@ -56,8 +56,8 @@ type Validator struct {
}
```
When hashing the Validator struct, the pubkey is not hashed,
because the address is already the hash of the pubkey.
When hashing the Validator struct, the address is not included,
because it is redundant with the pubkey.
The `state.Validators`, `state.LastValidators`, and `state.NextValidators`, must always by sorted by validator address,
so that there is a canonical order for computing the SimpleMerkleRoot.