Commit Graph

831 Commits

Author SHA1 Message Date
Jack Grigg 2530eb3a9d Temporarily re-expose Sapling `NoteCommitment` derivation 2023-03-16 23:27:01 +00:00
Jack Grigg a8003c8ff5 Temporarily re-expose ability to construct invalid Sapling bundles
Until zcash/zcash#6397 is closed, this ability is needed by `zcashd` for
crossing the FFI.
2023-03-08 03:45:01 +00:00
Kris Nuttycombe 9c56b21de7 Pin the `inferno` transitive dependency to avoid MSRV errors. 2023-02-16 11:06:24 -07:00
Jack Grigg 9852c31970 zcash_primitives 0.10.0 2023-02-01 02:10:42 +00:00
Jack Grigg 7f970bb82f Use `EphemeralSecretKey, EphemeralPublicKey, SharedSecret` types in APIs 2023-01-24 15:02:49 +00:00
Jack Grigg bc99cd2634 Move prepared key types into `sapling::keys`
We re-export them under `sapling::note_encryption` for now to make the
API changes smaller.
2023-01-24 15:02:43 +00:00
Jack Grigg ded14adbb3 Add `sapling::keys::DiversifiedTransmissionKey` 2023-01-24 15:02:38 +00:00
Jack Grigg 06ba399d80 Clean up the `sapling::Note` API 2023-01-24 15:02:32 +00:00
Jack Grigg 87d0bd7db1 Refactor `sapling::Note`
Its internals are now private, and it stores a `PaymentAddress` (and by
extension the diversifier) instead of `g_d`.
2023-01-24 15:02:27 +00:00
Jack Grigg dff21222fb Require `PaymentAddress` to contain a valid diversifier 2023-01-24 14:51:13 +00:00
Jack Grigg 42c332a7a8 Use `sapling::note::ExtractedNoteCommitment` type in APIs 2023-01-24 14:37:11 +00:00
Jack Grigg 0a26c812e0 Split `sapling::Authorization::Proof` type into Spend and Output types
While the Groth16 proofs have identical encodings, they are technically
for different circuits, and we need the ability to differentiate them
during bundle building.
2023-01-20 11:12:49 +00:00
Kris Nuttycombe 79f3f10714
Merge pull request #760 from zcash/759-msrv-1.60
Bump MSRV for `zcash_primitives` and dependents to 1.60
2023-01-19 19:33:15 -07:00
Jack Grigg 809427f6bd criterion 0.4 2023-01-20 00:03:10 +00:00
Jack Grigg 49b1cb3e69 Bump MSRV for `zcash_primitives` and dependents to 1.60
The MSRVs of the component crates are left as-is, partly because our
dependencies don't require us to bump them, and partly because those
crates have no pending changes and are relatively stable. We also plan
to split the component crates out into a separate repository, where it
will be easier to have a separate MSRV.

