Commit Graph

418 Commits

Author SHA1 Message Date
Dave Collins
b2cef202a7
multi: Round 4 prerel module release ver updates.
This modifies all prelease modules to use the latest commit to work out
more transitive dependency issues.  Several of these are needed due to
the dependency chain.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215031403-6b2ce76f0986
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215031403-6b2ce76f0986
2020-02-14 22:55:06 -06:00
Dave Collins
6b2ce76f09
multi: Round 3 prerel module release ver updates.
This modifies all prelease modules to use the latest commit to work out
more transitive dependency issues.  Several of these are needed due to
the dependency chain.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215023918-6247af01d5e3
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215023918-6247af01d5e3
2020-02-14 21:14:03 -06:00
Dave Collins
6247af01d5
multi: More prerel module release version updates.
This modifies all prelease modules to use the latest version to work out
more transitive dependency issues.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/hdkeychain/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/mining/v3@v3.0.0-20200215015031-3283587e6add
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200215015031-3283587e6add
2020-02-14 20:39:18 -06:00
Dave Collins
3283587e6a
multi: Update all prerel module release versions.
This modifies all prelease modules to use the latest version so they can
be used in require statements in consumer code that is also under
development without running into transitive dependency issues.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/mining/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200214194519-928737b3e580
2020-02-14 19:50:31 -06:00
Dave Collins
3bdcf8b915 multi: Update to prerel module release versions.
This modifies some recently-updated modules to use a valid prerelease
version so they can be used in require statements in consumer code that
is also under development.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/chaincfg/v3@v3.0.0-20200214194519-928737b3e580
- github.com/decred/dcrd/dcrec/secp256k1/v3@v3.0.0-20200214194519-928737b3e580
2020-02-14 14:08:02 -06:00
Dave Collins
2e2b9a34aa
txscript: Remove unused isStakeOutput function. 2020-02-13 15:45:09 -06:00
Dave Collins
5f8046a97c
txscript: Don't use GetScriptClass in consensus.
This modifies the consensus critical function which determines if the
redeem script of a p2sh or stake-tagged p2sh contains stake opcodes to
avoid calling the GetScriptClass function which is only intended
explicitly for working with standard script forms which only apply in
the context of the more restrictive standardness policy rules.

It also renames the function to better indicate its purpose is to
specifically check the redeem script as opposed to the entire signature
script.
2020-02-13 15:45:07 -06:00
Dave Collins
bcea78f4d7
secp256k1: Make private key independent type.
This modifies the PrivateKey type to be defined as its own struct as
opposed of in terms of an ecdsa.PrivateKey and updates the code and
tests accordingly.  It also removes the PrivKeyFromScalar and
GenerateKey funcs while here since they are effectively duplicates of
existing funcs that were added to satisfy the chainec interface which no
longer exists.

For now, it essentially keeps the same format with the exception of
embedding the ecdsa.PublicKey, but being its own type will alllow for it
to eventually be made opaque and thus provide greater optimizations.

This is continued work towards making the internals of the package
entirely independent of the crypto/elliptic and crypto/ecdsa stdlib
interfaces.
2020-02-10 22:40:34 -06:00
Donald Adu-Poku
e19d435157 multi: replace GetScriptClass consensus calls.
This removes GetScriptClass consensus
calls in favour of using script type identification
functions defined in the blockchain package.
2020-02-07 20:35:39 -06:00
Dave Collins
9817166145
secp256k1: Never fail signing.
This modifies the deterministic nonce generation via RFC6979 to accept
an additional parameter for the number of extra iterations to perform to
ensure a stream of deterministic nonces can be generated if needed.

It then updates the signing for both ECDSA and Schnorr to make use of
the new parameter to increment the iteration in the unlikely event a
returned nonce results in an invalid signature so that it will always
generate a valid signature.

