func TweakPrivKey(walletPrivKey *btcutil.WIF, tweak []byte, chainCfg *chaincfg.Params) (*btcutil.WIF, error) {
	resVal := new(big.Int).SetBytes(walletPrivKey.PrivKey.Serialize())
	n := new(big.Int).Set(btcec.S256().Params().N)
	path := getDerivationPathFromTweak(tweak)  
	for _, pathChild := range path {
		resVal = tweakValWithPathChild(pathChild, resVal)
		resVal.Mod(resVal, n)
	}
	resPrivKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), resVal.Bytes())
	resWalletPrivKey, err := btcutil.NewWIF(resPrivKey, chainCfg, walletPrivKey.CompressPubKey)
	if err != nil {
		return nil, err
	}
	return resWalletPrivKey, nil
}
Tweak a private key by adding the tweak to it's integer representation
package crypto
import (
	"crypto/ecdsa"
	"encoding/binary"
	"math/big"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcd/chaincfg"
	"github.com/btcsuite/btcutil"
	"github.com/btcsuite/btcutil/hdkeychain"
)
func GetWalletPrivKey(privKey string) (*btcutil.WIF, error) {
	key, err := btcutil.DecodeWIF(privKey)
	if err != nil {
		return nil, err
	}
	return key, nil
}
const derivationPathSize = 16                                        
const derivationPathChildSize = 2                                    
const derivationSize = derivationPathSize * derivationPathChildSize  
type derivationPathChild [derivationPathChildSize]byte
type derivationPath [derivationPathSize]derivationPathChild
func getDerivationPathFromTweak(tweak []byte) derivationPath {
	if len(tweak) != derivationSize {
		return derivationPath{}
	}
	var path derivationPath
	for it := 0; it < derivationPathSize; it++ {
		child := new(derivationPathChild)
		copy(child[:], tweak[it*derivationPathChildSize:it*derivationPathChildSize+derivationPathChildSize])
		path[it] = derivationPathChild(*child)
	}
	return path
}
func tweakValWithPathChild(child derivationPathChild, val *big.Int) *big.Int {
	childBytes := make([]byte, derivationPathChildSize)
	copy(childBytes, child[:])
	twkVal := new(big.Int).SetBytes(childBytes)
	return val.Add(val, twkVal)
}