Commit Graph

673 Commits

Author SHA1 Message Date
Kris Nuttycombe 74b0c50294 Fix transitivity of the test-dependencies feature. 2021-10-01 15:20:01 -06:00
Kris Nuttycombe da3c84ff31 Update hdwallet to depend upon secp256k1-v0.20 2021-10-01 12:52:19 -06:00
Kris Nuttycombe 6cf0749ac9 Merge remote-tracking branch 'upstream/master' into autoshield-poc-reorder 2021-10-01 11:03:41 -06:00
Jack Grigg b29803ae34 Update ZIP 244 test vectors with new consensus branch ID 2021-09-28 22:31:11 +01:00
Jack Grigg a90af6cb2d Update NU5 consensus branch ID and set testnet activation height 2021-09-28 22:12:31 +01:00
Jack Grigg 8f9ea0d116 pasta_curves 0.2.1
This is the first version that was relicensed as MIT OR Apache-2.0.
2021-09-22 22:16:59 +01:00
Jack Grigg afd4a4803c bip0039 0.9 2021-09-22 22:14:03 +01:00
Jack Grigg 4770675542 Bump Orchard patch to include Merkle path cleanups 2021-09-16 22:55:22 +01:00
Jack Grigg eae4ac4110 `impl memuse::DynamicUsage for Amount`
Required to use `DynamicUsage` with `orchard::Bundle<_, Amount>`.
2021-09-14 20:48:58 +01:00
Jack Grigg 65e1d32774 ff 0.11, group 0.11, etc. 2021-09-09 18:20:37 +01:00
Kris Nuttycombe 427e6acbd4 Allow CompactSize deserialization to target any type that can be TryFrom<u64> 2021-09-01 13:57:51 -06:00
str4d edcde252de
Merge pull request #428 from nuttycom/public_compact_size
Move the CompactSize, Vector, Array and Option encodings to a new zcash_encoding crate.
2021-09-01 20:45:28 +01:00
Kris Nuttycombe c1bad64fbd Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-09-01 11:08:52 -06:00
Kris Nuttycombe fa092da456 Fix stray clippy complaints. 2021-08-31 13:19:24 -06:00
Kris Nuttycombe ef98c7e48c Add zcash_encoding crate.
The CompactSize type, and the standardized encodings for the Vector,
Array and Option types are moved to the newly created crate.
2021-08-31 13:19:24 -06:00
Jack Grigg f03f05f251 zcash_note_encryption: Switch to chacha20poly1305 crate 2021-08-30 15:03:39 +01:00
Kris Nuttycombe edd7471d90 Merge remote-tracking branch 'upstream/master' into autoshield-poc-daa 2021-08-27 11:08:50 -06:00
Kris Nuttycombe ac139c6e9b Make CompactSize serialization functions public. 2021-08-25 09:55:08 -06:00
Jack Grigg f185f8dc83 pprof 0.5 2021-08-23 20:18:45 +01:00
Jack Grigg 5054621a6d fpe 0.5 2021-08-23 20:16:40 +01:00
str4d 9be36f3e54
Merge pull request #417 from nuttycom/incremental_merkle_tree_ser
Add manual serialization for bridgetree::Frontier
2021-08-17 14:57:59 +01:00
Kris Nuttycombe 77bb78d960 Apply suggestions from code review. 2021-08-17 07:31:15 -06:00
Kris Nuttycombe 1ed538b655 Fix clippy complaints. 2021-08-16 17:36:07 -06:00
Kris Nuttycombe 7b953283ce Add blanket implementation of Hashable for incrementalmerkletree::Hashable + HashSer 2021-08-16 13:48:37 -06:00
Kris Nuttycombe 837ad19262
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-08-16 10:20:14 -06:00
Kris Nuttycombe 5ba7bbc53b Serialize `Option` values by value, not by reference.
Co-authored-by: str4d <jack@electriccoin.co>
2021-08-16 10:06:38 -06:00
Kris Nuttycombe b783c4d0e7 Merge remote-tracking branch 'upstream/master' into autoshield-poc-daa 2021-08-12 11:21:30 -06:00
Kris Nuttycombe 98dc330cdb
Merge pull request #424 from daira/zip339-primitives
ZIP 339 support
2021-08-12 07:23:15 -06:00
Jack Grigg d8410063ab zcash_primitives: Implement `Domain::batch_epk` for `jubjub` 2021-08-11 00:21:00 +01:00
Jack Grigg 45521c7849 zcash_primitives: Test that batched trial decryption matches unbatched 2021-08-11 00:18:39 +01:00
Jack Grigg d0026b460b zcash_primitives: Implement batched trial decryption optimisation 2021-08-10 02:17:10 +01:00
Jack Grigg 0facec094f Update changelogs with `EphemeralKeyBytes` changes 2021-08-09 21:45:16 +01:00
Jack Grigg 279a8b6bb6 Use `EphemeralKeyBytes` type in place of `[u8; 32]` 2021-08-09 21:28:42 +01:00
Daira Hopwood d1443e5049 ZIP 339 support.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-08-07 01:07:54 +01:00
Jack Grigg 83c6a2d1ca Store OutputDescription `ephemeral_key` as bytes
This removes an unnecessary `to_bytes` during trial decryption of notes,
and more closely matches the protocol spec. We retain the consensus rule
canonicity check on epk due to `SaplingVerificationContext::check_output`
taking a `jubjub::ExtendedPoint`, forcing `zcashd` to parse the bytes.
2021-08-06 16:54:48 +01:00
str4d 945a199ddd
zcash_primitives: Use `not(unix)` instead of `windows` for flamegraphs
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-08-05 23:22:12 +01:00
Jack Grigg 16d38ea354 zcash_primitives: Remove spaces from benchmark group names 2021-08-05 22:40:46 +01:00
Jack Grigg 0f15743200 Disable default benchmark harness for all workspace crates
This is necessary in order to provide criterion-specific arguments to
`cargo bench`, such as `--profile-time`.
2021-08-05 22:39:36 +01:00
Jack Grigg 3ffa3ae435 zcash_primitives: Add flamegraph support to benchmarks on Unix
Use `cargo bench -- --profile-time TIME_IN_SECONDS` to measure the
flamegraphs. They will be placed in `target/criterion/`.
2021-08-05 22:24:16 +01:00
Jack Grigg 8b05727361 zcash_primitives: Benchmark trial decryption of compact outputs
These are effectively identical to full-output trial decryption (as the
primary cost is the scalar multiplication), but it's good to check.
2021-08-05 22:13:23 +01:00
Kris Nuttycombe 2945905d52 Implement manual serialization for incremental Merkle tree components.
This also adds parsing of the legacy CommitmentTree format,
to permit easy migration of persisted data.
2021-08-05 09:32:44 -06:00
Kris Nuttycombe 232feb71be Use orchard::Flags::to_byte/from_byte 2021-07-29 10:38:43 -06:00
Kris Nuttycombe 3b8f0214eb Move Orchard bundle commitments to the `orchard` crate. 2021-07-29 10:38:43 -06:00
Kris Nuttycombe 105f8da91f Update `nonempty` and `orchard` dependencies. 2021-06-30 12:57:56 -06:00
Kris Nuttycombe 1ae2bd727c Fix clippy complaints 2021-06-23 16:37:48 -06:00
Jack Grigg 69ee9f8ca5 Bump orchard deps
Includes additional patched dependencies, now that the orchard crate is
not pinning specific revisions of the in-development crates.
2021-06-15 20:20:53 +01:00
Jack Grigg 00b3e427e6 impl From<Amount> for orchard::ValueSum
This is necessary in order to be able to calculate bvk for Orchard
bundles.
2021-06-14 11:41:02 +01:00
Jack Grigg c7c79d266e zcash_note_encryption: Add `ShieldedOutput::ephemeral_key() -> EphemeralKeyBytes`
This replaces the `ShieldedOutput::epk() -> &Domain::EphemeralPublicKey`
which could not be satisfied by output types that did not parse epk.
2021-06-10 18:35:19 +01:00
str4d 3915abd0a1
Merge pull request #399 from str4d/zip-244-auth-digest-test-vectors
Bring in ZIP 244 auth digest test vectors.
2021-06-08 19:47:55 +01:00
Jack Grigg 684fd504a8 ZIP 244: Write transparent scripts in their consensus encoding 2021-06-08 18:47:34 +01:00
str4d fe07fb3c51
Merge pull request #396 from str4d/394-zip-216
Impl ZIP 216 on SaplingVerificationContext and redjubjub::PublicKey
2021-06-08 18:34:47 +01:00
Kris Nuttycombe 31ea91ced8 Ensure tze digest is only included if TZEs are in the consensus rules. 2021-06-08 11:33:52 -06:00
Jack Grigg acc19a76e2 Bring in ZIP 244 auth digest test vectors.
From https://github.com/zcash-hackworks/zcash-test-vectors/pull/34.
2021-06-08 18:17:30 +01:00
Jack Grigg 7e23b96a03 Extract ZIP 225 Orchard bundle parsing and serialization into helpers
These will be used by `zcashd` for handling the Orchard component of v5
transactions.
2021-06-08 17:29:04 +01:00
str4d 0bfd1f7544
Merge pull request #375 from nuttycom/feature/zip-225
ZIP 225 & ZIP 244
2021-06-08 17:28:25 +01:00
Kris Nuttycombe eb3d01aa6b
Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-06-08 07:02:52 -06:00
Kris Nuttycombe f70285d243 Fix error in transaction auth digest.
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-07 09:27:05 -06:00
Kris Nuttycombe 371f84dc9b Minor error message improvement.
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-07 09:27:05 -06:00
Kris Nuttycombe 0253442af0 Be more explicit about empty sapling & orchard hashes. 2021-06-07 09:27:05 -06:00
str4d 2f3e4989ba
Merge pull request #352 from str4d/zcash_address
New component: zcash_address crate
2021-06-07 00:36:48 +01:00
Jack Grigg e2fb5e6402 Impl ZIP 216 on SaplingVerificationContext and redjubjub::PublicKey
`PublicKey::verify` now always uses post-ZIP 216 validation rules, which
is fine in non-consensus contexts.

