Commit Graph

154 Commits

Author SHA1 Message Date
Kris Nuttycombe 6fbcba641d Fix a bug in initialization of the Orchard wallet after NU5 activation.
When initializing a new Orchard wallet after NU5 activation, it is
not valid to start from the empty note commitment tree; instead,
the note commitment tree needs to be initialized from the state of
the global Orchard Merkle frontier.

In addition, this change necessitates a change to how rewinds work,
such that in a rollback scenario with a newly initialized wallet
that does not have sufficient checkpoints to fully satisfy a requested
rewind, the rewind is allowed to proceed so long as it does not
invalidate any persisted witness data.
2022-04-04 13:05:42 -06:00
Kris Nuttycombe a852eb223b Update incrementalmerkletree version to fix GC bug & use updated API.
This also modifies the serialized form of the wallet's incremental
merkle tree. This will require a complete reindex for testnet wallets.
2022-03-31 10:52:48 -06:00
therealyingtong bc33ba5a9f Update FFI to use scoped APIs for viewing keys and addresses 2022-03-30 08:30:27 -06:00
Jack Grigg 9e9f58b26f Merge branch 'master' into unify-nu5-consensus-changes 2022-03-23 02:57:16 +00:00
Jack Grigg 77a971fbc1 Migrate to latest `zcash/librustzcash` revision
This includes:
- `orchard =0.1.0-beta.3` which includes the final circuit changes.
- The new NU5 consensus branch ID.
- Updated ZIP 244 test vectors (which use the NU5 consensus branch ID).
2022-03-23 02:05:06 +00:00
Jack Grigg e646905f1b cargo update 2022-03-22 19:34:29 +00:00
Kris Nuttycombe 315392ce3b Add OrchardWallet::GetTxActions
This method detects and returns metadata for any notes belonging to the
wallet that are spent in the transaction. It also trial-decrypts the
Orchard outputs of a transaction using the wallet's incoming viewing
keys along a set of OVKs provided by the caller, and returns metadata
about the notes that were successfully decrypted.
2022-03-18 08:03:16 -06:00
Kris Nuttycombe 80324bc653 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard-merge_master 2022-03-17 16:52:49 -06:00
Kris Nuttycombe 4eda33f184 Serialize the Orchard note commitment tree to the wallet.
This adds serialization of Orchard note commitment trees
to `SetBestChain` and deserialization and loading of those
trees to wallet load.
2022-03-11 22:47:37 -07:00
Daira Hopwood 999b395360 Improve memory hygiene, and use -stdin to pass the recovery phrase to the child zcash-cli process.
Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-10 17:17:06 +00:00
Kris Nuttycombe 8bf99eaacc Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard-merge_master 2022-03-09 22:17:49 -07:00
Kris Nuttycombe 237384cf2b Update incrementalmerkletree version 2022-03-07 18:32:58 -07:00
Daira Hopwood 6f5efcbb0f Improved error handling.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-07 18:39:23 +00:00
Daira Hopwood a36fceca70 Make a zcashd-wallet-tool executable.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-07 18:39:23 +00:00
Jack Grigg 7b7dddba0c cargo update 2022-03-01 00:34:02 +00:00
Jack Grigg 9f5f36e94c Migrate to `orchard` crate revision with circuit changes
Part of zcash/zcash#5385.
2022-02-28 23:52:49 +00:00
Kris Nuttycombe 258f0fc72f Add Orchard components to unified full viewing keys
Co-authored-by: Jack Grigg <jack@z.cash>
2022-02-22 21:08:10 +00:00
Kris Nuttycombe 6587b2ed86 Add Rust backend for Orchard components of the wallet.
Co-authored-by: str4d <thestr4d@gmail.com>
2022-02-17 17:50:17 -07:00
Jack Grigg 96d6ee0b8f Update ZIP 244 implementation
This brings in the changes that align the transparent parts of ZIP 244
with BIP 341.
2022-02-16 03:29:42 +00:00
Jack Grigg 2da0856e6f Add Orchard recipient support to the transaction builder
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-02-15 23:28:55 +00:00
Kris Nuttycombe 6c9b9a53b5 Update librustzcash dependency. 2022-02-02 17:40:36 -07:00
Kris Nuttycombe bdcb12e445 Add a first-class type for transparent full viewing keys. 2022-01-27 21:27:43 -07:00
Kris Nuttycombe c21ffff790 Add correct selection of change addresses to z_sendmany
This also alters `TransactionBuilder::SendChangeTo` to take a
`libzcash::ChangeAddress` value and thus avoids the invalid
t-addr case of CTxDestination.
2022-01-27 21:27:43 -07:00
Jack Grigg 714f14168c rust: Add missing checks for transparent UFVK items 2022-01-18 21:32:33 +00:00
Kris Nuttycombe fe777c5624 Fix encoding order of unified addresses. 2022-01-05 18:30:06 -07:00
Kris Nuttycombe 98967e2ec7 Merge remote-tracking branch 'upstream/master' into feature/wallet_unified_addresses 2022-01-05 18:20:31 -07:00
Jack Grigg d85bfb4744 Migrate to latest revisions of Zcash Rust crates 2021-12-18 01:44:27 +00:00
Jack Grigg e257844261 cargo update
In the three days since the last update, `futures 0.3.18` was yanked due
to panics: https://github.com/rust-lang/futures-rs/issues/2529
2021-12-16 16:55:11 +00:00
Kris Nuttycombe 640f31463f Update to ufvk zcash_address build. 2021-12-13 18:51:15 -07:00
Jack Grigg df0534e35a cargo update
Thanks to metrics-rs/metrics#231 being merged, our dependency tree is
now almost entirely de-duplicated!
2021-12-13 21:27:02 +00:00
Kris Nuttycombe e7c507cfb3 Update orchard & librustzcash dependency versions. 2021-11-29 13:05:54 -07:00
Jack Grigg 6c0bd90ee6 ed25519-zebra 3 2021-11-29 20:01:57 +00:00
Jack Grigg 5ae516f7b0 cargo update 2021-11-29 19:56:48 +00:00
Kris Nuttycombe 59a4c84112 Adds Orchard Address, IncomingViewingKey, FullViewingKey, and SpendingKey types. 2021-11-24 19:08:17 -07:00
Kris Nuttycombe 13b9a69230
Merge pull request #5306 from nuttycom/feature/mnemonic_seeds
Adds HD seed derivation from ZIP-339 mnemonic phrases.

