Commit Graph

165 Commits

Author SHA1 Message Date
Jack Grigg 067b3b3032 Update ZIP 244 test vectors
Source: c7f9463713/test-vectors/zcash/zip_0244.json
2022-02-15 02:42:14 +00:00
Jack Grigg 80f478e67e Make `PrecomputedTransactionData` a required argument of `SignatureHash`
The ZIP 244 changes mean that we're going to need to alter every
callsite to pass through all of the transparent `CTxOut`s being spent.
Given that we need to pass it over to Rust, it makes more sense to just
have `PrecomputedTransactionData` be the vehicle for conveying this data
across.
2022-02-15 02:42:14 +00:00
Jack Grigg 3acf7941d6 Move shielded signature checks out of `ContextualCheckTransaction`
The ZIP 244 changes mean that shielded signatures will now require
access to any transparent inputs of the transaction, so we need to
validate the shielded signatures around the same point during block
connection or `AcceptToMemoryPool` as when we validate transparent
signatures.
2022-02-15 02:40:15 +00:00
Kris Nuttycombe 2885ae7643 Derive transparent keys from mnemonic seed. 2021-10-19 17:51:14 -06:00
Jack Grigg 9a5951aab1 test: Check for updated empty-tx reject messages in transaction tests 2021-07-01 13:05:26 +01:00
Kris Nuttycombe 53828a38ba Make CTransaction::nConsensusBranchId a std::optional 2021-07-01 12:41:25 +01:00
Jack Grigg 3fe8285c7e Implement Orchard signature validation consensus rules 2021-06-14 22:47:00 +01:00
Jack Grigg 5ce1e649d3 Throw an exception instead of asserting if Rust tx parser fails
The Rust parser is stricter than the C++ parser, so we can reach errors
now non-contextually that previously were thrown by the consensus rules.

Various tests have been updated to check for these exceptions, as they
can no longer instantiate these transactions to pass to the consensus
rules. The tests use an unsafe constructor so they can still check the
consensus rules.
2021-06-13 07:57:39 +01:00
Jack Grigg 08baaaa492 Fix tests that assume CTxOuts can be "null" 2021-06-13 01:45:17 +01:00
Jack Grigg 0b8a348c2b ZIP 244 signature digests 2021-06-12 20:03:53 +01:00
Jack Grigg bd1fd2eaca ZIP 244 transaction digests 2021-06-12 20:03:53 +01:00
Jack Grigg bfc77d571e v5 transaction format parser
The majority of the parser is in C++, but Orchard bundles are parsed
exclusively by Rust.

The ZIP 244 test vectors are brought in here so we can start by testing
round-trip serialization.
2021-06-10 22:11:42 +01:00
Jack Grigg b1aa9365af Add JSDescriptionInfo for constructing JSDescriptions
This matches the existing transaction builder structs:
- SpendDescriptionInfo
- OutputDescriptionInfo
- TransparentInputInfo

It also removes the dependency of the transaction format on the proving
system.
2020-12-20 22:42:22 +00:00
Jack Grigg efb4246ad3 Replace libsodium's crypto_sign with ed25519-zebra
crypto_sign_verify_detached is still used within the consensus rules
until Canopy activation. ed25519-zebra generates signatures that are
valid under both pre- and post-Canopy rules (for our honest usage),
so we can use it to generate transaction signatures now. Then once
Canopy activates, we can remove the remaining usages of crypto_sign.
2020-08-20 19:00:47 +01:00
Kris Nuttycombe 0cdce269b5 Merge remote-tracking branch 'upstream/master' into bazel-patches 2020-08-14 14:30:15 -06:00
Kris Nuttycombe b383d6cada Merge remote-tracking branch 'upstream/master' into bazel-patches 2020-07-31 12:49:40 -06:00
Jack Grigg 042bd12a5c Move JSDescription::Verify to ProofVerifier::VerifySprout 2020-07-08 13:59:47 +12:00
Jack Grigg 35765ec9de Move ProofVerifier out of the libzcash namespace
It needs to be closer to the root of our dependency tree, so that it can
depend on the transaction format. The libzcash compilation unit is
further from the dependency tree root than the transaction format.
2020-07-08 13:59:47 +12:00
Jack Grigg 7e2558d2e2 Make ZCJoinSplit::prove static and remove ZCJoinSplit globals
We don't support making pre-Sapling JoinSplit proofs, and we load the
parameters for post-Sapling JoinSplit proofs at proving time, so there
is no need for a global ZCJoinSplit to be passed through the APIs.
2020-07-08 13:59:47 +12:00
Jack Grigg 80169c940f ZIP 213 consensus rules 2020-02-28 13:59:53 +13:00
Jack Grigg 7bbd846f0f Apply a consistent ban policy within ContextualCheckTransaction 2020-02-06 14:30:37 +00:00
MarcoFalke cbdceb0b28
transaction_tests: Be more strict checking dust
* Don't allow off-by-one or more
* Make clear dust is coupled with minRelayTxFee
* Check rounding for odd values
2019-12-17 12:18:50 -06:00
Homu 63c3d1ec94 Auto merge of #4227 - str4d:2074-scripts-1, r=str4d
Bitcoin script PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6335
- bitcoin/bitcoin#6424
- bitcoin/bitcoin#11058
- bitcoin/bitcoin#12460
- bitcoin/bitcoin#13194

Part of #2074.
2019-12-17 17:05:58 +00:00
Peter Todd 602960e5b5
Accept any sequence of PUSHDATAs in OP_RETURN outputs
Previously only one PUSHDATA was allowed, needlessly limiting
applications such as matching OP_RETURN contents with bloom filters that
operate on a per-PUSHDATA level. Now any combination that passes
IsPushOnly() is allowed, so long as the total size of the scriptPubKey
is less than 42 bytes. (unchanged modulo non-minimal PUSHDATA encodings)

