diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 378dd22aa..ca3c14b9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,6 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - steps: - uses: actions/checkout@v4 - name: Run tests @@ -28,6 +27,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable id: toolchain - run: rustup override set ${{steps.toolchain.outputs.name}} + - if: matrix.os == 'ubuntu-latest' + run: sudo apt-get -y install libfontconfig1-dev - name: Remove lockfile to build with latest dependencies run: rm Cargo.lock - name: Build crate @@ -101,7 +102,6 @@ jobs: container: image: xd009642/tarpaulin:develop-nightly options: --security-opt seccomp=unconfined - steps: - uses: actions/checkout@v4 - name: Generate coverage report @@ -116,6 +116,7 @@ jobs: - uses: actions/checkout@v4 - run: cargo fetch # Requires #![deny(rustdoc::broken_intra_doc_links)] in crates. + - run: sudo apt-get -y install libfontconfig1-dev - name: Check intra-doc links run: cargo doc --all-features --document-private-items diff --git a/CHANGELOG.md b/CHANGELOG.md index fc440977b..2307b3558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to Rust's notion of - `orchard::pczt::Zip32Derivation::extract_account_index` ### Changed -- MSRV is now 1.66 +- MSRV is now 1.70 - Migrated to `nonempty 0.11`. ## [0.10.1] - 2024-12-16 diff --git a/Cargo.toml b/Cargo.toml index 24b3388e5..34895c6ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ authors = [ "Kris Nuttycombe ", ] edition = "2021" -rust-version = "1.66" +rust-version = "1.70" description = "The Orchard shielded transaction protocol" license = "MIT OR Apache-2.0" repository = "https://github.com/zcash/orchard" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fb11b593c..cad9254a9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.66.0" +channel = "1.70.0" components = [ "clippy", "rustfmt" ] diff --git a/src/builder.rs b/src/builder.rs index f15269235..b2f19bca1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -639,7 +639,7 @@ impl Builder { .iter() .map(|output| NoteValue::zero() - output.value), ) - .fold(Some(ValueSum::zero()), |acc, note_value| acc? + note_value) + .try_fold(ValueSum::zero(), |acc, note_value| acc + note_value) .ok_or(OverflowError)?; i64::try_from(value_balance).and_then(|i| V::try_from(i).map_err(|_| value::OverflowError)) } @@ -813,7 +813,7 @@ fn build_bundle( let mut bundle_meta = BundleMetadata::new(num_requested_spends, num_requested_outputs); let pre_actions = indexed_spends .into_iter() - .zip(indexed_outputs.into_iter()) + .zip(indexed_outputs) .enumerate() .map(|(action_idx, ((spend_idx, spend), (out_idx, output)))| { // Record the post-randomization spend location @@ -836,9 +836,7 @@ fn build_bundle( // Determine the value balance for this bundle, ensuring it is valid. let value_balance = pre_actions .iter() - .fold(Some(ValueSum::zero()), |acc, action| { - acc? + action.value_sum() - }) + .try_fold(ValueSum::zero(), |acc, action| acc + action.value_sum()) .ok_or(OverflowError)?; finisher(pre_actions, flags, value_balance, bundle_meta, rng) @@ -1137,7 +1135,7 @@ impl OutputView for OutputInfo { } /// Generators for property testing. -#[cfg(any(test, feature = "test-dependencies"))] +#[cfg(all(feature = "circuit", any(test, feature = "test-dependencies")))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] pub mod testing { use alloc::vec::Vec; diff --git a/src/bundle.rs b/src/bundle.rs index acba245ef..e8edd30ae 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -178,7 +178,7 @@ impl fmt::Debug for Bundle { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Helper struct for debug-printing actions without exposing `NonEmpty`. struct Actions<'a, T>(&'a NonEmpty>); - impl<'a, T: fmt::Debug> fmt::Debug for Actions<'a, T> { + impl fmt::Debug for Actions<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.0.iter()).finish() } @@ -536,10 +536,9 @@ pub mod testing { use proptest::prelude::*; use crate::{ - circuit::Proof, primitives::redpallas::{self, testing::arb_binding_signing_key}, value::{testing::arb_note_value_bounded, NoteValue, ValueSum, MAX_NOTE_VALUE}, - Anchor, + Anchor, Proof, }; use super::{Action, Authorized, Bundle, Flags}; diff --git a/src/bundle/commitments.rs b/src/bundle/commitments.rs index ef440a272..fee2419db 100644 --- a/src/bundle/commitments.rs +++ b/src/bundle/commitments.rs @@ -14,14 +14,14 @@ fn hasher(personal: &[u8; 16]) -> State { Params::new().hash_length(32).personal(personal).to_state() } -/// Write disjoint parts of each Orchard shielded action as 3 separate hashes: +/// Write disjoint parts of each Orchard shielded action as 3 separate hashes +/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244]: /// * \[(nullifier, cmx, ephemeral_key, enc_ciphertext\[..52\])*\] personalized /// with ZCASH_ORCHARD_ACTIONS_COMPACT_HASH_PERSONALIZATION /// * \[enc_ciphertext\[52..564\]*\] (memo ciphertexts) personalized /// with ZCASH_ORCHARD_ACTIONS_MEMOS_HASH_PERSONALIZATION /// * \[(cv, rk, enc_ciphertext\[564..\], out_ciphertext)*\] personalized /// with ZCASH_ORCHARD_ACTIONS_NONCOMPACT_HASH_PERSONALIZATION -/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244] /// /// Then, hash these together along with (flags, value_balance_orchard, anchor_orchard), /// personalized with ZCASH_ORCHARD_ACTIONS_HASH_PERSONALIZATION diff --git a/src/constants.rs b/src/constants.rs index 7f40b5394..62548f9c1 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -3,7 +3,9 @@ pub mod fixed_bases; pub mod sinsemilla; pub mod util; +#[cfg(feature = "circuit")] pub use self::sinsemilla::{OrchardCommitDomains, OrchardHashDomains}; +#[cfg(feature = "circuit")] pub use fixed_bases::{NullifierK, OrchardFixedBases, OrchardFixedBasesFull, ValueCommitV}; /// $\mathsf{MerkleDepth^{Orchard}}$ diff --git a/src/constants/fixed_bases/commit_ivk_r.rs b/src/constants/fixed_bases/commit_ivk_r.rs index 7bb8a9486..75ba5458b 100644 --- a/src/constants/fixed_bases/commit_ivk_r.rs +++ b/src/constants/fixed_bases/commit_ivk_r.rs @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [ /// Full-width u-values for GENERATOR. /// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`]. -pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ +pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ [ [ 38, 43, 235, 53, 200, 116, 153, 194, 47, 92, 18, 54, 194, 221, 170, 155, 205, 143, 92, diff --git a/src/constants/fixed_bases/note_commit_r.rs b/src/constants/fixed_bases/note_commit_r.rs index ddf5c43ba..2d0e8e6b5 100644 --- a/src/constants/fixed_bases/note_commit_r.rs +++ b/src/constants/fixed_bases/note_commit_r.rs @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [ /// Full-width u-values for GENERATOR. /// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`]. -pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ +pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ [ [ 114, 245, 9, 0, 5, 43, 7, 118, 244, 43, 15, 200, 116, 210, 0, 24, 161, 28, 185, 152, diff --git a/src/constants/fixed_bases/nullifier_k.rs b/src/constants/fixed_bases/nullifier_k.rs index a6a09440a..cecc0c26a 100644 --- a/src/constants/fixed_bases/nullifier_k.rs +++ b/src/constants/fixed_bases/nullifier_k.rs @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [ /// Full-width u-values for GENERATOR /// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`]. -pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ +pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ [ [ 8, 177, 117, 90, 104, 127, 169, 131, 254, 128, 23, 151, 181, 247, 22, 208, 55, 1, 147, diff --git a/src/constants/fixed_bases/spend_auth_g.rs b/src/constants/fixed_bases/spend_auth_g.rs index f53d7aaab..0a83fc363 100644 --- a/src/constants/fixed_bases/spend_auth_g.rs +++ b/src/constants/fixed_bases/spend_auth_g.rs @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [ /// Full-width u-values for GENERATOR. /// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`]. -pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ +pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ [ [ 134, 139, 159, 167, 179, 203, 183, 86, 54, 69, 108, 127, 183, 40, 226, 188, 34, 72, diff --git a/src/constants/fixed_bases/value_commit_r.rs b/src/constants/fixed_bases/value_commit_r.rs index 9e4b2edce..859edb79f 100644 --- a/src/constants/fixed_bases/value_commit_r.rs +++ b/src/constants/fixed_bases/value_commit_r.rs @@ -28,7 +28,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [ /// Full-width u-values for GENERATOR. /// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`]. -pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ +pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [ [ [ 139, 239, 3, 113, 200, 111, 72, 118, 105, 23, 186, 243, 234, 10, 173, 186, 53, 143, diff --git a/src/note_encryption.rs b/src/note_encryption.rs index cece83580..2228b8030 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -249,7 +249,7 @@ impl BatchDomain for OrchardDomain { let (shared_secrets, ephemeral_keys): (Vec<_>, Vec<_>) = items.unzip(); SharedSecret::batch_to_affine(shared_secrets) - .zip(ephemeral_keys.into_iter()) + .zip(ephemeral_keys) .map(|(secret, ephemeral_key)| { secret.map(|dhsecret| SharedSecret::kdf_orchard_inner(dhsecret, ephemeral_key)) }) diff --git a/src/pczt/updater.rs b/src/pczt/updater.rs index c7691f777..5d032b1f0 100644 --- a/src/pczt/updater.rs +++ b/src/pczt/updater.rs @@ -17,7 +17,7 @@ impl Bundle { #[derive(Debug)] pub struct Updater<'a>(&'a mut Bundle); -impl<'a> Updater<'a> { +impl Updater<'_> { /// Provides read access to the bundle being updated. pub fn bundle(&self) -> &Bundle { self.0 @@ -42,7 +42,7 @@ impl<'a> Updater<'a> { #[derive(Debug)] pub struct ActionUpdater<'a>(&'a mut Action); -impl<'a> ActionUpdater<'a> { +impl ActionUpdater<'_> { /// Sets the ZIP 32 derivation path for the spent note's signing key. pub fn set_spend_zip32_derivation(&mut self, derivation: Zip32Derivation) { self.0.spend.zip32_derivation = Some(derivation); diff --git a/src/primitives/redpallas.rs b/src/primitives/redpallas.rs index cbef23436..23074d945 100644 --- a/src/primitives/redpallas.rs +++ b/src/primitives/redpallas.rs @@ -102,7 +102,7 @@ impl Eq for VerificationKey {} impl PartialOrd for VerificationKey { fn partial_cmp(&self, other: &Self) -> Option { - <[u8; 32]>::from(self).partial_cmp(&<[u8; 32]>::from(other)) + Some(self.cmp(other)) } } diff --git a/src/value.rs b/src/value.rs index dac380ece..516bf8e18 100644 --- a/src/value.rs +++ b/src/value.rs @@ -213,14 +213,16 @@ impl Add for ValueSum { } impl<'a> Sum<&'a ValueSum> for Result { - fn sum>(iter: I) -> Self { - iter.fold(Ok(ValueSum(0)), |acc, v| (acc? + *v).ok_or(OverflowError)) + fn sum>(mut iter: I) -> Self { + iter.try_fold(ValueSum(0), |acc, v| acc + *v) + .ok_or(OverflowError) } } impl Sum for Result { - fn sum>(iter: I) -> Self { - iter.fold(Ok(ValueSum(0)), |acc, v| (acc? + v).ok_or(OverflowError)) + fn sum>(mut iter: I) -> Self { + iter.try_fold(ValueSum(0), |acc, v| acc + v) + .ok_or(OverflowError) } }