This replaces random generation of transparent spending keys with BIP-44-compatible derivation from a mnemonic seed phrase, and replaces the random HD seed previously used for Sapling HD key derivation
with the same mnemonic seed. After this change, all new transparent and Sapling addresses
will be derived from a new randomly generated mnemonic seed, which is produced in such a way that 
it is guaranteed to produce valid unified spending keys at account 0 for all address types.

Closes #5176.
Closes #2673.
2021-11-18 17:52:36 -07:00
Jack Grigg ca7160ebab tracing-subscriber 0.3 2021-11-06 21:06:30 +00:00
Jack Grigg 2005c91d41 cargo update 2021-11-06 21:06:30 +00:00
Kris Nuttycombe 67557df165 Use SecureString for mnemonic phrase. 2021-10-30 08:26:59 -06:00
Kris Nuttycombe ebab190fdf Replace account ID with ZIP-0032 key path in listaddresses output.
Account ID information is insufficiently granular to identify separate
pools of spend authority.
2021-10-20 13:33:47 -06:00
Kris Nuttycombe daf443c9e6 Update librustzcash dependency version. 2021-10-19 11:48:02 -06:00
Kris Nuttycombe 8883ae8b9e Add support for externally searching for valid Sapling diversifiers.
In order to support generation of unified addresses, it needs
to be possible for the code generating a unified address to search
the space of Sapling diversifiers to obtain a valid diversifier.