Closes zcash/librustzcash#759.
2023-01-19 23:48:24 +00:00
Jack Grigg 19d8e2125e Introduce `sapling::keys::{EphemeralSecretKey, EphemeralPublicKey}` types 2023-01-06 22:42:33 +00:00
Jack Grigg 7fb80d55d6 Introduce `sapling::keys::SharedSecret` type 2023-01-06 22:24:40 +00:00
Jack Grigg 1df49c517e Refactor Sapling key derivation 2023-01-06 22:24:40 +00:00
Jack Grigg 88d46fd6b3 Refactor Sapling note commitment derivation 2023-01-06 22:24:40 +00:00
Jack Grigg 65271b49e5 Refactor Sapling nullifier derivation 2023-01-06 22:24:40 +00:00
Jack Grigg f1d3e03a9b zcash_primitives: Reorganise `sapling` module into submodules
The module structure now matches the `orchard` crate, to make subsequent
refactoring easier. The public API is not altered by this commit.
2023-01-06 22:24:35 +00:00
Kris Nuttycombe 95cbc7abaf
Merge pull request #734 from zcash/sapling-type-safety
Improve Sapling type safety
2023-01-05 13:12:45 -07:00
Jack Grigg 23922ca290 Add Sapling value types
These are modeled after the value types developed for the `orchard`
crate.
2022-12-20 05:16:39 +00:00
Kris Nuttycombe 125d2bc3d5
Merge pull request #727 from nuttycom/test/shield_transparent_funds
Add `shielding_threshold` argument to `shield_transparent_funds`.
2022-12-15 13:11:55 -07:00
Jack Grigg fee0b6a18d Make Sapling transaction structs non-transparent
We instead provide getters for the struct fields.
2022-12-13 04:03:06 +00:00
str4d 51932b7366
Merge pull request #732 from nuttycom/fix/clippy_lints
Fix clippy complaints.
2022-12-10 02:21:54 +00:00
Kris Nuttycombe bbe6280bb0 Fix clippy complaints. 2022-12-09 09:32:34 -07:00
Kris Nuttycombe 0f56f095c2 Add `shielding_threshold` argument to `shield_transparent_funds`.
Previously, the shielding threshold was fixed to 100000 zatoshis.

Fixes #726
2022-12-08 17:15:48 -07:00
Kris Nuttycombe fff6983512 Replace a number of uses of `assert!(matches!(...))` with `assert_matches!(...)`
The remaining uses of `assert!(matches!(...))` are all in cases where
for some reason the `assert_matches` macro interferes with correct
type inference.
2022-12-08 12:17:14 -07:00
Jack Grigg 4435c4789f zcash_primitives 0.9.1 2022-12-06 06:14:28 +00:00
Jack Grigg a1da018f1c zcash_primitives: Count Sapling padding in `Builder::build_zfuture` fees
Closes zcash/librustzcash#709.
2022-12-06 06:13:09 +00:00
Hazel OHearn 08bf711744
We now pad sapling outputs to two with at least one input for fee calculation 2022-11-18 17:30:49 -04:00
Jack Grigg c3b6e5a72a zcash_primitives 0.9.0 2022-11-11 20:37:55 +00:00
Jack Grigg 318d1b7522 Clean up changelogs 2022-11-11 20:29:26 +00:00
str4d 116ed0a3fc
Merge pull request #699 from zcash/wallet/error_display
Add missing `std::fmt::Display` implementations for error types.
2022-11-11 07:26:04 +00:00
str4d 53d56362cd Fix typos in error type `Display` messages 2022-11-11 05:33:48 +00:00
Kris Nuttycombe ed96131c4f Add missing `std::fmt::Display` implementations for error types. 2022-11-10 21:17:57 -07:00
Jack Grigg 69665b9284 Add identity `MapAuth` implementations 2022-11-11 03:38:58 +00:00
Kris Nuttycombe 73ab884073 Implement ZIP 317 fee estimation, calculation, & change selection 2022-11-10 15:30:13 -07:00
Kris Nuttycombe 847ba49761 Add dust note detection to change selection.
The change selection algorithm has the most useful information for
determining whether or not a note is dust, so this adds a new error case
to `ChangeError` that allows the change selection to report the presence
of input notes without economic value back to its caller.
2022-11-10 12:18:30 -07:00
Kris Nuttycombe 9a7dc0db84 Add traits for fee estimation and input selection
This adds a set of abstractions that allow wallets to provide
independent strategies for fee estimation and note selection, and
implementations of these strategies that perform these operations in the
same fashion as the existing `spend` and `shield_transparent_funds`
functions.

This required a somewhat hefty rework of the error handling in
zcash_client_backend. It fixes an issue with the error types whereby
callees needed to have a bit too much information about the error
types produced by their callers.

