Skip to content

Commit 2d1bf02

Browse files
committed
add method to convert secret to pub key
1 parent d8deef7 commit 2d1bf02

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

x/lending/types/utils.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package types
2+
3+
import "github.com/btcsuite/btcd/btcec/v2"
4+
5+
// SecretToPubKey gets the serialized public key of the given secret on the secp256k1 curve
6+
// Assume that the secret is 256-bit bytes
7+
func SecretToPubKey(secretBytes []byte) []byte {
8+
var secret btcec.ModNScalar
9+
_ = secret.SetByteSlice(secretBytes)
10+
11+
var result btcec.JacobianPoint
12+
btcec.ScalarBaseMultNonConst(&secret, &result)
13+
14+
return btcec.JacobianToByteSlice(result)
15+
}

0 commit comments

Comments
 (0)