diff --git a/engine/model_access_keys.go b/engine/model_access_keys.go index 49ea0a33a..d254b3135 100644 --- a/engine/model_access_keys.go +++ b/engine/model_access_keys.go @@ -37,7 +37,7 @@ type AccessKey struct { // newAccessKey will start a new model func newAccessKey(xPubID string, opts ...ModelOps) *AccessKey { privateKey, _ := primitives.NewPrivateKey() - publicKey := hex.EncodeToString(privateKey.PubKey().SerializeCompressed()) + publicKey := hex.EncodeToString(privateKey.PubKey().Compressed()) id := utils.Hash(publicKey) return &AccessKey{ diff --git a/engine/model_access_keys_test.go b/engine/model_access_keys_test.go index 0891c796d..244a97285 100644 --- a/engine/model_access_keys_test.go +++ b/engine/model_access_keys_test.go @@ -25,7 +25,7 @@ func Test_newAccessKey(t *testing.T) { assert.IsType(t, ec.PrivateKey{}, *privateKey) publicKey := privateKey.PubKey() assert.IsType(t, ec.PublicKey{}, *publicKey) - id := utils.Hash(hex.EncodeToString(publicKey.SerializeCompressed())) + id := utils.Hash(hex.EncodeToString(publicKey.Compressed())) assert.Equal(t, id, key.ID) }) diff --git a/engine/model_draft_transactions_test.go b/engine/model_draft_transactions_test.go index f91b870d7..98d64520a 100644 --- a/engine/model_draft_transactions_test.go +++ b/engine/model_draft_transactions_test.go @@ -1225,7 +1225,7 @@ func TestDraftTransaction_SignInputs(t *testing.T) { unlocker := input.UnlockingScript.ToASM() require.NoError(t, err) scriptParts := strings.Split(unlocker, " ") - pubKey := hex.EncodeToString(privateKey.PubKey().SerializeCompressed()) + pubKey := hex.EncodeToString(privateKey.PubKey().Compressed()) var hash []byte hash, err = tx.CalcInputSignatureHash(0, sighash.AllForkID) diff --git a/engine/model_paymail_addresses.go b/engine/model_paymail_addresses.go index 61b98515e..f6168c097 100644 --- a/engine/model_paymail_addresses.go +++ b/engine/model_paymail_addresses.go @@ -214,7 +214,7 @@ func (m *PaymailAddress) GetPubKey() (string, error) { return "", spverrors.Wrapf(err, "failed to get public key") } - return hex.EncodeToString(pubKey.SerializeCompressed()), nil + return hex.EncodeToString(pubKey.Compressed()), nil } // GetNextXpub will get the next child xPub for external operations. diff --git a/engine/model_paymail_addresses_test.go b/engine/model_paymail_addresses_test.go index caacad347..d75051518 100644 --- a/engine/model_paymail_addresses_test.go +++ b/engine/model_paymail_addresses_test.go @@ -206,7 +206,7 @@ func TestNewPaymail(t *testing.T) { expectedPubKey, err := expectedHdPubKey.ECPubKey() require.NoError(t, err) - require.Equal(t, hex.EncodeToString(expectedPubKey.SerializeCompressed()), firstPubKey) + require.Equal(t, hex.EncodeToString(expectedPubKey.Compressed()), firstPubKey) }) t.Run("RotatePubKey() test", func(t *testing.T) { @@ -247,7 +247,7 @@ func TestNewPaymail(t *testing.T) { expectedPubKey, err := expectedExternalXpub.ECPubKey() require.NoError(t, err) - require.Equal(t, hex.EncodeToString(expectedPubKey.SerializeCompressed()), secondPubKey) + require.Equal(t, hex.EncodeToString(expectedPubKey.Compressed()), secondPubKey) }) t.Run("ExternalXPub and PubKey rotation test", func(t *testing.T) { diff --git a/engine/script/template/evaluate.go b/engine/script/template/evaluate.go index 43d55bfcf..7b129589d 100644 --- a/engine/script/template/evaluate.go +++ b/engine/script/template/evaluate.go @@ -35,7 +35,7 @@ func Evaluate(scriptBytes []byte, pubKey *ec.PublicKey) ([]byte, error) { } // Serialize the public key to compressed format - dPKBytes := pubKey.SerializeCompressed() + dPKBytes := pubKey.Compressed() // Apply Hash160 (SHA-256 followed by RIPEMD-160) to the compressed public key dPKHash, err := utils.Hash160(dPKBytes) diff --git a/engine/script/template/p2pkh_test.go b/engine/script/template/p2pkh_test.go index edce5ffd1..71558177f 100644 --- a/engine/script/template/p2pkh_test.go +++ b/engine/script/template/p2pkh_test.go @@ -84,7 +84,7 @@ func TestEvaluate(t *testing.T) { assert.NoError(t, err) mockPublicKey, err := ec.ParsePubKey(pubKeyBytes) assert.NoError(t, err) - mockPubKeyHash := crypto.Hash160(mockPublicKey.SerializeCompressed()) + mockPubKeyHash := crypto.Hash160(mockPublicKey.Compressed()) t.Run("Valid Cases", func(t *testing.T) { validTests := []struct { diff --git a/engine/types/type42/linking_key.go b/engine/types/type42/linking_key.go index 1e5a08635..c8a13ae74 100644 --- a/engine/types/type42/linking_key.go +++ b/engine/types/type42/linking_key.go @@ -82,7 +82,7 @@ func DeriveLinkedKey(source *ec.PublicKey, linkPubKey *ec.PublicKey, invoiceNumb } // Compute the shared secret - publicKeyBytes := source.SerializeCompressed() + publicKeyBytes := source.Compressed() // Compute the HMAC result hmacResult, err := calculateHMAC(publicKeyBytes, invoiceNumber) diff --git a/engine/types/type42/linking_key_test.go b/engine/types/type42/linking_key_test.go index dfb6e325b..2524dd536 100644 --- a/engine/types/type42/linking_key_test.go +++ b/engine/types/type42/linking_key_test.go @@ -22,7 +22,7 @@ func TestDeriveLinkedKey(t *testing.T) { linkPubKey, err := ec.ParsePubKey(linkPubKeyBytes) assert.NoError(t, err) - validHMAC, err := calculateHMAC(sourcePubKey.SerializeCompressed(), "valid-invoice") + validHMAC, err := calculateHMAC(sourcePubKey.Compressed(), "valid-invoice") assert.NoError(t, err) validDerivedKey, err := calculateLinkedPublicKey(validHMAC, linkPubKey) assert.NoError(t, err) diff --git a/engine/utils/utils_test.go b/engine/utils/utils_test.go index bad829731..f98a9a92c 100644 --- a/engine/utils/utils_test.go +++ b/engine/utils/utils_test.go @@ -227,14 +227,14 @@ func TestDerivePublicKey(t *testing.T) { require.NoError(t, err) assert.Equal(t, "03d406421c2733d69a76147c67f8c2194857a2f088299ebf8f1c3790396aa70b4e", - hex.EncodeToString(pubKey.SerializeCompressed()), + hex.EncodeToString(pubKey.Compressed()), ) pubKey, err = DerivePublicKey(hdKey, 1, 1) require.NoError(t, err) assert.Equal(t, "0263e4a3696fe4e5136536988169bc3fbec730b912ade7988c57098a47a81a0ae1", - hex.EncodeToString(pubKey.SerializeCompressed()), + hex.EncodeToString(pubKey.Compressed()), ) }) } diff --git a/go.mod b/go.mod index 94e9050ed..e8a574f00 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/aws/aws-sdk-go v1.55.5 github.com/bitcoin-sv/go-paymail v0.21.0 - github.com/bitcoin-sv/go-sdk v1.1.9 + github.com/bitcoin-sv/go-sdk v1.1.10 github.com/bitcoin-sv/spv-wallet/models v0.28.0 github.com/bitcoinschema/go-map v0.2.0 github.com/coocood/freecache v1.2.4 diff --git a/go.sum b/go.sum index 4166afc70..6b6fe39c3 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bitcoin-sv/go-paymail v0.21.0 h1:xcyCWBpXG79Bek+uEC9HknPC9McFzafDKNRiHBi3110= github.com/bitcoin-sv/go-paymail v0.21.0/go.mod h1:CzDCfKjxMI0Ve5Z4V7IuCUP+BXS4PuJ4A7TAQVbESmw= -github.com/bitcoin-sv/go-sdk v1.1.9 h1:N/LlZUMHNYKjEBuY72c3XSlzUI/q7IN34R0p6J0Qtjc= -github.com/bitcoin-sv/go-sdk v1.1.9/go.mod h1:NOAkJLbjqKOLuxJmb9ABG86ExTZp4HS8+iygiDIUps4= +github.com/bitcoin-sv/go-sdk v1.1.10 h1:rGFqFRvZPKGLb+CUF5JmCIxtR3DGNBOG6C3o4W6eZfk= +github.com/bitcoin-sv/go-sdk v1.1.10/go.mod h1:NOAkJLbjqKOLuxJmb9ABG86ExTZp4HS8+iygiDIUps4= github.com/bitcoinschema/go-bob v0.5.0 h1:Fjl60RuiQiUuZWLfXE8ETdcgmJBHYu9MYfbrbZU7yHs= github.com/bitcoinschema/go-bob v0.5.0/go.mod h1:bREtBvZuMKe3DX2oCUSE+LOuy9HDJnOC3qcWr0oLoy4= github.com/bitcoinschema/go-bpu v0.2.0 h1:/WI/F+ShIj50HUD1EBPPHTCBzSeiPDohy77W3Y8xx+s=