Reflect the updated note selection and error handling in zcash_client_sqlite.
2022-11-10 12:17:59 -07:00
Kris Nuttycombe 981d45e966 Documentation & changelog fixes. 2022-11-03 19:27:17 -06:00
Kris Nuttycombe cdfca848ea Improve type safety of note commitment tree node construction. 2022-11-03 18:44:48 -06:00
Kris Nuttycombe 1be86b7a54 Derive the correct note when spending from a change address. 2022-11-03 18:44:48 -06:00
Kris Nuttycombe b68d37a0b1 Use DiversifiableFullViewingKey instead of ExtFVK where possible. 2022-11-03 18:44:45 -06:00
str4d d4f4f5ad91
Merge pull request #658 from nuttycom/wallet/builder_explicit_change
Update the transaction builder to make change outputs explicit
2022-11-04 00:42:31 +00:00
Kris Nuttycombe 28db1e324f Update changelog. 2022-11-03 18:14:15 -06:00
Kris Nuttycombe 9c894ebf3e Create per-protocol fees modules. 2022-11-03 15:07:14 -06:00
Kris Nuttycombe c92d81b15d Move the `TzeInput` trait to the `tze::components::builder` module 2022-11-03 09:57:36 -06:00
Kris Nuttycombe 37e78e1fe3 Expose less information about Sapling outputs to change calculation. 2022-11-03 09:56:50 -06:00
Kris Nuttycombe 1be97e9cef Address comments from code review. 2022-11-03 09:56:08 -06:00
Kris Nuttycombe 9496fc6118 Add fee calculator to the transaction builder.
This adds a fee calculation strategy abstraction that can be used to
dynamically compute fees so that the total fees required may be taken
taken into account during note selection, and also removes automatic
change creation from the transaction builder.

Change outputs must now be directly created by the caller by the caller.
This is a necessary prerequisite for permitting fees to adjust based
upon the contents of the transaction being constructed.

The initial implementation of the fee strategy simply uses the current
default fee.
2022-11-02 08:28:16 -06:00
Jack Grigg 3720b45feb Categorise dependencies in `Cargo.toml` files
This should make it easier to upgrade dependencies in future.
2022-11-01 09:02:54 +00:00
Jack Grigg a0016588ac Remove unused dependencies
Some were only used by tests, others weren't used at all.
2022-11-01 09:02:27 +00:00
Kris Nuttycombe 8cb16d878e Require a source transparent address to shield transparent funds.
Previously, `shield_transparent_funds` was only shielding funds
associated with the legacy default transparent address. This meant
that transparent funds sent to unified addresses could not reliably
be shielded, as a unified address will frequently be constructed
using a diversifier index greater than zero.

This modifies the `get_transparent_receivers` method to return address
metadata containing the account ID and diversifier index used to derive
each address along with the receiver.
2022-10-25 12:53:54 -06:00
Kris Nuttycombe 373e69907f
Improve reason for yanking of the 0.8.0 version of `zcash_primitives`.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-10-19 17:53:50 -06:00
Sean Bowe f588d0dbeb
Bump zcash_primitives version to 0.8.1 and yank 0.8.0. 2022-10-19 16:59:53 -06:00
Sean Bowe bd7f9d7c3c
Bump zcash_encoding and zcash_address crate versions to 0.2. 2022-10-19 16:51:59 -06:00
Kris Nuttycombe 5bf36989e2 Fix beta clippy complaints. 2022-10-19 13:35:51 -06:00
Sean Bowe 176e21b015
Update zcash_primitives to orchard 0.3; release zcash_primitives and zcash_proofs 0.8. 2022-10-19 13:32:51 -06:00
Kris Nuttycombe c773ea3b3e Make the internals of `WalletTransparentOutput` private. 2022-10-14 12:38:55 -06:00
Jack Grigg 8f068b3b71 zcash_note_encryption 0.2.0 2022-10-13 21:35:39 +00:00
Jack Grigg 24f7d1c9bc zcash_primitives: Require `group 0.12.1` for `wnaf-memuse` feature flag 2022-10-13 06:19:34 +00:00
Kris Nuttycombe d6484da088 Minor documentation fixes.
Co-authored-by: ying tong <yingtong@z.cash>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-10-05 13:02:21 -06:00
Kris Nuttycombe 60785a1d7a Fix Sapling key organization.
This change moves Sapling-specific key generation into a
submodule of `zip32`. Public reexports are used to keep the
existing API consistent.
2022-10-03 20:28:04 -06:00
Jack Grigg 913aa0a988 zcash_client_backend: Correctly track heap usage of batch items
As of zcash/librustzcash#633, `SaplingDomain::IncomingViewingKey` now
allocates memory internally, and this memory persists as long as the
`BatchRunner` is alive. Now that we have decoupled the measurement of
heap usage for batch tasks from their internals, we can add bounds to
all of the generic parameters of `Batch` to enable correctly measuring
their actual heap usage.