Finally, it removes the error return from Sign since it can no longer
fail.
2020-01-31 11:51:27 -06:00
Dave Collins
4dcf035476
secp256k1: Remove unused chainec code.
This removes several functions that only existed to satisfy the chainec
interfaces which no longer exist.  It also updates any callers that were
directly using functions instead of just directly access the fields or
underlying functions accordingly.
2020-01-31 11:46:07 -06:00
Dave Collins
85f0c09df2
secp256k1: Start v3 module dev cycle.
Upcoming changes constitute breaking public API changes to the secp256k1
module, therefore, this follows the process for introducing major API
breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2020-01-29 13:45:59 -06:00
Dave Collins
be7ab82cf9
chaincfg: Start v3 module dev cycle.
Upcoming changes constitute breaking public API changes to the chaincfg
module, therefore, this follows the process for introducing major API
breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the
  new version in the same commit
  - Repeat the process for any other modules the require a new major as a
    result of consuming the new major(s)
2020-01-29 13:24:14 -06:00
Dave Collins
83f8020051
multi: Update to prerel module release versions.
This modifies the various modules to use a valid prerelease version so
they can be used in require statements in consumer code that is also
under development.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v3@v3.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/blockchain/v3@v3.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/connmgr/v3@v3.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/dcrutil/v3@v3.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/mempool/v4@v4.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/mining/v3@v3.0.0-20200104000002-54b67d3474fb
- github.com/decred/dcrd/txscript/v3@v3.0.0-20200104000002-54b67d3474fb
2020-01-08 18:52:46 -06:00
Dave Collins
b6d8ccdedf
multi: Address a bunch of lint issues. 2019-12-30 13:54:41 -06:00
Dave Collins
aad3f7c85b
txscript: Optimize conditional execution mem usage.
The existing implementation to handle conditional execution makes use of
a stack to track the state of each nested conditional.  It is already
fairly efficient in terms of execution costs since it only considers the
most recent conditional stack entry and makes use of pushing OpCondSkip
to essentially track the nesting depth in unexecuted branches, however,
using a stack is less efficient in terms of memory usage than is
actually necessary since there is no need to use a stack at all given
that all that is really needed to provide the necessary behavior is the
current conditional nesting depth and the depth at which branch
execution was disabled (if it has been disabled).

Given the above, this optimizes the txscript conditional execution logic
by replacing the condition stack with two int32 fields to track the
aforementioned cases and updates the conditional execution opcode and
logic accordingly.
2019-12-30 13:50:01 -06:00
David Hill
4971faff25 multi: remove whitespace 2019-11-21 18:31:30 -06:00
David Hill
0ae54f2e05 txscript: drop chainec 2019-10-25 21:27:01 -05:00
David Hill
1de253d49f txscript: Add signature type to KeyClosure API
This also removes the signature type parameter of SignTxOutput
2019-10-25 19:20:39 -05:00
David Hill
e3a04d40c7 txscript: Start v3 module dev cycle.
Several upcoming changes constitute breaking the public API.
2019-10-24 20:48:43 -05:00
David Hill
6d39abb6be dcrutil: Start v3 module dev cycle.
Several upcoming changes constitute breaking the public API.
2019-10-24 19:13:26 -05:00
Dave Collins
679a7abdfc
txscript: Prepare v2.1.0.
This updates the txscript module dependencies and serves as a base for
txscript/v2.1.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/v2@v2.3.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.1
- github.com/decred/dcrd/wire@v1.3.0

The full list of updated direct dependencies since the previous
txscript/v2.0.0 release are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/chaincfg/v2@v2.3.0
- github.com/decred/dcrd/crypto/ripemd160@v1.0.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.0
- github.com/decred/dcrd/dcrec/secp256k1/v2@v2.0.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.1
- github.com/decred/dcrd/wire@v1.3.0
2019-10-15 11:21:52 -05:00
Dave Collins
ee4a0e2e2a
multi: Use dcrec/edwards/v2 module.
This updates the following modules to use the dcrec/edwards/v2 module:

- chaincfg/v2
- dcrutil/v2
- txscript/v2
2019-10-08 10:43:08 -05:00
Dave Collins
6e647f731f
multi: Use crypto/ripemd160 module.
This updates the main, dcrutil, and blockchain modules to make use of
the new crypto/ripemd160 module.
2019-10-08 10:21:03 -05:00
Dave Collins
cebab1ef64
multi: Use secp256k1/v2 module.
This updates the following modules to use the secp256k1/v2 module:

- blockchain
- chaincfg/v2
- dcrutil/v2
- hdkeychain/v2
- mempool/v3
- txscript/v2
- main

