Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ func Sha256HexString(str string) string {
return hex.EncodeToString(hash[:])
}

func DerivePublicKey(seedHexString string, network lightspark_crypto.BitcoinNetwork, derivationPath string) (string, error) {
func DerivePublicKey(seedHexString string, derivationPath string) (string, error) {
seedBytes, err := hex.DecodeString(seedHexString)
if err != nil {
return "", err
}

return lightspark_crypto.DerivePublicKey(seedBytes, network, derivationPath)
xpriv, err := DeriveXpriv(seedBytes, derivationPath)
if err != nil {
return "", err
}

xpub := xpriv.PublicKey()
return xpub.String(), nil
}

func ECDH(seedBytes []byte, network lightspark_crypto.BitcoinNetwork, otherPubKey string) (string, error) {
Expand Down
45 changes: 45 additions & 0 deletions crypto/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strconv"
"strings"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/tyler-smith/go-bip32"
)

Expand Down Expand Up @@ -87,3 +88,47 @@ func GeneratePreimageAndPaymentHash(key []byte, nonce []byte) ([]byte, []byte, e

return preimage, paymentHash[:], nil
}

func GetPerCommitmentPoint(seedBytes []byte, derivationPath string, perCommitmentPointIdx uint64) ([]byte, error) {
secret, err := ReleasePerCommitmentSecret(seedBytes, derivationPath, perCommitmentPointIdx)
if err != nil {
return nil, err
}

privKey, _ := btcec.PrivKeyFromBytes(secret)
pubKey := privKey.PubKey()
return pubKey.SerializeCompressed(), nil
}

func ReleasePerCommitmentSecret(seedBytes []byte, derivationPath string, perCommitmentPointIdx uint64) ([]byte, error) {
xpriv, err := DeriveXpriv(seedBytes, derivationPath)
if err != nil {
return nil, err
}

privKeyHash := sha256.Sum256(xpriv.Key)
channelSeed := privKeyHash[:]
commitmentSeed := buildCommitmentSeed(channelSeed)
commitmentSecret := buildCommitmentSecret(commitmentSeed[:], perCommitmentPointIdx)
return commitmentSecret, nil
}

func buildCommitmentSeed(channelSeed []byte) [32]byte {
combined := append(channelSeed, []byte("commitment seed")...)
return sha256.Sum256(combined)
}

func buildCommitmentSecret(seed []byte, idx uint64) []byte {
res := make([]byte, len(seed))
copy(res, seed)

for i := range 48 {
bitpos := 47 - i
if (idx & (1 << bitpos)) == (1 << bitpos) {
res[bitpos/8] ^= 1 << (bitpos & 7)
hash := sha256.Sum256(res)
res = hash[:]
}
}
return res
}
24 changes: 22 additions & 2 deletions crypto/test/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@
package crypto_test

import (
"encoding/hex"
"github.com/lightsparkdev/go-sdk/crypto"
"testing"

lightspark_crypto "github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require"
)

func TestDerivePublicKey(t *testing.T) {
privateKeySeed := "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"
derivationPath := "m/0/2147483647'/1"

publicKey, err := crypto.DerivePublicKey(privateKeySeed, lightspark_crypto.Mainnet, derivationPath)
publicKey, err := crypto.DerivePublicKey(privateKeySeed, derivationPath)
require.NoError(t, err)
require.Equal(t, "xpub6DF8uhdarytz3FWdA8TvFSvvAh8dP3283MY7p2V4SeE2wyWmG5mg5EwVvmdMVCQcoNJxGoWaU9DCWh89LojfZ537wTfunKau47EL2dhHKon", publicKey)
}

func TestCommitment(t *testing.T) {
seedHexString := "000102030405060708090a0b0c0d0e0f"
seedBytes, err := hex.DecodeString(seedHexString)
require.NoError(t, err)

derivationPath := "m/3/2104864975"
commitmentPointIdx := uint64(281474976710654)
commitmentPoint, err := crypto.GetPerCommitmentPoint(seedBytes, derivationPath, commitmentPointIdx)
require.NoError(t, err)

commitmentSecret, err := crypto.ReleasePerCommitmentSecret(seedBytes, derivationPath, commitmentPointIdx)
require.NoError(t, err)

privKey, _ := btcec.PrivKeyFromBytes(commitmentSecret)
pubKey := privKey.PubKey()
serializedPubKey := pubKey.SerializeCompressed()
require.Equal(t, commitmentPoint, serializedPubKey)
}
2 changes: 2 additions & 0 deletions examples/lnurl-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions examples/lnurl-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25Yn
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
Expand All @@ -16,6 +18,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down
8 changes: 4 additions & 4 deletions examples/remote-signing-server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/lightsparkdev/go-sdk/examples/remote-signing-server

go 1.22.0
go 1.22.6

toolchain go1.23.2

Expand All @@ -13,8 +13,8 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/btcsuite/btcd v0.24.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd v0.24.3-0.20240921052913-67b8efd3ba53 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/btcutil/psbt v1.1.9 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
Expand Down Expand Up @@ -44,7 +44,7 @@ require (
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions examples/remote-signing-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
github.com/btcsuite/btcd v0.24.0 h1:gL3uHE/IaFj6fcZSu03SvqPMSx7s/dPzfpG/atRwWdo=
github.com/btcsuite/btcd v0.24.0/go.mod h1:K4IDc1593s8jKXIF7yS7yCTSxrknB9z0STzc2j6XgE4=
github.com/btcsuite/btcd v0.24.3-0.20240921052913-67b8efd3ba53 h1:XOZ/wRGHkKv0AqxfDks5IkzaQ1Ge6fq322ZOOG5VIkU=
github.com/btcsuite/btcd v0.24.3-0.20240921052913-67b8efd3ba53/go.mod h1:zHK7t7sw8XbsCkD64WePHE3r3k9/XoGAcf6mXV14c64=
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=
Expand Down Expand Up @@ -162,8 +162,8 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
1 change: 1 addition & 0 deletions examples/uma-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions examples/uma-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
)

require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
Expand Down
21 changes: 5 additions & 16 deletions remotesigning/remote_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,9 @@ func HandleEcdhRequest(request *ECDHRequest, seedBytes []byte) (*ECDHResponse, e

func HandleGetPerCommitmentPointRequest(request *GetPerCommitmentPointRequest, seedBytes []byte) (*GetPerCommitmentPointResponse, error) {
log.Println("Handling GET_PER_COMMITMENT_POINT webhook")
bitcoinNetwork, err := bitcoinNetworkConversion(request.BitcoinNetwork)
if err != nil {
return nil, err
}

perCommitmentPoint, err := lightspark_crypto.GetPerCommitmentPoint(
perCommitmentPoint, err := crypto.GetPerCommitmentPoint(
seedBytes,
bitcoinNetwork,
request.DerivationPath,
request.PerCommitmentPointIdx)
if err != nil {
Expand All @@ -240,14 +235,8 @@ func HandleGetPerCommitmentPointRequest(request *GetPerCommitmentPointRequest, s

func HandleReleasePerCommitmentSecretRequest(request *ReleasePerCommitmentSecretRequest, seedBytes []byte) (*ReleasePerCommitmentSecretResponse, error) {
log.Println("Handling RELEASE_PER_COMMITMENT_SECRET webhook")
bitcoinNetwork, err := bitcoinNetworkConversion(request.BitcoinNetwork)
if err != nil {
return nil, err
}

perCommitmentSecret, err := lightspark_crypto.ReleasePerCommitmentSecret(
perCommitmentSecret, err := crypto.ReleasePerCommitmentSecret(
seedBytes,
bitcoinNetwork,
request.DerivationPath,
request.PerCommitmentPointIdx)
if err != nil {
Expand All @@ -265,11 +254,11 @@ func HandleReleasePerCommitmentSecretRequest(request *ReleasePerCommitmentSecret

func HandleInvoicePaymentHashRequest(request *InvoicePaymentHashRequest, seedBytes []byte) (*InvoicePaymentHashResponse, error) {
log.Println("Handling REQUEST_INVOICE_PAYMENT_HASH webhook")
nonce, err := lightspark_crypto.GeneratePreimageNonce(seedBytes)
nonce, err := crypto.GeneratePreimageNonce()
if err != nil {
return nil, err
}
paymentHash, err := lightspark_crypto.GeneratePreimageHash(seedBytes, nonce)
_, paymentHash, err := crypto.GeneratePreimageAndPaymentHash(seedBytes, nonce)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -323,7 +312,7 @@ func HandleReleaseInvoicePreimageRequest(request *ReleasePaymentPreimageRequest,
return nil, err
}

preimage, err := lightspark_crypto.GeneratePreimage(seedBytes, nonceBytes)
preimage, _, err := crypto.GeneratePreimageAndPaymentHash(seedBytes, nonceBytes)
if err != nil {
return nil, err
}
Expand Down
16 changes: 2 additions & 14 deletions services/signing_key_loader.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package services

import (
"encoding/hex"
"errors"

"github.com/lightsparkdev/go-sdk/crypto"
"github.com/lightsparkdev/go-sdk/objects"
"github.com/lightsparkdev/go-sdk/requester"
"github.com/lightsparkdev/go-sdk/scripts"
lightspark_crypto "github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go"
)

type SigningKeyLoader struct {
Expand Down Expand Up @@ -67,23 +65,13 @@ func (s *SigningKeyLoader) loadSigningKeyFromMasterSeed() (requester.SigningKey,
if s.masterSeedAndNetwork == nil {
return nil, errors.New("invalid signing key loader")
}
var network lightspark_crypto.BitcoinNetwork
if s.masterSeedAndNetwork.network == objects.BitcoinNetworkMainnet {
network = lightspark_crypto.Mainnet
} else if s.masterSeedAndNetwork.network == objects.BitcoinNetworkTestnet {
network = lightspark_crypto.Testnet
} else if s.masterSeedAndNetwork.network == objects.BitcoinNetworkRegtest {
network = lightspark_crypto.Regtest
} else {
return nil, errors.New("invalid network")
}

derivationPath := "m/5"
key, error := lightspark_crypto.DerivePrivateKey(s.masterSeedAndNetwork.masterSeed, network, derivationPath)
key, error := crypto.DeriveXpriv(s.masterSeedAndNetwork.masterSeed, derivationPath)
if error != nil {
return nil, error
}
keyBytes, error := hex.DecodeString(key)
keyBytes := key.Key
if error != nil {
return nil, error
}
Expand Down
2 changes: 1 addition & 1 deletion services/test/local/local_wallet_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestGetNodeWalletAddressWithKeys(t *testing.T) {

// Get the master xpub
seed := env.MasterSeedHex
ourMasterPubkey, err := crypto.DerivePublicKey(seed, lightspark_crypto.Regtest, "m")
ourMasterPubkey, err := crypto.DerivePublicKey(seed, "m")
require.NoError(t, err)

pubkey1, err := hex.DecodeString(address.MultisigWalletAddressValidationParameters.CounterpartyFundingPubkey)
Expand Down
6 changes: 3 additions & 3 deletions services/test/regtest/regtest_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"testing"
"time"

"github.com/lightsparkdev/go-sdk/crypto"
"github.com/lightsparkdev/go-sdk/objects"
"github.com/lightsparkdev/go-sdk/services"
servicestest "github.com/lightsparkdev/go-sdk/services/test"
"github.com/lightsparkdev/go-sdk/utils"
lightspark_crypto "github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -216,12 +216,12 @@ func createInvoiceWithPaymentHashForNode(t *testing.T, client *services.Lightspa
return nil, err
}

nonce, err := lightspark_crypto.GeneratePreimageNonce(seedBytes)
nonce, err := crypto.GeneratePreimageNonce()
if err != nil {
return nil, err
}

paymentHash, err := lightspark_crypto.GeneratePreimageHash(seedBytes, nonce)
_, paymentHash, err := crypto.GeneratePreimageAndPaymentHash(seedBytes, nonce)
if err != nil {
return nil, err
}
Expand Down