Also, this fixes the odd bug where previously the PUSHDATA could be
replaced by any single opcode, even sigops consuming opcodes such as
CHECKMULTISIG. (20 sigops!)
2019-12-04 20:35:01 +00:00
Luke Dashjr 4884e75c8c
Policy: MOVEONLY: 3 functions to policy.o:
- [script/standard.o] IsStandard
- [main.o] IsStandardTx
- [main.o] AreInputsStandard

Also, don't use namespace std in policy.cpp
2019-12-04 20:34:14 +00:00
Dimitris Apostolou cec2bd93cf
Remove stale comment 2019-11-29 16:37:38 +02:00
Jack Grigg fe3cb8ec93
Remove makeGrothProof argument from JoinSplit::prove 2019-09-16 13:10:54 +01:00
Jack Grigg 1b4cf1337c
Use Sapling JSDescriptions in Boost tests 2019-08-22 15:42:42 +01:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Dimitris Apostolou f57f76d789
Rename vjoinsplit to vJoinSplit 2019-06-16 19:13:49 +03:00
Jack Grigg be94721953
Globals: Explicitly pass const CChainParams& to ContextualCheckTransaction() 2019-05-23 17:48:28 +01:00
Jack Grigg 13cfabb36c
Globals: Explicitly pass const CChainParams& to IsStandardTx() 2019-05-23 17:48:26 +01:00
Eirik Ogilvie-Wigley 4fc309f0f5 Rename Merkle Trees to include sprout or sapling 2018-08-01 10:31:09 -06:00
Ariel Gabizon e1a3461cc2 Improve/Fix variable names
ZCProof was too general. pubKeyHash was actually the JoinSplit pubkey
itself.
2018-06-09 20:27:35 -07:00
Jack Grigg a6bbb26e08
Replace boost::array with std::array 2018-05-26 00:12:57 +12:00
Sean Bowe b7a6c32178 Integrate Groth16 verification and proving. 2018-05-14 16:26:23 -06:00
Jack Grigg e5eab182b5
Use boost::variant to represent shielded addresses and keys
libzcash::PaymentAddress has been renamed to libzcash::SproutPaymentAddress,
and a new typedef boost::variant is now libzcash::PaymentAddress. Similarly
for ViewingKey and SpendingKey.

A new class InvalidEncoding is introduced as the default boost::variant
option for each address and key type; it is used during decoding instead
of boost::optional.

All address and key storage functions in the wallet have been modified to
refer specifically to the Sprout types, as they are used very precisely.
In most other cases, the more general type is leveraged as much as possible,
and we convert to the Sprout type when necessary. This will be subsequently
wrapped in, or replaced with, context-specific functions once Sapling
types are implemented.
2018-05-11 17:14:49 -04:00
Homu 9e5398686c Auto merge of #3206 - bitcartel:3194_polymorphic_note_class, r=str4d
Update note classes to be polymorphic

Closes #3194.  Lays foundation for introduction of Sapling notes through refactoring and creation of a class hierarchy for Sprout notes.  This PR updates some tests, but otherwise is a no-op.
2018-05-02 08:07:35 -07:00
Eirik Ogilvie-Wigley 812098256f Coinbase transactions can not have shielded spend or output 2018-04-26 15:53:26 -06:00
Eirik Ogilvie-Wigley 4b4662b06d Make sure transactions have non-empty outputs 2018-04-26 15:24:59 -06:00
Sean Bowe 6679855147
Check that duplicate Sapling nullifiers don't exist within a transaction. 2018-04-25 17:10:34 -06:00
Simon b230fe6836 Refactoring: Rename class libzcash::Note to libzcash::SproutNote. 2018-04-25 11:33:24 -07:00
Jack Grigg b1608eed82
Add a constant for Overwinter's transaction version 2018-04-23 20:39:04 +01:00
Simon 68cc953012 Part of #2966, extending Sprout tests to other epochs.
Tests updated:
- test_Get
- test_simple_joinsplit_invalidity
2018-03-26 16:22:37 -07:00
Jack Grigg be12669982
Add consensus branch ID parameter to SignatureHash, remove SigVersion parameter
We do not need to be able to calculate multiple SignatureHash versions for a
single transaction format; instead, we use the transaction format to determine
the SigVersion.

The consensus branch ID *does* need to be passed in from the outside, as only
the caller knows the context in which the SignatureHash is being calculated
(ie. mempool acceptance vs. block validation).

JoinSplit signature verification has been moved into ContextualCheckTransaction,
where the consensus branch ID can be obtained.

The argument to the sign command for zcash-tx has been modified to take a height
in addition to the optional sigtype flags.
2018-02-20 04:22:20 +00:00
Pieter Wuille 6514771a44
Rename to PrecomputedTransactionData 2018-02-20 04:22:20 +00:00
Nicolas DORIER 90285e7b81
Unit test for sighash caching
Zcash: Modified to use P2PKH.
2018-02-20 04:22:20 +00:00
Pieter Wuille f762d44973
Precompute sighashes
Original version by Nicolas Dorier. Precomputing version by Pieter Wuille.

Edited for Zcash by Ariel Gabizon and Jack Grigg
2018-02-20 04:22:20 +00:00
Pieter Wuille c86a1cb86e
BIP143: Verification logic
Includes simplifications by Eric Lombrozo.

Edited for Zcash merge by Ariel Gabizon.
2018-02-20 04:22:19 +00:00
Pieter Wuille 2d42e1a993
Refactor script validation to observe amounts
This is a preparation for BIP143 support.

Edited for Zcash merge by Ariel Gabizon.
2018-02-20 04:22:19 +00:00