Commit Graph

482 Commits

Author SHA1 Message Date
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
Kris Nuttycombe 879eea863a Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-04-08 08:20:23 -06:00
Kris Nuttycombe 213cd6cce9 Fix Clippy complaints. 2021-04-08 08:20:23 -06:00
Kris Nuttycombe 5b13bb3a1e Add try_output_recovery_with_ovk to shared note encryption code. 2021-04-08 08:20:23 -06:00
Kris Nuttycombe 266285b536 Move generalized note encryption functionality to zcash_note_encryption crate. 2021-04-08 08:20:21 -06:00
Kris Nuttycombe e77839232d Generalize note encryption and decryption.
This commit introduces a `Domain` trait which defines the types
and operations that are shared between Sapling and Orchard note
encryption and decryption processes.
2021-04-08 08:19:10 -06:00
Kris Nuttycombe 5baccdf052 Move note_encryption into the sapling module. 2021-04-08 08:19:10 -06:00
Jack Grigg 2f3847638d zcash_primitives: Revert to SproutProof::PHGR
Unlike regular acronyms or abbreviations, this is author initials, which
we've decided to keep capitalised.
2021-04-02 10:39:25 +13:00
Jack Grigg 63db2729e9 Temporarily allow clippy::result_unit_err lint
Fixing these lints is deferred to zcash/librustzcash#367.
2021-03-27 19:01:03 +13:00
Jack Grigg 56b577b31e clippy: Fix small lints 2021-03-27 19:01:03 +13:00
Jack Grigg 564c2714fe clippy: Use Iterator::try_for_each 2021-03-27 19:01:03 +13:00
Jack Grigg 636845d0f9 Renames to use lower-case abbreviations (matching Rust convention)
As of our MSRV bump to 1.51.0, we get lints for this.
2021-03-27 19:01:03 +13:00
Jack Grigg eefc516e26 zcash_primitives: Update changelog for Sapling refactor 2021-03-27 17:10:18 +13:00
Jack Grigg 8ac663f116 Fix some doctests and intra-doc links after moving Sapling primitives 2021-03-27 17:10:18 +13:00
Kris Nuttycombe 33effb7d67 Move sapling keys into sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 4086df772c Move sapling-specific primitives into the sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe abbf5dfd83 Move pedersen hash test vectors into Sapling 2021-03-27 16:18:21 +13:00
Kris Nuttycombe bc087a5ff7 Move pedersen hashes to sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 88d58aac0a Move relevant utils into sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 16948d9d78 Move zcash_primitives::prover to sapling module 2021-03-27 16:18:21 +13:00
Kris Nuttycombe bf97b21632 Move redjubjub to sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe de1345a1c2 Move group_hash to sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe c839193b20 Move TZE components to a separate module & add TzeOutPoint 2021-03-27 15:52:20 +13:00
Kris Nuttycombe 97f2502a5e Factor transparent transaction components into a separate module. 2021-03-27 15:49:17 +13:00
Kris Nuttycombe 96709c6423 Move Sapling transaction components to a separate module. 2021-03-27 15:49:17 +13:00
Kris Nuttycombe 7fcb7bbe99 Factor Sprout transaction elements into a separate module. 2021-03-27 15:49:17 +13:00
Kris Nuttycombe 6e371a8c13 Make Sprout elements crate-public. 2021-03-27 15:49:17 +13:00
Jack Grigg 9d9c0579f8 Use new name for broken_intra_doc_links lint
We also add the lint to crates in the workspace that didn't have it.

Closes zcash/librustzcash#279.
2021-03-27 08:27:17 +13:00
Jack Grigg afa0b29e62 Bump MSRV to 1.51.0
This is the MSRV for the orchard crate, which we will be depending on
soon.
2021-03-27 08:21:45 +13:00
Jack Grigg 725699c76b zcash_primitives 0.5.0 2021-03-26 18:51:35 +13:00
Jack Grigg 675048e52b Fix broken intra-doc links and lints 2021-03-26 10:07:20 +13:00
Jack Grigg 55e73d7910 Fix clippy lints 2021-03-26 10:07:20 +13:00
Kris Nuttycombe c41c71c514
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2021-03-25 15:00:54 -06:00
Kris Nuttycombe ebdd6cf976 Add SaplingIvk newtype to changelogs. 2021-03-24 18:39:21 -06:00
Jack Grigg e122c3d974 Remove reference to ZIP 302 structured memos from changelog
We're removing those from the ZIP draft until they can be agreed upon.
2021-03-23 13:52:22 +13:00
Jack Grigg 46872e2590 Update changelogs with Memo changes 2021-03-18 10:00:27 +13:00
Jack Grigg 8a84203685 Remove Default impl from MemoBytes
Memo fields have two ways to encode an empty memo:

