Repository: kaspanet/kaspad
Pull request #1640 (2021-03-30 14:32:35)

Use go-secp256k1 v0.0.5

codecov[bot]: # [Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=h1) Report
> Merging [#1640](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=desc) (de0337f) into [v0.10.0-dev](https://codecov.io/gh/kaspanet/kaspad/commit/9266d179a95005979e385471581b2244f17c7d77?el=desc) (9266d17) will **not change** coverage.
> The diff coverage is `0.00%`.

[![Impacted file tree graph](https://codecov.io/gh/kaspanet/kaspad/pull/1640/graphs/tree.svg?width=650&height=150&src=pr&token=2FBIEEJTNU)](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=tree)

```diff
@@             Coverage Diff              @@
##           v0.10.0-dev    #1640   +/-   ##
============================================
  Coverage        60.41%   60.41%           
============================================
  Files              533      533           
  Lines            20687    20687           
============================================
  Hits             12499    12499           
  Misses            6233     6233           
  Partials          1955     1955           
```


| [Impacted Files](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [cmd/wallet/create.go](https://codecov.io/gh/kaspanet/kaspad/pull/1640/diff?src=pr&el=tree#diff-Y21kL3dhbGxldC9jcmVhdGUuZ28=) | `0.00% <0.00%> (ø)` | |
| [cmd/wallet/send.go](https://codecov.io/gh/kaspanet/kaspad/pull/1640/diff?src=pr&el=tree#diff-Y21kL3dhbGxldC9zZW5kLmdv) | `0.00% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=footer). Last update [9266d17...de0337f](https://codecov.io/gh/kaspanet/kaspad/pull/1640?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/cmd/wallet/create.go b/cmd/wallet/create.go
index 99edebd3..816dc714 100644
--- a/cmd/wallet/create.go
+++ b/cmd/wallet/create.go
@@ -9,7 +9,7 @@ import (
 )
 
 func create(conf *createConfig) error {
-	privateKey, err := secp256k1.GeneratePrivateKey()
+	privateKey, err := secp256k1.GenerateSchnorrKeyPair()
 	if err != nil {
 		return errors.Wrap(err, "Failed to generate private key")
 	}
diff --git a/cmd/wallet/send.go b/cmd/wallet/send.go
index eb930ddc..f7cb801d 100644
--- a/cmd/wallet/send.go
+++ b/cmd/wallet/send.go
@@ -77,7 +77,7 @@ func parsePrivateKey(privateKeyHex string) (*secp256k1.SchnorrKeyPair, *secp256k
 	if err != nil {
 		return nil, nil, errors.Wrap(err, "Error parsing private key hex")
 	}
-	keyPair, err := secp256k1.DeserializePrivateKeyFromSlice(privateKeyBytes)
+	keyPair, err := secp256k1.DeserializeSchnorrPrivateKeyFromSlice(privateKeyBytes)
 	if err != nil {
 		return nil, nil, errors.Wrap(err, "Error deserializing private key")
 	}
diff --git a/go.mod b/go.mod
index 20646e4e..50290d5f 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	github.com/jessevdk/go-flags v1.4.0
 	github.com/jrick/logrotate v1.0.0
 	github.com/kaspanet/go-muhash v0.0.4
-	github.com/kaspanet/go-secp256k1 v0.0.3
+	github.com/kaspanet/go-secp256k1 v0.0.5
 	github.com/pkg/errors v0.9.1
 	github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
 	golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670
diff --git a/go.sum b/go.sum
index 0fa0e3a5..688f29b1 100644
--- a/go.sum
+++ b/go.sum
@@ -43,12 +43,10 @@ github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGAR
 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
 github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI=
 github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
-github.com/kaspanet/go-muhash v0.0.2 h1:l1cw83YPulkAQFMSTxZKiQyU/kCI4t9dvABswetd9Fw=
-github.com/kaspanet/go-muhash v0.0.2/go.mod h1:10bPW5mO1vNHPSejaAh9ZTtLZE16jzEvgaP7f3Q5s/8=
 github.com/kaspanet/go-muhash v0.0.4 h1:CQrm1RTJpQy+h4ZFjj9qq42K5fmA5QTGifzb47p4qWk=
 github.com/kaspanet/go-muhash v0.0.4/go.mod h1:10bPW5mO1vNHPSejaAh9ZTtLZE16jzEvgaP7f3Q5s/8=
-github.com/kaspanet/go-secp256k1 v0.0.3 h1:zvrKddgUm/sZ0capLUZVcn2tKoAvQaXytZYrOzLZWx4=
-github.com/kaspanet/go-secp256k1 v0.0.3/go.mod h1:cFbxhxKkxqHX5eIwUGKARkph19PehipDPJejWB+H0jM=
+github.com/kaspanet/go-secp256k1 v0.0.5 h1:WQqb65tyr8amsBkj337BVH3PTVWCrmufb68aTGpK3mM=
+github.com/kaspanet/go-secp256k1 v0.0.5/go.mod h1:cFbxhxKkxqHX5eIwUGKARkph19PehipDPJejWB+H0jM=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
 github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=


Test patch:
diff --git a/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go b/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go
index 2e45294c..73309d29 100644
--- a/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go
+++ b/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go
@@ -46,7 +46,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
 		defer tearDown(false)
 
 		pastMedianManager.pastMedianTimeForTest = 1
-		privateKey, err := secp256k1.GeneratePrivateKey()
+		privateKey, err := secp256k1.GenerateSchnorrKeyPair()
 		if err != nil {
 			t.Fatalf("Failed to generate a private key: %v", err)
 		}
@@ -249,7 +249,7 @@ func TestSigningTwoInputs(t *testing.T) {
 		}
 		defer teardown(false)
 
-		privateKey, err := secp256k1.GeneratePrivateKey()
+		privateKey, err := secp256k1.GenerateSchnorrKeyPair()
 		if err != nil {
 			t.Fatalf("Failed to generate a private key: %v", err)
 		}
diff --git a/domain/consensus/utils/consensushashing/calculate_signature_hash_test.go b/domain/consensus/utils/consensushashing/calculate_signature_hash_test.go
index eb9caaf2..a578fef0 100644
--- a/domain/consensus/utils/consensushashing/calculate_signature_hash_test.go
+++ b/domain/consensus/utils/consensushashing/calculate_signature_hash_test.go
@@ -334,7 +334,7 @@ func signTx(b *testing.B, tx *externalapi.DomainTransaction, sigHashTypes []cons
 	if err != nil {
 		b.Fatalf("Error parsing private key hex: %+v", err)
 	}
-	keyPair, err := secp256k1.DeserializePrivateKeyFromSlice(privateKeyBytes)
+	keyPair, err := secp256k1.DeserializeSchnorrPrivateKeyFromSlice(privateKeyBytes)
 	if err != nil {
 		b.Fatalf("Error deserializing private key: %+v", err)
 	}
diff --git a/domain/consensus/utils/txscript/sigcache_test.go b/domain/consensus/utils/txscript/sigcache_test.go
index fd513d04..2c24084a 100644
--- a/domain/consensus/utils/txscript/sigcache_test.go
+++ b/domain/consensus/utils/txscript/sigcache_test.go
@@ -14,7 +14,7 @@ import (
 // public key and the public key. This function is used to generate randomized
 // test data.
 func genRandomSig() (*secp256k1.Hash, *secp256k1.SchnorrSignature, *secp256k1.SchnorrPublicKey, error) {
-	privKey, err := secp256k1.GeneratePrivateKey()
+	privKey, err := secp256k1.GenerateSchnorrKeyPair()
 	if err != nil {
 		return nil, nil, nil, err
 	}
diff --git a/domain/consensus/utils/txscript/sign_test.go b/domain/consensus/utils/txscript/sign_test.go
index ef6646f5..5538539e 100644
--- a/domain/consensus/utils/txscript/sign_test.go
+++ b/domain/consensus/utils/txscript/sign_test.go
@@ -192,7 +192,7 @@ func TestSignTxOutput(t *testing.T) {
 		for i := range tx.Inputs {
 			msg := fmt.Sprintf("%d:%d", hashType, i)
 
-			key, err := secp256k1.GeneratePrivateKey()
+			key, err := secp256k1.GenerateSchnorrKeyPair()
 			if err != nil {
 				t.Errorf("failed to make privKey for %s: %s",
 					msg, err)
@@ -243,7 +243,7 @@ func TestSignTxOutput(t *testing.T) {
 		for i := range tx.Inputs {
 			msg := fmt.Sprintf("%d:%d", hashType, i)
 
-			key, err := secp256k1.GeneratePrivateKey()
+			key, err := secp256k1.GenerateSchnorrKeyPair()
 			if err != nil {
 				t.Errorf("failed to make privKey for %s: %s",
 					msg, err)
@@ -321,7 +321,7 @@ func TestSignTxOutput(t *testing.T) {
 		for i := range tx.Inputs {
 			msg := fmt.Sprintf("%d:%d", hashType, i)
 
-			key, err := secp256k1.GeneratePrivateKey()
+			key, err := secp256k1.GenerateSchnorrKeyPair()
 			if err != nil {
 				t.Errorf("failed to make privKey for %s: %s",
 					msg, err)
@@ -386,7 +386,7 @@ func TestSignTxOutput(t *testing.T) {
 		for i := range tx.Inputs {
 			msg := fmt.Sprintf("%d:%d", hashType, i)
 
-			key, err := secp256k1.GeneratePrivateKey()
+			key, err := secp256k1.GenerateSchnorrKeyPair()
 			if err != nil {
 				t.Errorf("failed to make privKey for %s: %s",
 					msg, err)
@@ -476,7 +476,7 @@ func TestSignTxOutput(t *testing.T) {
 func generateKeys() (keyPair *secp256k1.SchnorrKeyPair, scriptPublicKey *externalapi.ScriptPublicKey,
 	addressPubKeyHash *util.AddressPubKeyHash, err error) {
 
-	key, err := secp256k1.GeneratePrivateKey()
+	key, err := secp256k1.GenerateSchnorrKeyPair()
 	if err != nil {
 		return nil, nil, nil, errors.Errorf("failed to make privKey: %s", err)
 	}
@@ -813,7 +813,7 @@ var sigScriptTests = []tstSigScript{
 func TestSignatureScript(t *testing.T) {
 	t.Parallel()
 
-	privKey, _ := secp256k1.DeserializePrivateKey(&privKeyD)
+	privKey, _ := secp256k1.DeserializeSchnorrPrivateKey(&privKeyD)
 
 nexttest:
 	for i := range sigScriptTests {
diff --git a/stability-tests/simple-sync/mineloop.go b/stability-tests/simple-sync/mineloop.go
index 86659904..7ddf70b7 100644
--- a/stability-tests/simple-sync/mineloop.go
+++ b/stability-tests/simple-sync/mineloop.go
@@ -74,7 +74,7 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
 }
 
 func generateAddress() (util.Address, error) {
-	privateKey, err := secp256k1.GeneratePrivateKey()
+	privateKey, err := secp256k1.GenerateSchnorrKeyPair()
 	if err != nil {
 		return nil, err
 	}
diff --git a/testing/integration/tx_relay_test.go b/testing/integration/tx_relay_test.go
index 47f0f3e4..e0704aca 100644
--- a/testing/integration/tx_relay_test.go
+++ b/testing/integration/tx_relay_test.go
@@ -109,7 +109,7 @@ func generateTx(t *testing.T, firstBlockCoinbase *externalapi.DomainTransaction,
 	if err != nil {
 		t.Fatalf("Error decoding private key: %+v", err)
 	}
-	privateKey, err := secp256k1.DeserializePrivateKeyFromSlice(privateKeyBytes)
+	privateKey, err := secp256k1.DeserializeSchnorrPrivateKeyFromSlice(privateKeyBytes)
 	if err != nil {
 		t.Fatalf("Error deserializing private key: %+v", err)
 	}
diff --git a/testing/integration/utxo_index_test.go b/testing/integration/utxo_index_test.go
index f64854bb..d9a76508 100644
--- a/testing/integration/utxo_index_test.go
+++ b/testing/integration/utxo_index_test.go
@@ -187,7 +187,7 @@ func buildTransactionForUTXOIndexTest(t *testing.T, entry *appmessage.UTXOsByAdd
 	if err != nil {
 		t.Fatalf("Error decoding private key: %+v", err)
 	}
-	privateKey, err := secp256k1.DeserializePrivateKeyFromSlice(privateKeyBytes)
+	privateKey, err := secp256k1.DeserializeSchnorrPrivateKeyFromSlice(privateKeyBytes)
 	if err != nil {
 		t.Fatalf("Error deserializing private key: %+v", err)
 	}