Commit Graph

55 Commits

Author SHA1 Message Date
Jane Lusby 8281b9040c
Start work on new Amount type (#554) 2020-07-01 16:31:30 -07:00
Jane Lusby 6cbb6d4574
consolidate arbitrary impls to one file in zebra-chain (#553)
* consolidate arbitrary impls to one file in zebra-chain

* move the ones I missed

* move test-vectors

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-06-30 14:23:38 -07:00
teor 719aa75581 chain: Add a comment about transaction sizes
We don't need to check transaction sizes yet, because we aren't
parsing or generating transactions outside of blocks.

Part of #483.
2020-06-24 18:22:36 +10:00
Henry de Valence 9ddcccdcb4 Update ed25519-zebra to 0.3 2020-06-16 00:42:25 -04:00
Henry de Valence a023ba9b16
Add serde bounds to zebra-chain structures. (#231) 2020-06-15 15:08:14 -07:00
Jane Lusby 9f802cd8dd Wrap Transaction in Arc 2020-06-06 18:13:17 -04:00
Deirdre Connolly b263489af6
Export ed25519 zebra (#445)
And use that one, and our similar redjubjub export, everywhere.

Fixes #405

* Move PRs to 'In Progress' column on project board when created
2020-06-06 18:10:32 -04:00
Jane Lusby 4a2d2a359c
add cargo fmt to ci (#403)
* add cargo fmt to ci

* rebase on main

* switch to stable

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-05-27 19:12:25 -07:00
Jane Lusby b6b35364f3 cleanup warnings throughout codebase 2020-05-27 15:42:29 -04:00
Kiminuo 6465689555 transaction/hash.rs: Add FromStr implementation (issue #299)
Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com>
2020-05-14 15:30:11 -04:00
Deirdre Connolly df7ed7ae81
Move note encryption types around (#362)
* Move around and dedupe note *Cipertext types

* Bump code coverage test timeout to 5 minutes

* Try uploading coverage to codecov.io
2020-04-19 14:45:25 -04:00
Deirdre Connolly 21eca164d8 Refine Output description ephemeral_key to jubjub::AffinePoint
And impl Arbitrary for Output to support better generation of those points in proptests.
2020-04-18 22:05:13 -04:00
Deirdre Connolly 7a4be955be Remove todo 2020-04-18 22:05:13 -04:00
Deirdre Connolly cdfcdc4751 Tidy imports 2020-04-18 04:40:31 -04:00
Deirdre Connolly 05ca1c0c8a Refine JoinSplit ephemeral keys to be x25519_dalek::PublicKey
Impls PartialEq and Eq and Arbitrary on JoinSplit because PublicKey
does not impl them and we can't do it directly.

Resolves #313
2020-04-13 15:32:04 -04:00
Deirdre Connolly 955a4ebc3c Rename SpendDescription to Spend, OutputDescription to Output 2020-04-09 17:17:21 -04:00
Henry de Valence 2d2603cf65 Add a CoinbaseData field, replacing Vec<u8>.
The CoinbaseData field can only be constructed by the transaction parser, so we
can ensure that a coinbase input is always serializable, as CoinbaseData
instances can't be constructed outside of the parser that maintains the data
size invariant.
2020-02-19 15:42:20 -05:00
Henry de Valence b443d7a4be Fix clippy lints. 2020-02-14 18:23:41 -05:00
Henry de Valence 44b299d15c Parse block heights in coinbase transactions.
BIP34, which is included in Zcash, encodes the block height into each
block by adding it into the unused BitcoinScript field of the block's
coinbase transaction.  However, this is done just by requiring that the
script pushes the block height onto the stack when it executes, and
there are multiple different ways to push data onto the stack in
BitcoinScript.  Also, the genesis block does not include the block
height, by accident.

Because we want to *parse* transactions into an algebraic data type that
encodes their structural properties, rather than allow possibly-invalid
data to float through the internals of our node, we want to extract the
block height upfront and store it separately from the rest of the
coinbase data, which is inert.  So the serialization code now contains
just enough logic to parse BitcoinScript-encoded block heights, and
special-case the encoding of the genesis block.

Elsewhere in the source code, the `LockTime` struct requires that we
must use block heights less than 500,000,000 (above which the number is
interpreted as a unix timestamp, not a height).  To unify invariants, we
ensure that the parsing logic works with block heights up to
500,000,000, even though these are unlikely to ever be used for Zcash.
2020-02-14 18:23:41 -05:00
Henry de Valence 4957567409 Represent coinbase inputs explicitly.
Coinbase inputs are handled differently from other inputs and have
different consensus rules, so they should be represented differently in
the source code.  This lets us discard extraneous details (for instance,
it's not necessary to maintain the all-zero hash) and specialize logic.
2020-02-14 18:23:41 -05:00
Henry de Valence 972d16518f Make ZcashSerialize infallible mod its Writer.
Closes #158.

As discussed on the issue, this makes it possible to safely serialize
data into hashes, and encourages serializable data to make illegal
states unrepresentable.
2020-02-05 19:48:43 -05:00
Henry de Valence f04f4f0b98 Apply clippy fixes 2020-02-05 12:42:32 -08:00
Deirdre Connolly 69164a6943 Add test for BlockHeaderHash::from(BlockHeader) 2020-02-04 18:04:53 -05:00
Deirdre Connolly 3ea4a6a9ab Move transaction test vectors around
Resolves #210
2020-02-04 18:04:53 -05:00
Deirdre Connolly ac3c31b1c2 Rearrange and tidy imports 2020-01-28 03:48:23 -05:00
Deirdre Connolly 157add149a Note that shielded_data::EncryptedCiphertext should move as part of note encryption work
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2020-01-28 03:48:23 -05:00
Deirdre Connolly 101f0a5c0a Remove commented out asserts in serialize
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2020-01-28 03:48:23 -05:00
Deirdre Connolly cdeaeaa3d6 Remove commented out asserts
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2020-01-28 03:48:23 -05:00
Deirdre Connolly 09e34f258f Note that joinsplit::EncryptedCiphertext structs should move as part of note encryption work
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2020-01-28 03:48:23 -05:00
Deirdre Connolly 283d06bb08 Add (de)serialization roundtrip proptext for shielded_data::(Encrypted,Out)Ciphertext 2020-01-28 03:48:23 -05:00
Deirdre Connolly 2df20b9e6c Add (de)serialization roundtrip proptext for joinsplit::EncryptedCiphertext 2020-01-28 03:48:23 -05:00
Deirdre Connolly a259a6b4b1 Add and use v4_strategy() 2020-01-28 03:48:23 -05:00
Deirdre Connolly a93e2db44b Add and use OutCiphertext
Instead of [u64; 10].
2020-01-28 03:48:23 -05:00
Deirdre Connolly 289f8ec9ca impl Arbitrary for SpendDescription and refine impl for ShieldedData 2020-01-28 03:48:23 -05:00
Deirdre Connolly f8781c3415 Refine Arbitrary impl for JoinSplitData<P> 2020-01-28 03:48:23 -05:00
Deirdre Connolly 100c5b15ec Impl Arbitrary for ShieldedData and derive it for other types
Wraps the construction of redjubjub Signature so we don't
need an explicit impl for it.
2020-01-28 03:48:23 -05:00
Deirdre Connolly 7632863454 Impl Arbitrary for JoinSplitData<P>
Wraps the construction of ed25519 PublicKeyBytes and Signature so we don't
need an explicit impl for ed25519 types.
2020-01-28 03:48:23 -05:00
Deirdre Connolly b47e886eed Add transaction v3 proptest strategy 2020-01-28 03:48:23 -05:00
Deirdre Connolly 9cbc60a2d7 Proptest v1 and v2 transaction variants 2020-01-28 03:48:23 -05:00
Deirdre Connolly 31b759a924 Update (de)serialization to use EncryptedCiphertext types 2020-01-28 03:48:23 -05:00
Deirdre Connolly ffd64d4b71 Add shielded_data::EncryptedCiphertext 2020-01-28 03:48:23 -05:00
Deirdre Connolly 95f3c61e53 Add joinsplit::EncryptedCiphertext and derive(Arbitrary) on JoinSplit* 2020-01-28 03:48:23 -05:00
Deirdre Connolly b0c0055915 Transaction::V1 round trip proptest 2020-01-28 03:48:23 -05:00
Deirdre Connolly dfb28b7854 Stubbing out an Arbitrary impl for variant V1 of the Transaction enum 2020-01-28 03:48:23 -05:00
Henry de Valence 60f3f35d89 Refine Ed25519 byte arrays to ed25519-zebra types. 2020-01-24 16:43:31 -05:00
Henry de Valence 2e04610be3 Fix doc errors (missing links, etc). 2020-01-24 13:38:23 -08:00
Henry de Valence 4d5c8c7940 Clarify Transaction docs to point to iterator methods.
Closes #191.
2020-01-24 13:38:23 -08:00
Henry de Valence 41021c65ad Implement transaction (de)serialization. 2019-12-31 02:46:39 -05:00
Henry de Valence 53cae4647e Make invalid ShieldedData unrepresentable.
ShieldedData objects must have at least one spend or output; using Either
ensures that at least one must be present.  This is similar to the
JoinSplitData case, but slightly more complicated: rather than enforcing that
one list has at least one element (which can be done as `(first, rest)`), here
we need to use Either.   This has the downside that it is possible to construct
multiple equivalent internal representations (choosing whether a spend or
output goes in the `first` slot), but this easily fixed with a custom PartialEq
implementation.
2019-12-31 02:46:39 -05:00
Henry de Valence 8ff4139c1f Use Groth16Proof in ShieldedData, not just JoinSplits. 2019-12-31 02:46:39 -05:00