github.com/onflow/flow-go/crypto@v0.24.8/hash/types.go (about)

     1  package hash
     2  
     3  //revive:disable:var-naming
     4  
     5  // HashingAlgorithm is an identifier for a hashing algorithm.
     6  type HashingAlgorithm int
     7  
     8  const (
     9  	// Supported hashing algorithms
    10  	UnknownHashingAlgorithm HashingAlgorithm = iota
    11  	// SHA-2
    12  	SHA2_256
    13  	SHA2_384
    14  	// SHA-3
    15  	SHA3_256
    16  	SHA3_384
    17  	// KMAC (Keccak based MAC algorithm)
    18  	KMAC128
    19  	// legacy Keccak
    20  	Keccak_256
    21  )
    22  
    23  // String returns the string representation of this hashing algorithm.
    24  func (h HashingAlgorithm) String() string {
    25  	return [...]string{
    26  		"UNKNOWN",
    27  		"SHA2_256",
    28  		"SHA2_384",
    29  		"SHA3_256",
    30  		"SHA3_384",
    31  		"KMAC128",
    32  		"Keccak_256"}[h]
    33  }
    34  
    35  const (
    36  	// minimum targeted bits of security
    37  	securityBits = 128
    38  
    39  	// Lengths of hash outputs in bytes
    40  	HashLenSHA2_256   = 32
    41  	HashLenSHA2_384   = 48
    42  	HashLenSHA3_256   = 32
    43  	HashLenSHA3_384   = 48
    44  	HashLenKeccak_256 = 32
    45  
    46  	// KMAC
    47  	// the minimum key length in bytes
    48  	KmacMinKeyLen = securityBits / 8
    49  )