1package wesh23import "crypto/sha256"45// blockSize is SHA-256's internal block size, the padding width HMAC uses.6const blockSize = 6478// HMACSHA256 computes HMAC-SHA256 as specified in RFC 2104.9//10// gno's standard library exposes sha256.Sum256 but no streaming hash.Hash and11// no crypto/hmac, so the construction is spelled out here:12//13// HMAC(K, m) = H((K' ⊕ opad) ‖ H((K' ⊕ ipad) ‖ m))14//15// with K' the key hashed down when longer than the block size, then16// zero-padded up to it. This is the primitive weshnet's rendezvous point17// derivation is built on, so it has to agree byte-for-byte; see18// [RendezvousPoint].19func HMACSHA256(key, msg []byte) []byte {20 k := key21 if len(k) > blockSize {22 sum := sha256.Sum256(k)23 k = sum[:]24 }2526 ipad := make([]byte, blockSize)27 opad := make([]byte, blockSize)28 copy(ipad, k)29 copy(opad, k)30 for i := 0; i < blockSize; i++ {31 ipad[i] ^= 0x3632 opad[i] ^= 0x5c33 }3435 inner := sha256.Sum256(append(ipad, msg...))36 outer := sha256.Sum256(append(opad, inner[:]...))37 return outer[:]38}39Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.