The hdkeychain/v3 and txscript/v2 modules both use types from secp256k1
in their public API.

Consequently, in order avoid forcing them to bump their major versions,
secp256k1/v1.0.3 was released with the types redefined in terms of the
secp256k1/v2 module so callers still using v1 of the module that are not
ready to upgrade to the v2 module yet can interoperate by updating to
the latest patch version.
2019-10-08 10:14:13 -05:00
Dave Collins
3e2208f8c1
build: Replace TravisCI with CI via Github actions. 2019-09-20 19:59:04 -05:00
David Hill
0781162661 multi: remove unused funcs and vars 2019-09-05 10:13:18 -05:00
Aaron Campbell
8be96a8729 multi: Correct typos.
Correct typos found by reading code, ispell, and creative grepping.
2019-08-22 10:20:03 -05:00
Aaron Campbell
8371deb906 txscript: Fix duplicate test name. 2019-08-22 09:02:56 -05:00
Aaron Campbell
03678bb754 multi: Correct typos.
Correct typos found by reading code and creative grepping.
2019-08-16 17:37:58 -05:00
Dave Collins
8354a310bc
main: Consume latest module minors and patches.
This updates the main module to use the latest available minor and patch
versions of all modules and reverts the recent change that incorrectly
removed all of the blake256 references from the various go.sum files.

The following required direct dependencies are bumped as follows:

- github.com/decred/dcrd/blockchain/stake@v1.2.1
- github.com/decred/dcrd/blockchain/stake/v2@v2.0.1
- github.com/decred/dcrd/certgen@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.5.2
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/chaincfg/v2@v2.2.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.0
- github.com/decred/dcrd/gcs@v1.1.0
- github.com/decred/dcrd/hdkeychain/v2@v2.0.1
- github.com/decred/dcrd/txscript/v2@v2.0.0
- github.com/decred/dcrwallet/rpc/jsonrpc/types@v1.2.0
2019-08-08 10:05:35 -05:00
Nicola Larosa
1149d54cb9 multi: Use crypto/blake256.
This updates the code to make use of the new crypto/blake256 module instead of
github.com/dchest/blake256.

* change the references in the chaincfg/chainhash and gcs modules
* update chaincfg/chainhash to use the new Sum256 API
* remove references to dchest/blake256 from all go.sum files
2019-08-07 18:54:55 -05:00
Aaron Campbell
b5404408f1 txscript: Fix typo in script test data. 2019-08-07 16:24:57 -05:00
Dave Collins
69e641e393
release: Introduce txscript v2 module. 2019-06-24 15:13:39 -05:00
Dave Collins
1e34495ddb
txscript: Use dcrutil/v2.
This udpates the txscript module to use v2 of the dcrutil module and v2
of the chaincfg module since dcrutil/v2 requires it.

While here, it also modifies the signing functions to accept the new
dcrutil.AddressParams instead of a pointer to a chaincfg.Params struct
in order to remove the tight coupling between txscript and chaincfg at
the API boundary.

It also updates the tests accordingly.
2019-06-24 15:13:39 -05:00
Dave Collins
ae32a34020
txscript: Use secp256k1 types in sig cache.
This modifies the signature cache to accept concrete secp256k1
signatures and pubkeys to break its dependency on the chainec package
which is planned to be removed in the future.

There are no other types that are currently using the signature cache
and, if additional types are desired, they should be handled uniquely,
either through the use of a separate cache or through specialized and
efficient conversion code.

Not all signature algorithms are based on EC crypto, particularly
post-quantum algorithms, so it doesn't make sense to try to shoehorn all
signature algorithms into an EC interface.
2019-06-24 15:13:38 -05:00
Dave Collins
d74040a8bf
txscript: Remove DefaultScriptVersion.
This removes the DefaultScriptVersion constant and updates the code and
tests to use version 0 scripts accordingly.