We also add `DynamicUsage` impls for a bunch of `zcash_primitives` types
that will be used with `BatchRunner` (or its equivalent implementation
in `zcashd`) by callers.
2022-09-24 21:01:19 +00:00
Daira Hopwood e53439a236 Update chacha20poly1305 dependency in zcash_primitives to 0.10,
consistent with zcash_note_encryption.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-23 21:52:40 +01:00
Kris Nuttycombe 03c3370de8 Fix problems identified by clippy's beta lints 2022-09-17 08:57:37 -06:00
Kris Nuttycombe 29220c716f Remove `zcash_primitives` as a zcash_note_encryption dev dependency.
This was only used to provide example code for Sapling usage of
the `NoteEncryption` struct; this example code has been moved
to `sapling::note_encryption`.
2022-09-16 12:52:00 -06:00
Daira Hopwood 20e869f501 zcash_primitives: Use prepared epk and ivk in Sapling note decryption
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-15 03:40:45 +01:00
Daira Hopwood d77ed9c6cf Change batch decryption benchmark to cover more cases of (nivks, noutputs).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-15 03:20:14 +01:00
Jack Grigg 8f03208439 zcash_client_backend: Add tags to IVKs in the batch scanner
This removes the dependency on `SaplingIvk::to_repr()`, and enables us
to alter the type of `D::IncomingViewingKey` to improve the performance
of batch scanning.

For the welding rig, we already annotate the viewing keys with
`AccountId`, so we use `(AccountId, Scope)` as the tag.
2022-09-13 21:40:58 +00:00
Kris Nuttycombe a93c9d334e Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-09-10 17:02:43 -06:00
Kris Nuttycombe 7934e834d3 Add test for fee calculation in add_transaction_views migration. 2022-09-10 11:01:36 -06:00
Kris Nuttycombe 95610f7b4f Add fee to the transactions table & compute correct net_value in v_transactions. 2022-09-09 16:12:29 -06:00
Jack Grigg 7112ed9da5 zcash_client_backend: Add `WalletReadTransparent::get_transparent_receivers`
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-09-08 20:24:42 +00:00
Kris Nuttycombe 7b7288c750 (cleanup) Make the internals of `zip32::DiversifierKey` private 2022-09-08 11:17:14 -06:00
Kris Nuttycombe f15a6d8e80 Add `no_std` implementations of Sapling key encoding & decoding. 2022-09-08 11:05:59 -06:00
str4d 980f6b4e6c
Merge pull request #627 from nuttycom/edition_2021
Update to Rust 2021
2022-09-07 11:41:44 +01:00
Kris Nuttycombe d7e2e2f7c1 Remove use of `IntoIterator::into_iter` 2022-09-02 12:05:15 -06:00
Kris Nuttycombe a93f5945ab Remove redundant TryFrom/TryInto imports. 2022-09-02 12:05:15 -06:00
Kris Nuttycombe 16a0e43f2d Update to Rust 2021 and explicitly set MSRVs 2022-09-02 12:05:09 -06:00
Jack Grigg e5dad037e9 zcash_primitives: Make `NullifierDerivingKey` internals public
The `zcashd` Rust code relies on being able to construct the Sapling
types transparently. This part of the "public API" of the crate was
broken when the `NullifierDerivingKey` newtype was introduced. We do
want to migrate to all of these types having stronger type safety
guarantees (by only constructing them via constructors), but that should
be done consistently across the types. For now we maintain the existing
API by changing `NullifierDerivingKey` to be a transparent newtype.
2022-09-02 01:13:20 +00:00
Kris Nuttycombe f5a18b8fa5 Add conversions from u32 and u64 to DiversifierIndex 2022-08-31 17:15:47 -06:00
Kris Nuttycombe ba1bb65a5f Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-08-26 16:09:05 -06:00
Kris Nuttycombe c4da498cf4 Shield funds to the internal Sapling key for a specified account.
This updates `shield_transparent_funds` to look up the internal
(change) address for the account specified, and use that as the
destination for shielding transparent funds.