- 0xF6 followed by all-zeroes, encoding "there is no memo".
- All-zeroes, encoding the empty UTF-8 string.

In almost all cases you want the former, but users thinking about byte
slices may expect MemoBytes::default() to result in the latter. To
ensure clarity, we now require calling either MemoBytes::default() or
MemoBytes::from_bytes(&[]) to be explicit.

No such confusion exists for the Memo enum, because the two types are
visibly separated as different enum cases, and Memo::Empty makes sense
as the default.
2021-03-17 21:16:01 +13:00
Jack Grigg c7a3ef0e88 Split memo-handling into MemoBytes struct and Memo enum
The MemoBytes struct is a minimal wrapper around the memo bytes, and only
imposes the existence of null-padding for shorter memos. The only error
case is attempting to construct a memo that is too long. MemoBytes is
guaranteed to be round-trip encodable (modulo null padding).

The Memo enum implements the additional memo rules defined in ZIP 302,
interpreting the contents of a memo (for example, parsing it as text).
2021-03-17 21:05:50 +13:00
Jack Grigg 48f7ef84a4 Move Memo into zcash_primitives::memo 2021-03-17 19:58:40 +13:00
Kris Nuttycombe b5bbbb6f5a Factor out nullifier update from database actions in scan_cached_blocks 2021-03-09 20:59:57 -07:00
Jack Grigg 463e252af4 Fix more intra-doc links 2021-03-04 23:01:42 +00:00
Jack Grigg d221b230c6 Fix intra-doc links 2021-03-04 17:41:08 +00:00
Jack Grigg 464b533937 Bump MSRV to 1.47.0
We'll be needing it shortly for ff et al.
2021-03-04 17:32:57 +00:00
Jack Grigg 8b64c18b0d aes 0.6 2021-03-04 17:04:26 +00:00
Jack Grigg 9463e41cab hex-literal 0.3 2021-03-04 17:01:59 +00:00
Jack Grigg b960cdfd92 secp256k1 0.20 2021-03-04 17:01:59 +00:00
str4d 36e4b0d51a
Merge pull request #329 from nuttycom/ivk_payment_addresses
Introduce SaplingIvk newtype & use IVKs where possible.
2021-03-04 07:04:05 +13:00
str4d 47f3b5f045
Merge pull request #343 from str4d/changelogs-add-unreleased
Add details of unreleased changes to changelogs
2021-02-23 08:57:52 +13:00
Jack Grigg d999463d26 Add temporary workaround for funty breakage 2021-02-22 19:15:37 +00:00
Jack Grigg 1f6f45bbe7 Add details of unreleased changes to changelogs 2021-02-22 16:59:07 +00:00
str4d 9f14c757e6
Merge pull request #340 from str4d/changelogs
Add changelogs to the crates
2021-02-14 02:34:20 +13:00
Kris Nuttycombe b37b5876f2
Merge pull request #318 from nuttycom/tx_version_enum
Add TxVersion enum to make interacting with transaction version values safer.
2021-02-04 12:47:12 -07:00
Kris Nuttycombe 974669a50b Fix clippy lints. 2021-02-04 11:41:29 -07:00
Kris Nuttycombe 796161e9b4
Add suggested comment clarifying future additions to the TxVersion enum
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-02-04 11:22:13 -07:00
Jack Grigg bd3e18984c Changelogs: s/project/library 2021-02-04 15:16:32 +00:00
Jack Grigg b5c7d7f1e7 Add changelogs to the crates
The changelogs are accurate for the 0.4.0 release tag, but don't yet
include changes before or after that tag.
2021-02-04 15:13:22 +00:00
Kris Nuttycombe 1cc7949518 Rename CommitmentTree::new -> CommitmentTree::empty 2021-02-04 07:49:48 -07:00
Kris Nuttycombe 3423b03c6d Fix a couple more lints. 2021-02-04 07:31:00 -07:00
Kris Nuttycombe 98530184c0 Fix clippy complaints. 2021-02-03 14:27:31 -07:00
Kris Nuttycombe 7a57aee530 Introduce SaplingIvk newtype & use IVKs where possible.
This includes making it possible to obtain a payment address from just the IVK + diversifier.
2021-02-02 15:27:13 -07:00
François Garillot 45f3f5a945
Simplify a few pattern matches
A few pattern-matches correspond directly to standard combinators on
`Result`, `Option`. This uses them for concision / clarity.

