github.com/deso-protocol/core@v1.2.9/desohash/algorithm.go (about) 1 package desohash 2 3 import ( 4 "crypto/sha256" 5 6 "github.com/deso-protocol/core/desohash/sha3m" 7 "golang.org/x/crypto/sha3" 8 ) 9 10 var DeSoHashV1MixConstant = [32]byte{140, 179, 163, 187, 73, 73, 228, 174, 70, 139, 110, 123, 77, 160, 46, 52, 165, 81, 68, 184, 179, 231, 190, 73, 152, 85, 103, 158, 216, 208, 207, 245} 11 12 func DeSoHashV1(input []byte) [32]byte { 13 result := sha3m.Sum256(input[:]) 14 15 for i, c := range DeSoHashV1MixConstant { 16 result[i] ^= c 17 } 18 19 return result 20 } 21 22 func DeSoHashV0(input []byte) [32]byte { 23 output := sha256.Sum256(input) 24 25 for ii := 0; ii < 100; ii++ { 26 if ii%7 == 0 { 27 output = sha3.Sum256(output[:]) 28 } 29 output = sha256.Sum256(output[:]) 30 } 31 32 return output 33 }