Commit Graph

1009 Commits

Author SHA1 Message Date
Andrew Arnott 1733af8718
Declare `NonHardenedChildIndex` struct 2024-02-10 12:46:46 -07:00
Kris Nuttycombe 2360609f1a zcash_primitives: Rename `TransparentAddress` variants.
This resolves an old TODO.
2024-02-02 10:52:17 -07:00
str4d dca890adcd
Merge pull request #1102 from zcash/doc-improvements
Various documentation improvements
2024-01-25 21:02:01 +00:00
str4d 4873e2586f
zcash_primitives: Adjust doc comment on `BlockHash`
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2024-01-25 19:17:21 +00:00
str4d 3a0b634101
Merge pull request #1103 from nerdcash/docFixes
Doc improvements
2024-01-23 16:19:50 +00:00
Kris Nuttycombe 28e36dc57b
Merge pull request #1054 from pacu/regtest-support
Add regtest support to `Parameter` for Mobile SDKs
2024-01-19 12:09:09 -07:00
Andrew Arnott 296e770ec8
Update zcash_primitives/src/transaction/fees/zip317.rs
Co-authored-by: str4d <thestr4d@gmail.com>
2024-01-18 17:48:56 -07:00
Kris Nuttycombe 09bbc79669 Fix rustfmt 2024-01-18 14:58:04 -07:00
Andrew Arnott aabee02247
Doc improvements 2024-01-17 21:33:12 -07:00
Daira Emma Hopwood 76f92268c3 Remove notices about the BOSL license exception, which are no longer needed.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2024-01-17 23:28:15 +00:00
Francisco Gindre 17f074d460
PR Suggestion by @nuttycom: remove the `FullNodeParameters` enum 2024-01-17 18:55:21 -03:00
Francisco Gindre 529fd3d562
Add Regtest variant of `Network` and Parameter
closes #1051

Also:
Adds encoding tests + cargo fmt
Adds tests on ZIP-321
Adds coverage on new code
Supports nu6 activation
`local-consensus` feature is disabled by default
2024-01-17 18:21:06 -03:00
Jack Grigg 3206255b8a Various documentation improvements 2024-01-16 22:30:05 +00:00
Kris Nuttycombe cc39bf4429 zcash_primitives: Add Orchard bundle metadata to transaction builder. 2024-01-16 13:19:24 -07:00
Kris Nuttycombe 24ebe4c643 Address comments from code review.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2024-01-05 17:00:46 -07:00
Kris Nuttycombe 56f2ac573c zcash_client_backend: Add Orchard support to change strategies.
This modifies the `compute_balance` method to operate in a
bundle-oriented fashion, which simplifies the API and makes it easier to
elide Orchard functionality in the case that the `orchard` feature is
not enabled.
2024-01-05 16:59:54 -07:00
Kris Nuttycombe 5126fd6b5f
Merge pull request #1086 from zcash/docs-rs-feature-flags
Show feature flags in documentation
2024-01-04 14:34:40 -07:00
Jack Grigg 3989ee9926 Show feature flags in documentation
This can be rendered locally with:
    RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --no-deps --workspace --all-features