Refactorings reviewed by the author after suggestion from [comby-rust](https://github.com/huitseeker/comby-rust).
2021-02-01 13:37:54 -05:00
Kris Nuttycombe 937fa06136 Fix randomized tests of zfuture transaction roundtrip. 2021-01-25 16:32:57 -07:00
Kris Nuttycombe 6373e7d053 Raise an error in the case that sprout version < 1.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-01-25 16:32:57 -07:00
Kris Nuttycombe 1dd5a6dbcb Check all transaction versions in has_sprout and uses_groth_proof checks. 2021-01-25 16:32:57 -07:00
Kris Nuttycombe 06cd91059f Enable transaction serialization roundtrip tests outsize zfuture. 2021-01-25 16:32:57 -07:00
Kris Nuttycombe da4cf23668 Add TxVersion enum to make interacting with transaction version values safer.
Co-authored-by: str4d <thestr4d@gmail.com>
2021-01-25 16:32:57 -07:00
Sean Bowe 6315f7dc28
Use wNAF multiplication for Sapling key agreement. 2021-01-22 15:16:06 -07:00
Kris Nuttycombe 8e8ed2bb4f Rename get_verified_balance -> get_balance_at 2021-01-15 12:00:14 -07:00
Kris Nuttycombe c70a9ed81f Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <thestr4d@gmail.com>
2021-01-15 11:57:58 -07:00
Kris Nuttycombe ce06db197a Rustfmt. 2021-01-12 21:10:34 -07:00
Kris Nuttycombe db9eb29eba Merge remote-tracking branch 'upstream/master' into data_access_api 2021-01-12 21:09:40 -07:00
Kris Nuttycombe 7acc75249b Fix documentation of human-readable prefixes. 2021-01-12 20:45:28 -07:00
Kris Nuttycombe 7d92150965 Fix test compilation with WalletWrite changes. 2021-01-11 18:13:40 -07:00
Kris Nuttycombe aad2e174c1 Consistently use nullifier and AccountId newtypes. 2021-01-08 21:49:38 -07:00
Kris Nuttycombe 27d7b6c569 A few doc updates. 2021-01-08 18:08:02 -07:00
Kris Nuttycombe 472dac7a22
Revert intra_doc_link_resolution_failure flag change. 2020-12-17 07:36:18 -07:00
Kris Nuttycombe cf0c3ea90f Relax RngCore type constraints.
The intent of this change is to permit tests to use deterministic
random sources, rather than cryptographically strong ones.
2020-12-14 13:44:05 -07:00
Kris Nuttycombe c24f663e40 Use methods on sigversion to gate ZIP-243 and TZE signature parts. 2020-12-14 14:54:29 +00:00
Kris Nuttycombe 790071953c Use rust feature flagging to allow conditionally enabling TZE-related code.
This also uses the test-dependencies feature flag for conditional
inclusion of proptest-related modules which may be used by
dependent crates for generation of samples in testing.
2020-12-14 14:54:12 +00:00
Daira Hopwood 62675f4b4f Use the SHA-256d HashReader and HashWriter for transaction hashing.
This hashes the transaction as it is read, rather than hashing a re-serialization.

Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-12-03 21:22:58 +00:00
Daira Hopwood 1f18da239f Add HashReader and HashWriter for SHA-256d.
Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-12-03 21:22:58 +00:00
Kris Nuttycombe cf2dae8af0 Add hrp_sapling_extended_spending_key to Parameters trait. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe ee0e059eb3 Add coin_type to consensus parameters. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe a437df191e Initial skeleton of low-level database access API. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 1285ab0af2 Fix tests to account for modified default fees. 2020-11-24 01:24:19 +00:00
Kevin Gorham 53ebc378cc ZIP-313 change default fee amount. 2020-11-24 01:22:14 +00:00
Kris Nuttycombe f40174464a
Use slices as parameters rather than &Vec references.
Co-authored-by: str4d <thestr4d@gmail.com>
2020-11-19 14:49:24 -07:00
Kris Nuttycombe 726f02513d Make the functions which produce the components of the sighash reusable.
When implementing transaction nonmalleability, it will be useful
to have this already done.
2020-11-19 11:25:24 -07:00
Jack Grigg be8bae71be Suppress clippy lints where we want the given behaviour 2020-10-30 14:10:35 +00:00
Jack Grigg 91796adcda Remove wrapping closures around mapping functions 2020-10-30 14:10:35 +00:00
Jack Grigg 025deda712 impl Default for T on types with T::new() 2020-10-30 14:10:35 +00:00
Jack Grigg 44cbc6cc6d Remove unnecessary references 2020-10-30 14:10:35 +00:00