Skip to content

Commit 51de731

Browse files
committed
optimize
1 parent 0b89079 commit 51de731

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

x/lending/types/taproot.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ import (
1010
"github.com/btcsuite/btcd/chaincfg"
1111
"github.com/btcsuite/btcd/txscript"
1212

13+
"github.com/sideprotocol/side/crypto/adaptor"
1314
"github.com/sideprotocol/side/crypto/hash"
1415
"github.com/sideprotocol/side/x/dlc/types"
1516
)
1617

18+
// HashLoanSecret hashes the given secret
19+
// Assume that the secret is a valid hex string
1720
func HashLoanSecret(secret string) string {
18-
// Todo later
19-
return secret
21+
secretBytes, _ := hex.DecodeString(secret)
22+
23+
return hex.EncodeToString(hash.Sha256(secretBytes))
2024
}
2125

26+
// AdaptorPoint gets the corresponding adaptor point from the given secret
27+
// Assume that the secret is a valid hex string
2228
func AdaptorPoint(secret string) string {
23-
return secret
29+
secretBytes, _ := hex.DecodeString(secret)
30+
31+
return hex.EncodeToString(adaptor.SecretToPubKey(secretBytes))
2432
}
2533

2634
func GetTaprootAddress(script []byte) (*btcutil.AddressTaproot, error) {

0 commit comments

Comments
 (0)