`SaplingVerificationContext` is used by `zcashd`'s consensus rules.
2021-06-06 23:45:15 +01:00
Kris Nuttycombe b93c503263 Deserialize signatures directly into actions.
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-05 10:19:36 -06:00
Kris Nuttycombe 4f764c3c80 Use Vector read/write operations where possible instead of Array
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-05 10:12:39 -06:00
Kris Nuttycombe 97bef30582 Remove consensus branch id from roundtrip serialization check.
Possible now that it's part of the transaction.
2021-06-05 09:48:52 -06:00
Kris Nuttycombe 47ce97c3d2 Keep builder spend data in spend_auth_sig fields. 2021-06-05 09:45:55 -06:00
Kris Nuttycombe 69e5a491ff Fix generation of arbitrary jubjub points. 2021-06-04 17:28:44 -06:00
Kris Nuttycombe d0a911cb87 Fix rustdocs 2021-06-04 16:38:01 -06:00
Kris Nuttycombe 28d3f481cd Apply suggestions from code review. 2021-06-04 16:38:01 -06:00
Kris Nuttycombe e71a1ce345 Rename Vector::write_items -> Array::write and Vector::read_count -> Array::read 2021-06-04 16:38:01 -06:00
Kris Nuttycombe 4623f98d9a Fix bugs in construction of Sapling txid hashes. 2021-06-04 16:38:01 -06:00
Kris Nuttycombe df0095ebba Add ZIP-244 test vectors. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 6348400cf4 Store patial authorizing data for sapling components in bundle authorization. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 6635895e55 Clean up TZE signature generation. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe ab1b31ebf6 Store partial authorizing data for transparent txs in transparent authorization. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe dac68ce2aa Drop proptest space size to reduce test runtime. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 38b864c100 Implement V5 transaction serialization & roundtrip property tests. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe e828dbf5d0 Add v5 parsing and serialization for Sapling components. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 1a5aad723b Use generalized signature_hash for transaction builder. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 55d1090f70 Add v5 txid & signature hashing. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 1138343c89 Add data structures for transaction digests. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe fd1790fec2 Move sighash.rs -> sighash_v4.rs 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 4bcad97ba1 Add amount conversion for Orchard values. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 2ae55b4145 Add more flexibility to vector serialization. 2021-06-04 15:45:39 -06:00
Jack Grigg 1222391dd7 Migrate to bitvec 0.22, ff 0.10, etc.
Requires patching three dependencies:

