diff --git a/x/lending/types/taproot.go b/x/lending/types/taproot.go index 51889277..c9432c78 100644 --- a/x/lending/types/taproot.go +++ b/x/lending/types/taproot.go @@ -10,17 +10,25 @@ import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" + "github.com/sideprotocol/side/crypto/adaptor" "github.com/sideprotocol/side/crypto/hash" "github.com/sideprotocol/side/x/dlc/types" ) +// HashLoanSecret hashes the given secret +// Assume that the secret is a valid hex string func HashLoanSecret(secret string) string { - // Todo later - return secret + secretBytes, _ := hex.DecodeString(secret) + + return hex.EncodeToString(hash.Sha256(secretBytes)) } +// AdaptorPoint gets the corresponding adaptor point from the given secret +// Assume that the secret is a valid hex string func AdaptorPoint(secret string) string { - return secret + secretBytes, _ := hex.DecodeString(secret) + + return hex.EncodeToString(adaptor.SecretToPubKey(secretBytes)) } func GetTaprootAddress(script []byte) (*btcutil.AddressTaproot, error) {