func CalcMessageHash12(msg []byte, protocol string) Hash12 {
	return CalcHash12(append(msg, protocol...))
}
CalcMessageHash12 returns the 12-byte sha256 sum of the given msg suffixed with protocol.
package types
import (
	"fmt"
	"math/big"
	"math/rand"
	"reflect"
	"github.com/libonomy/libonomy-p2p/common/util"
	"github.com/libonomy/libonomy-p2p/log"
	"github.com/libonomy/sha256-simd"
)
const (
	Hash32Length = 32
	hash20Length = 20
	hash12Length = 12
)
type Hash12 [hash12Length]byte
type Hash32 [Hash32Length]byte
type Hash20 [hash20Length]byte
func (h Hash12) Field(name string) log.Field { return log.String(name, util.Bytes2Hex(h[:])) }
func (h Hash20) Bytes() []byte { return h[:] }
func (h Hash20) Big() *big.Int { return new(big.Int).SetBytes(h[:]) }
func (h Hash20) Hex() string { return util.Encode(h[:]) }
func (h Hash20) String() string {
	return h.Hex()
}
func (h Hash20) ShortString() string {
	l := len(h.Hex())
	return h.Hex()[util.Min(2, l):util.Min(7, l)]
}
func (h Hash20) Format(s fmt.State, c rune) {
	_, _ = fmt.Fprintf(s, "%"+string(c), h[:])
}
func (h *Hash20) UnmarshalText(input []byte) error {
	return util.UnmarshalFixedText("Hash", input, h[:])
}
func (h *Hash20) UnmarshalJSON(input []byte) error {
	return util.UnmarshalFixedJSON(hashT, input, h[:])
}
func (h Hash20) MarshalText() ([]byte, error) {
	return util.Bytes(h[:]).MarshalText()
}
func (h *Hash20) SetBytes(b []byte) {
	if len(b) > len(h) {
		b = b[len(b)-32:]
	}
	copy(h[32-len(b):], b)
}
func (h Hash20) ToHash32() (h32 Hash32) {
	copy(h32[:], h[:])
	return
}
func (h Hash20) Field(name string) log.Field { return log.String(name, util.Bytes2Hex(h[:])) }
func CalcHash12(data []byte) (h Hash12) {
	h32 := sha256.Sum256(data)
	copy(h[:], h32[:])
	return
}
func CalcBlocksHash12(view []BlockID) (h Hash12) {
	h32 := CalcBlocksHash32(view, nil)
	copy(h[:], h32[:])
	return
}
func CalcBlocksHash32(view []BlockID, additionalBytes []byte) Hash32 {
	sortedView := make([]BlockID, len(view))
	copy(sortedView, view)
	SortBlockIDs(sortedView)
	return CalcBlockHash32Presorted(sortedView, additionalBytes)
}
func CalcBlockHash32Presorted(sortedView []BlockID, additionalBytes []byte) Hash32 {
	hash := sha256.New()
	hash.Write(additionalBytes)
	for _, id := range sortedView {
		hash.Write(id.ToBytes())  
	}
	var res Hash32
	hash.Sum(res[:0])
	return res
}