2024-01-04 19:07:22 +00:00
Kris Nuttycombe f18d082aa3 zcash_client_backend: Introduce an "orchard-client" feature flag.
We plan to also introduce a similar flag to gate access to Sapling
functionality. Since introduction of Orchard functionality is still
nascent, it's the correct time to introduce this isolation, before
there's more functionality that needs to be isolated in this fashion.
2024-01-03 17:05:20 -07:00
Jack Grigg 2ea83243a7 Document the feature flags 2024-01-03 20:15:21 +00:00
Jack Grigg 0df4c6f043 Remove implicit feature flags for optional dependencies
All optional dependencies are enabled as part of dedicated feature
flags.
2024-01-03 20:15:21 +00:00
Jack Grigg b7bba9bbb2 zcash_primitives: Remove `keys` module 2024-01-03 17:29:59 +00:00
Kris Nuttycombe 704e8e1144 zcash_primitives: Updates to reflect `sapling-crypto` and `orchard` builder changes. 2024-01-02 13:00:11 -07:00
Kris Nuttycombe d74f635d9d zcash_client_backend: Factor out common single-output change strategy logic. 2023-12-14 12:55:34 -07:00
Jack Grigg 35ea2ff38b zcash_primitives: Remove `sapling-crypto` re-export and update changelog 2023-12-12 19:50:26 +00:00
Jack Grigg b6907b14e6 Use `sapling-crypto` crate directly outside `zcash_primitives` 2023-12-12 19:50:26 +00:00
Jack Grigg bf984ff38d zcash_primitives: Remove benchmarks that were moved to `sapling-crypto` 2023-12-12 18:45:32 +00:00
Jack Grigg 6acc64e61c Move `zcash_primitives::sapling` module into `sapling-crypto` 2023-12-11 17:07:45 +00:00
Jack Grigg b6ee98ed46 zcash_primitives: Add `ProverProgress` trait to `sapling::builder`
This breaks the link between the concrete `Sender<Progress>` channel
used by the main builder in `zcash_primitives`, and the proof creation
APIs in what will become the `sapling-crypto` crate.

Part of zcash/librustzcash#1044.
2023-12-11 16:37:53 +00:00
str4d ecd5402266
Merge pull request #1061 from zcash/1044-sapling-prf-expand
zcash_primitives: Introduce type-safe `PRF^expand`
2023-12-07 18:03:37 +00:00
Jack Grigg ce7b7df0cc zcash_primitives: Switch to type-safe `PRF^expand`
Part of zcash/librustzcash#1044.
2023-12-07 17:09:44 +00:00
Kris Nuttycombe 4eaa41affa zcash_primitives: Remove and relocate `InputView` traits. 2023-12-06 20:17:43 -07:00
Jack Grigg d332aacf98 Merge branch 'main' into 1044-extract-zip32 2023-12-06 18:04:36 +00:00
Jack Grigg 3dfd478141 Migrate to published `zip32` crate outside this repository 2023-12-06 18:04:09 +00:00
Jack Grigg 5aa0e6c6ee Revert "Convert zip32 crate into a module of zcash_primitives"
This reverts commit f25a8a557e.
2023-12-05 18:07:53 +00:00
Kris Nuttycombe 8c1480304e zcash_client_backend: Wrap entire Sapling note in `SaplingReceivedNote` 2023-12-05 10:49:35 -07:00
Jack Grigg 54e8dd35c1 zcash_primitives: Remove old Sapling re-exports from `zip32` module 2023-12-05 17:31:17 +00:00
str4d fb424364ce
Merge pull request #1057 from nuttycom/wallet/orchard_balance
Expose Orchard value in balance API & add Orchard components to ScannedBlock
2023-12-05 17:01:10 +00:00
Kris Nuttycombe 214a3750c5 zcash_client_backend: Make `Balance` and `AccountBalance` fields private.
Public methods for mutation of these fields have been provided that
perform checking for overflow of the valid monetary range as part
of their operation.
2023-12-04 13:53:27 -07:00
Jack Grigg 906e203663 zcash_primitives: Move Sapling `HashSer` impl into `merkle_tree` module
The `HashSer` trait will remain in `zcash_primitives` while the Sapling
type it is implemented for moves to `sapling-crypto`.