Fixed #614
2022-08-26 16:03:25 -06:00
Kris Nuttycombe 6156215d4c Add parallelized batched trial decryption to wallet scanning.
Co-authored-by: str4d <jack@electriccoin.co>
2022-08-18 16:48:22 -06:00
Kris Nuttycombe cdfaa57496 Add migrations to support using UFVKs instead of Sapling extfvks.
Fixes #594
2022-08-18 10:15:58 -06:00
Kris Nuttycombe f1c2da7b1d Add sapling::NullifierDerivingKey newtype.
Nullifier computation only requires the nullifier deriving key,
not the entire Sapling viewing key. This separation of concerns
will be needed for batch decryption when wallet-internal keys
will need to be considered.
2022-07-28 15:23:21 -06:00
Kris Nuttycombe 5873950648 Restructure batch decryption to avoid cartesian product of results.
While it is necessary in the worst case to perform `m * n` decryptions,
where `m` is the number of outputs being decrypted and `n` is the number
of IVKs, it is possible to stop performing trial decryptions when the
first successful decryption is performed. Also, it's inconvenient and
unnecessary to return the full cartesian product of these results, as
only one IVK will decrypt a given output. This commit modifies batch
trial decryption to stop on the first successful decryption, and instead
of returning the cartesian product of results we return the index of the
input IVK along with the output it decrypted. Note that this means that
trial decryption is not constant-time with respect to the number and/or
order of IVKs.
2022-07-28 15:23:21 -06:00
Kris Nuttycombe 94c8d8e7ef Return the network type for encoding addresses as part of the network parameters. 2022-06-30 12:09:32 -06:00
Daira Hopwood dae2e008e9
Merge pull request #577 from daira/bosl-notice
Projects that rely on BOSL exceptions should say that they do
2022-06-29 12:59:07 +01:00
Kris Nuttycombe 0142a3db1b
Merge pull request #570 from zcash/387-migrate-from-extfvk-to-ufvk
`zcash_client_*`: Migrate from `ExtendedFullViewingKey` to `UnifiedFullViewingKey`
2022-06-28 10:49:37 -06:00
Daira Hopwood a9aa2929d2 Address feedback about the use of "permissive".
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-06-28 16:46:13 +01:00
Daira Hopwood 75ca854005 Projects that rely on BOSL exceptions should say that they do.
fixes #576

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-06-28 12:29:16 +01:00
Jack Grigg e952ff637e zcash_primitives 0.7.0 2022-06-24 17:00:39 +00:00
Jack Grigg a3cae5d36a equihash 0.2.0 2022-06-24 17:00:26 +00:00
Jack Grigg 59b20c6e31 pprof 0.9 2022-06-24 16:27:06 +00:00
Jack Grigg 18fb1f0b07 orchard 0.2 2022-06-24 16:25:51 +00:00
Jack Grigg 3a3c3863cd zcash_primitives: Update changelog 2022-06-24 16:01:24 +00:00