Commit Graph

69 Commits

Author SHA1 Message Date
Hazel OHearn 8c2326cdac
Error -> BuildError 2022-12-01 16:58:26 -04:00
Hazel OHearn 4f27b6bac3
Add concrete error types for add_spend and add_output 2022-12-01 16:51:04 -04:00
Kris Nuttycombe 33bce9b567
Merge pull request #359 from daira/add-value-balance-to-builder-docfix
Correct the doc comment and add a test for `Builder::value_balance`
2022-10-10 13:36:35 -06:00
Tomas Krnak 5fbbded49e Add `SpendInfo::new` and `Circuit::from_action_context`
Author: Tomas Krnak <tomas@krnak.cz>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-20 18:52:07 +01:00
Daira Hopwood 6458e27185 Add minimal test that `Builder::value_balance` works.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-19 14:05:46 +01:00
Daira Hopwood fbfc8f9ed8 Correct the doc comment for the `Builder::value_balance` method added in #352.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-19 14:05:46 +01:00
Hazel OHearn 8011e0d57a
add value_balance to builder 2022-09-15 16:47:54 -03:00
Jack Grigg e76a91adff Document how to obtain inputs for `Builder::add_spend`
Closes zcash/orchard#244.
2022-06-23 22:51:05 +00:00
Jack Grigg be69324b9c Migrate to `halo2_proofs 0.2.0` 2022-06-23 19:24:57 +00:00
Jack Grigg 6d6832f3f1 Fix clippy lints 2022-05-06 19:33:10 +00:00
Tomas Krnak e47abb8018 Support externally computed signatures
Co-authored-by: str4d <thestr4d@gmail.com>
2022-05-05 18:12:27 +02:00
Jack Grigg 3ca8c662a4 Merge branch 'main' into str4d/circuit-review 2022-05-04 17:09:15 +00:00
Jack Grigg 3ccf27e519 Update `Builder::build` docs
Closes zcash/orchard#279.
2022-05-04 14:57:08 +00:00
Kris Nuttycombe 4e3e469780 Update incrementalmerkletree dependency version. 2022-05-04 08:01:02 -06:00
Jack Grigg 70b6eb3623 Simplify witness synthesis for `v_net`
`NoteValue - NoteValue` is always guaranteed to produce a valid
`ValueSum`, so we make that infallible and introduce a new helper method
`ValueSum::magnitude_sign` that we use for circuit synthesis.
2022-04-29 20:03:17 +00:00
Jack Grigg ae6a50611a Pass `g_d_new` and `pk_d_new` directly to `Circuit`
The initial Action circuit specification indicated that only the byte
encodings of `g_d_new` and `pk_d_new` would be witnessed, but we ended
up witnessing the points directly instead. This commit removes the
leftover (and now redundant) encoding-decoding round trip.
2022-04-29 18:04:01 +00:00
Jack Grigg 200c366ea4 Rename `Bundle::{try_}authorize` to `Bundle::{try_}map_authorization`
Closes zcash/orchard#71.
2022-04-29 00:16:16 +00:00
Jack Grigg 5c5c999439 Move `orchard::bundle::Action` to its own module
The `Bundle` struct is variable in size and requires allocations, but
`Action` is not. This split will make it cleaner to disable the bundle
logic for no-std support.
2022-04-28 22:59:07 +00:00
Jack Grigg b1ce38405a Use `core` instead of `std` where possible 2022-04-28 20:20:23 +00:00
Jack Grigg 4574d4793a Migrate to 2021 edition 2022-04-28 17:23:30 +00:00
Jack Grigg 06995064d7 incrementalmerkletree 0.3.0-beta.2 2022-04-06 18:19:39 +00:00
therealyingtong a0424984c6 Add explicit scoping for viewing keys and addresses
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-03-30 20:49:37 +08:00
Jack Grigg eb7a9668aa Merge branch 'non-consensus-changes-on-branchid-c4cd541e' into merge-non-consensus-changes-2 2022-02-28 20:46:55 +00:00
Jack Grigg def4d4d9ae Add missing `Debug` trait bounds for `Builder` components
All relevant types have `Debug` impls, but some of the trait and method
impls were lacking `Debug` bounds on their generic types. This prevented
`Debug` impls being used on the overall partially-constructed `Bundle`
types.
2022-02-28 20:09:30 +00:00
Kris Nuttycombe 273662c00b
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-02-24 09:16:39 -07:00
Kris Nuttycombe 1cf828fe7b Update the incremental merkle tree version and the Rust toolchain.
Use derived equality and ordering (which delegate to constant-time
versions) for note::nullifier::Nullifier and tree::MerkleHashOrchard
so that these types can be used as map keys in wallets.
2022-02-23 20:43:02 -07:00
Jack Grigg 17ad25ee35 Merge branch 'non-consensus-changes-on-branchid-c4cd541e' into merge-non-consensus-changes 2022-02-15 22:46:47 +00:00
Daira Hopwood e92d1167af The address used to derive g_d_old and pk_d_old is the recipient address of the note being spent. 2022-02-15 14:39:32 -07:00
Kris Nuttycombe 5d5e289197 Remove default_diversifier and default_address methods. 2022-02-15 14:39:32 -07:00
str4d 4ae32ef98a
Merge pull request #282 from zcash/clone-unauthorized-bundle
Add `Clone` impls to various structs
2022-02-12 03:23:11 +00:00
Jack Grigg c4cd541e6c Add `Clone` impls to various structs
This enables `InProgress<Unproven, Unauthorized>: Clone`, which allows
the bundle returned by `Builder::build` to be cloned. In pure-Rust
wallets this should not be necessary, but it is required for `zcashd`
due to FFI-crossing.
2022-02-12 02:04:52 +00:00
Jack Grigg ce301a6aa3 Shuffle spends and recipients before pairing them into Actions
Callers cannot assume that any specific output corresponds to a specific
Orchard recipient, and must trial-decrypt all outputs to find the ones
belonging to them. This is consistent with higher-layer semantics like
having Unified Addresses as recipients (where the mapping from recipient
to a specific output would become much more complex).

