package main import ( "crypto/sha256" "fmt" ) func tagged(tag string, msg []byte) [32]byte { h := sha256.Sum256([]byte(tag)) b := append(append([]byte{}, h[:]...), h[:]...) return sha256.Sum256(append(b, msg...)) } func main() { fmt.Printf("%x\n", tagged("BIP0340/challenge", []byte("demo"))) }