Historically, invalid diviersifiers were simply skipped, so we retain
this behavior when obtaining a Sapling address from the legacy HD seed.
2021-10-19 11:48:02 -06:00
Jack Grigg 8f0f8b6687 cargo update 2021-10-08 16:53:00 +00:00
Jack Grigg 6e90c84be7 Fix bugs in testnet Orchard circuit
The consensus branch ID is updated (as the NU5 consensus rules are
altered). The testnet NU5 activation height is also reset.
2021-09-28 22:56:37 +01:00
Jack Grigg 00724c9f5a Update halo2 and orchard dependencies with BOSL Zcash exception 2021-09-22 23:10:57 +01:00
Jack Grigg 660e938499 cargo update
Includes pasta_curves 0.2.1, which relicenses to MIT OR Apache-2.0.
2021-09-22 22:51:26 +01:00
Jack Grigg d087c8b089 cargo update 2021-09-17 13:52:09 +01:00
Jack Grigg 2aa9f766b2 Migrate to latest revisions of orchard and the zcash_* crates 2021-09-17 03:56:32 +01:00
Jack Grigg 710a5f8a9e Migrate to latest revisions of Zcash Rust crates 2021-09-15 00:35:53 +01:00
Jack Grigg 4b8885759e cargo update 2021-09-15 00:35:53 +01:00
Kris Nuttycombe a61318ec85 Use manual serialization for Merkle frontiers rather than bincode. 2021-08-24 09:47:04 -06:00
Daira Hopwood 5475b17ae9 Cargo.toml: use librustzcash after the merge of https://github.com/zcash/librustzcash/pull/424 .
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-08-19 21:07:53 +01:00
Jack Grigg 5ace59b38f rust: metrics 0.17 2021-07-30 18:22:05 +01:00
Jack Grigg 6e2a5b3f92 rust: cargo update 2021-07-30 18:22:05 +01:00
Jack Grigg 776e9c5a4b Add support for decoding and encoding Unified Addresses 2021-07-13 03:22:47 +01:00
Kris Nuttycombe e588d1d790 Update Orchard commitment tree hashes to use total MerkleCRH^Orchard. 2021-07-09 10:40:49 -06:00
Kris Nuttycombe 7a2be88768 ZIP 213: Add checks to support Orchard shielded coinbase outputs. 2021-07-01 12:42:37 +01:00
Kris Nuttycombe 5550dbe1b8 Fix implmentation of OrchardMerkleTree.DynamicMemoryUsage 2021-06-28 16:33:40 -06:00
Kris Nuttycombe 4b36b6fc20 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 13:54:15 -06:00
Kris Nuttycombe a3214285c2 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 13:54:15 -06:00
Kris Nuttycombe 34f192b8f0 Update to released version of incrementalmerkletree 2021-06-28 09:56:05 -06:00
Kris Nuttycombe ecec1f9769 Update orchard dependency. 2021-06-24 11:53:30 -06:00
Kris Nuttycombe 68ce7e4828 Implement the Rust side of the incremental merkle tree FFI. 2021-06-23 16:06:30 -06:00
Jack Grigg 9ad5b75b30 rust: Load Orchard circuit parameters at startup 2021-06-21 18:33:57 +01:00
Jack Grigg 3192820dbc rust: Migrate to zcash_history with versioned trees 2021-06-18 12:35:53 +01:00
Jack Grigg 36b4d130ab rust: Fix patched dependencies
The orchard crate was pinning a specific rev of zcash_note_encryption
which prevented CI from vendoring the crate dependencies. Now orchard
uses a patch, which enables us to similarly patch here to get the
correct crate versions throughout our tree (while the crates are still
in flux).
2021-06-15 01:11:32 +01:00
Jack Grigg af1b9c15bb Implement Orchard authorization batch validator
- Currently, only RedPallas signatures are batch-validated. We can extend
  this validator to cover Halo 2 proofs in the future.

- Signatures in a batch are not retried individually if the batch fails:
  - For per-transaction batching (when adding to the mempool), we don't
    care which signature within the transaction failed.
  - For per-block batching, we currently don't care which transaction
    failed. We might do so in future, at which point this behaviour can
    be easily changed.
2021-06-14 22:47:00 +01:00
Jack Grigg bfc77d571e v5 transaction format parser
The majority of the parser is in C++, but Orchard bundles are parsed
exclusively by Rust.

The ZIP 244 test vectors are brought in here so we can start by testing
round-trip serialization.
2021-06-10 22:11:42 +01:00
Jack Grigg 0be07bb70c Implement ZIP 216 consensus rules
In addition to the specified consensus rules, we unconditionally enable
ZIP 216 in the following situations:

- Wallet code
  - Transaction building
  - Nullifiers for wallet notes
- Tests
- Benchmarks