Part of zcash/librustzcash#1044.
2023-12-04 20:26:00 +00:00
Jack Grigg 8acc03783e zcash_primitives: Refactor `sapling::tree::Node` around `jubjub::Base` 2023-12-04 20:24:24 +00:00
Daira Emma Hopwood acf146248e
Merge pull request #1056 from zcash/581-use-redjubjub-crate
zcash_primitives: Replace `sapling::redjubjub` with `redjubjub` crate
2023-12-04 18:27:32 +00:00
Tomek Piotrowski 22ad737267
zcash_primitives: Add Network Upgrade 6 to `consensus::NetworkUpgrade` (#1048)
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-12-04 14:41:41 +00:00
Jack Grigg ded09f99b5 zcash_primitives: Add RedJubjub test vectors 2023-12-01 14:22:49 +00:00
Jack Grigg 5ccba3e1af zcash_primitives: Introduce newtypes for `ask` and `ak`
The Sapling key components specification places more constraints on the
values of `ask` and `ak` than general RedJubjub signing and verification
keys.
2023-12-01 11:19:31 +00:00
Jack Grigg de1ed21051 zcash_primitives: Replace `sapling::redjubjub` with `redjubjub` crate
As a side-effect, we remove the ability to verify individual
transactions with pre-ZIP 216 rules (which we already removed from
`zcashd` consensus nodes in zcash/zcash#6000 and zcash/zcash#6399, as
all pre-ZIP 216 transactions on mainnet are also valid under ZIP 216).
2023-11-30 17:52:31 +00:00
Kris Nuttycombe 1e5d253c9c Fix dependencies to repair `cargo -p` subproject builds. 2023-11-29 12:37:18 -07:00
Kris Nuttycombe 7f3d057a1b zcash_primitives: Avoid passing duplicate diversifier information to Sapling builder.
The note provided to `add_sapling_spend` contains the recipient address,
and we can extract the diversifier from this address, so we should not
pass it separately.
2023-11-28 10:54:06 -07:00
Jack Grigg 0d06e561bb Update Sapling imports to migrate off re-exports at old paths 2023-11-28 03:40:41 +00:00
Jack Grigg 54fa31e00c zcash_primitives: Separate `GROTH_PROOF_SIZE` constant for `sapling` module 2023-11-28 03:25:14 +00:00
Jack Grigg 106f5a353a Remove `MemoBytes` usage from `zcash_primitives::sapling` 2023-11-28 03:25:14 +00:00
Jack Grigg 7064efe697 zcash_primitives: Improve ZIP 32 comments 2023-11-28 01:38:53 +00:00
Jack Grigg f7726141c3 zcash_primitives: Reject non-canonical ZIP 32 Sapling master key encodings 2023-11-28 01:38:53 +00:00
Jack Grigg 7badba29ea zcash_primitives: Move `zip32::sapling` to `sapling::zip32` 2023-11-28 01:38:53 +00:00
Jack Grigg 45ef8b1604 zcash_primitives: Add constructor and getter to `zip32::ChainCode` 2023-11-28 01:38:53 +00:00
Jack Grigg 61bb18d97f zcash_primitives: Refactor `zip32::ChildIndex` to be an opaque struct 2023-11-28 01:38:53 +00:00
Jack Grigg a9310e3969 zcash_primitives: Remove non-hardened Sapling ZIP 32 derivation 2023-11-28 01:34:31 +00:00
Jack Grigg cdd20e8583 zcash_primitives: Make `value_balance` generic in `sapling::Bundle`
This removes the dependency on `Amount`, and matches how we handle this
in the `orchard` crate.

Part of zcash/librustzcash#1044.
2023-11-23 07:08:13 +00:00
Jack Grigg eb0b5a1b24 zcash_primitives: Remove `consensus::Parameters` from `sapling` module
Part of zcash/librustzcash#1044.
2023-11-22 04:29:36 +00:00
Kris Nuttycombe 236cd569ee
Merge pull request #891 from nuttycom/proposal-ffi
Add protobuf representation for transaction proposals
2023-11-15 15:47:46 -07:00
Daira Emma Hopwood e32cf8b5ac Use `{ENC,OUT}_CIPHERTEXT_SIZE` constants in `zcash_primitives::transaction::components::sapling`.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-11-10 20:38:50 +00:00
Daira Emma Hopwood e5bdc72b52 Use `{ENC,OUT}_CIPHERTEXT_SIZE` constants in `zcash_primitives::sapling::bundle`.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-11-10 20:30:31 +00:00
Kris Nuttycombe 33169719ce zcash_client_backend: Add serialization & parsing for protobuf Proposal representation. 2023-11-09 20:07:16 -07:00
Jack Grigg c6dd9ad858 zcash_primitives: Expose Sapling bundle component parsers needed by zcashd
These can be removed after future zcashd refactors.
2023-11-10 02:09:22 +00:00
Jack Grigg 68ae453e5d zcash_primitives: Move Sapling bundle parsing into `transaction::components::sapling` 2023-11-10 02:09:22 +00:00
Jack Grigg e1a5539094 zcash_primitives: Rework Sapling parsers to be plain functions
Once `zcash_primitives::sapling` is extracted to `sapling-crypto`, these
would have become orphan impls.
2023-11-10 01:06:18 +00:00
Jack Grigg 54eb03e34e zcash_primitives: Move Sapling bundle types into `sapling` module 2023-11-09 04:04:07 +00:00
Jack Grigg f5595122f9 zcash_primitives: Move `builder` module to `zcash_primitives::sapling` 2023-11-09 04:02:19 +00:00
str4d 64d657ed31
Merge pull request #1033 from zcash/sapling-params-refactor
Introduce newtypes for Sapling circuit parameters
2023-11-08 21:01:30 +00:00
str4d e4b9d73d0c
Merge pull request #1003 from nuttycom/wallet/reusable_input_selection
zcash_client_backend: Factor out `InputSource` from `WalletRead`
2023-11-08 20:20:03 +00:00
Kris Nuttycombe aa063ae3fd zcash_client_backend: Factor out input source traits from `WalletRead`
Prior to this change, it's necessary to implement the entirety of the
`WalletRead` trait in order to be able to use the input selection
functionality provided by `zcash_client_backend::data_api::input_selection`.
This change factors out the minimal operations required for transaction
proposal construction to better reflect the principle of least authority
and make the input selection code reusable in more contexts.

In order to minimize the operations of the newly-created `InputSource`
and `ShieldingSource` traits, this change also removes the
`min_confirmations` field from transaction proposals, in favor of
storing explicit target and anchor heights. This has the effect of
limiting the lifetime of transaction proposals to `PRUNING_DEPTH -
min_confirmations` blocks.
2023-11-08 12:41:49 -07:00
Jack Grigg 82535112c2 zcash_primitives: Add Sapling verification key newtypes 2023-11-07 03:11:15 +00:00
Jack Grigg 1b9f26c984 Move `{Spend,Output}Parameters` from `zcash_proofs` to `zcash_primitives` 2023-11-07 03:09:25 +00:00
Jack Grigg 8bb9c4e7ba Move Sapling proof verifiers from `zcash_proofs` to `zcash_primitives` 2023-11-07 03:08:43 +00:00
Jack Grigg 3b8c932ab9 zcash_primitives: Implement `Clone` on bundle marker types
This enables unauthorized Sapling bundles to be cloned, for example when
loading them into a `TransactionData` for signature hashing.
2023-11-04 04:27:07 +00:00
Jack Grigg b20641ae58 zcash_primitives: Remove `sapling::prover::TxProver`
Removed
-------
- `zcash_primitives::sapling`:
  - `prover::TxProver` (use `SpendProver` and `OutputProver` instead).
  - `prover::mock::MockTxProver` (use `MockSpendProver` and `MockOutputProver`
    instead).
2023-11-03 21:08:37 +00:00
Jack Grigg a77b6c631c Add missing unreleased changelog entries 2023-11-03 00:56:56 +00:00
Jack Grigg bed5bc6cf6 Clean up unreleased changelog entries 2023-11-03 00:56:26 +00:00
Jack Grigg b2ff29db78 Refactor Sapling builder to separate out proof generation
Closes zcash/librustzcash#741.
2023-10-31 22:01:34 +00:00
Kris Nuttycombe 570ea48588 Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-10-26 15:24:45 -06:00
Kris Nuttycombe cc0cc2de84 zcash_primitives: add StandardFeeRule
`StandardFeeRule` is an enumeration of the standard fees that have
existed in the history of Zcash zips. It is provided to simplify
transition to new fee strategies; legacy elements of this enumeration
are introduced already-deprecated.
2023-10-25 08:08:49 -06:00
Kris Nuttycombe caee90dce9 `zcash_primitives`: Use sapling::NoteValue instead of bare u64 2023-10-24 16:36:56 -06:00
Kris Nuttycombe 9cd60c536e Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-10-24 13:11:35 -06:00
Kris Nuttycombe f7527e14c9 Use `NonNegativeAmount` for note and utxo value fields 2023-10-23 12:59:26 -06:00
Kris Nuttycombe a2b5c2c784 zcash_client_backend: Use `NonNegativeAmount` for fee and change amounts.
In order to use `uint64` for amounts that must be nonnegative in the
`proposal.proto` file, it is useful to update fee and change computation
to use `NonNegativeAmount` where possible.
2023-10-10 16:12:47 -06:00
Kris Nuttycombe 030c1825a8
Merge pull request #1011 from nuttycom/wallet/note_identifiers
Make `ReceivedSaplingNote` internals private, and use (TxId, output_index) for note identifiers.
2023-10-10 07:30:33 -06:00
zancas 4bd3259ad0
Add a MARGINAL_FEE constant for the ZIP 317 marginal fee 2023-10-09 15:23:55 -06:00
sasha 74840829c8 zcash_client_backend: Make `ReceivedSaplingNote` internals private.
This also adds the txid and index to `ReceivedSaplingNote` for use as a
globally identifier for the note.
2023-10-09 12:22:12 -06:00
Jack Grigg e1a4238a71 zcash_primitives: Add helper impls of `{Try}MapAuth` for closures 2023-10-06 23:48:27 +00:00
Jack Grigg 65efee1a16 zcash_primitives: Add `sapling::Bundle::try_map_authorization` 2023-10-06 23:46:02 +00:00
Jack Grigg b09b435135 zcash_primitives: Change `sapling::MapAuth` to take `&mut self` 2023-10-06 23:43:43 +00:00
Jack Grigg 241a1a3660 zcash_primitives: Add some more `Clone` and `Debug` impls 2023-10-06 22:05:49 +00:00
Jack Grigg 04aa5a044b zcash_primitives: Add `MockSpendProver` and `MockOutputProver`
These are analogues of `MockTxProver` in that they implement the
corresponding Sapling prover traits.
2023-10-06 20:31:31 +00:00
Jack Grigg 296f75954b Add `SpendProver::encode_proof` and `OutputProver::encode_proof` 2023-10-06 20:19:41 +00:00
Kris Nuttycombe e6fa567332
Merge pull request #1000 from zingolabs/add_debugs_to_inputs
add Debug to transaction builder-reported types
2023-10-04 09:15:29 -06:00
Kris Nuttycombe b73c51f974
Merge pull request #1004 from zingolabs/add_fee_getter
Add fee getter
2023-10-03 12:04:29 -06:00
zancas b9f8ec8ed2
add pub getter to transaction builder
use getter in original context to DRY

add doc-comment

Minor cleanup & documentation fixes.

Co-Authored-By: Daira Emma Hopwood <daira@jacaranda.org>
2023-10-03 11:13:06 -06:00
Jack Grigg 0d46fe72cc zcash_primitives: Introduce an `OutputProver` trait 2023-10-02 16:59:01 +00:00
Jack Grigg 290bfa8b31 zcash_primitives: Introduce a `SpendProver` trait 2023-10-02 16:59:01 +00:00
zancas b5e24751d6
add Debug to transaction builder-reported types 2023-09-29 12:55:06 -06:00