It is being removed because it is highly error prone since anything that
is working with scripts needs to understand the version it is dealing
with and having a constant that could change that version out from under
them could easily lead to buggy behavior.
2019-06-24 15:13:37 -05:00
Dave Collins
e5acc5651b
txscript: Remove GetMultisigMandN.
This removes the deprecated GetMultisigMandN function.
2019-06-24 15:13:35 -05:00
Dave Collins
641be388b4
txscript: Remove GetScriptHashFromP2SHScript.
This removes the deprecated GetScriptHashFromP2SHScript function.
2019-06-24 15:13:34 -05:00
Dave Collins
4f7a4c9858
txscript: Remove multisig redeem script err return.
This removes the previously deprecated error return from the
MultisigRedeemScriptFromScriptSig function and updates the tests
accordingly.
2019-06-24 15:13:34 -05:00
Dave Collins
b92aa63e07
txscript: Remove CalcScriptInfo.
This removes the deprecated CalcScriptInfo function along with the
associated ScriptInfo struct and tests.
2019-06-24 15:13:33 -05:00
Dave Collins
41f1139e3b
txscript: Unexport IsStakeOutput
This unexports the previously deprecated isStakeOutput function and
updates all callers in the module accordingly.
2019-06-24 15:13:32 -05:00
Dave Collins
68e1655bba
txscript: Remove IsMultisigScript err return.
This removes the previously deprecated error return from the
IsMultisigScript function and updates all callers in the module and
tests accordingly.
2019-06-24 15:13:32 -05:00
Dave Collins
6dea351b42
txscript: Remove third GetPreciseSigOpCount param.
This removes the previously deprecated and unused third parameter of the
GetPreciseSigOpCount function.
2019-06-24 15:13:31 -05:00
Dave Collins
16b9f67d4f
txscript: Unexport HasP2SHScriptSigStakeOpCodes.
This unexports the previously deprecated HasP2SHScriptSigStakeOpCodes
function and updates all callers in the module accordingly.
2019-06-24 15:13:31 -05:00
Dave Collins
e0a318cd75
txscript: Remove DisableLog. 2019-06-24 15:13:30 -05:00
Dave Collins
ad0d98ce75
txscript; Use const for sighashall optimization.
This breaks the dependency on chaincfg.SigHashOptimization which is no
longer available in v2 of the chaincfg module.  The constant is set to
false to ensure the same semantics are kept and an additional comment
has been added regarding the status.
2019-06-24 15:13:30 -05:00
Dave Collins
b5dd4a030a
txscript: Prepare v1.1.0.
This updates the txscript dependencies and serves as a base for
txscript/v1.1.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
- github.com/decred/dcrd/dcrutil@v1.3.0
- golang.org/x/crypto@v0.0.0-20190611184440-5c40567a22f8

The full list of updated direct dependencies since the previous
txscripti/v1.0.2 release are as follows:

- github.com/decred/dcrd/chaincfg@v1.5.1
- github.com/decred/dcrd/dcrec@v1.0.0
- github.com/decred/dcrd/dcrec/edwards@v1.0.0
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
- github.com/decred/dcrd/dcrutil@v1.3.0
- golang.org/x/crypto@v0.0.0-20190611184440-5c40567a22f8
2019-06-19 14:47:05 -05:00
Dave Collins
ce852eb852
blockchain: Do coinbase nulldata check locally.
This refactors the consensus code which extracts the null data from the
coinbase from txscript.ExtractCoinbaseNullData so that it is performed
directly in the validation code where it more properly belongs.

The only reason the extraction was previously done in txscript is
because it was not possible to parse scripts outside of it, but that is
no longer the case now that txscript offers an exported tokenizer for
that purpose.

The extraction code is ever so slightly more efficient now that it no
longer needs to be as generic since it now has direct knowledge of the
conditions that need to be handled.

Great care was taken to ensure the semantics are not changed while
refactoring the code and no additional tests are added in this commit
because all of the conditions and code paths are covered by the tests
recently added to the full block tests.

While here, also perform some related code cleanup in the function and
improve the error messages .

Since the txscript.ExtractCoinbaseNullData is no longer necessary, this
deprecates the function and releated error code and constant so they can
be removed in the next major version of txscript.

Finally, since this relies on the script tokenizer which is not yet in a
released version of the txscript module, bump the requirement to include
an as yet unreleased version of txscript to ensure the next time the
blockchain module is released, it will require a newer version of
txscript to be released first.
2019-06-19 13:26:33 -05:00
David Hill
893aa30dce multi: Use https links where available. 2019-06-18 14:20:06 -05:00