Closes zcash/zcash#5201.
2021-06-10 11:36:12 +01:00
Jack Grigg 3d6c1e4426 metrics 0.16 and metrics-exporter-prometheus 0.5
Includes the allowlist logic that we upstreamed.
2021-06-06 00:53:19 +01:00
Jack Grigg 419275c4f5 Migrate to latest zcash_* crates
This includes the ff 0.10 dependency stack.
2021-06-06 00:53:19 +01:00
Jack Grigg 3dad214577 cargo update 2021-06-06 00:53:19 +01:00
Jack Grigg c9e3d03320 rust: Pin hyper 0.14.2
hyper 0.14.3 added an unstable C API, but the changes to enable it
require us to configure cargo with a linker for cross-compilation.
We'll need to figure this out eventually, but for now let's just
pin hyper to a version that doesn't require it.
2021-03-30 15:12:35 +13:00
Jack Grigg d08cdbe5f7 metrics: Implement IP access control on Prometheus scrape endpoint 2021-03-30 15:12:08 +13:00
Jack Grigg a79ffa3b50 rust: Add a Prometheus metrics exporter
The -prometheusmetrics=host_name:port config option enables the metrics
exporter.
2021-03-30 15:12:07 +13:00
Jack Grigg 8482ed6356 rust: Implement FFI interface to metrics crate 2021-03-30 15:11:17 +13:00
Jack Grigg 8393b3da88 rust: zcash_{primitives, proofs} 0.5.0 2021-03-27 11:47:25 +13:00
Jack Grigg 5ffcb198a7 cargo update 2021-03-27 10:42:04 +13:00
Jack Grigg df489e9a50 rust: Pin funty =1.1.0
Temporary workaround for https://github.com/myrrlyn/funty/issues/3
2021-02-20 18:34:11 +00:00
Jack Grigg 81fd148475 cargo update 2021-02-20 18:32:34 +00:00
therealyingtong cb50c0a083 Cargo update 2021-02-18 20:02:36 +08:00
Jack Grigg 780e35419a cargo update 2021-01-25 12:10:25 +00:00
Jack Grigg 674fc8eb63 depends: cargo update 2021-01-04 16:41:06 +00:00
Jack Grigg bdf44b1cf8 cargo update 2020-12-18 19:42:07 +00:00
Jack Grigg 120b184d8f cargo update 2020-11-10 21:39:55 +00:00
Jack Grigg b56e5aa7b8 cargo update 2020-10-05 20:01:58 +01:00
Jack Grigg 2d172e121f Replace libsodium's crypto_generichash_blake2b with blake2b_simd 2020-09-24 15:58:14 +01:00
Sean Bowe 52777e6d74
Update to latest zcash_* and zkcrypto crates. 2020-09-22 15:15:25 -06:00
Sean Bowe 16e91b0534
cargo update 2020-09-22 15:07:27 -06:00
Jack Grigg f0babb8356 depends: cargo update 2020-08-25 13:07:22 +01:00
Jack Grigg c10ba7da41 depends: Migrate to zcash_* 0.3.0 Rust crates 2020-08-25 13:07:22 +01:00
Jack Grigg 70c518bb84 depends: tracing-core 0.1.13 2020-08-07 15:26:28 +01:00
Jack Grigg 2b7d824714 Use a tracing EnvFilter directive for -debug flags 2020-08-07 15:08:10 +01:00
Jack Grigg e04da74957 FFI wrapper around tracing crate
The tracing crate is initialized with an optional log path, and will
either start a background thread for non-blocking log writing, or write
directly to standard output with ANSI encoding.

C preprocessor macros are used to emulate the Rust macros natively
provided by the tracing crate. They handle the creation of static
tracing callsites, and ensure that the correct file and line number
information is used for each logging site.
2020-08-07 15:07:44 +01:00
Jack Grigg e6a52fa9c8 Add tracing to librustzcash dependencies 2020-08-07 15:07:44 +01:00
Kris Nuttycombe 84e8cce77d Use ed25519-zebra from crates.io. 2020-07-08 13:11:27 -06:00
Sean Bowe ba04450945
Remove unused curve25519-dalek dev-dependency. 2020-06-23 16:29:51 -06:00
Sean Bowe 14bdf7e811
Remove bincode crate. 2020-06-23 15:38:59 -06:00
Sean Bowe 2a3527bfe8
Add test that a weird signature successfully validates. 2020-06-23 14:31:41 -06:00
Sean Bowe 9f71fa1c09
Change to version of ed25519-zebra crate which is compliant with ZIP 215. 2020-06-23 13:17:27 -06:00
Sean Bowe 3688f508d8
Make ed25519-zebra available via librustzcash. 2020-06-22 15:58:26 -06:00