code: func (l *listenContext) cookieHash(id stack.TransportEndpointID, ts uint32, nonceIndex int) uint32 {
  
  	// Initialize block with fixed-size data: local ports and v.
  	var payload [8]byte
  	binary.BigEndian.PutUint16(payload[0:], id.LocalPort)
  	binary.BigEndian.PutUint16(payload[2:], id.RemotePort)
  	binary.BigEndian.PutUint32(payload[4:], ts)
  
  	// Feed everything to the hasher.
  	l.hasherMu.Lock()
  	l.hasher.Reset()
  	l.hasher.Write(payload[:])
  	l.hasher.Write(l.nonce[nonceIndex][:])
  	io.WriteString(l.hasher, string(id.LocalAddress))
  	io.WriteString(l.hasher, string(id.RemoteAddress))
  
  	// Finalize the calculation of the hash and return the first 4 bytes.
  	h := make([]byte, 0, sha1.Size)
  	h = l.hasher.Sum(h)
  	l.hasherMu.Unlock()
  
  	return binary.BigEndian.Uint32(h[:])
  }
docs: // cookieHash calculates the cookieHash for the given id, timestamp and nonce
  // index. The hash is used to create and validate cookies.