- bellman is pending a new release.
- nom is part of the funty breakage; we are blocking on a new release.
- orchard is in development.
2021-06-04 22:02:48 +01:00
Kris Nuttycombe 9149d48afc
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-03 20:25:10 -06:00
Kris Nuttycombe 231aa5d01a
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-03 18:47:49 -06:00
Kris Nuttycombe cc9dbf8bde Fix clippy complaint. 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 732b97d021 Update changelog. 2021-06-03 18:46:38 -06:00
Kris Nuttycombe a305760bb1 Move TZE components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 523424e50b Move Transparent components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 670d03e74f Move Sprout components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 84e8952ec3 Move Sapling components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 488d02aad3 Add Orchard bundle to TransactionData
This also adds parsing and serialization for Orchard bundle parts.

This requires changes to the TZE builder components, because they
refer to the TransactionData type in the context for witness creation.
2021-06-03 13:03:29 -06:00
Kris Nuttycombe 12d2dfd1bd
Merge pull request #386 from nuttycom/feature/zip-225-builder_modularization
ZIP-225/244 #2: Refactor transaction builder to create separate builders for each section.
2021-06-02 21:29:19 -06:00
Kris Nuttycombe 2098196440 Fix errors caused by use of zero heights. 2021-06-02 21:07:29 -06:00
Kris Nuttycombe 2b96e2eb0c Fix TZE demo test errors. 2021-06-02 18:23:25 -06:00
Kris Nuttycombe e32e2d6e7f Fix ordering of Sapling build errors. 2021-06-02 17:15:35 -06:00
Kris Nuttycombe 0743f9e815
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-02 17:11:04 -06:00
Kris Nuttycombe 2c891a8000 Fix incorrect progress notifier. 2021-06-02 17:09:17 -06:00
Kris Nuttycombe 14d07cd826 Fix intra-doc links & rustfmt. 2021-06-02 17:09:17 -06:00
Kris Nuttycombe d2402f4861
Apply changelog suggestions.
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-02 16:58:08 -06:00
Kris Nuttycombe b487a7f820 Sapling builder can store network params. 2021-06-02 16:57:27 -06:00
Kris Nuttycombe 4878b5b19b Address comments from review. 2021-06-02 16:48:55 -06:00
Kris Nuttycombe 72ac97a35f Derive transaction version & branch id from target height. 2021-06-02 13:45:29 -06:00
Kris Nuttycombe 7466ef42d8 Move change_address back to the main builder
Also, store the target height in the sapling builder.
2021-06-02 12:35:18 -06:00
Kris Nuttycombe bd3b2afa59 Update changelog. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe c872f39547 Restore progresscounter. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe 3770e5de8b Move TZE transaction builder to an independent module. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe c1a8de27f3 Move Sapling transaction builder to an independent module. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe ba6fc053b5 Move transparent transaction builder to an independent module. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe 8267d06846 Refactor transaction builder to create separate builders for each section. 2021-06-02 11:48:46 -06:00
str4d f7f5cd472b
Merge branch 'master' into note-decryption-fixes 2021-06-02 18:45:01 +01:00
Kris Nuttycombe 168314cec6 Update changelog. 2021-06-01 07:05:01 -06:00
Kris Nuttycombe 62bd06f14e Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-01 07:03:31 -06:00
Kris Nuttycombe 76999eb5c7 Make txid contents private & use txid for TzeOutPoint 2021-06-01 07:03:31 -06:00
Kris Nuttycombe 936b552de2 Add NoteValue newtype, Nullifier::as_ref and proptest generation. 2021-06-01 07:03:31 -06:00
Kris Nuttycombe 3dc05a69eb Add Nu5 NetworkUpgrade variant. 2021-06-01 07:03:31 -06:00
Kris Nuttycombe 4efb21d1c7 Make amount addition and subtraction traits use checked operations. 2021-06-01 07:03:31 -06:00
Jack Grigg 362838c3fa zcash_note_encryption: Fix array size in Domain::extract_{esk, pk_d}
Decrypted output size is `OUT_PLAINTEXT_BYTES`, which the decryptor
can always provide (either by decrypting into the correct size array
as now, or truncating the buffer before passing it to the domain).
2021-05-28 23:48:03 +01:00
Jack Grigg f6705f23c3 zcash_note_encryption: Add ovk recovery API 2021-05-28 23:45:23 +01:00
Jack Grigg ae43e6c074 zcash_note_encryption: Pass cmstar_bytes to Domain::derive_ock
PRF^ock in the spec takes cm* as a byte array.
2021-05-28 23:41:13 +01:00
Jack Grigg 6f0e7c86a3 zcash_primitives: Add Builder::with_progress_notifier to changelog 2021-05-26 22:02:01 +01:00
Jack Grigg d031dabcfc Builder: Move progress notifier configuration to a builder method
This is what builder methods are for :) and it helps to limit the growth
of alternate `build` methods.
2021-05-26 21:58:08 +01:00
str4d d9a3b98120
Merge pull request #377 from adityapk00/builder_progress
Report Sapling Tx Builder Progress
2021-05-26 21:52:38 +01:00
Jack Grigg 6717cd821c Move F4Jumble implementation into zcash_address 2021-05-20 22:50:59 +01:00
str4d d50bb12a97
Merge pull request #334 from str4d/dependency-updates
Dependency updates
2021-05-20 17:48:52 +01:00
str4d 35dadc7f6c
f4jumble: Test both directions against test vectors 2021-05-20 14:16:39 +01:00
Jack Grigg 9a80ae5cd1 bitvec 0.20 2021-05-19 18:29:37 +01:00
Jack Grigg 5623e02a7c Migrate to ff 0.9 et al. 2021-05-19 18:29:37 +01:00
Kris Nuttycombe 1dcba34167 Add checks against f4jumble test vectors. 2021-05-19 08:50:50 -06:00
Kris Nuttycombe 774d166fff Use VALID_LENGTH constant for f4jumble proptest generation. 2021-05-19 08:29:10 -06:00
Kris Nuttycombe 4346ca9e50 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-05-19 08:29:10 -06:00
Kris Nuttycombe 69ce777dd1 Use macros for personalization & iterator for g function.
Co-authored-by: str4d <jack@electriccoin.co>
2021-05-19 08:29:01 -06:00
Kris Nuttycombe 08a3fb9639 Implement F4Jumble 2021-05-19 08:28:58 -06:00
str4d 1b0f2060dd
Improve documentation of builder::Progress 2021-05-18 13:45:48 +01:00
Aditya Kulkarni f3aded9c84 Send builder progress 2021-05-17 09:44:42 -07:00
Daira Hopwood da431a0eb2
rustfmt fix 2021-05-03 14:08:06 +01:00
narodnik 618a6165c7 Replace redundant code with call to Field::random() which does the same as the code. 2021-05-03 13:34:13 +02:00
Kris Nuttycombe 8828276361 Query for unspent utxos checks to ensure that spending tx is mined.
Also make it an error to try to send a memo to a transparent address.
2021-04-16 14:26:51 -06:00
Kris Nuttycombe 862e221a9b Put transparent dependencies behind a feature flag. 2021-04-16 14:23:26 -06:00
Jack Grigg 28a45028ab cargo fmt 2021-04-16 14:03:55 +12:00
Kris Nuttycombe 3434cc8b6a Add a note about canonicity of ephemeral public keys. 2021-04-15 15:32:45 -06:00
Kris Nuttycombe b2b3efd4c2 Fix naming cmstar -> cmstar_bytes and cm -> cmstar 2021-04-15 15:24:45 -06:00
Kris Nuttycombe 00d04de547 Make cmstar check follow the spec more closely. 2021-04-14 15:38:58 -06:00
Kris Nuttycombe 12cb8265d8 Fix formatting. 2021-04-12 18:47:45 -06:00
Kris Nuttycombe fae1a1517a Simplify try_sapling_output_recovery. 2021-04-12 18:40:17 -06:00
Kris Nuttycombe 6fc1d1d1c0 Use ephemeral_key bytes instead of the epk abstract point where specified. 2021-04-12 16:19:50 -06:00
Kris Nuttycombe 324fc36521 Use ShieldedOutput trait for note encryption/decryption.
This change modifies note encryption and decryption functions
to treat a shielded output as a single value instead of handling
the parts of an output as independent arguments.
2021-04-12 12:59:06 -06:00
Kris Nuttycombe cfdbafe2e3 Add myself to crate contributors. 2021-04-08 10:13:04 -06:00
Kris Nuttycombe a560101bb2 Remove spurious mut references. 2021-04-08 10:08:00 -06:00