Closes zcash/orchard#203.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-02-07 22:37:37 +00:00
therealyingtong f74cb9e4d3 Delete gadgets and their primitives; add `halo2_gadgets` dependency. 2022-01-29 01:57:01 +08:00
therealyingtong 5b26c7d67a Pass rng to create_proof API.
As of halo2#444, all APIs now take `R: RngCore` arguments instead of
internally depending on `rand::rngs::OsRng`.
2022-01-05 21:30:45 +08:00
Jack Grigg 369b99ee3f Add `doc_cfg` annotations 2021-12-17 22:08:58 +00:00
therealyingtong 1f2132a8c0 Use correct MERKLE_DEPTH_ORCHARD in proptests.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2021-09-16 21:37:59 +02:00
therealyingtong d47c157ae0 Replace arb_tree proptest with incrementalmerkletree impl. 2021-09-16 20:50:27 +02:00
therealyingtong c3e24794f0 zip32.rs: master and child key derivation for ExtendedSpendingKey 2021-08-31 15:49:32 -06:00
Jack Grigg 9117273c08 Fix bug in `Builder` initialization of `Circuit` struct
`rcv` was being used correctly outside the circuit to derive `cv_net`
but then `Circuit` was just storing 0. The `round_trip` test passed
because it uses `rcv = 0` everywhere.
2021-07-28 22:51:43 +01:00
Jack Grigg 513f3cf8a6 Make `Builder::build` public 2021-07-28 14:37:12 +01:00
Jack Grigg 01fbd59683 Move proof creation out of `Builder::build` 2021-07-28 14:37:12 +01:00
Jack Grigg 6b495f711a Extract InProgress type from Unauthorized and PartiallyAuthorized
This enables bundle proofs and signatures to be handled separately
outside the builder.
2021-07-28 13:48:03 +01:00
therealyingtong 8cf7a6872c Minor refactors, text fixes, and docfixes.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-23 00:15:54 +08:00
therealyingtong 07770a0be0 builder.rs: Update ActionInfo::build() to fill in Circuit fields. 2021-07-21 20:35:43 +08:00
therealyingtong bdf2d6d9f8 circuit.rs: Define Circuit fields, impl Default for Circuit
The Default Circuit sets all fields to None. This is used as a
placeholder in src/builder.rs.

The circuit in the Circuit::round_trip() test has been filled in.
2021-07-21 20:35:43 +08:00
Kris Nuttycombe 78adc9c810 Anchor computation is partial. 2021-06-24 09:43:10 -06:00
Daira Hopwood 1c19bea842 Fix clippy lints.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-06-16 19:13:40 +01:00
Jack Grigg de78186503 Store anchors as pallas::Base instead of [u8; 32]
This matches what we store in `MerklePath`, and better enforces the
required type.
2021-06-12 21:35:37 +01:00
Jack Grigg 57f84c3eea builder: Encrypt output notes 2021-06-11 23:55:17 +01:00
str4d 0ead91a88c
Merge pull request #110 from zcash/tree-logic
Implement tree logic in Builder
2021-06-11 21:39:40 +01:00