From f1c6df48c9c67d939622c9f6b7e78b10985e18a3 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Tue, 1 Dec 2020 08:48:23 +0200 Subject: [PATCH] [#1028] Replace oldschnorr with the BIP340 schnorr variant (#1165) * Update go-secp256k1 to v0.0.3 * Update the txscript engine to support only 32 bytes pubkeys * Update the txscript engine tests * Update txscript/sign.go to use the new Schnorr KeyPair API * Update txscript sign_test to use the new schnorr * Update sigcache tests to use new schnorr pubkey * Update integration tests to use the new txscript and new schnorr pubkey --- domain/consensus/utils/txscript/engine.go | 7 +- .../consensus/utils/txscript/engine_test.go | 19 +- .../consensus/utils/txscript/sigcache_test.go | 16 +- domain/consensus/utils/txscript/sign.go | 25 +- domain/consensus/utils/txscript/sign_test.go | 479 +++++------------- go.mod | 2 +- go.sum | 44 +- testing/integration/config_test.go | 6 +- testing/integration/tx_relay_test.go | 13 +- 9 files changed, 180 insertions(+), 431 deletions(-) diff --git a/domain/consensus/utils/txscript/engine.go b/domain/consensus/utils/txscript/engine.go index c22abf9ae..fde7653e8 100644 --- a/domain/consensus/utils/txscript/engine.go +++ b/domain/consensus/utils/txscript/engine.go @@ -364,12 +364,7 @@ func (vm *Engine) checkHashTypeEncoding(hashType SigHashType) error { // checkPubKeyEncoding returns whether or not the passed public key adheres to // the strict encoding requirements if enabled. func (vm *Engine) checkPubKeyEncoding(pubKey []byte) error { - if len(pubKey) == 33 && (pubKey[0] == 0x02 || pubKey[0] == 0x03) { - // Compressed - return nil - } - if len(pubKey) == 65 && pubKey[0] == 0x04 { - // Uncompressed + if len(pubKey) == 32 { return nil } diff --git a/domain/consensus/utils/txscript/engine_test.go b/domain/consensus/utils/txscript/engine_test.go index 46f1dafc6..5d0968d28 100644 --- a/domain/consensus/utils/txscript/engine_test.go +++ b/domain/consensus/utils/txscript/engine_test.go @@ -163,33 +163,38 @@ func TestCheckPubKeyEncoding(t *testing.T) { isValid bool }{ { - name: "uncompressed ok", + name: "uncompressed - invalid", key: hexToBytes("0411db93e1dcdb8a016b49840f8c53bc1eb68" + "a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf" + "9744464f82e160bfa9b8b64f9d4c03f999b8643f656b" + "412a3"), - isValid: true, + isValid: false, }, { - name: "compressed ok", + name: "compressed - invalid", key: hexToBytes("02ce0b14fb842b1ba549fdd675c98075f12e9" + "c510f8ef52bd021a9a1f4809d3b4d"), - isValid: true, + isValid: false, }, { - name: "compressed ok", + name: "compressed - invalid", key: hexToBytes("032689c7c2dab13309fb143e0e8fe39634252" + "1887e976690b6b47f5b2a4b7d448e"), - isValid: true, + isValid: false, }, { - name: "hybrid", + name: "hybrid - invalid", key: hexToBytes("0679be667ef9dcbbac55a06295ce870b07029" + "bfcdb2dce28d959f2815b16f81798483ada7726a3c46" + "55da4fbfc0e1108a8fd17b448a68554199c47d08ffb1" + "0d4b8"), isValid: false, }, + { + name: "32 bytes pubkey - Ok", + key: hexToBytes("2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448e"), + isValid: true, + }, { name: "empty", key: nil, diff --git a/domain/consensus/utils/txscript/sigcache_test.go b/domain/consensus/utils/txscript/sigcache_test.go index 905fc0f7a..fd513d045 100644 --- a/domain/consensus/utils/txscript/sigcache_test.go +++ b/domain/consensus/utils/txscript/sigcache_test.go @@ -53,8 +53,8 @@ func TestSigCacheAddExists(t *testing.T) { // The previously added triplet should now be found within the sigcache. sig1Copy := secp256k1.DeserializeSchnorrSignature(sig1.Serialize()) - key1Serialized, _ := key1.SerializeCompressed() - key1Copy, _ := secp256k1.DeserializeSchnorrPubKey(key1Serialized) + key1Serialized, _ := key1.Serialize() + key1Copy, _ := secp256k1.DeserializeSchnorrPubKey(key1Serialized[:]) if !sigCache.Exists(*msg1, sig1Copy, key1Copy) { t.Errorf("previously added item not found in signature cache") } @@ -78,8 +78,8 @@ func TestSigCacheAddEvictEntry(t *testing.T) { sigCache.Add(*msg, sig, key) sigCopy := secp256k1.DeserializeSchnorrSignature(sig.Serialize()) - keySerialized, _ := key.SerializeCompressed() - keyCopy, _ := secp256k1.DeserializeSchnorrPubKey(keySerialized) + keySerialized, _ := key.Serialize() + keyCopy, _ := secp256k1.DeserializeSchnorrPubKey(keySerialized[:]) if !sigCache.Exists(*msg, sigCopy, keyCopy) { t.Errorf("previously added item not found in signature" + "cache") @@ -108,8 +108,8 @@ func TestSigCacheAddEvictEntry(t *testing.T) { // The entry added above should be found within the sigcache. sigNewCopy := secp256k1.DeserializeSchnorrSignature(sigNew.Serialize()) - keyNewSerialized, _ := keyNew.SerializeCompressed() - keyNewCopy, _ := secp256k1.DeserializeSchnorrPubKey(keyNewSerialized) + keyNewSerialized, _ := keyNew.Serialize() + keyNewCopy, _ := secp256k1.DeserializeSchnorrPubKey(keyNewSerialized[:]) if !sigCache.Exists(*msgNew, sigNewCopy, keyNewCopy) { t.Fatalf("previously added item not found in signature cache") } @@ -132,8 +132,8 @@ func TestSigCacheAddMaxEntriesZeroOrNegative(t *testing.T) { // The generated triplet should not be found. sig1Copy := secp256k1.DeserializeSchnorrSignature(sig1.Serialize()) - key1Serialized, _ := key1.SerializeCompressed() - key1Copy, _ := secp256k1.DeserializeSchnorrPubKey(key1Serialized) + key1Serialized, _ := key1.Serialize() + key1Copy, _ := secp256k1.DeserializeSchnorrPubKey(key1Serialized[:]) if sigCache.Exists(*msg1, sig1Copy, key1Copy) { t.Errorf("previously added signature found in sigcache, but" + "shouldn't have been") diff --git a/domain/consensus/utils/txscript/sign.go b/domain/consensus/utils/txscript/sign.go index d2783705c..e6a450916 100644 --- a/domain/consensus/utils/txscript/sign.go +++ b/domain/consensus/utils/txscript/sign.go @@ -16,7 +16,7 @@ import ( // RawTxInSignature returns the serialized Schnorr signature for the input idx of // the given transaction, with hashType appended to it. func RawTxInSignature(tx *externalapi.DomainTransaction, idx int, script []byte, - hashType SigHashType, key *secp256k1.PrivateKey) ([]byte, error) { + hashType SigHashType, key *secp256k1.SchnorrKeyPair) ([]byte, error) { hash, err := CalcSignatureHash(script, hashType, tx, idx) if err != nil { @@ -39,7 +39,7 @@ func RawTxInSignature(tx *externalapi.DomainTransaction, idx int, script []byte, // as the idx'th input. privKey is serialized in either a compressed or // uncompressed format based on compress. This format must match the same format // used to generate the payment address, or the script validation will fail. -func SignatureScript(tx *externalapi.DomainTransaction, idx int, script []byte, hashType SigHashType, privKey *secp256k1.PrivateKey, compress bool) ([]byte, error) { +func SignatureScript(tx *externalapi.DomainTransaction, idx int, script []byte, hashType SigHashType, privKey *secp256k1.SchnorrKeyPair) ([]byte, error) { sig, err := RawTxInSignature(tx, idx, script, hashType, privKey) if err != nil { return nil, err @@ -49,17 +49,12 @@ func SignatureScript(tx *externalapi.DomainTransaction, idx int, script []byte, if err != nil { return nil, err } - var pkData []byte - if compress { - pkData, err = pk.SerializeCompressed() - } else { - pkData, err = pk.SerializeUncompressed() - } + pkData, err := pk.Serialize() if err != nil { return nil, err } - return NewScriptBuilder().AddData(sig).AddData(pkData).Script() + return NewScriptBuilder().AddData(sig).AddData(pkData[:]).Script() } func sign(dagParams *dagconfig.Params, tx *externalapi.DomainTransaction, idx int, @@ -75,13 +70,12 @@ func sign(dagParams *dagconfig.Params, tx *externalapi.DomainTransaction, idx in switch class { case PubKeyHashTy: // look up key for address - key, compressed, err := kdb.GetKey(address) + key, err := kdb.GetKey(address) if err != nil { return nil, class, nil, err } - signedScript, err := SignatureScript(tx, idx, script, hashType, - key, compressed) + signedScript, err := SignatureScript(tx, idx, script, hashType, key) if err != nil { return nil, class, nil, err } @@ -162,15 +156,14 @@ func mergeScripts(dagParams *dagconfig.Params, tx *externalapi.DomainTransaction // KeyDB is an interface type provided to SignTxOutput, it encapsulates // any user state required to get the private keys for an address. type KeyDB interface { - GetKey(util.Address) (*secp256k1.PrivateKey, bool, error) + GetKey(util.Address) (*secp256k1.SchnorrKeyPair, error) } // KeyClosure implements KeyDB with a closure. -type KeyClosure func(util.Address) (*secp256k1.PrivateKey, bool, error) +type KeyClosure func(util.Address) (*secp256k1.SchnorrKeyPair, error) // GetKey implements KeyDB by returning the result of calling the closure. -func (kc KeyClosure) GetKey(address util.Address) (*secp256k1.PrivateKey, - bool, error) { +func (kc KeyClosure) GetKey(address util.Address) (*secp256k1.SchnorrKeyPair, error) { return kc(address) } diff --git a/domain/consensus/utils/txscript/sign_test.go b/domain/consensus/utils/txscript/sign_test.go index 32c438320..7a36cab24 100644 --- a/domain/consensus/utils/txscript/sign_test.go +++ b/domain/consensus/utils/txscript/sign_test.go @@ -16,25 +16,18 @@ import ( "github.com/kaspanet/kaspad/util" ) -type addressToKey struct { - key *secp256k1.PrivateKey - compressed bool -} - -func mkGetKey(keys map[string]addressToKey) KeyDB { +func mkGetKey(keys map[string]*secp256k1.SchnorrKeyPair) KeyDB { if keys == nil { - return KeyClosure(func(addr util.Address) (*secp256k1.PrivateKey, - bool, error) { - return nil, false, errors.New("nope") + return KeyClosure(func(addr util.Address) (*secp256k1.SchnorrKeyPair, error) { + return nil, errors.New("nope") }) } - return KeyClosure(func(addr util.Address) (*secp256k1.PrivateKey, - bool, error) { - a2k, ok := keys[addr.EncodeAddress()] + return KeyClosure(func(addr util.Address) (*secp256k1.SchnorrKeyPair, error) { + key, ok := keys[addr.EncodeAddress()] if !ok { - return nil, false, errors.New("nope") + return nil, errors.New("nope") } - return a2k.key, a2k.compressed, nil + return key, nil }) } @@ -139,7 +132,7 @@ func TestSignTxOutput(t *testing.T) { Outputs: outputs, } - // Pay to Pubkey Hash (uncompressed) + // Pay to Pubkey Hash (merging with correct) for _, hashType := range hashTypes { for i := range tx.Inputs { msg := fmt.Sprintf("%d:%d", hashType, i) @@ -157,63 +150,14 @@ func TestSignTxOutput(t *testing.T) { break } - uncompressedPubKey, err := pubKey.SerializeUncompressed() - if err != nil { - t.Errorf("failed to make a pubkey for %s: %s", - key, err) - break - } - - address, err := util.NewAddressPubKeyHash( - util.Hash160(uncompressedPubKey), util.Bech32PrefixKaspaTest) - if err != nil { - t.Errorf("failed to make address for %s: %v", - msg, err) - break - } - - scriptPubKey, err := PayToAddrScript(address) - if err != nil { - t.Errorf("failed to make scriptPubKey "+ - "for %s: %v", msg, err) - } - - if err := signAndCheck(msg, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, - }), mkGetScript(nil), nil); err != nil { - t.Error(err) - break - } - } - } - - // Pay to Pubkey Hash (uncompressed) (merging with correct) - for _, hashType := range hashTypes { - for i := range tx.Inputs { - msg := fmt.Sprintf("%d:%d", hashType, i) - key, err := secp256k1.GeneratePrivateKey() - if err != nil { - t.Errorf("failed to make privKey for %s: %s", - msg, err) - break - } - - pubKey, err := key.SchnorrPublicKey() - if err != nil { - t.Errorf("failed to make a publickey for %s: %s", - key, err) - break - } - - uncompressedPubKey, err := pubKey.SerializeUncompressed() + serializedPubKey, err := pubKey.Serialize() if err != nil { t.Errorf("failed to make a pubkey for %s: %s", key, err) break } address, err := util.NewAddressPubKeyHash( - util.Hash160(uncompressedPubKey), util.Bech32PrefixKaspaTest) + util.Hash160(serializedPubKey[:]), util.Bech32PrefixKaspaTest) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -228,8 +172,8 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(nil), nil) if err != nil { t.Errorf("failed to sign output %s: %v", msg, @@ -241,8 +185,8 @@ func TestSignTxOutput(t *testing.T) { // again and merge. sigScript, err = SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(nil), sigScript) if err != nil { t.Errorf("failed to sign output %s a "+ @@ -278,7 +222,7 @@ func TestSignTxOutput(t *testing.T) { break } - compressedPubKey, err := pubKey.SerializeCompressed() + serializedPubKey, err := pubKey.Serialize() if err != nil { t.Errorf("failed to make a pubkey for %s: %s", key, err) @@ -286,7 +230,7 @@ func TestSignTxOutput(t *testing.T) { } address, err := util.NewAddressPubKeyHash( - util.Hash160(compressedPubKey), util.Bech32PrefixKaspaTest) + util.Hash160(serializedPubKey[:]), util.Bech32PrefixKaspaTest) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -300,8 +244,8 @@ func TestSignTxOutput(t *testing.T) { } if err := signAndCheck(msg, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(nil), nil); err != nil { t.Error(err) break @@ -309,7 +253,7 @@ func TestSignTxOutput(t *testing.T) { } } - // Pay to Pubkey Hash (compressed) with duplicate merge + // Pay to Pubkey Hash with duplicate merge for _, hashType := range hashTypes { for i := range tx.Inputs { msg := fmt.Sprintf("%d:%d", hashType, i) @@ -328,7 +272,7 @@ func TestSignTxOutput(t *testing.T) { break } - compressedPubKey, err := pubKey.SerializeCompressed() + serializedPubKey, err := pubKey.Serialize() if err != nil { t.Errorf("failed to make a pubkey for %s: %s", key, err) @@ -336,7 +280,7 @@ func TestSignTxOutput(t *testing.T) { } address, err := util.NewAddressPubKeyHash( - util.Hash160(compressedPubKey), util.Bech32PrefixKaspaTest) + util.Hash160(serializedPubKey[:]), util.Bech32PrefixKaspaTest) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -351,8 +295,8 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(nil), nil) if err != nil { t.Errorf("failed to sign output %s: %v", msg, @@ -364,8 +308,8 @@ func TestSignTxOutput(t *testing.T) { // again and merge. sigScript, err = SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(nil), sigScript) if err != nil { t.Errorf("failed to sign output %s a "+ @@ -383,168 +327,8 @@ func TestSignTxOutput(t *testing.T) { } // As before, but with p2sh now. - // Pay to Pubkey Hash (uncompressed) - for _, hashType := range hashTypes { - for i := range tx.Inputs { - msg := fmt.Sprintf("%d:%d", hashType, i) - key, err := secp256k1.GeneratePrivateKey() - if err != nil { - t.Errorf("failed to make privKey for %s: %s", - msg, err) - break - } - pubKey, err := key.SchnorrPublicKey() - if err != nil { - t.Errorf("failed to make a publickey for %s: %s", - key, err) - break - } - - uncompressedPubKey, err := pubKey.SerializeUncompressed() - if err != nil { - t.Errorf("failed to make a pubkey for %s: %s", - key, err) - break - } - - address, err := util.NewAddressPubKeyHash( - util.Hash160(uncompressedPubKey), util.Bech32PrefixKaspaTest) - if err != nil { - t.Errorf("failed to make address for %s: %v", - msg, err) - break - } - - scriptPubKey, err := PayToAddrScript(address) - if err != nil { - t.Errorf("failed to make scriptPubKey "+ - "for %s: %v", msg, err) - break - } - - scriptAddr, err := util.NewAddressScriptHash( - scriptPubKey, util.Bech32PrefixKaspaTest) - if err != nil { - t.Errorf("failed to make p2sh addr for %s: %v", - msg, err) - break - } - - scriptScriptPubKey, err := PayToAddrScript( - scriptAddr) - if err != nil { - t.Errorf("failed to make script scriptPubKey for "+ - "%s: %v", msg, err) - break - } - - if err := signAndCheck(msg, tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, - }), mkGetScript(map[string][]byte{ - scriptAddr.EncodeAddress(): scriptPubKey, - }), nil); err != nil { - t.Error(err) - break - } - } - } - - // Pay to Pubkey Hash (uncompressed) with duplicate merge - for _, hashType := range hashTypes { - for i := range tx.Inputs { - msg := fmt.Sprintf("%d:%d", hashType, i) - key, err := secp256k1.GeneratePrivateKey() - if err != nil { - t.Errorf("failed to make privKey for %s: %s", - msg, err) - break - } - - pubKey, err := key.SchnorrPublicKey() - if err != nil { - t.Errorf("failed to make a publickey for %s: %s", - key, err) - break - } - - uncompressedPubKey, err := pubKey.SerializeUncompressed() - if err != nil { - t.Errorf("failed to make a pubkey for %s: %s", - key, err) - break - } - - address, err := util.NewAddressPubKeyHash( - util.Hash160(uncompressedPubKey), util.Bech32PrefixKaspaTest) - if err != nil { - t.Errorf("failed to make address for %s: %v", - msg, err) - break - } - - scriptPubKey, err := PayToAddrScript(address) - if err != nil { - t.Errorf("failed to make scriptPubKey "+ - "for %s: %v", msg, err) - break - } - - scriptAddr, err := util.NewAddressScriptHash( - scriptPubKey, util.Bech32PrefixKaspaTest) - if err != nil { - t.Errorf("failed to make p2sh addr for %s: %v", - msg, err) - break - } - - scriptScriptPubKey, err := PayToAddrScript( - scriptAddr) - if err != nil { - t.Errorf("failed to make script scriptPubKey for "+ - "%s: %v", msg, err) - break - } - - _, err = SignTxOutput(&dagconfig.TestnetParams, - tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, - }), mkGetScript(map[string][]byte{ - scriptAddr.EncodeAddress(): scriptPubKey, - }), nil) - if err != nil { - t.Errorf("failed to sign output %s: %v", msg, - err) - break - } - - // by the above loop, this should be valid, now sign - // again and merge. - sigScript, err := SignTxOutput(&dagconfig.TestnetParams, - tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, - }), mkGetScript(map[string][]byte{ - scriptAddr.EncodeAddress(): scriptPubKey, - }), nil) - if err != nil { - t.Errorf("failed to sign output %s a "+ - "second time: %v", msg, err) - break - } - - err = checkScripts(msg, tx, i, sigScript, scriptScriptPubKey) - if err != nil { - t.Errorf("twice signed script invalid for "+ - "%s: %v", msg, err) - break - } - } - } - - // Pay to Pubkey Hash (compressed) + // Pay to Pubkey Hash for _, hashType := range hashTypes { for i := range tx.Inputs { msg := fmt.Sprintf("%d:%d", hashType, i) @@ -563,7 +347,7 @@ func TestSignTxOutput(t *testing.T) { break } - compressedPubKey, err := pubKey.SerializeCompressed() + serializedPubKey, err := pubKey.Serialize() if err != nil { t.Errorf("failed to make a pubkey for %s: %s", key, err) @@ -571,7 +355,7 @@ func TestSignTxOutput(t *testing.T) { } address, err := util.NewAddressPubKeyHash( - util.Hash160(compressedPubKey), util.Bech32PrefixKaspaTest) + util.Hash160(serializedPubKey[:]), util.Bech32PrefixKaspaTest) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -601,8 +385,8 @@ func TestSignTxOutput(t *testing.T) { } if err := signAndCheck(msg, tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): scriptPubKey, }), nil); err != nil { @@ -631,7 +415,7 @@ func TestSignTxOutput(t *testing.T) { break } - compressedPubKey, err := pubKey.SerializeCompressed() + serializedPubKey, err := pubKey.Serialize() if err != nil { t.Errorf("failed to make a pubkey for %s: %s", key, err) @@ -639,7 +423,7 @@ func TestSignTxOutput(t *testing.T) { } address, err := util.NewAddressPubKeyHash( - util.Hash160(compressedPubKey), util.Bech32PrefixKaspaTest) + util.Hash160(serializedPubKey[:]), util.Bech32PrefixKaspaTest) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -670,8 +454,8 @@ func TestSignTxOutput(t *testing.T) { _, err = SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): scriptPubKey, }), nil) @@ -685,8 +469,8 @@ func TestSignTxOutput(t *testing.T) { // again and merge. sigScript, err := SignTxOutput(&dagconfig.TestnetParams, tx, i, scriptScriptPubKey, hashType, - mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + mkGetKey(map[string]*secp256k1.SchnorrKeyPair{ + address.EncodeAddress(): key, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): scriptPubKey, }), nil) @@ -717,7 +501,6 @@ type tstSigScript struct { name string inputs []tstInput hashType SigHashType - compress bool scriptAtWrongIndex bool } @@ -732,12 +515,15 @@ var ( 0xb4, 0xfc, 0x4e, 0x55, 0xd4, 0x88, 0x42, 0xb3, 0xa1, 0x65, 0xac, 0x70, 0x7f, 0x3d, 0xa4, 0x39, 0x5e, 0xcb, 0x3b, 0xb0, 0xd6, 0x0e, 0x06, 0x92} - uncompressedScriptPubKey = []byte{0x76, 0xa9, 0x14, 0xd1, 0x7c, 0xb5, + oldUncompressedScriptPubKey = []byte{0x76, 0xa9, 0x14, 0xd1, 0x7c, 0xb5, 0xeb, 0xa4, 0x02, 0xcb, 0x68, 0xe0, 0x69, 0x56, 0xbf, 0x32, 0x53, 0x90, 0x0e, 0x0a, 0x86, 0xc9, 0xfa, 0x88, 0xac} - compressedScriptPubKey = []byte{0x76, 0xa9, 0x14, 0x27, 0x4d, 0x9f, 0x7f, + oldCompressedScriptPubKey = []byte{0x76, 0xa9, 0x14, 0x27, 0x4d, 0x9f, 0x7f, 0x61, 0x7e, 0x7c, 0x7a, 0x1c, 0x1f, 0xb2, 0x75, 0x79, 0x10, 0x43, 0x65, 0x68, 0x27, 0x9d, 0x86, 0x88, 0xac} + p2pkhScriptPubKey = []byte{0x76, 0xa9, 0x14, 0x7e, 0x01, 0x76, 0xb6, + 0x72, 0x08, 0xc0, 0x08, 0x98, 0x85, 0x97, 0x00, 0x4e, 0x1a, 0x8d, + 0x60, 0x89, 0xfe, 0x42, 0x6f, 0x88, 0xac} shortScriptPubKey = []byte{0x76, 0xa9, 0x14, 0xd1, 0x7c, 0xb5, 0xeb, 0xa4, 0x02, 0xcb, 0x68, 0xe0, 0x69, 0x56, 0xbf, 0x32, 0x53, 0x90, 0x0e, 0x0a, 0x88, 0xac} @@ -749,12 +535,94 @@ const fee = 5000000 var sigScriptTests = []tstSigScript{ { - name: "one input uncompressed", + name: "one input old uncompressed", inputs: []tstInput{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: oldUncompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + }, + hashType: SigHashAll, + scriptAtWrongIndex: false, + }, + { + name: "two inputs old uncompressed", + inputs: []tstInput{ + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal, + ScriptPublicKey: oldUncompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal + fee, + ScriptPublicKey: oldUncompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + }, + hashType: SigHashAll, + scriptAtWrongIndex: false, + }, + { + name: "one input old compressed", + inputs: []tstInput{ + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal, + ScriptPublicKey: oldCompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + }, + hashType: SigHashAll, + scriptAtWrongIndex: false, + }, + { + name: "two inputs old compressed", + inputs: []tstInput{ + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal, + ScriptPublicKey: oldCompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal + fee, + ScriptPublicKey: oldCompressedScriptPubKey, + }, + sigscriptGenerates: true, + inputValidates: false, + indexOutOfRange: false, + }, + }, + hashType: SigHashAll, + scriptAtWrongIndex: false, + }, + { + name: "one input 32byte pubkey", + inputs: []tstInput{ + { + txout: &externalapi.DomainTransactionOutput{ + Value: coinbaseVal, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -762,16 +630,15 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll, - compress: false, scriptAtWrongIndex: false, }, { - name: "two inputs uncompressed", + name: "two inputs 32byte pubkey", inputs: []tstInput{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -780,7 +647,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal + fee, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -788,50 +655,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll, - compress: false, - scriptAtWrongIndex: false, - }, - { - name: "one input compressed", - inputs: []tstInput{ - { - txout: &externalapi.DomainTransactionOutput{ - Value: coinbaseVal, - ScriptPublicKey: compressedScriptPubKey, - }, - sigscriptGenerates: true, - inputValidates: true, - indexOutOfRange: false, - }, - }, - hashType: SigHashAll, - compress: true, - scriptAtWrongIndex: false, - }, - { - name: "two inputs compressed", - inputs: []tstInput{ - { - txout: &externalapi.DomainTransactionOutput{ - Value: coinbaseVal, - ScriptPublicKey: compressedScriptPubKey, - }, - sigscriptGenerates: true, - inputValidates: true, - indexOutOfRange: false, - }, - { - txout: &externalapi.DomainTransactionOutput{ - Value: coinbaseVal + fee, - ScriptPublicKey: compressedScriptPubKey, - }, - sigscriptGenerates: true, - inputValidates: true, - indexOutOfRange: false, - }, - }, - hashType: SigHashAll, - compress: true, scriptAtWrongIndex: false, }, { @@ -840,7 +663,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -848,7 +671,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashNone, - compress: false, scriptAtWrongIndex: false, }, { @@ -857,7 +679,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -865,7 +687,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashSingle, - compress: false, scriptAtWrongIndex: false, }, { @@ -874,7 +695,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -882,7 +703,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll | SigHashAnyOneCanPay, - compress: false, scriptAtWrongIndex: false, }, { @@ -891,7 +711,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: false, @@ -899,7 +719,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAnyOneCanPay, - compress: false, scriptAtWrongIndex: false, }, { @@ -908,7 +727,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: false, @@ -916,24 +735,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: 0x04, - compress: false, - scriptAtWrongIndex: false, - }, - { - name: "invalid compression", - inputs: []tstInput{ - { - txout: &externalapi.DomainTransactionOutput{ - Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, - }, - sigscriptGenerates: true, - inputValidates: false, - indexOutOfRange: false, - }, - }, - hashType: SigHashAll, - compress: true, scriptAtWrongIndex: false, }, { @@ -949,7 +750,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll, - compress: false, scriptAtWrongIndex: false, }, { @@ -958,7 +758,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -967,7 +767,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal + fee, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -975,7 +775,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll, - compress: false, scriptAtWrongIndex: true, }, { @@ -984,7 +783,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -993,7 +792,7 @@ var sigScriptTests = []tstSigScript{ { txout: &externalapi.DomainTransactionOutput{ Value: coinbaseVal + fee, - ScriptPublicKey: uncompressedScriptPubKey, + ScriptPublicKey: p2pkhScriptPubKey, }, sigscriptGenerates: true, inputValidates: true, @@ -1001,7 +800,6 @@ var sigScriptTests = []tstSigScript{ }, }, hashType: SigHashAll, - compress: false, scriptAtWrongIndex: true, }, } @@ -1046,8 +844,7 @@ nexttest: } script, err = SignatureScript(tx, idx, sigScriptTests[i].inputs[j].txout.ScriptPublicKey, - sigScriptTests[i].hashType, privKey, - sigScriptTests[i].compress) + sigScriptTests[i].hashType, privKey) if (err == nil) != sigScriptTests[i].inputs[j].sigscriptGenerates { if err == nil { diff --git a/go.mod b/go.mod index 57a1ac0a6..50ef525b8 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/protobuf v1.4.2 github.com/jessevdk/go-flags v1.4.0 github.com/jrick/logrotate v1.0.0 - github.com/kaspanet/go-secp256k1 v0.0.2 + github.com/kaspanet/go-secp256k1 v0.0.3 github.com/pkg/errors v0.9.1 github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 diff --git a/go.sum b/go.sum index 8bfb2dbe2..ef0ff054b 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,21 @@ -cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 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/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4 h1:rEvIZUSZ3fx39WIi3JkQqQBitGwpELBIYWeBVh6wn+E= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -35,7 +23,6 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= @@ -45,55 +32,40 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= 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-secp256k1 v0.0.2 h1:KZGXddYHxzS02rx6EPPQYYe2tZ/rREj4P6XxgQQwQIw= -github.com/kaspanet/go-secp256k1 v0.0.2/go.mod h1:W9OcWBKzH8P/PN2WAUn9k2YmZG/Uc660WAL1NTS3G3M= -github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= +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/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= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -106,13 +78,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20200228224639-71482053b885 h1:y09Juz/HD0YjGlyEd4bLUWG0s8Yx6iPniPqUGzUxNrU= -golang.org/x/tools v0.0.0-20200228224639-71482053b885/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= @@ -134,14 +101,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/testing/integration/config_test.go b/testing/integration/config_test.go index 4089d6cf3..dd5253073 100644 --- a/testing/integration/config_test.go +++ b/testing/integration/config_test.go @@ -18,13 +18,13 @@ const ( rpcAddress2 = "127.0.0.1:12346" rpcAddress3 = "127.0.0.1:12347" - miningAddress1 = "kaspasim:qzmdkk8ay8sgvp8cnwts8gtdylz9j7572slwdh85qv" + miningAddress1 = "kaspasim:qzpj2cfa9m40w9m2cmr8pvfuqpp32mzzwsuw6ukhfd" miningAddress1PrivateKey = "be9e9884f03e687166479e22d21b064db7903d69b5a46878aae66521c01a6094" - miningAddress2 = "kaspasim:qze20hwkc4lzq37jt0hrym5emlsxxs8j3qyf3y4ghs" + miningAddress2 = "kaspasim:qr7w7nqsdnc3zddm6u8s9fex4ysk95hm3v30q353ym" miningAddress2PrivateKey = "98bd8d8e1f7078abefd017839f83edd0e3c8226ed4989e4d7a8bceb5935de193" - miningAddress3 = "kaspasim:qretklduvhg5h2aj7jd8w4heq7pvtkpv9q6w4sqfen" + miningAddress3 = "kaspasim:qz7n8gfak3j2wt9vywy5ljhs3v3xu7lgmutfjqaay5" miningAddress3PrivateKey = "eb0af684f2cdbb4ed2d85fbfe0b7f40654a7777fb2c47f142ffb5543b594d1e4" defaultTimeout = 10 * time.Second diff --git a/testing/integration/tx_relay_test.go b/testing/integration/tx_relay_test.go index 42cbb5d52..1975a5700 100644 --- a/testing/integration/tx_relay_test.go +++ b/testing/integration/tx_relay_test.go @@ -6,15 +6,12 @@ import ( "testing" "time" - "github.com/kaspanet/kaspad/domain/consensus/utils/constants" - - "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" - "github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization" - - "github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper" - "github.com/kaspanet/go-secp256k1" "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization" + "github.com/kaspanet/kaspad/domain/consensus/utils/constants" + "github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper" "github.com/kaspanet/kaspad/domain/consensus/utils/txscript" "github.com/kaspanet/kaspad/util" ) @@ -116,7 +113,7 @@ func generateTx(t *testing.T, firstBlockCoinbase *externalapi.DomainTransaction, } signatureScript, err := txscript.SignatureScript(appmessage.MsgTxToDomainTransaction(tx), 0, - fromScript, txscript.SigHashAll, privateKey, true) + fromScript, txscript.SigHashAll, privateKey) if err != nil { t.Fatalf("Error signing transaction: %+v", err) }